From 1ff97803666dd9ba619598c9707cffbd51a4058d Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Sat, 22 Jun 2019 22:27:27 +0700 Subject: 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 --- src/target/trx_toolkit/data_msg.py | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'src/target') diff --git a/src/target/trx_toolkit/data_msg.py b/src/target/trx_toolkit/data_msg.py index f14c2951..6d6b76c4 100644 --- a/src/target/trx_toolkit/data_msg.py +++ b/src/target/trx_toolkit/data_msg.py @@ -136,16 +136,6 @@ class DATAMSG: 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 @@ class DATAMSG: # 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 @@ class DATAMSG: 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 -- cgit v1.2.3