diff --git a/src/someipy/serialization.py b/src/someipy/serialization.py index 6b46649..e3f2d21 100644 --- a/src/someipy/serialization.py +++ b/src/someipy/serialization.py @@ -64,7 +64,7 @@ def serialize(self) -> bytes: Returns: bytes: The serialized value of the object. """ - return struct.pack(">B", self.value) + return struct.pack("B", payload) + (self.value,) = struct.unpack(" bytes: Returns: bytes: The serialized value of the object. """ - return struct.pack(">H", self.value) + return struct.pack("H", payload) + (self.value,) = struct.unpack(" bytes: - return struct.pack(">L", self.value) + return struct.pack("L", payload) + (self.value,) = struct.unpack(" bytes: Returns: bytes: The serialized value of the object. """ - return struct.pack(">B", int(self.value)) + return struct.pack("B", payload) + (int_value,) = struct.unpack(" bytes: result = bytes() length_data_in_bytes = len(self.data) * self._single_element_length if self._length_field_length == 1: - result += struct.pack(">B", length_data_in_bytes) + result += struct.pack("H", length_data_in_bytes) + result += struct.pack("L", length_data_in_bytes) + result += struct.pack("B", payload[:1]) + (length,) = struct.unpack("H", payload[:2]) + (length,) = struct.unpack("L", payload[:4]) + (length,) = struct.unpack(" bytes: raise ValueError( "Length of the string exceeds maximum value of 255 for 1 byte length field." ) - result += struct.pack(">B", length) + result += struct.pack(" 65535: raise ValueError( "Length of the string exceeds maximum value of 65535 for 2 byte length field." ) - result += struct.pack(">H", length) + result += struct.pack(" 4294967295: raise ValueError( "Length of the string exceeds maximum value of 4294967295 for 4 byte length field." ) - result += struct.pack(">L", length) + result += struct.pack("B", length_field) + (length,) = struct.unpack("H", length_field) + (length,) = struct.unpack("L", length_field) + (length,) = struct.unpack("