From 318f8b78aad5961eba6b179f84e772bff759ade3 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Tue, 20 Feb 2018 19:43:02 +0700 Subject: fake_trx/data_dump.py: use 2 bytes to store message length One byte may store a value in range [0x00, 0xff]. The maximal 0xff value is 255 in dec, so a message length is limited to 255 bytes. This is enough for GSM bursts, but not for EDGE. Since this change, two bytes of header are used to store the pending message length. All captures created before are not supported anymore... Change-Id: I5a69d5cf2914fe56b2f9acca6054c9470627f91e --- src/target/fake_trx/data_dump.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/target/fake_trx/data_dump.py b/src/target/fake_trx/data_dump.py index b9047365..56e314c4 100644 --- a/src/target/fake_trx/data_dump.py +++ b/src/target/fake_trx/data_dump.py @@ -30,7 +30,7 @@ class DATADump: # Constants TAG_L12TRX = '\x01' TAG_TRX2L1 = '\x02' - HDR_LENGTH = 2 + HDR_LENGTH = 3 # Generates raw bytes from a DATA message # Return value: raw message bytes @@ -46,15 +46,18 @@ class DATADump: # Generate a message payload msg_raw = msg.gen_msg() - # Calculate the length + # Calculate and pack the message length msg_len = len(msg_raw) + # Pack to unsigned short (2 bytes, BE) + msg_len = struct.pack(">H", msg_len) + # Concatenate a message with header - return bytearray([tag, msg_len]) + msg_raw + return bytearray(tag + msg_len) + msg_raw def parse_hdr(self, hdr): # Extract the header info - msg_len = struct.unpack("H", hdr[1:3])[0] tag = hdr[0] # Check if tag is known -- cgit v1.2.3