[PATCH] osmocom-bb[fixeria/trx]: fake_trx/data_msg.py: implement ToA parsing support

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Wed Feb 28 09:07:15 UTC 2018


Review at  https://gerrit.osmocom.org/6991

fake_trx/data_msg.py: implement ToA parsing support

This change implements ToA (Timing of Arrival) parsing, which
was missing in the DATAMSG_TRX2L1. Since we use integer math,
a ToA value is represented in units 1/256 symbol periods.

Change-Id: Ib11482c06b977c4cf01b0644f5845a2e49d059fb
---
M src/target/fake_trx/burst_send.py
M src/target/fake_trx/data_dump.py
M src/target/fake_trx/data_msg.py
3 files changed, 3 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.osmocom.org:29418/osmocom-bb refs/changes/91/6991/1

diff --git a/src/target/fake_trx/burst_send.py b/src/target/fake_trx/burst_send.py
index d6c5c0c..882fcd6 100755
--- a/src/target/fake_trx/burst_send.py
+++ b/src/target/fake_trx/burst_send.py
@@ -90,10 +90,6 @@
 			if not self.msg_pass_filter(l12trx, msg):
 				continue
 
-			# HACK: as ToA parsing is not implemented yet,
-			# we have to use a fixed value for now...
-			msg.toa256 = 0
-
 			print("[i] Sending a burst %s to %s..."
 				% (msg.desc_hdr(), self.conn_mode))
 
diff --git a/src/target/fake_trx/data_dump.py b/src/target/fake_trx/data_dump.py
index 5e16da8..1d7805e 100644
--- a/src/target/fake_trx/data_dump.py
+++ b/src/target/fake_trx/data_dump.py
@@ -257,11 +257,6 @@
 		# Randomize the header
 		msg.rand_hdr()
 
-		# HACK: as ToA parsing is not implemented yet,
-		# we have to use a fixed value for now...
-		if isinstance(msg, DATAMSG_TRX2L1):
-			msg.toa256 = 0
-
 		# Append
 		messages_ref.append(msg)
 
@@ -293,10 +288,6 @@
 		assert(messages_check[i].fn == messages_ref[i].fn)
 		assert(messages_check[i].tn == messages_ref[i].tn)
 
-		# HACK: as ToA parsing is not implemented yet,
-		# we have to use a fixed value for now...
-		messages_check[i].toa256 = 0
-
 		# Validate a message
 		assert(messages_check[i].validate())
 
@@ -318,10 +309,6 @@
 		assert(messages_check[i].burst == messages_ref[i].burst)
 		assert(messages_check[i].fn == messages_ref[i].fn)
 		assert(messages_check[i].tn == messages_ref[i].tn)
-
-		# HACK: as ToA parsing is not implemented yet,
-		# we have to use a fixed value for now...
-		messages_check[i].toa256 = 0
 
 		# Validate a message
 		assert(messages_check[i].validate())
@@ -345,11 +332,6 @@
 	assert(msg10.fn == messages_ref[10].fn)
 	assert(msg10.tn == messages_ref[10].tn)
 
-	# HACK: as ToA parsing is not implemented yet,
-	# we have to use a fixed value for now...
-	msg0.toa256 = 0
-	msg10.toa256 = 0
-
 	# Validate both messages
 	assert(msg0.validate())
 	assert(msg10.validate())
@@ -371,10 +353,6 @@
 		assert(messages_check[i].burst == messages_ref[i + 10].burst)
 		assert(messages_check[i].fn == messages_ref[i + 10].fn)
 		assert(messages_check[i].tn == messages_ref[i + 10].tn)
-
-		# HACK: as ToA parsing is not implemented yet,
-		# we have to use a fixed value for now...
-		messages_check[i].toa256 = 0
 
 		# Validate a message
 		assert(messages_check[i].validate())
diff --git a/src/target/fake_trx/data_msg.py b/src/target/fake_trx/data_msg.py
index 5dbebcf..5f93187 100644
--- a/src/target/fake_trx/data_msg.py
+++ b/src/target/fake_trx/data_msg.py
@@ -23,6 +23,7 @@
 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
 import random
+import struct
 
 from gsm_shared import *
 
@@ -391,8 +392,7 @@
 		self.rssi = -(hdr[5])
 
 		# Parse ToA (Time of Arrival)
-		# FIXME: parsing unsupported
-		self.toa256 = None
+		self.toa256 = struct.unpack(">h", hdr[6:8])[0]
 
 	# Generates message specific burst
 	def gen_burst(self):
@@ -494,9 +494,7 @@
 	# Compare message specific parts
 	assert(msg_trx2l1_dec.rssi == msg_trx2l1_ref.rssi)
 	assert(msg_l12trx_dec.pwr == msg_l12trx_ref.pwr)
-
-	# FIXME: ToA check disabled until the parsing is implemented
-	# assert(msg_trx2l1_dec.toa256 == msg_trx2l1_ref.toa256)
+	assert(msg_trx2l1_dec.toa256 == msg_trx2l1_ref.toa256)
 
 	print("[?] Compare message specific data: OK")
 

-- 
To view, visit https://gerrit.osmocom.org/6991
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib11482c06b977c4cf01b0644f5845a2e49d059fb
Gerrit-PatchSet: 1
Gerrit-Project: osmocom-bb
Gerrit-Branch: fixeria/trx
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>


More information about the gerrit-log mailing list