aboutsummaryrefslogtreecommitdiffstats
path: root/tools/gr-usrptest/apps
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gr-usrptest/apps')
-rw-r--r--tools/gr-usrptest/apps/CMakeLists.txt26
-rwxr-xr-xtools/gr-usrptest/apps/usrp_phasealignment.py72
-rwxr-xr-xtools/gr-usrptest/apps/usrp_selftest.py17
3 files changed, 115 insertions, 0 deletions
diff --git a/tools/gr-usrptest/apps/CMakeLists.txt b/tools/gr-usrptest/apps/CMakeLists.txt
new file mode 100644
index 000000000..a40192924
--- /dev/null
+++ b/tools/gr-usrptest/apps/CMakeLists.txt
@@ -0,0 +1,26 @@
+# Copyright 2011 Free Software Foundation, Inc.
+#
+# This file is part of GNU Radio
+#
+# GNU Radio 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, or (at your option)
+# any later version.
+#
+# GNU Radio 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 GNU Radio; see the file COPYING. If not, write to
+# the Free Software Foundation, Inc., 51 Franklin Street,
+# Boston, MA 02110-1301, USA.
+
+include(GrPython)
+
+GR_PYTHON_INSTALL(
+ PROGRAMS
+ usrp_phasealignment.py
+ DESTINATION bin
+)
diff --git a/tools/gr-usrptest/apps/usrp_phasealignment.py b/tools/gr-usrptest/apps/usrp_phasealignment.py
new file mode 100755
index 000000000..928788be4
--- /dev/null
+++ b/tools/gr-usrptest/apps/usrp_phasealignment.py
@@ -0,0 +1,72 @@
+#!/usr/bin/env python
+
+from gnuradio.uhd.uhd_app import UHDApp
+from usrptest.flowgraphs import phasealignment_fg
+from usrptest.functions import run_test, setup_phase_alignment_parser, setup_tx_phase_alignment_parser, setup_manual_phase_alignment_parser
+import time
+import argparse
+
+
+def plot_results(results):
+ import matplotlib.pyplot as plt
+ ax = plt.axes()
+ ax.set_ylim(-180, 180)
+ for result in results:
+ plt.errorbar(
+ range(len(result['avg'])),
+ result["avg"],
+ result["stddev"],
+ label="{} - {}".format(result["first"], result["second"]),
+ axes=ax)
+ ax.legend(loc='upper left', bbox_to_anchor=(0.0, 0.0))
+ plt.show()
+
+
+def print_results(results):
+ for result in results:
+ print('Results for: {first} - {second}'.format(
+ first=result['first'], second=result['second']))
+ for i, (avg,
+ stddev) in enumerate(zip(result['avg'], result['stddev'])):
+ print('\t {}. run avg: {}, stddev: {}'.format(i + 1, avg, stddev))
+
+
+def main():
+ parser = argparse.ArgumentParser(conflict_handler='resolve')
+ UHDApp.setup_argparser(parser=parser)
+ parser = setup_phase_alignment_parser(parser)
+ parser = setup_tx_phase_alignment_parser(parser)
+ parser = setup_manual_phase_alignment_parser(parser)
+ args = parser.parse_args()
+ test_app = UHDApp(args=args)
+ if args.auto and args.start_freq and args.stop_freq:
+ from random import uniform
+ bw = (args.stop_freq - args.start_freq) / args.freq_bands
+ for nband in range(args.freq_bands):
+ freq1 = args.start_freq + nband * bw
+ new_freq = uniform(freq1, freq1 + bw)
+ test_app.args.freq = new_freq
+ raw_input(
+ "New test frequency: {:f} MHz. Adjust your signal generator and press ENTER to start measurement.".
+ format(new_freq / 1e6))
+ fg = phasealignment_fg.phasealignment_fg(test_app)
+ fg.start()
+ results = run_test(fg, args.runs)
+ fg.stop()
+ fg.wait()
+ if args.plot:
+ plot_results(results)
+ print_results(results)
+ else:
+ fg = phasealignment_fg.phasealignment_fg(test_app)
+ fg.start()
+ results = run_test(fg, args.runs)
+ fg.stop()
+ fg.wait()
+ if args.plot:
+ plot_results(results)
+ print_results(results)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/tools/gr-usrptest/apps/usrp_selftest.py b/tools/gr-usrptest/apps/usrp_selftest.py
new file mode 100755
index 000000000..3dcd4e6ca
--- /dev/null
+++ b/tools/gr-usrptest/apps/usrp_selftest.py
@@ -0,0 +1,17 @@
+#!/usr/bin/env python
+
+import argparse
+from usrptest import parsers
+from usrptest.flowgraphs import selftest_fg
+
+
+def main():
+ parser = argparse.ArgumentParser()
+ parser = parsers.add_core_args(parser)
+ parser = parsers.add_selftest_args(parser)
+ args = parser.parse_args()
+ my_flowgraph = selftest_fg.selftest_fg(args.frequency, args.samp_rate, args.dphase ,args.devices)
+ results = my_flowgraph.run()
+ print(results)
+if __name__ == '__main__':
+ main()