From 68fbc436f2a23a8aeaa2293ee7b23e1087d39a32 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Wed, 25 Sep 2019 00:36:40 +0200 Subject: [PATCH] fix length problem --- owrx/pskreporter.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/owrx/pskreporter.py b/owrx/pskreporter.py index 8acd1a1..8b2edb9 100644 --- a/owrx/pskreporter.py +++ b/owrx/pskreporter.py @@ -94,17 +94,14 @@ class Uploader(object): packets = [] # 50 seems to be a safe bet for chunk in chunks(encoded, 50): - sInfo = self.padBytes(b"".join(chunk), 4) - sInfoLength = len(sInfo) - length = sInfoLength + 16 + len(rHeader) + len(sHeader) + len(rInfo) + 4 + sInfo = self.getSenderInformation(chunk) + length = 16 + len(rHeader) + len(sHeader) + len(rInfo) + len(sInfo) header = self.getHeader(length) packets.append( header + rHeader + sHeader + rInfo - + bytes(Uploader.senderDelimiter) - + sInfoLength.to_bytes(2, "big") + sInfo ) @@ -186,6 +183,11 @@ class Uploader(object): + [0x00, 0x96, 0x00, 0x04] ) + def getSenderInformation(self, chunk): + sInfo = self.padBytes(b"".join(chunk), 4) + sInfoLength = len(sInfo) + 4 + return bytes(Uploader.senderDelimiter) + sInfoLength.to_bytes(2, "big") + sInfo + def pad(self, b, l): return b + [0x00 for _ in range(0, -1 * len(b) % l)]