Skip to content

Commit eea6b5e

Browse files
committed
fix: change endainess to LE fo signed vars and structs
1 parent 9f9a8d7 commit eea6b5e

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

‎src/someipy/serialization.py‎

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ def serialize(self) -> bytes:
104104
Returns:
105105
bytes: The serialized value of the object.
106106
"""
107-
return struct.pack(">b", self.value)
107+
return struct.pack("<b", self.value)
108108

109109
def deserialize(self, payload):
110110
"""
@@ -116,7 +116,7 @@ def deserialize(self, payload):
116116
Returns:
117117
self: The deserialized object.
118118
"""
119-
(self.value,) = struct.unpack(">b", payload)
119+
(self.value,) = struct.unpack("<b", payload)
120120
return self
121121

122122

@@ -184,7 +184,7 @@ def serialize(self) -> bytes:
184184
Returns:
185185
bytes: The serialized value of the object.
186186
"""
187-
return struct.pack(">h", self.value)
187+
return struct.pack("<h", self.value)
188188

189189
def deserialize(self, payload):
190190
"""
@@ -231,10 +231,10 @@ def __len__(self):
231231
return 4
232232

233233
def serialize(self) -> bytes:
234-
return struct.pack(">l", self.value)
234+
return struct.pack("<l", self.value)
235235

236236
def deserialize(self, payload):
237-
(self.value,) = struct.unpack(">l", payload)
237+
(self.value,) = struct.unpack("<l", payload)
238238
return self
239239

240240

@@ -250,10 +250,10 @@ def __len__(self):
250250
return 8
251251

252252
def serialize(self) -> bytes:
253-
return struct.pack(">Q", self.value)
253+
return struct.pack("<Q", self.value)
254254

255255
def deserialize(self, payload):
256-
(self.value,) = struct.unpack(">Q", payload)
256+
(self.value,) = struct.unpack("<Q", payload)
257257
return self
258258

259259

@@ -269,10 +269,10 @@ def __len__(self):
269269
return 8
270270

271271
def serialize(self) -> bytes:
272-
return struct.pack(">q", self.value)
272+
return struct.pack("<q", self.value)
273273

274274
def deserialize(self, payload):
275-
(self.value,) = struct.unpack(">q", payload)
275+
(self.value,) = struct.unpack("<q", payload)
276276
return self
277277

278278

@@ -348,7 +348,7 @@ def serialize(self) -> bytes:
348348
349349
This method serializes the value of the object into bytes using the big-endian byte order. It expects the value to be a float. The serialized value is returned as a bytes object.
350350
"""
351-
return struct.pack(">f", self.value)
351+
return struct.pack("<f", self.value)
352352

353353
def deserialize(self, payload):
354354
"""
@@ -360,9 +360,9 @@ def deserialize(self, payload):
360360
Returns:
361361
self: The deserialized object.
362362
363-
This method deserializes the payload into the value of the object. It expects the payload to be a 4-byte float in big-endian byte order. The deserialized value is assigned to the `value` attribute of the object. The deserialized object is then returned.
363+
This method deserializes the payload into the value of the object. It expects the payload to be a 4-byte float in little-endian byte order. The deserialized value is assigned to the `value` attribute of the object. The deserialized object is then returned.
364364
"""
365-
(self.value,) = struct.unpack(">f", payload)
365+
(self.value,) = struct.unpack("<f", payload)
366366
return self
367367

368368
def __eq__(self, other) -> Bool:
@@ -406,7 +406,7 @@ def serialize(self) -> bytes:
406406
407407
This method serializes the value of the object into bytes using the big-endian byte order. It expects the value to be a float. The serialized value is returned as a bytes object.
408408
"""
409-
return struct.pack(">d", self.value)
409+
return struct.pack("<d", self.value)
410410

411411
def deserialize(self, payload):
412412
"""
@@ -418,9 +418,9 @@ def deserialize(self, payload):
418418
Returns:
419419
self: The deserialized object.
420420
421-
This method deserializes the payload into the value of the object. It expects the payload to be an 8-byte float in big-endian byte order. The deserialized value is assigned to the `value` attribute of the object. The deserialized object is then returned.
421+
This method deserializes the payload into the value of the object. It expects the payload to be an 8-byte float in little-endian byte order. The deserialized value is assigned to the `value` attribute of the object. The deserialized object is then returned.
422422
"""
423-
(self.value,) = struct.unpack(">d", payload)
423+
(self.value,) = struct.unpack("<d", payload)
424424
return self
425425

426426
def __eq__(self, other) -> Bool:

0 commit comments

Comments
 (0)