Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added uhd_modes.py, a UHD port of the usrp_modes.py program. Basicall…

…y the same but takes a rate instead of a decimation.

Right now there's a 1e6 gain block in there because old USRP spit out roughly 1e6x data as USRP2. Haven't investigated this for USRP vs USRP2 yet. Don't know why blocks care, actually.
  • Loading branch information...
commit 13c5acca528399feea01367a2812ac661c212294 1 parent 4a92b25
Nick Foster authored
Showing with 170 additions and 558 deletions.
  1. +0 −558 config/Makefile
  2. +170 −0 src/python/uhd_modes.py
View
558 config/Makefile
@@ -1,558 +0,0 @@
-# Makefile.in generated by automake 1.11.1 from Makefile.am.
-# config/Makefile. Generated from Makefile.in by configure.
-
-# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
-# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
-# Inc.
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-
-
-#
-# Copyright 2001 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.
-#
-
-# -*- Makefile -*-
-#
-# Copyright 2004,2006,2009 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.
-#
-
-pkgdatadir = $(datadir)/gr-howto-write-a-block
-pkgincludedir = $(includedir)/gr-howto-write-a-block
-pkglibdir = $(libdir)/gr-howto-write-a-block
-pkglibexecdir = $(libexecdir)/gr-howto-write-a-block
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = i686-pc-linux-gnu
-host_triplet = i686-pc-linux-gnu
-target_triplet = i686-pc-linux-gnu
-DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
- $(top_srcdir)/Makefile.common
-subdir = config
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/config/gr_gprof.m4 \
- $(top_srcdir)/config/gr_lib64.m4 \
- $(top_srcdir)/config/gr_no_undefined.m4 \
- $(top_srcdir)/config/gr_pwin32.m4 \
- $(top_srcdir)/config/gr_python.m4 \
- $(top_srcdir)/config/gr_scripting.m4 \
- $(top_srcdir)/config/gr_swig.m4 $(top_srcdir)/config/lf_cc.m4 \
- $(top_srcdir)/config/lf_cxx.m4 \
- $(top_srcdir)/config/lf_warnings.m4 \
- $(top_srcdir)/config/libtool.m4 \
- $(top_srcdir)/config/ltoptions.m4 \
- $(top_srcdir)/config/ltsugar.m4 \
- $(top_srcdir)/config/ltversion.m4 \
- $(top_srcdir)/config/lt~obsolete.m4 \
- $(top_srcdir)/config/pkg.m4 \
- $(top_srcdir)/config/gr_standalone.m4 \
- $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
- $(ACLOCAL_M4)
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = $(top_builddir)/config.h
-CONFIG_CLEAN_FILES =
-CONFIG_CLEAN_VPATH_FILES =
-SOURCES =
-DIST_SOURCES =
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = ${SHELL} /home/nick/gr-air-nick/missing --run aclocal-1.11
-AMTAR = ${SHELL} /home/nick/gr-air-nick/missing --run tar
-AR = ar
-AS = as
-AUTOCONF = ${SHELL} /home/nick/gr-air-nick/missing --run autoconf
-AUTOHEADER = ${SHELL} /home/nick/gr-air-nick/missing --run autoheader
-AUTOMAKE = ${SHELL} /home/nick/gr-air-nick/missing --run automake-1.11
-AWK = gawk
-CC = gcc
-CCAS = gcc
-CCASDEPMODE = depmode=gcc3
-CCASFLAGS = -g -O2 -Wall
-CCDEPMODE = depmode=gcc3
-CFLAGS = -g -O2 -Wall
-CPP = gcc -E
-CPPFLAGS =
-CXX = g++
-CXXCPP = g++ -E
-CXXDEPMODE = depmode=gcc3
-CXXFLAGS = -g -O2 -Wall -Woverloaded-virtual
-CYGPATH_W = echo
-DEFS = -DHAVE_CONFIG_H
-DEPDIR = .deps
-DLLTOOL = dlltool
-DSYMUTIL =
-DUMPBIN =
-ECHO_C =
-ECHO_N = -n
-ECHO_T =
-EGREP = /bin/grep -E
-EXEEXT =
-FGREP = /bin/grep -F
-GNURADIO_CORE_CFLAGS = -pthread -I/usr/local/include/gnuradio -I/usr/local/include
-GNURADIO_CORE_CPPFLAGS = -I/usr/local/include/gnuradio -I/usr/local/include
-GNURADIO_CORE_INCLUDEDIR = /usr/local/include/gnuradio
-GNURADIO_CORE_LIBS = -L/usr/local/lib -lboost_thread-mt -lboost_date_time-mt -lgnuradio-core -lgruel -lfftw3f -lgsl -lgslcblas -lm
-GREP = /bin/grep
-INSTALL = /usr/bin/install -c
-INSTALL_DATA = ${INSTALL} -m 644
-INSTALL_PROGRAM = ${INSTALL}
-INSTALL_SCRIPT = ${INSTALL}
-INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
-LD = /usr/bin/ld
-LDFLAGS =
-LIBOBJS =
-LIBS = -L/usr/local/lib -lboost_thread-mt -lboost_date_time-mt -lgnuradio-core -lgruel -lfftw3f -lgsl -lgslcblas -lm
-LIBTOOL = $(SHELL) $(top_builddir)/libtool
-LIPO =
-LN_S = ln -s
-LTLIBOBJS =
-MAKEINFO = ${SHELL} /home/nick/gr-air-nick/missing --run makeinfo
-MKDIR_P = /bin/mkdir -p
-NM = /usr/bin/nm -B
-NMEDIT =
-NO_UNDEFINED =
-OBJDUMP = objdump
-OBJEXT = o
-OTOOL =
-OTOOL64 =
-PACKAGE = gr-howto-write-a-block
-PACKAGE_BUGREPORT =
-PACKAGE_NAME = gr-howto-write-a-block
-PACKAGE_STRING = gr-howto-write-a-block 3.3svn
-PACKAGE_TARNAME = gr-howto-write-a-block
-PACKAGE_URL =
-PACKAGE_VERSION = 3.3svn
-PATH_SEPARATOR = :
-PKG_CONFIG = /usr/bin/pkg-config
-PYTHON = /usr/bin/python
-PYTHON_CPPFLAGS = -I/usr/include/python2.6
-PYTHON_EXEC_PREFIX = ${exec_prefix}
-PYTHON_LDFLAGS =
-PYTHON_PLATFORM = linux2
-PYTHON_PREFIX = ${prefix}
-PYTHON_VERSION = 2.6
-RANLIB = ranlib
-RM_PROG = /bin/rm
-SED = /bin/sed
-SET_MAKE =
-SHELL = /bin/bash
-STRIP = strip
-SWIG = /usr/bin/swig -c++
-SWIG_PYTHON_CPPFLAGS = -I/usr/include/python2.6
-SWIG_PYTHON_LIB = -lswigpy
-SWIG_PYTHON_OPT = -python
-VERSION = 3.3svn
-XMLTO =
-abs_builddir = /home/nick/gr-air-nick/config
-abs_srcdir = /home/nick/gr-air-nick/config
-abs_top_builddir = /home/nick/gr-air-nick
-abs_top_srcdir = /home/nick/gr-air-nick
-ac_ct_CC = gcc
-ac_ct_CXX = g++
-ac_ct_DUMPBIN =
-am__include = include
-am__leading_dot = .
-am__quote =
-am__tar = ${AMTAR} chof - "$$tardir"
-am__untar = ${AMTAR} xf -
-autoconf_default_CXXFLAGS = -g -O2
-bindir = ${exec_prefix}/bin
-build = i686-pc-linux-gnu
-build_alias =
-build_cpu = i686
-build_os = linux-gnu
-build_vendor = pc
-builddir = .
-datadir = ${datarootdir}
-datarootdir = ${prefix}/share
-docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
-dvidir = ${docdir}
-exec_prefix = ${prefix}
-gr_libdir_suffix =
-host = i686-pc-linux-gnu
-host_alias =
-host_cpu = i686
-host_os = linux-gnu
-host_vendor = pc
-htmldir = ${docdir}
-includedir = ${prefix}/include
-infodir = ${datarootdir}/info
-install_sh = ${SHELL} /home/nick/gr-air-nick/install-sh
-libdir = ${exec_prefix}/lib
-libexecdir = ${exec_prefix}/libexec
-localedir = ${datarootdir}/locale
-localstatedir = ${prefix}/var
-lt_ECHO = echo
-mandir = ${datarootdir}/man
-mkdir_p = /bin/mkdir -p
-oldincludedir = /usr/include
-pdfdir = ${docdir}
-pkgpyexecdir = ${pyexecdir}/gr-howto-write-a-block
-pkgpythondir = ${pythondir}/gr-howto-write-a-block
-prefix = /usr/local
-program_transform_name = s,x,x,
-psdir = ${docdir}
-pyexecdir = ${exec_prefix}/lib/python2.6/dist-packages
-pythondir = ${prefix}/lib/python2.6/dist-packages
-sbindir = ${exec_prefix}/sbin
-sharedstatedir = ${prefix}/com
-srcdir = .
-swig_CXXFLAGS = -g -O1 -Wno-strict-aliasing -Wno-parentheses
-sysconfdir = ${prefix}/etc
-target = i686-pc-linux-gnu
-target_alias =
-target_cpu = i686
-target_os = linux-gnu
-target_vendor = pc
-top_build_prefix = ../
-top_builddir = ..
-top_srcdir = ..
-
-# these flags are used when compiling non-SWIG-wrapper files
-# when going in to non-SWIG libraries
-AM_CXXFLAGS = -g -O2
-
-# these flags are used when compiling any CXX file
-AM_CPPFLAGS = \
- $(STD_DEFINES_AND_INCLUDES) \
- $(PYTHON_CPPFLAGS) \
- $(CPPUNIT_INCLUDES) \
- $(GNURADIO_CORE_CPPFLAGS)
-
-
-# these are used by both SWIG and CXX
-STD_DEFINES_AND_INCLUDES = \
- $(DEFINES) \
- -I$(GNURADIO_CORE_INCLUDEDIR) \
- -I$(GNURADIO_CORE_INCLUDEDIR)/swig
-
-
-# includes
-grincludedir = $(includedir)/gnuradio
-
-# swig includes
-swigincludedir = $(grincludedir)/swig
-
-# Install this stuff in the appropriate subdirectory
-# This usually ends up at:
-# ${prefix}/lib/python${python_version}/site-packages/gnuradio
-grpythondir = $(pythondir)/gnuradio
-grpyexecdir = $(pyexecdir)/gnuradio
-
-# Don't assume that make predefines $(RM), because BSD make does
-# not. We define it now in configure.ac using AM_PATH_PROG, but now
-# here have to add a -f to be like GNU make.
-RM = $(RM_PROG) -f
-
-# Other common defines; use "+=" to add to these
-STAMPS =
-MOSTLYCLEANFILES = $(BUILT_SOURCES) $(STAMPS) *.pyc *.pyo *~ *.tmp *.loT
-
-# Install m4 macros in this directory
-m4datadir = $(datadir)/aclocal
-
-# List your m4 macros here
-m4macros = \
- acx_pthread.m4 \
- ax_boost_base.m4 \
- ax_boost_date_time.m4 \
- ax_boost_filesystem.m4 \
- ax_boost_iostreams.m4 \
- ax_boost_program_options.m4 \
- ax_boost_python.m4 \
- ax_boost_regex.m4 \
- ax_boost_serialization.m4 \
- ax_boost_signals.m4 \
- ax_boost_system.m4 \
- ax_boost_test_exec_monitor.m4 \
- ax_boost_thread.m4 \
- ax_boost_unit_test_framework.m4 \
- ax_boost_wserialization.m4 \
- bnv_have_qt.m4 \
- cppunit.m4 \
- gr_check_createfilemapping.m4 \
- gr_check_mc4020.m4 \
- gr_check_shm_open.m4 \
- gr_check_usrp.m4 \
- gr_doxygen.m4 \
- gr_fortran.m4 \
- gr_gprof.m4 \
- gr_lib64.m4 \
- gr_libgnuradio_core_extra_ldflags.m4 \
- gr_no_undefined.m4 \
- gr_omnithread.m4 \
- gr_pwin32.m4 \
- gr_python.m4 \
- gr_require_mc4020.m4 \
- gr_scripting.m4 \
- gr_set_md_cpu.m4 \
- gr_standalone.m4 \
- gr_subversion.m4 \
- gr_swig.m4 \
- gr_sysv_shm.m4 \
- lf_cc.m4 \
- lf_cxx.m4 \
- lf_warnings.m4 \
- lf_x11.m4 \
- mkstemp.m4 \
- onceonly.m4 \
- pkg.m4 \
- usrp_fusb_tech.m4 \
- usrp_libusb.m4 \
- usrp_sdcc.m4
-
-
-# Don't install m4 macros anymore
-# m4data_DATA = $(m4macros)
-EXTRA_DIST = $(m4macros)
-all: all-am
-
-.SUFFIXES:
-$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(top_srcdir)/Makefile.common $(am__configure_deps)
- @for dep in $?; do \
- case '$(am__configure_deps)' in \
- *$$dep*) \
- ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
- && { if test -f $@; then exit 0; else break; fi; }; \
- exit 1;; \
- esac; \
- done; \
- echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu config/Makefile'; \
- $(am__cd) $(top_srcdir) && \
- $(AUTOMAKE) --gnu config/Makefile
-.PRECIOUS: Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
- @case '$?' in \
- *config.status*) \
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
- *) \
- echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
- esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-
-$(top_srcdir)/configure: $(am__configure_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(ACLOCAL_M4): $(am__aclocal_m4_deps)
- cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
-$(am__aclocal_m4_deps):
-
-mostlyclean-libtool:
- -rm -f *.lo
-
-clean-libtool:
- -rm -rf .libs _libs
-tags: TAGS
-TAGS:
-
-ctags: CTAGS
-CTAGS:
-
-
-distdir: $(DISTFILES)
- @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
- list='$(DISTFILES)'; \
- dist_files=`for file in $$list; do echo $$file; done | \
- sed -e "s|^$$srcdirstrip/||;t" \
- -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
- case $$dist_files in \
- */*) $(MKDIR_P) `echo "$$dist_files" | \
- sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
- sort -u` ;; \
- esac; \
- for file in $$dist_files; do \
- if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
- if test -d $$d/$$file; then \
- dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
- if test -d "$(distdir)/$$file"; then \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
- cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
- find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
- fi; \
- cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
- else \
- test -f "$(distdir)/$$file" \
- || cp -p $$d/$$file "$(distdir)/$$file" \
- || exit 1; \
- fi; \
- done
- $(MAKE) $(AM_MAKEFLAGS) \
- top_distdir="$(top_distdir)" distdir="$(distdir)" \
- dist-hook
-check-am: all-am
-check: check-am
-all-am: Makefile
-installdirs:
-install: install-am
-install-exec: install-exec-am
-install-data: install-data-am
-uninstall: uninstall-am
-
-install-am: all-am
- @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-am
-install-strip:
- $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
- install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
- `test -z '$(STRIP)' || \
- echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
-mostlyclean-generic:
- -test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
-
-clean-generic:
-
-distclean-generic:
- -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
- -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-
-maintainer-clean-generic:
- @echo "This command is intended for maintainers to use"
- @echo "it deletes files that may require special tools to rebuild."
-clean: clean-am
-
-clean-am: clean-generic clean-libtool mostlyclean-am
-
-distclean: distclean-am
- -rm -f Makefile
-distclean-am: clean-am distclean-generic
-
-dvi: dvi-am
-
-dvi-am:
-
-html: html-am
-
-html-am:
-
-info: info-am
-
-info-am:
-
-install-data-am:
-
-install-dvi: install-dvi-am
-
-install-dvi-am:
-
-install-exec-am:
-
-install-html: install-html-am
-
-install-html-am:
-
-install-info: install-info-am
-
-install-info-am:
-
-install-man:
-
-install-pdf: install-pdf-am
-
-install-pdf-am:
-
-install-ps: install-ps-am
-
-install-ps-am:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-am
- -rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-am
-
-mostlyclean-am: mostlyclean-generic mostlyclean-libtool
-
-pdf: pdf-am
-
-pdf-am:
-
-ps: ps-am
-
-ps-am:
-
-uninstall-am:
-
-.MAKE: install-am install-strip
-
-.PHONY: all all-am check check-am clean clean-generic clean-libtool \
- dist-hook distclean distclean-generic distclean-libtool \
- distdir dvi dvi-am html html-am info info-am install \
- install-am install-data install-data-am install-dvi \
- install-dvi-am install-exec install-exec-am install-html \
- install-html-am install-info install-info-am install-man \
- install-pdf install-pdf-am install-ps install-ps-am \
- install-strip installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-generic mostlyclean \
- mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
- uninstall uninstall-am
-
-
-# Don't distribute the files defined in the variable 'no_dist_files'
-dist-hook:
- @for file in $(no_dist_files); do \
- echo $(RM) $(distdir)/$$file; \
- $(RM) $(distdir)/$$file; \
- done;
-
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
View
170 src/python/uhd_modes.py
@@ -0,0 +1,170 @@
+#!/usr/bin/env python
+
+from gnuradio import gr, gru, optfir, eng_notation, blks2, air
+from gnuradio import uhd
+from gnuradio.eng_option import eng_option
+from optparse import OptionParser
+import time, os, sys
+from string import split, join
+from usrpm import usrp_dbid
+from modes_print import modes_print
+from modes_sql import modes_sql
+import gnuradio.gr.gr_threading as _threading
+import MySQLdb
+
+
+class top_block_runner(_threading.Thread):
+ def __init__(self, tb):
+ _threading.Thread.__init__(self)
+ self.setDaemon(1)
+ self.tb = tb
+ self.done = False
+ self.start()
+
+ def run(self):
+ self.tb.run()
+ self.done = True
+
+
+"""
+
+The following are optional command line parameters:
+
+-R SUBDEV Daughter board specification, defaults to first found
+-f FREQ USRP receive frequency (1090 MHz Default)
+-g GAIN Daughterboard gain setting. Defaults to mid-range.
+-d DECIM USRP decimation rate
+-t THRESH Receiver valid pulse threshold
+-a Output all frames. Defaults only output frames
+
+Once the program is running, ctrl-break (Ctrl-C) stops operation.
+"""
+
+class adsb_rx_block (gr.top_block):
+
+ def __init__(self, options, args, queue):
+ gr.top_block.__init__(self)
+
+ self.options = options
+ self.args = args
+
+ if options.filename is None:
+ self.u = uhd.simple_source("", uhd.io_type_t.COMPLEX_FLOAT32)
+
+ if(options.rx_subdev_spec is None):
+ options.rx_subdev_spec = ""
+ self.u.set_subdev_spec(options.rx_subdev_spec)
+
+ rate = options.rate
+ self.u.set_samp_rate(rate)
+ rate = int(self.u.get_samp_rate()) #retrieve actual
+
+ if options.gain is None: #set to halfway
+ g = self.u.get_gain_range()
+ options.gain = (g[0]+g[1]) / 2.0
+
+ if not(self.tune(options.freq)):
+ print "Failed to set initial frequency"
+
+ print "Setting gain to %i" % (options.gain,)
+ self.u.set_gain(options.gain)
+# self.subdev.set_bw(self.options.bandwidth) #only for DBSRX
+
+ else:
+ rate = options.rate
+ self.u = gr.file_source(gr.sizeof_gr_complex, options.filename)
+
+ print "Rate is %i" % (rate,)
+ print "Gain is %i" % (self.u.get_gain(),)
+ pass_all = 0
+ if options.output_all :
+ pass_all = 1
+
+ self.gain = gr.multiply_const_cc(1000000)
+ self.demod = gr.complex_to_mag()
+ self.avg = gr.moving_average_ff(100, 1.0/100, 400);
+ self.preamble = air.modes_preamble(rate, options.threshold)
+ self.framer = air.modes_framer(rate)
+ self.slicer = air.modes_slicer(rate, queue)
+
+# if options.rate < 16:
+ #there's a really nasty spur at 1088 caused by a multiple of the USRP xtal. if you use a decimation of 16, it gets filtered out by the CIC. if not, it really fucks with you unless you filter it out.
+# filter_coeffs = gr.firdes.band_reject(1.0, rate, 1.7e6, 2.3e6, 0.5e6, gr.firdes.WIN_HAMMING)
+# self.filt = gr.fir_filter_ccf(1, filter_coeffs)
+# self.connect(self.u, self.filt)
+# else:
+ self.filt = self.u
+
+ self.connect(self.filt, self.gain, self.demod)
+ self.connect(self.demod, self.avg)
+ self.connect(self.demod, (self.preamble, 0))
+ self.connect(self.avg, (self.preamble, 1))
+ self.connect(self.demod, (self.framer, 0))
+ self.connect(self.preamble, (self.framer, 1))
+ self.connect(self.demod, (self.slicer, 0))
+ self.connect(self.framer, (self.slicer, 1))
+
+ def tune(self, freq):
+ result = self.u.set_center_freq(freq)
+ return result
+
+
+if __name__ == '__main__':
+ usage = "%prog: [options] output filename"
+ parser = OptionParser(option_class=eng_option, usage=usage)
+ parser.add_option("-R", "--rx-subdev-spec", type="subdev",
+ help="select USRP Rx side A or B", metavar="SUBDEV")
+ parser.add_option("-f", "--freq", type="eng_float", default=1090e6,
+ help="set receive frequency in Hz [default=%default]", metavar="FREQ")
+ parser.add_option("-g", "--gain", type="int", default=None,
+ help="set RF gain", metavar="dB")
+ parser.add_option("-r", "--rate", type="int", default=4000000,
+ help="set ADC sample rate [default=%default]")
+ parser.add_option("-T", "--threshold", type="eng_float", default=3.0,
+ help="set pulse detection threshold above noise in dB [default=%default]")
+ parser.add_option("-a","--output-all", action="store_true", default=False,
+ help="output all frames")
+ parser.add_option("-b","--bandwidth", type="eng_float", default=5e6,
+ help="set DBSRX front-end bandwidth in Hz [default=5e6]")
+ parser.add_option("-F","--filename", type="string", default=None,
+ help="read data from file instead of USRP")
+ parser.add_option("-D","--database", action="store_true", default=False,
+ help="send to database instead of printing to screen")
+ (options, args) = parser.parse_args()
+# if len(args) != 1:
+# parser.print_help()
+# sys.exit(1)
+
+# filename = args[0]
+
+ queue = gr.msg_queue()
+
+ if options.database is True:
+ db = MySQLdb.connect(host="localhost", user="planes", passwd="planes", db="planes")
+
+ fg = adsb_rx_block(options, args, queue)
+ runner = top_block_runner(fg)
+
+ while 1:
+ try:
+ if queue.empty_p() == 0 :
+ while queue.empty_p() == 0 :
+ msg = queue.delete_head() #blocking read
+ if options.database is False:
+ print modes_print(msg.to_string())
+ else:
+ query = modes_sql(msg.to_string())
+ if query is not None:
+ c = db.cursor()
+ c.execute(query)
+
+ elif runner.done:
+ break
+ else:
+ time.sleep(0.1)
+
+ except KeyboardInterrupt:
+ fg.stop()
+ runner = None
+ break
+
Please sign in to comment.
Something went wrong with that request. Please try again.