Change in ...osmocom-bb[master]: trx_toolkit/data_msg.py: inline both gen_fn() and parse_fn()

fixeria gerrit-no-reply at lists.osmocom.org
Mon Jun 24 14:18:11 UTC 2019


fixeria has submitted this change and it was merged. ( 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(-)

Approvals:
  laforge: Looks good to me, but someone else must approve
  fixeria: Looks good to me, approved
  Jenkins Builder: Verified



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: 2
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at gnumonks.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190624/a6dcf8f5/attachment.html>


More information about the gerrit-log mailing list