From 473d63abdc00b05703e5aa3246a2eb6f75239c08 Mon Sep 17 00:00:00 2001 From: JS Ng <45561895+ngjunsiang@users.noreply.github.com> Date: Thu, 16 May 2024 16:11:36 +0000 Subject: [PATCH 1/3] [fix] read and write unsigned bytes in SignalPdu --- opendis/dis7.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/opendis/dis7.py b/opendis/dis7.py index db44079..4f7a445 100644 --- a/opendis/dis7.py +++ b/opendis/dis7.py @@ -7450,7 +7450,7 @@ def serialize(self, outputStream): outputStream.write_short(len(self.data) * 8) outputStream.write_short(self.samples) for b in self.data: - outputStream.write_byte(b) + outputStream.write_unsigned_byte(b) def parse(self, inputStream): """Parse a message. This may recursively call embedded objects.""" @@ -7463,7 +7463,7 @@ def parse(self, inputStream): self.dataLength = inputStream.read_short() self.samples = inputStream.read_short() for idx in range(0, self.dataLength // 8): - element = inputStream.read_byte() + element = inputStream.read_unsigned_byte() self.data.append(element) From 60fc802fc2152c99a44baa6c33f71f96d5e58264 Mon Sep 17 00:00:00 2001 From: JS Ng <45561895+ngjunsiang@users.noreply.github.com> Date: Fri, 17 May 2024 15:17:21 +0000 Subject: [PATCH 2/3] [fix] read and write unsigned bytes in SignalPdu fixing lines 3790, 3794, 3801, 3806 --- opendis/dis7.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opendis/dis7.py b/opendis/dis7.py index 4f7a445..3067de7 100644 --- a/opendis/dis7.py +++ b/opendis/dis7.py @@ -3787,23 +3787,23 @@ def serialize(self, outputStream): outputStream.write_unsigned_int(self.variableDatumID) outputStream.write_unsigned_int(self.variableDatumLength) for x in range(self.variableDatumLength // 8): # length is in bits - outputStream.write_byte(self.variableData[x]) + outputStream.write_unsigned_byte(self.variableData[x]) #send padding for x in range(self.datumPaddingSizeInBits() // 8): - outputStream.write_byte(0) + outputStream.write_unsigned_byte(0) def parse(self, inputStream): """Parse a message. This may recursively call embedded objects.""" self.variableDatumID = inputStream.read_unsigned_int() self.variableDatumLength = inputStream.read_unsigned_int() for x in range(self.variableDatumLength // 8): # length is in bits - self.variableData.append(inputStream.read_byte()) + self.variableData.append(inputStream.read_unsigned_byte()) # Skip over padding # "This field shall be padded at the end to make the length a multiple of 64-bits." for x in range(self.datumPaddingSizeInBits() // 8): - inputStream.read_byte() + inputStream.read_unsigned_byte() class EventIdentifierLiveEntity: From 98b2834c57f821197aa630b1d41ce876fa86ee4f Mon Sep 17 00:00:00 2001 From: JS Ng <45561895+ngjunsiang@users.noreply.github.com> Date: Sat, 18 May 2024 13:20:42 +0000 Subject: [PATCH 3/3] [fix] SignalPdu dataLength and samples read as uint16 instead of int16 --- opendis/dis7.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/opendis/dis7.py b/opendis/dis7.py index 3067de7..ea53ea8 100644 --- a/opendis/dis7.py +++ b/opendis/dis7.py @@ -7447,8 +7447,8 @@ def serialize(self, outputStream): outputStream.write_unsigned_short(self.encodingScheme) outputStream.write_unsigned_short(self.tdlType) outputStream.write_unsigned_int(self.sampleRate) - outputStream.write_short(len(self.data) * 8) - outputStream.write_short(self.samples) + outputStream.write_unsigned_short(len(self.data) * 8) + outputStream.write_unsigned_short(self.samples) for b in self.data: outputStream.write_unsigned_byte(b) @@ -7460,8 +7460,8 @@ def parse(self, inputStream): self.encodingScheme = inputStream.read_unsigned_short() self.tdlType = inputStream.read_unsigned_short() self.sampleRate = inputStream.read_unsigned_int() - self.dataLength = inputStream.read_short() - self.samples = inputStream.read_short() + self.dataLength = inputStream.read_unsigned_short() + self.samples = inputStream.read_unsigned_short() for idx in range(0, self.dataLength // 8): element = inputStream.read_unsigned_byte() self.data.append(element)