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.orgHello Piotr Krysik, Vadim Yanitskiy, I'd like you to do a code review. Please visit https://gerrit.osmocom.org/13812 to review the following change. Change subject: Filter out SoapyAudio devices ...................................................................... Filter out SoapyAudio devices When gr-osmosdr is compiled with SoapySDR support and SoapyAudio is installed the audio device is picked as a first choice when detecting devices but grgsm tools are not able to work with audio devices. So in such cases the user has to always specify the correct SDR device in the args parameter which is a bit inconvenient. When args is not specified call osmosdr.device_find to get all devices and filter out unspported ones like SoapyAudio devices. When args is specifed just try to create osmosdr.source with whatever value has been specified. Add -l and --list-devices command line option that prints information about all detected devices. Example commands: grgsm_capture --list-devices grgsm_capture --list-devices --args=nofake grgsm_capture --args=uhd,type=b210 -a 111 capture.cfile grgsm_livemon --args=rtl grgsm_livemon --args=uhd,type=b210 Change-Id: Ib84081041ca6c2bc18b9da0c32bac9d3ecef65ca --- M apps/grgsm_livemon.grc M apps/grgsm_livemon_headless.grc M apps/grgsm_scanner M apps/helpers/grgsm_capture M python/__init__.py M python/misc_utils/CMakeLists.txt A python/misc_utils/device.py 7 files changed, 66 insertions(+), 8 deletions(-) git pull ssh://gerrit.osmocom.org:29418/gr-gsm refs/changes/12/13812/1 diff --git a/apps/grgsm_livemon.grc b/apps/grgsm_livemon.grc index 46b83e2..176aa6c 100644 --- a/apps/grgsm_livemon.grc +++ b/apps/grgsm_livemon.grc @@ -2844,7 +2844,7 @@ </param> <param> <key>args</key> - <value>args</value> + <value>str(grgsm.device.get_default_args(args))</value> </param> <param> <key>_enabled</key> diff --git a/apps/grgsm_livemon_headless.grc b/apps/grgsm_livemon_headless.grc index a1ce284..2f3e981 100644 --- a/apps/grgsm_livemon_headless.grc +++ b/apps/grgsm_livemon_headless.grc @@ -2414,7 +2414,7 @@ </param> <param> <key>args</key> - <value>args</value> + <value>str(grgsm.device.get_default_args(args))</value> </param> <param> <key>_enabled</key> diff --git a/apps/grgsm_scanner b/apps/grgsm_scanner index 32210ed..83b99d1 100755 --- a/apps/grgsm_scanner +++ b/apps/grgsm_scanner @@ -36,7 +36,7 @@ import osmosdr import pmt import time - +import sys # from wideband_receiver import * @@ -208,7 +208,8 @@ # if no file name is given process data from rtl_sdr source print "Args=", args - self.rtlsdr_source = osmosdr.source(args="numchan=" + str(1) + " " + args) + self.rtlsdr_source = osmosdr.source(args="numchan=" + str(1) + " " + + str(grgsm.device.get_default_args(args))) #self.rtlsdr_source.set_min_output_buffer(int(sample_rate*rec_len)) #this line causes segfaults on HackRF self.rtlsdr_source.set_sample_rate(sample_rate) @@ -387,7 +388,10 @@ parser.add_option("-g", "--gain", dest="gain", type="eng_float", default=24.0, help="Set gain [default=%default]") parser.add_option("", "--args", dest="args", type="string", default="", - help="Set device arguments [default=%default]") + help="Set device arguments [default=%default]." + "Use --list-devices the view the available devices") + parser.add_option("-l", "--list-devices", action="store_true", + help="List available SDR devices, use --args to specify hints") parser.add_option("--speed", dest="speed", type="intx", default=4, help="Scan speed [default=%default]. Value range 0-5.") parser.add_option("-v", "--verbose", action="store_true", @@ -404,6 +408,10 @@ if options is None: (options, args) = argument_parser().parse_args() + if options.list_devices: + grgsm.device.print_devices(options.args) + sys.exit(0) + if options.band not in grgsm.arfcn.get_bands(): parser.error("Invalid GSM band\n") diff --git a/apps/helpers/grgsm_capture b/apps/helpers/grgsm_capture index 081544a..f3886ba 100755 --- a/apps/helpers/grgsm_capture +++ b/apps/helpers/grgsm_capture @@ -53,8 +53,8 @@ # Setting up RF source ################################################## - self.sdr_source = \ - osmosdr.source(args="numchan=" + str(1) + " " + device_args) + self.sdr_source = osmosdr.source(args="numchan=" + str(1) + " " + + str(grgsm.device.get_default_args(device_args))) self.sdr_source.set_sample_rate(samp_rate) self.sdr_source.set_center_freq(freq, 0) @@ -141,12 +141,19 @@ osmogroup.add_option("", "--args", dest="device_args", type="string", default="", help="Set device arguments " - "[default=%default]") + "[default=%default]. Use --list-devices the view the available devices") + + osmogroup.add_option("-l", "--list-devices", action="store_true", + help="List available SDR devices, use --args to specify hints") parser.add_option_group(osmogroup) (options, args) = parser.parse_args() + if options.list_devices: + grgsm.device.print_devices(options.device_args) + sys.exit(0) + if not args: parser.error("Please provide an output file name to save the captured data\n") diff --git a/python/__init__.py b/python/__init__.py index 00d14ac..e2905e8 100644 --- a/python/__init__.py +++ b/python/__init__.py @@ -59,6 +59,7 @@ from fn_time import * from txtime_bursts_tagger import * import arfcn +import device # diff --git a/python/misc_utils/CMakeLists.txt b/python/misc_utils/CMakeLists.txt index ec732a4..76304ca 100644 --- a/python/misc_utils/CMakeLists.txt +++ b/python/misc_utils/CMakeLists.txt @@ -23,5 +23,6 @@ clock_offset_corrector_tagged.py hier_block.py fn_time.py + device.py DESTINATION ${GR_PYTHON_DIR}/grgsm ) diff --git a/python/misc_utils/device.py b/python/misc_utils/device.py new file mode 100644 index 0000000..eac1388 --- /dev/null +++ b/python/misc_utils/device.py @@ -0,0 +1,41 @@ +import osmosdr +import os + +def get_devices(hint=""): + return osmosdr.device_find(osmosdr.device_t(hint)) + +def match(dev, filters): + for f in filters: + for k, v in f.items(): + if (k not in dev or dev[k] != v): + break + else: + return True + return False + +def exclude(devices, filters = ({'driver': 'audio'},)): + return [dev for dev in devices if not match(dev, filters)] + +def get_all_args(hint="nofake"): + return map(lambda dev: dev.to_string(), exclude(get_devices(hint))) + +def get_default_args(args): + # The presence of GRC_BLOCKS_PATH environment variable indicates that + # gnuradio-companion compiles a flowgraph and in this case no exception + # have to be thrown otherwise the generaged python script will be invalid. + # This allows compilation of flowgraphs without an SDR device. + if args or os.getenv("GRC_BLOCKS_PATH"): + return args + + devices = get_all_args("nofake") + if not devices: + raise RuntimeError("Unable to find any supported SDR devices") + + return devices[0] + +def print_devices(hint=""): + devices = exclude(get_devices(hint)) + if devices: + print("\n".join(map(lambda dev: dev.to_string(), devices))) + else: + print("Unable to find any supported SDR devices") -- To view, visit https://gerrit.osmocom.org/13812 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: Ib84081041ca6c2bc18b9da0c32bac9d3ecef65ca Gerrit-Change-Number: 13812 Gerrit-PatchSet: 1 Gerrit-Owner: Vasil Velichkov <vvvelichkov at gmail.com> Gerrit-Reviewer: Piotr Krysik <ptrkrysik at gmail.com> Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com> -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190429/8b3cfce5/attachment.htm>