From b1ae186c55109dd324d8186bcb493b2fac657619 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Sun, 17 Nov 2019 20:37:05 +0700 Subject: [PATCH] trx_toolkit/fake_trx.py: refactor L12TRX -> TRX2L1 burst transformation The burst transformation in BurstForwarder.forward_msg() used to be done only once, so then the resulting message was distributed over the list of connected (and active) transceivers. This approach limits the path loss simulation capabilities, because a reference to the same message is passed to FakeTRX.send_data_msg(). If one transceiver changes (or removes) the burst bits, the other transceivers would not receive the original message. Let's do the transformation individually for each transceiver, so the original message will always remain unchanged. Change-Id: Ia016a3a9bb6e9f17182a7168aa5a501ae9b9978b --- src/target/trx_toolkit/burst_fwd.py | 12 ++++-------- src/target/trx_toolkit/fake_trx.py | 5 +---- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/target/trx_toolkit/burst_fwd.py b/src/target/trx_toolkit/burst_fwd.py index b418aef1..fd6013bd 100644 --- a/src/target/trx_toolkit/burst_fwd.py +++ b/src/target/trx_toolkit/burst_fwd.py @@ -65,12 +65,6 @@ class BurstForwarder: self.trx_list.remove(trx) def forward_msg(self, src_trx, rx_msg): - # Transform from L12TRX to TRX2L1 - tx_msg = rx_msg.gen_trx2l1() - if tx_msg is None: - log.error("Forwarding failed, could not transform " - "message (%s) => dropping..." % rx_msg.desc_hdr()) - # Iterate over all known transceivers for trx in self.trx_list: if trx == src_trx: @@ -81,7 +75,9 @@ class BurstForwarder: continue if trx.rx_freq != src_trx.tx_freq: continue - if tx_msg.tn not in trx.ts_list: + if rx_msg.tn not in trx.ts_list: continue - trx.send_data_msg(src_trx, rx_msg, tx_msg) + # Transform from L12TRX to TRX2L1 and forward + tx_msg = rx_msg.gen_trx2l1(ver = trx.data_if._hdr_ver) + trx.handle_data_msg(src_trx, rx_msg, tx_msg) diff --git a/src/target/trx_toolkit/fake_trx.py b/src/target/trx_toolkit/fake_trx.py index f226f032..f0dc5a52 100755 --- a/src/target/trx_toolkit/fake_trx.py +++ b/src/target/trx_toolkit/fake_trx.py @@ -199,10 +199,7 @@ class FakeTRX(Transceiver): # Takes (partially initialized) TRX2L1 message, # simulates RF path parameters (such as RSSI), # and sends towards the L1 - def send_data_msg(self, src_trx, src_msg, msg): - # Override header version - msg.ver = self.data_if._hdr_ver - + def handle_data_msg(self, src_trx, src_msg, msg): # Complete message header msg.toa256 = self.toa256 msg.rssi = self.rssi -- 2.11.4.GIT