summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <axilirator@gmail.com>2018-02-28 15:48:17 +0700
committerVadim Yanitskiy <axilirator@gmail.com>2018-02-28 22:34:27 +0700
commitd9cb0654179b3d3bcd2878a001593e95f0a22f80 (patch)
tree751734b5dd1c3a8dbc597bcb1669c53ef44622f8
parent9fc30a4102a46866d88b84b6640372cb09ddf32e (diff)
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 of 1/256 symbol periods. Change-Id: Ib11482c06b977c4cf01b0644f5845a2e49d059fb
-rwxr-xr-xsrc/target/fake_trx/burst_send.py4
-rw-r--r--src/target/fake_trx/data_dump.py22
-rw-r--r--src/target/fake_trx/data_msg.py8
3 files changed, 3 insertions, 31 deletions
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 @@ class Application:
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 @@ if __name__ == '__main__':
# 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 @@ if __name__ == '__main__':
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())
@@ -319,10 +310,6 @@ if __name__ == '__main__':
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 @@ if __name__ == '__main__':
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())
@@ -372,10 +354,6 @@ if __name__ == '__main__':
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 @@ class DATAMSG_TRX2L1(DATAMSG):
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 @@ if __name__ == '__main__':
# 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")