diff options
author | Martin Braun <martin.braun@ettus.com> | 2015-10-07 15:06:42 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2015-10-07 15:06:42 -0700 |
commit | 90b88a27d27c52c337941a99773dfeb70e9c5917 (patch) | |
tree | cc620ca5b5ca5d13a05c45a67e2aa2329992c45a /host/tests/devtest/usrp_probe.py | |
parent | 9401bdbd214a7842c4ba913595cc79e27124589d (diff) | |
download | uhd-90b88a27d27c52c337941a99773dfeb70e9c5917.tar.gz uhd-90b88a27d27c52c337941a99773dfeb70e9c5917.tar.bz2 uhd-90b88a27d27c52c337941a99773dfeb70e9c5917.zip |
tests: Added first batch of device tests
- Currently supported: B2xx, X3x0
- Runs some simple examples
Diffstat (limited to 'host/tests/devtest/usrp_probe.py')
-rw-r--r-- | host/tests/devtest/usrp_probe.py | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/host/tests/devtest/usrp_probe.py b/host/tests/devtest/usrp_probe.py new file mode 100644 index 000000000..ba3c645e4 --- /dev/null +++ b/host/tests/devtest/usrp_probe.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# +# Copyright 2015 Ettus Research LLC +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. +# +""" Run uhd_find_devices and parse the output. """ + +import re +import subprocess + +def get_usrp_list(device_filter=None): + """ Returns a list of dicts that contain USRP info """ + try: + if device_filter is not None: + output = subprocess.check_output(['uhd_find_devices', '--args', device_filter]) + else: + output = subprocess.check_output('uhd_find_devices') + except subprocess.CalledProcessError: + return [] + split_re = "\n*-+\n-- .*\n-+\n" + uhd_strings = re.split(split_re, output) + result = [] + for uhd_string in uhd_strings: + if not re.match("Device Address", uhd_string): + continue + this_result = {k: v for k, v in re.findall(" ([a-z]+): (.*)", uhd_string)} + args_string = "" + try: + args_string = "type={},serial={}".format(this_result['type'], this_result['serial']) + except KeyError: + continue + this_result['args'] = args_string + result.append(this_result) + return result + +if __name__ == "__main__": + print get_usrp_list() + print get_usrp_list('type=x300') |