diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2019-06-22 22:27:27 +0700 |
---|---|---|
committer | fixeria <axilirator@gmail.com> | 2019-06-24 14:18:09 +0000 |
commit | 1ff97803666dd9ba619598c9707cffbd51a4058d (patch) | |
tree | bf713f5ab3fdca7d6ce92f1ffd549ff00d130801 /src/target/trx_toolkit/data_msg.py | |
parent | 84bd7b27469a6b4994b64f0606c9b3f9daaa7d51 (diff) |
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
Diffstat (limited to 'src/target/trx_toolkit/data_msg.py')
-rw-r--r-- | src/target/trx_toolkit/data_msg.py | 17 |
1 files changed, 3 insertions, 14 deletions
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 |