Change in gr-gsm[master]: grgsm_scanner: Add --debug option

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/.

Vasil Velichkov gerrit-no-reply at lists.osmocom.org
Wed Sep 5 20:33:40 UTC 2018


Vasil Velichkov has uploaded this change for review. ( https://gerrit.osmocom.org/10784


Change subject: grgsm_scanner: Add --debug option
......................................................................

grgsm_scanner: Add --debug option

When set the stdout and stderr won't be redirected to /dev/null which
will facilitate resolving issues

Change-Id: I11e99facb5a1ab9c9bfee3c314a91a74f98a2523
---
M apps/grgsm_scanner
1 file changed, 21 insertions(+), 16 deletions(-)



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

diff --git a/apps/grgsm_scanner b/apps/grgsm_scanner
index b57569d..32210ed 100755
--- a/apps/grgsm_scanner
+++ b/apps/grgsm_scanner
@@ -297,7 +297,7 @@
         return "ARFCN: %4u, Freq: %6.1fM, CID: %5u, LAC: %5u, MCC: %3u, MNC: %3u, Pwr: %3i" % (
             self.arfcn, self.freq / 1e6, self.cid, self.lac, self.mcc, self.mnc, self.power)
 
-def do_scan(samp_rate, band, speed, ppm, gain, args, prn = None):
+def do_scan(samp_rate, band, speed, ppm, gain, args, prn = None, debug = False):
     signallist = []
     channels_num = int(samp_rate / 0.2e6)
     for arfcn_range in grgsm.arfcn.get_arfcn_ranges(band):
@@ -311,14 +311,15 @@
 
         while current_freq < stop_freq:
 
-            # silence rtl_sdr output:
-            # open 2 fds
-            null_fds = [os.open(os.devnull, os.O_RDWR) for x in xrange(2)]
-            # save the current file descriptors to a tuple
-            save = os.dup(1), os.dup(2)
-            # put /dev/null fds on 1 and 2
-            os.dup2(null_fds[0], 1)
-            os.dup2(null_fds[1], 2)
+            if not debug:
+                # silence rtl_sdr output:
+                # open 2 fds
+                null_fds = [os.open(os.devnull, os.O_RDWR) for x in xrange(2)]
+                # save the current file descriptors to a tuple
+                save = os.dup(1), os.dup(2)
+                # put /dev/null fds on 1 and 2
+                os.dup2(null_fds[0], 1)
+                os.dup2(null_fds[1], 2)
 
             # instantiate scanner and processor
             scanner = wideband_scanner(rec_len=6 - speed,
@@ -359,12 +360,14 @@
 
             scanner = None
 
-            # restore file descriptors so we can print the results
-            os.dup2(save[0], 1)
-            os.dup2(save[1], 2)
-            # close the temporary fds
-            os.close(null_fds[0])
-            os.close(null_fds[1])
+
+            if not debug:
+                # restore file descriptors so we can print the results
+                os.dup2(save[0], 1)
+                os.dup2(save[1], 2)
+                # close the temporary fds
+                os.close(null_fds[0])
+                os.close(null_fds[1])
             if prn:
                 prn(found_list)
             signallist.extend(found_list)
@@ -389,6 +392,8 @@
                       help="Scan speed [default=%default]. Value range 0-5.")
     parser.add_option("-v", "--verbose", action="store_true",
                       help="If set, verbose information output is printed: ccch configuration, cell ARFCN's, neighbour ARFCN's")
+    parser.add_option("-d", "--debug", action="store_true",
+                      help="Print additional debug messages")
 
     """
         Dont forget: sudo sysctl kernel.shmmni=32000
@@ -415,7 +420,7 @@
                 print info.get_verbose_info()
     print ""
     do_scan(options.samp_rate, options.band, options.speed,
-            options.ppm, options.gain, options.args, prn = printfunc)
+            options.ppm, options.gain, options.args, prn = printfunc, debug = options.debug)
 
 if __name__ == '__main__':
     main()

-- 
To view, visit https://gerrit.osmocom.org/10784
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: I11e99facb5a1ab9c9bfee3c314a91a74f98a2523
Gerrit-Change-Number: 10784
Gerrit-PatchSet: 1
Gerrit-Owner: Vasil Velichkov <vvvelichkov at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180905/b3898ee3/attachment.htm>


More information about the gerrit-log mailing list