fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmocom-bb/+/14574
Change subject: trx_toolkit/data_msg.py: inline both gen_fn() and parse_fn() ...................................................................... trx_toolkit/data_msg.py: inline both gen_fn() and parse_fn() Both functions are never used outside of both gen_msg() and parse_msg(). AFAIR, they were more complicated until we started to use struct, but now they can be easily inlined. Change-Id: Ie64b271cf502f3df23b32f4b14a1e2b551a0f794 --- M src/target/trx_toolkit/data_msg.py 1 file changed, 3 insertions(+), 14 deletions(-) git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/74/14574/1 diff --git a/src/target/trx_toolkit/data_msg.py b/src/target/trx_toolkit/data_msg.py index f14c295..6d6b76c 100644 --- a/src/target/trx_toolkit/data_msg.py +++ b/src/target/trx_toolkit/data_msg.py @@ -136,16 +136,6 @@ return True - # Generates frame number to bytes - def gen_fn(self, fn): - # Big endian, 4 bytes - return struct.pack(">L", fn) - - # Parses frame number from bytes - def parse_fn(self, buf): - # Big endian, 4 bytes - return struct.unpack(">L", buf)[0] - # Generates a TRX DATA message def gen_msg(self, legacy = False): # Validate all the fields @@ -158,9 +148,8 @@ # Put timeslot index buf.append(self.tn) - # Put frame number - fn = self.gen_fn(self.fn) - buf += fn + # Put frame number (4 octets, BE) + buf += struct.pack(">L", self.fn) # Generate message specific header part hdr = self.gen_hdr() @@ -186,7 +175,7 @@ raise ValueError("Message is to short") # Parse both fn and tn - self.fn = self.parse_fn(msg[1:5]) + self.fn = struct.unpack(">L", msg[1:5])[0] self.tn = msg[0] # Specific message part -- To view, visit https://gerrit.osmocom.org/c/osmocom-bb/+/14574 To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings Gerrit-Project: osmocom-bb Gerrit-Branch: master Gerrit-Change-Id: Ie64b271cf502f3df23b32f4b14a1e2b551a0f794 Gerrit-Change-Number: 14574 Gerrit-PatchSet: 1 Gerrit-Owner: fixeria <axilira...@gmail.com> Gerrit-MessageType: newchange