Change in gr-gsm[master]: trx/txtime_setter: reduce code nesting in process_txtime_of_burst()

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Vadim Yanitskiy gerrit-no-reply at lists.osmocom.org
Thu Dec 20 23:56:08 UTC 2018


Vadim Yanitskiy has uploaded this change for review. ( https://gerrit.osmocom.org/12394


Change subject: trx/txtime_setter: reduce code nesting in process_txtime_of_burst()
......................................................................

trx/txtime_setter: reduce code nesting in process_txtime_of_burst()

Change-Id: I5c334e16d6b28a5e32cd62a177ad56bfc8e748ee
---
M lib/transmitter/txtime_setter_impl.cc
1 file changed, 39 insertions(+), 39 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/gr-gsm refs/changes/94/12394/1

diff --git a/lib/transmitter/txtime_setter_impl.cc b/lib/transmitter/txtime_setter_impl.cc
index 3c07cc6..50092f4 100644
--- a/lib/transmitter/txtime_setter_impl.cc
+++ b/lib/transmitter/txtime_setter_impl.cc
@@ -116,52 +116,52 @@
 
     void txtime_setter_impl::process_txtime_of_burst(pmt::pmt_t msg_in)
     {
-      if (d_fn_ref != UNKNOWN_FN)
-      {
-        pmt::pmt_t blob = pmt::cdr(msg_in);
+      if (d_fn_ref == UNKNOWN_FN)
+        return;
 
-        // Extract GSMTAP header from message
-        gsmtap_hdr *header = (gsmtap_hdr *) pmt::blob_data(blob);
-        uint32_t frame_nr = be32toh(header->frame_number);
-        uint32_t ts_num = header->timeslot;
+      pmt::pmt_t blob = pmt::cdr(msg_in);
 
-        time_format txtime = fn_time_delta_cpp(d_fn_ref, d_time_ref,
-          frame_nr, d_time_hint, ts_num, d_ts_ref);
+      // Extract GSMTAP header from message
+      gsmtap_hdr *header = (gsmtap_hdr *) pmt::blob_data(blob);
+      uint32_t frame_nr = be32toh(header->frame_number);
+      uint32_t ts_num = header->timeslot;
 
-        time_spec_t txtime_spec = time_spec_t(txtime.first, txtime.second);
-        txtime_spec -= d_delay_correction;
-        txtime_spec -= d_timing_advance;
+      time_format txtime = fn_time_delta_cpp(d_fn_ref, d_time_ref,
+        frame_nr, d_time_hint, ts_num, d_ts_ref);
 
-        time_spec_t current_time_estimate = time_spec_t(d_time_hint.first, d_time_hint.second);
+      time_spec_t txtime_spec = time_spec_t(txtime.first, txtime.second);
+      txtime_spec -= d_delay_correction;
+      txtime_spec -= d_timing_advance;
 
-        if (txtime_spec <= current_time_estimate) { // Drop too late bursts
-          std::cout << "lB" << std::flush;
-        } else if (txtime_spec > current_time_estimate + MAX_EARLY_TIME_DIFF) { // Drop too early bursts
-          std::cout << "eB" << std::flush;      //TODO: too early condition might happen when changing BTSes.
-                                                //Wrong fn_time is applied to new or old bursts in such situation.
-                                                //This solution is not perfect as MS might be blocked upto 
-                                                //MAX_EARLY_TIME_DIFF seconds.
-                                                //Better solution would be to indentify fn_time and burst coming
-                                                //from given BTS (i.e. based on ARFCN) and dropping bursts for which
-                                                //the bts_id doesn't match with bts_id of fn_time.
-        } else { //process bursts that are in the right time-frame
-          pmt::pmt_t tags_dict = pmt::dict_add(
-            pmt::make_dict(),
-            pmt::intern("tx_time"),
-            pmt::make_tuple(
-              pmt::from_uint64(txtime_spec.get_full_secs()),
-              pmt::from_double(txtime_spec.get_frac_secs()))
-          );
+      time_spec_t current_time_estimate = time_spec_t(d_time_hint.first, d_time_hint.second);
 
-          tags_dict = pmt::dict_add(tags_dict,
-            pmt::intern("fn"), pmt::from_uint64(frame_nr));
-          tags_dict = pmt::dict_add(tags_dict,
-            pmt::intern("ts"), pmt::from_uint64(ts_num));
+      if (txtime_spec <= current_time_estimate) { // Drop too late bursts
+        std::cout << "lB" << std::flush;
+      } else if (txtime_spec > current_time_estimate + MAX_EARLY_TIME_DIFF) { // Drop too early bursts
+        std::cout << "eB" << std::flush;      //TODO: too early condition might happen when changing BTSes.
+                                              //Wrong fn_time is applied to new or old bursts in such situation.
+                                              //This solution is not perfect as MS might be blocked upto
+                                              //MAX_EARLY_TIME_DIFF seconds.
+                                              //Better solution would be to indentify fn_time and burst coming
+                                              //from given BTS (i.e. based on ARFCN) and dropping bursts for which
+                                              //the bts_id doesn't match with bts_id of fn_time.
+      } else { //process bursts that are in the right time-frame
+        pmt::pmt_t tags_dict = pmt::dict_add(
+          pmt::make_dict(),
+          pmt::intern("tx_time"),
+          pmt::make_tuple(
+            pmt::from_uint64(txtime_spec.get_full_secs()),
+            pmt::from_double(txtime_spec.get_frac_secs()))
+        );
 
-          // Send a message to the output
-          pmt::pmt_t msg_out = pmt::cons(tags_dict, pmt::cdr(msg_in));
-          message_port_pub(pmt::mp("bursts_out"), msg_out);
-        }
+        tags_dict = pmt::dict_add(tags_dict,
+          pmt::intern("fn"), pmt::from_uint64(frame_nr));
+        tags_dict = pmt::dict_add(tags_dict,
+          pmt::intern("ts"), pmt::from_uint64(ts_num));
+
+        // Send a message to the output
+        pmt::pmt_t msg_out = pmt::cons(tags_dict, pmt::cdr(msg_in));
+        message_port_pub(pmt::mp("bursts_out"), msg_out);
       }
     }
 

-- 
To view, visit https://gerrit.osmocom.org/12394
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: gr-gsm
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I5c334e16d6b28a5e32cd62a177ad56bfc8e748ee
Gerrit-Change-Number: 12394
Gerrit-PatchSet: 1
Gerrit-Owner: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181220/1a939a3e/attachment.htm>


More information about the gerrit-log mailing list