This is merely a historical archive of years 2008-2021, before the migration to mailman3.
A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.
Harald Welte gerrit-no-reply at lists.osmocom.org
Review at https://gerrit.osmocom.org/6837
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
---
M src/target/fake_trx/data_dump.py
1 file changed, 7 insertions(+), 4 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/37/6837/1
diff --git a/src/target/fake_trx/data_dump.py b/src/target/fake_trx/data_dump.py
index b904736..56e314c 100644
--- a/src/target/fake_trx/data_dump.py
+++ b/src/target/fake_trx/data_dump.py
@@ -30,7 +30,7 @@
# 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 @@
# 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("<B", hdr[1])[0]
+ msg_len = struct.unpack(">H", hdr[1:3])[0]
tag = hdr[0]
# Check if tag is known
--
To view, visit https://gerrit.osmocom.org/6837
To unsubscribe, visit https://gerrit.osmocom.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5a69d5cf2914fe56b2f9acca6054c9470627f91e
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: master
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>