diff options
35 files changed, 1 insertions, 3293 deletions
diff --git a/config/Makefile.am b/config/Makefile.am index eb1056eb6..527aefa7e 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -68,7 +68,6 @@ m4macros = \ grc_gr_trellis.m4 \ grc_gr_usrp.m4 \ grc_gr_video_sdl.m4 \ - grc_gr_vrt.m4 \ grc_gr_wxgui.m4 \ grc_mblock.m4 \ grc_gruel.m4 \ diff --git a/config/grc_gr_vrt.m4 b/config/grc_gr_vrt.m4 deleted file mode 100644 index ff2d06347..000000000 --- a/config/grc_gr_vrt.m4 +++ /dev/null @@ -1,38 +0,0 @@ -dnl Copyright 2008,2009 Free Software Foundation, Inc. -dnl -dnl This file is part of GNU Radio -dnl -dnl GNU Radio is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 3, or (at your option) -dnl any later version. -dnl -dnl GNU Radio is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with GNU Radio; see the file COPYING. If not, write to -dnl the Free Software Foundation, Inc., 51 Franklin Street, -dnl Boston, MA 02110-1301, USA. - -AC_DEFUN([GRC_GR_VRT],[ - GRC_ENABLE(gr-vrt) - - dnl Don't do gr-usrp if gnuradio-core or vrt skipped - GRC_CHECK_DEPENDENCY(gr-vrt, vrt) - GRC_CHECK_DEPENDENCY(gr-vrt, gnuradio-core) - - AC_CONFIG_FILES([ \ - gr-vrt/Makefile \ - gr-vrt/gnuradio-vrt.pc \ - gr-vrt/src/Makefile \ - gr-vrt/src/run_tests \ - ]) - - GRC_BUILD_CONDITIONAL(gr-vrt,[ - dnl run_tests is created from run_tests.in. Make it executable. - AC_CONFIG_COMMANDS([run_tests_vrt], [chmod +x gr-vrt/src/run_tests]) - ]) -]) diff --git a/gr-vrt/.gitignore b/gr-vrt/.gitignore deleted file mode 100644 index 5cf95da46..000000000 --- a/gr-vrt/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile -Makefile.in -gnuradio-vrt.pc diff --git a/gr-vrt/Makefile.am b/gr-vrt/Makefile.am deleted file mode 100644 index 96019be97..000000000 --- a/gr-vrt/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright 2001,2006,2008,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. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = src - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = gnuradio-vrt.pc diff --git a/gr-vrt/gnuradio-vrt.pc.in b/gr-vrt/gnuradio-vrt.pc.in deleted file mode 100644 index b5f416051..000000000 --- a/gr-vrt/gnuradio-vrt.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@/gnuradio - -Name: gnuradio-vrt -Description: GNU Software Radio support for Virtual Radio Transport (VRT aka VITA-49) -Requires: gnuradio-core vrt -Version: @VERSION@ -Libs: -L${libdir} -lgnuradio-vrt -Cflags: -I${includedir} diff --git a/gr-vrt/src/.gitignore b/gr-vrt/src/.gitignore deleted file mode 100644 index 9ae817ed4..000000000 --- a/gr-vrt/src/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -Makefile -Makefile.in -.deps -.libs -run_tests -vrt.py -vrt.pyc -vrt.cc diff --git a/gr-vrt/src/Makefile.am b/gr-vrt/src/Makefile.am deleted file mode 100644 index 671c10274..000000000 --- a/gr-vrt/src/Makefile.am +++ /dev/null @@ -1,122 +0,0 @@ -# -# Copyright 2004,2005,2006,2008,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. -# - -include $(top_srcdir)/Makefile.common - -# ---------------------------------------------------------------------- -# Local Python files, not installed -# -# qa_vrt.py -# ---------------------------------------------------------------------- - -noinst_PYTHON = qa_vrt.py - -# ---------------------------------------------------------------------- -# Miscellaneous build operations -# ---------------------------------------------------------------------- - -EXTRA_DIST = run_tests.in -TESTS = run_tests -DISTCLEANFILES = run_tests - -# ---------------------------------------------------------------------- -# C++ block API interface librar(ies) -# -# libgnuradio_vrt.so -# ---------------------------------------------------------------------- -AM_CPPFLAGS = \ - $(STD_DEFINES_AND_INCLUDES) \ - $(GRUEL_INCLUDES) \ - $(PYTHON_CPPFLAGS) \ - $(VRT_INCLUDES) \ - $(WITH_INCLUDES) - -lib_LTLIBRARIES = libgnuradio-vrt.la - -libgnuradio_vrt_la_SOURCES = \ - missing_pkt_checker.cc \ - vrt_source_base.cc \ - vrt_source_32fc.cc \ - vrt_quadradio_source_32fc.cc - - -#libgnuradio_vrt_la_SOURCES = \ -# rx_16sc_handler.cc \ -# rx_32fc_handler.cc \ -# vrt_base.cc \ -# vrt_source_base.cc \ -# vrt_source_16sc.cc \ -# vrt_source_32fc.cc - -# vrt_sink_base.cc \ -# vrt_sink_16sc.cc \ -# vrt_sink_32fc.cc - -libgnuradio_vrt_la_LIBADD = \ - $(VRT_LA) \ - $(GNURADIO_CORE_LA) - -grinclude_HEADERS = \ - vrt_source_base.h \ - vrt_source_32fc.h \ - vrt_quadradio_source_32fc.h - -# vrt_source_16sc.h \ -# vrt_sink_base.h \ -# vrt_sink_16sc.h \ -# vrt_sink_32fc.h - -noinst_HEADERS = \ - missing_pkt_checker.h - - -# ---------------------------------------------------------------------- -# Python SWIG wrapper around C++ library -# -# vrt.py -# _vrt.so -# ---------------------------------------------------------------------- - -TOP_SWIG_IFILES = \ - vrt.i - -# Install so that they end up available as: -# import gnuradio.vrt -# This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio -vrt_pythondir_category = \ - gnuradio - -# additional arguments to the SWIG command -vrt_swig_args = \ - $(VRT_INCLUDES) - -# additional libraries for linking with the SWIG-generated library -vrt_la_swig_libadd = \ - libgnuradio-vrt.la - -include $(top_srcdir)/Makefile.swig - -# add some of the variables generated inside the Makefile.swig.gen -BUILT_SOURCES = $(swig_built_sources) - -# Do not distribute the output of SWIG -no_dist_files = $(swig_built_sources) diff --git a/gr-vrt/src/Makefile.swig.gen b/gr-vrt/src/Makefile.swig.gen deleted file mode 100644 index b0a4a22fa..000000000 --- a/gr-vrt/src/Makefile.swig.gen +++ /dev/null @@ -1,259 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 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. -# - -# Makefile.swig.gen for vrt.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/vrt -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/vrt -## -## The following can be overloaded to change the install location, but -## this has to be done in the including Makefile.am -before- -## Makefile.swig is included. - -vrt_pythondir_category ?= gnuradio/vrt -vrt_pylibdir_category ?= $(vrt_pythondir_category) -vrt_pythondir = $(pythondir)/$(vrt_pythondir_category) -vrt_pylibdir = $(pyexecdir)/$(vrt_pylibdir_category) - -## SWIG headers are always installed into the same directory. - -vrt_swigincludedir = $(swigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Stamps used to ensure parallel make does the right thing. These -## are removed by "make clean", but otherwise unused except during the -## parallel built. These will not be included in a tarball, because -## the SWIG-generated files will be removed from the distribution. - -STAMPS += $(DEPDIR)/vrt-generate-* - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Add the .py and .cc files to the list of SWIG built sources. The -## .h file is sometimes built, but not always ... so that one has to -## be added manually by the including Makefile.am . - -swig_built_sources += vrt.py vrt.cc - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -vrt_swiginclude_HEADERS = \ - vrt.i \ - $(vrt_swiginclude_headers) - -vrt_pylib_LTLIBRARIES = \ - _vrt.la - -_vrt_la_SOURCES = \ - vrt.cc \ - $(vrt_la_swig_sources) - -_vrt_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(vrt_la_swig_libadd) - -_vrt_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(vrt_la_swig_ldflags) - -_vrt_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - $(vrt_la_swig_cxxflags) - -vrt_python_PYTHON = \ - vrt.py \ - $(vrt_python) - -## Entry rule for running SWIG - -vrt.h vrt.py vrt.cc: vrt.i -## This rule will get called only when MAKE decides that one of the -## targets needs to be created or re-created, because: -## -## * The .i file is newer than any or all of the generated files; -## -## * Any or all of the .cc, .h, or .py files does not exist and is -## needed (in the case this file is not needed, the rule for it is -## ignored); or -## -## * Some SWIG-based dependecy of the .cc file isn't met and hence the -## .cc file needs be be regenerated. Explanation: Because MAKE -## knows how to handle dependencies for .cc files (regardless of -## their name or extension), then the .cc file is used as a target -## instead of the .i file -- but with the dependencies of the .i -## file. It is this last reason why the line: -## -## if test -f $@; then :; else -## -## cannot be used in this case: If a .i file dependecy is not met, -## then the .cc file needs to be rebuilt. But if the stamp is newer -## than the .cc file, and the .cc file exists, then in the original -## version (with the 'test' above) the internal MAKE call will not -## be issued and hence the .cc file will not be rebuilt. -## -## Once execution gets to here, it should always proceed no matter the -## state of a stamp (as discussed in link above). The -## $(DEPDIR)/vrt-generate stuff is used to allow for parallel -## builds to "do the right thing". The stamp has no relationship with -## either the target files or dependency file; it is used solely for -## the protection of multiple builds during a given call to MAKE. -## -## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM -## (15). At a caught signal, the quoted command will be issued before -## exiting. In this case, remove any stamp, whether temporary of not. -## The trap is valid until the process exits; the process includes all -## commands appended via "\"s. -## - trap 'rm -rf $(DEPDIR)/vrt-generate-*' 1 2 13 15; \ -## -## Create a temporary directory, which acts as a lock. The first -## process to create the directory will succeed and issue the MAKE -## command to do the actual work, while all subsequent processes will -## fail -- leading them to wait for the first process to finish. -## - if mkdir $(DEPDIR)/vrt-generate-lock 2>/dev/null; then \ -## -## This code is being executed by the first process to succeed in -## creating the directory lock. -## -## Remove the stamp associated with this filename. -## - rm -f $(DEPDIR)/vrt-generate-stamp; \ -## -## Tell MAKE to run the rule for creating this stamp. -## - $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/vrt-generate-stamp WHAT=$<; \ -## -## Now that the .cc, .h, and .py files have been (re)created from the -## .i file, future checking of this rule during the same MAKE -## execution will come back that the rule doesn't need to be executed -## because none of the conditions mentioned at the start of this rule -## will be positive. Remove the the directory lock, which frees up -## any waiting process(es) to continue. -## - rmdir $(DEPDIR)/vrt-generate-lock; \ - else \ -## -## This code is being executed by any follower processes while the -## directory lock is in place. -## -## Wait until the first process is done, testing once per second. -## - while test -d $(DEPDIR)/vrt-generate-lock; do \ - sleep 1; \ - done; \ -## -## Succeed if and only if the first process succeeded; exit this -## process returning the status of the generated stamp. -## - test -f $(DEPDIR)/vrt-generate-stamp; \ - exit $$?; \ - fi; - -$(DEPDIR)/vrt-generate-stamp: -## This rule will be called only by the first process issuing the -## above rule to succeed in creating the lock directory, after -## removing the actual stamp file in order to guarantee that MAKE will -## execute this rule. -## -## Call SWIG to generate the various output files; special -## post-processing on 'mingw32' host OS for the dependency file. -## - if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(vrt_swig_args) \ - -MD -MF $(DEPDIR)/vrt.Std \ - -module vrt -o vrt.cc $(WHAT); then \ - if test $(host_os) = mingw32; then \ - $(RM) $(DEPDIR)/vrt.Sd; \ - $(SED) 's,\\\\,/,g' < $(DEPDIR)/vrt.Std \ - > $(DEPDIR)/vrt.Sd; \ - $(RM) $(DEPDIR)/vrt.Std; \ - $(MV) $(DEPDIR)/vrt.Sd $(DEPDIR)/vrt.Std; \ - fi; \ - else \ - $(RM) $(DEPDIR)/vrt.S*; exit 1; \ - fi; -## -## Mess with the SWIG output .Std dependency file, to create a -## dependecy file valid for the input .i file: Basically, simulate the -## dependency file created for libraries by GNU's libtool for C++, -## where all of the dependencies for the target are first listed, then -## each individual dependency is listed as a target with no further -## dependencies. -## -## (1) remove the current dependency file -## - $(RM) $(DEPDIR)/vrt.d -## -## (2) Copy the whole SWIG file: -## - cp $(DEPDIR)/vrt.Std $(DEPDIR)/vrt.d -## -## (3) all a carriage return to the end of the dependency file. -## - echo "" >> $(DEPDIR)/vrt.d -## -## (4) from the SWIG file, remove the first line (the target); remove -## trailing " \" and " " from each line. Append ":" to each line, -## followed by 2 carriage returns, then append this to the end of -## the dependency file. -## - $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/vrt.Std | \ - awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/vrt.d -## -## (5) remove the SWIG-generated file -## - $(RM) $(DEPDIR)/vrt.Std -## -## Create the stamp for this filename generation, to signal success in -## executing this rule; allows other threads waiting on this process -## to continue. -## - touch $(DEPDIR)/vrt-generate-stamp - -# KLUDGE: Force runtime include of a SWIG dependency file. This is -# not guaranteed to be portable, but will probably work. If it works, -# we have accurate dependencies for our swig stuff, which is good. - -@am__include@ @am__quote@./$(DEPDIR)/vrt.d@am__quote@ - diff --git a/gr-vrt/src/missing_pkt_checker.cc b/gr-vrt/src/missing_pkt_checker.cc deleted file mode 100644 index 09b70fe2c..000000000 --- a/gr-vrt/src/missing_pkt_checker.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <missing_pkt_checker.h> - -int -missing_pkt_checker::check(const vrt::expanded_header *hdr) -{ - // FIXME assumes we're inspecting only a single stream - - int nmissing = 0; - int actual = hdr->pkt_cnt(); - int expected = (d_last_pkt_cnt + 1) & 0xf; - if (actual != expected && !d_resync){ - d_nwrong_pkt_cnt++; - if (actual > expected) - nmissing = actual - expected; - else - nmissing = actual + 16 - expected; - d_nmissing_pkt_est += nmissing; - } - d_last_pkt_cnt = actual; - d_npackets++; - d_resync = false; - return nmissing; -} diff --git a/gr-vrt/src/missing_pkt_checker.h b/gr-vrt/src/missing_pkt_checker.h deleted file mode 100644 index ab171ffa3..000000000 --- a/gr-vrt/src/missing_pkt_checker.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MISSING_PKT_CHECKER_H -#define INCLUDED_MISSING_PKT_CHECKER_H - -#include <vrt/expanded_header.h> -#include <stdint.h> - -/*! - * \brief Check for missing packets - */ -class missing_pkt_checker -{ - // FIXME assumes we're inspecting only a single stream - - bool d_resync; - uint64_t d_npackets; //< total number of packets - int d_last_pkt_cnt; //< the last pkt_cnt we saw - uint64_t d_nwrong_pkt_cnt; //< number of incorrect pkt_cnt - uint64_t d_nmissing_pkt_est; //< estimate of total number of missing pkts - -public: - missing_pkt_checker() - : d_resync(true), d_npackets(0), d_last_pkt_cnt(0xf), d_nwrong_pkt_cnt(0), - d_nmissing_pkt_est(0) {} - - /*! - * \brief check header pkt_cnt and return 0 if OK, else estimate of number of missing packets. - */ - int check(const vrt::expanded_header *hdr); - - void resync() { d_resync = true; } - uint64_t npackets() const { return d_npackets; } - uint64_t nwrong_pkt_cnt() const { return d_nwrong_pkt_cnt; } - uint64_t nmissing_pkt_est() const { return d_nmissing_pkt_est; } -}; - - -#endif /* INCLUDED_MISSING_PKT_CHECKER_H */ diff --git a/gr-vrt/src/qa_vrt.py b/gr-vrt/src/qa_vrt.py deleted file mode 100755 index 9df1edd92..000000000 --- a/gr-vrt/src/qa_vrt.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2008,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. -# - -from gnuradio import gr, gr_unittest -import vrt - -class qa_vrt(gr_unittest.TestCase): - - def setUp(self): - self.tb = gr.top_block() - - def tearDown(self): - self.tb = None - - def test_000_nop (self): - """Just see if we can import the module... - They may not have a VRT connected, etc. Don't try to run anything""" - pass - -if __name__ == '__main__': - gr_unittest.main () diff --git a/gr-vrt/src/run_tests.in b/gr-vrt/src/run_tests.in deleted file mode 100644 index 5c56c4674..000000000 --- a/gr-vrt/src/run_tests.in +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -# 1st parameter is absolute path to component source directory -# 2nd parameter is absolute path to component build directory -# 3rd parameter is path to Python QA directory - -# For OS/X -DYLD_LIBRARY_PATH=@abs_top_builddir@/vrt/host/lib/legacy:@abs_top_builddir@/vrt/host/lib/legacy/.libs:$DYLD_LIBRARY_PATH -export DYLD_LIBRARY_PATH - -# For Win32 -PATH=@abs_top_builddir@/vrt/host/lib/legacy:@abs_top_builddir@/vrt/host/lib/legacy/.libs:$PATH - -@top_builddir@/run_tests.sh \ - @abs_top_srcdir@/gr-vrt \ - @abs_top_builddir@/gr-vrt \ - @srcdir@ diff --git a/gr-vrt/src/vrt.i b/gr-vrt/src/vrt.i deleted file mode 100644 index 9016dc33e..000000000 --- a/gr-vrt/src/vrt.i +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,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. - */ - -%include "gnuradio.i" // the common stuff -%import <stdint.i> - -%{ -#include "vrt_quadradio_source_32fc.h" -#include <vrt/quadradio.h> -//#include "vrt_quadradio_source_16sc.h" -//#include "vrt_sink_32fc.h" -//#include "vrt_sink_16sc.h" -%} - -%template(uint32_t_vector) std::vector<uint32_t>; - -// ---------------------------------------------------------------- - -class vrt_source_base : public gr_sync_block -{ -protected: - vrt_source_base() throw (std::runtime_error); - -public: - ~vrt_source_base(); - -}; - -class vrt_source_32fc : public vrt_source_base -{ -protected: - vrt_source_32fc() throw (std::runtime_error); - -public: - ~vrt_source_32fc(); - void reset(); -}; - -// ---------------------------------------------------------------- - -GR_SWIG_BLOCK_MAGIC(vrt,quadradio_source_32fc) - -%include "vrt_quadradio_source_32fc.h" - -%include <vrt/quadradio.h> diff --git a/gr-vrt/src/vrt_quadradio_source_32fc.cc b/gr-vrt/src/vrt_quadradio_source_32fc.cc deleted file mode 100644 index cd779bdf5..000000000 --- a/gr-vrt/src/vrt_quadradio_source_32fc.cc +++ /dev/null @@ -1,226 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <vrt_quadradio_source_32fc.h> -#include <vrt/quadradio.h> -#include <vrt/rx_packet_handler.h> -#include <cstdio> - -vrt_quadradio_source_32fc_sptr -vrt_make_quadradio_source_32fc(const std::string &ip, - size_t rx_bufsize, - size_t samples_per_pkt, - int rxdspno) -{ - return gnuradio::get_initial_sptr(new vrt_quadradio_source_32fc(ip, - rx_bufsize, - samples_per_pkt, - rxdspno)); -} - -vrt_quadradio_source_32fc::vrt_quadradio_source_32fc(const std::string &ip, - size_t rx_bufsize, - size_t samples_per_pkt, - int rxdspno) - : vrt_source_32fc("quadradio_source_32fc"), - d_samples_per_pkt(samples_per_pkt == 0 ? (rxdspno == 0 ? 800 : 200) : samples_per_pkt), - d_qr(vrt::quadradio::sptr(new vrt::quadradio(ip, rx_bufsize))), - d_rxdspno(rxdspno) -{ -} - -vrt_quadradio_source_32fc::~vrt_quadradio_source_32fc() -{ - d_qr->stop_streaming(d_rxdspno); -} - -vrt::rx::sptr -vrt_quadradio_source_32fc::vrt_rx() const -{ - return d_qr->vrt_rx(); -} - -bool -vrt_quadradio_source_32fc::start() -{ - // throw away any stale packets before starting - vrt::rx_packet_handler nop; - vrt_rx()->rx_packets(&nop, true); - d_checker.resync(); - - return d_qr->start_streaming(d_rxdspno, d_samples_per_pkt); -} - -bool -vrt_quadradio_source_32fc::stop() -{ - return d_qr->stop_streaming(d_rxdspno); -} - -bool -vrt_quadradio_source_32fc::set_dboard_pins(int which_dboard, int v) -{ - return d_qr->set_dboard_pins(which_dboard, v); -} - -bool -vrt_quadradio_source_32fc::set_center_freq(double target_freq) -{ - return d_qr->set_center_freq(target_freq); -} - -bool -vrt_quadradio_source_32fc::set_band_select(int band) -{ - return d_qr->set_band_select(static_cast<vrt_band_sel_t>(band)); -} - -int -vrt_quadradio_source_32fc::get_band_select(void) -{ - return static_cast<int>(d_qr->get_band_select()); -} - -//void -//vrt_quadradio_source_32fc::set_10dB_atten(bool on) -//{ -// return d_qr->set_10dB_atten(on); -//} - -bool -vrt_quadradio_source_32fc::select_rx_antenna(const std::string &ant) -{ - return d_qr->select_rx_antenna(ant); -} - -bool -vrt_quadradio_source_32fc::set_attenuation0(int attenuation) -{ - return d_qr->set_attenuation0(attenuation); -} - -bool -vrt_quadradio_source_32fc::set_attenuation1(int attenuation) -{ - return d_qr->set_attenuation1(attenuation); -} - -void -vrt_quadradio_source_32fc::set_adc_gain(bool on){ - d_qr->set_adc_gain(on); -} - -void -vrt_quadradio_source_32fc::set_dc_offset_comp(bool on){ - d_qr->set_dc_offset_comp(on); -} - -void -vrt_quadradio_source_32fc::set_digital_gain(float gain){ - d_qr->set_digital_gain(gain); -} - -void -vrt_quadradio_source_32fc::set_test_signal(int type){ - d_qr->set_test_signal(static_cast<vrt_test_sig_t>(type)); -} - -bool -vrt_quadradio_source_32fc::set_setting_reg(int regno, int value) -{ - return d_qr->set_setting_reg(regno, value); -} - -bool -vrt_quadradio_source_32fc::set_hsadc_conf(int which_dboard, int regno, int value) -{ - return d_qr->set_hsadc_conf(which_dboard, regno, value); -} - -bool -vrt_quadradio_source_32fc::set_lsdac(int which_dboard, int which_dac, int value) -{ - return d_qr->set_lsdac(which_dboard, which_dac, value); -} - -bool -vrt_quadradio_source_32fc::set_mem32(int addr, int value) -{ - return d_qr->set_mem32(addr, value); -} - -bool -vrt_quadradio_source_32fc::set_lo_freq(double freq) -{ - return d_qr->set_lo_freq(freq); -} - -bool -vrt_quadradio_source_32fc::set_cal_freq(double freq) -{ - return d_qr->set_cal_freq(freq); -} - -/*--------------------------------------------------------------------*/ -#define IQ_IMBAL_NUM_TAPS 30 -#define IQ_IMBAL_REG_NO 162 - -//helper function to set the iq imbalance register with a tap -static int get_iq_imbal_reg(bool real, bool init, float tap){ - int val = int(round(tap)); - val &= 0x1ffffff; //lower 25 bits for tap - val |= (real?0:1) << 30; //30th bit for filter type - val |= (init?1:0) << 31; //31st bit for initialization - printf("Reg %d Val %x\n", IQ_IMBAL_REG_NO, val); - return val; -} - -void -vrt_quadradio_source_32fc::set_iq_imbal_taps(const std::vector<gr_complex> taps){ - int i = 0; - /* set the real part of the taps */ - get_iq_imbal_reg(true, true, 0); - for (i = 0; i < IQ_IMBAL_NUM_TAPS; i++){ - set_setting_reg(IQ_IMBAL_REG_NO, get_iq_imbal_reg(true, false, taps[IQ_IMBAL_NUM_TAPS-i-1].real())); - } - get_iq_imbal_reg(false, true, 0); - /* set the imaginary part of the taps */ - for (i = 0; i < IQ_IMBAL_NUM_TAPS; i++){ - set_setting_reg(IQ_IMBAL_REG_NO, get_iq_imbal_reg(false, false, taps[IQ_IMBAL_NUM_TAPS-i-1].imag())); - } -} - -bool -vrt_quadradio_source_32fc::set_beamforming(std::vector<gr_complex> gains){ - int32_t gains_ints[8]; - for (int i = 0; i < 4; i++){ - gains_ints[2*i] = int32_t(gains[i].real()); - gains_ints[2*i+1] = int32_t(gains[i].imag()); - } - return d_qr->set_beamforming(gains_ints); -} - -bool -vrt_quadradio_source_32fc::set_cal_enb(bool enb){ - return d_qr->set_cal_enb(enb); -} diff --git a/gr-vrt/src/vrt_quadradio_source_32fc.h b/gr-vrt/src/vrt_quadradio_source_32fc.h deleted file mode 100644 index bb3935c46..000000000 --- a/gr-vrt/src/vrt_quadradio_source_32fc.h +++ /dev/null @@ -1,136 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_VRT_QUADRADIO_SOURCE_32FC_H -#define INCLUDED_VRT_QUADRADIO_SOURCE_32FC_H - -#include <vrt_source_32fc.h> - -namespace vrt { - class quadradio; -}; - -class vrt_quadradio_source_32fc; -typedef boost::shared_ptr<vrt_quadradio_source_32fc> vrt_quadradio_source_32fc_sptr; - -vrt_quadradio_source_32fc_sptr -vrt_make_quadradio_source_32fc(const std::string &ip, - size_t rx_bufsize = 0, - size_t samples_per_pkt = 0, - int rxdspno = 0); - -class vrt_quadradio_source_32fc : public vrt_source_32fc -{ - size_t d_samples_per_pkt; - boost::shared_ptr<vrt::quadradio> d_qr; - int d_rxdspno; - - vrt_quadradio_source_32fc(const std::string &ip, size_t rx_bufsize, - size_t samples_per_pkt, int rxdspno); - - friend vrt_quadradio_source_32fc_sptr - vrt_make_quadradio_source_32fc(const std::string &ip, size_t rx_bufsize, - size_t samples_per_pkt, int rxdspno); - -public: - virtual ~vrt_quadradio_source_32fc(); - virtual vrt::rx::sptr vrt_rx() const; - - /*! - * \brief Called by scheduler when starting flowgraph - */ - virtual bool start(); - - /*! - * \brief Called by scheduler when stopping flowgraph - */ - virtual bool stop(); - - /*! - * \brief Set the LO frequency (actually just sets the band select for now). - */ - bool set_center_freq(double target_freq); - - /*! - * \brief Set the band select dboard bits. - */ - bool set_band_select(int band); - int get_band_select(void); - - /*! - * \brief Turn the 10 dB attenuation on/off. - */ - //void set_10dB_atten(bool on); - - /*! - * \brief Set the antenna type to the main rf or calibrator. - * \param ant "rf" or "cal" - */ - bool select_rx_antenna(const std::string &ant); - - /*! - * \brief Set the attenuation. - * \param attenuation 0 to 31 in dB - */ - bool set_attenuation0(int attenuation); - bool set_attenuation1(int attenuation); - - void set_iq_imbal_taps(const std::vector<gr_complex> taps); - - void set_adc_gain(bool on); - void set_dc_offset_comp(bool on); - void set_digital_gain(float gain); - void set_test_signal(int type); - - bool set_setting_reg(int regno, int value); - - /*! - * \brief write \p v to daugherboard control setting register - */ - bool set_dboard_pins(int which_dboard, int v); - bool set_hsadc_conf(int which_dboard, int regno, int value); - bool set_lsdac(int which_dboard, int which_dac, int value); - bool set_mem32(int addr, int value); - bool set_lo_freq(double freq); - bool set_cal_freq(double freq); - bool set_beamforming(std::vector<gr_complex> gains); - bool set_cal_enb(bool enb); - - //caldiv public access methods - double get_cal_freq(void){return d_cal_freq;} - bool get_cal_locked(void){return d_cal_locked;} - bool get_cal_enabled(void){return d_cal_enabled;} - double get_lo_freq(void){return d_lo_freq;} - bool get_lo_locked(void){return d_lo_locked;} - double get_caldiv_temp(void){return d_caldiv_temp;} - int get_caldiv_revision(void){return d_caldiv_rev;} - int get_caldiv_serial(void){return d_caldiv_ser;} - int get_caldiv_model(void){return d_caldiv_mod;} - - //gps public access methods - int get_utc_time(void){return d_utc_time;} - double get_altitude(void){return d_altitude;} - double get_longitude(void){return d_longitude;} - double get_latitude(void){return d_latitude;} -}; - - - -#endif /* INCLUDED_VRT_QUADRADIO_SOURCE_32FC_H */ diff --git a/gr-vrt/src/vrt_sink_16sc.cc b/gr-vrt/src/vrt_sink_16sc.cc deleted file mode 100644 index 09abe29ee..000000000 --- a/gr-vrt/src/vrt_sink_16sc.cc +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <vrt_sink_16sc.h> -#include <vrt/metadata.h> -#include <gr_io_signature.h> -#include <iostream> - -vrt_sink_16sc_sptr -vrt_make_sink_16sc(const std::string &ifc, const std::string &mac_addr) - throw (std::runtime_error) -{ - return gnuradio::get_initial_sptr(new vrt_sink_16sc(ifc, mac_addr)); -} - -vrt_sink_16sc::vrt_sink_16sc(const std::string &ifc, const std::string &mac_addr) - throw (std::runtime_error) - : vrt_sink_base("vrt_sink_16sc", - gr_make_io_signature(1, 1, sizeof(std::complex<int16_t>)), - ifc, mac_addr) -{ - // NOP -} - -vrt_sink_16sc::~vrt_sink_16sc() -{ - // NOP -} - -int -vrt_sink_16sc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - std::complex<int16_t> *in = (std::complex<int16_t> *)input_items[0]; - - vrt::tx_metadata metadata; - metadata.timestamp = -1; - metadata.send_now = 1; - metadata.start_of_burst = 1; - - bool ok = d_u2->tx_16sc(0, // FIXME: someday, streams will have channel numbers - in, noutput_items, &metadata); - if (!ok){ - std::cerr << "vrt_sink_16sc: tx_16sc failed" << std::endl; - return -1; // say we're done - } - - return noutput_items; -} diff --git a/gr-vrt/src/vrt_sink_16sc.h b/gr-vrt/src/vrt_sink_16sc.h deleted file mode 100644 index ba6e673be..000000000 --- a/gr-vrt/src/vrt_sink_16sc.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -#ifndef INCLUDED_USRP2_SINK_16SC_H -#define INCLUDED_USRP2_SINK_16SC_H - -#include <vrt_sink_base.h> - -class vrt_sink_16sc; -typedef boost::shared_ptr<vrt_sink_16sc> vrt_sink_16sc_sptr; - -vrt_sink_16sc_sptr -vrt_make_sink_16sc(const std::string &ifc="eth0", - const std::string &mac="") - throw (std::runtime_error); - -class vrt_sink_16sc : public vrt_sink_base -{ -private: - friend vrt_sink_16sc_sptr - vrt_make_sink_16sc(const std::string &ifc, - const std::string &mac) - throw (std::runtime_error); - -protected: - vrt_sink_16sc(const std::string &ifc, const std::string &mac) - throw (std::runtime_error); - -public: - ~vrt_sink_16sc(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_USRP2_SINK_16SC_H */ diff --git a/gr-vrt/src/vrt_sink_32fc.cc b/gr-vrt/src/vrt_sink_32fc.cc deleted file mode 100644 index a9987a361..000000000 --- a/gr-vrt/src/vrt_sink_32fc.cc +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <vrt_sink_32fc.h> -#include <vrt/metadata.h> -#include <gr_io_signature.h> -#include <iostream> - -vrt_sink_32fc_sptr -vrt_make_sink_32fc(const std::string &ifc, const std::string &mac_addr) - throw (std::runtime_error) -{ - return gnuradio::get_initial_sptr(new vrt_sink_32fc(ifc, mac_addr)); -} - -vrt_sink_32fc::vrt_sink_32fc(const std::string &ifc, const std::string &mac_addr) - throw (std::runtime_error) - : vrt_sink_base("vrt_sink_32fc", - gr_make_io_signature(1, 1, sizeof(gr_complex)), - ifc, mac_addr) -{ - // NOP -} - -vrt_sink_32fc::~vrt_sink_32fc() -{ - // NOP -} - -int -vrt_sink_32fc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *in = (gr_complex *)input_items[0]; - - vrt::tx_metadata metadata; - metadata.timestamp = -1; - metadata.send_now = 1; - metadata.start_of_burst = 1; - - bool ok = d_u2->tx_32fc(0, // FIXME: someday, streams will have channel numbers - in, noutput_items, &metadata); - if (!ok){ - std::cerr << "vrt_sink_32fc: tx_32fc failed" << std::endl; - return -1; // say we're done - } - - return noutput_items; -} diff --git a/gr-vrt/src/vrt_sink_32fc.h b/gr-vrt/src/vrt_sink_32fc.h deleted file mode 100644 index 55a6512f0..000000000 --- a/gr-vrt/src/vrt_sink_32fc.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -#ifndef INCLUDED_USRP2_SINK_32FC_H -#define INCLUDED_USRP2_SINK_32FC_H - -#include <vrt_sink_base.h> - -class vrt_sink_32fc; -typedef boost::shared_ptr<vrt_sink_32fc> vrt_sink_32fc_sptr; - -vrt_sink_32fc_sptr -vrt_make_sink_32fc(const std::string &ifc="eth0", - const std::string &mac="") - throw (std::runtime_error); - -class vrt_sink_32fc : public vrt_sink_base -{ -private: - friend vrt_sink_32fc_sptr - vrt_make_sink_32fc(const std::string &ifc, - const std::string &mac) - throw (std::runtime_error); - -protected: - vrt_sink_32fc(const std::string &ifc, const std::string &mac) - throw (std::runtime_error); - -public: - ~vrt_sink_32fc(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_USRP2_SINK_32FC_H */ diff --git a/gr-vrt/src/vrt_sink_base.cc b/gr-vrt/src/vrt_sink_base.cc deleted file mode 100644 index a75024dcc..000000000 --- a/gr-vrt/src/vrt_sink_base.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <vrt_sink_base.h> -#include <gr_io_signature.h> -#include <iostream> - -vrt_sink_base::vrt_sink_base(const char *name, - gr_io_signature_sptr input_signature, - const std::string &ifc, - const std::string &mac) - throw (std::runtime_error) - : vrt_base(name, - input_signature, - gr_make_io_signature(0, 0, 0), - ifc, mac) -{ - // NOP -} - -vrt_sink_base::~vrt_sink_base () -{ - // NOP -} - -bool -vrt_sink_base::set_gain(double gain) -{ - return d_u2->set_tx_gain(gain); -} - -bool -vrt_sink_base::set_lo_offset(double frequency) -{ - return d_u2->set_tx_lo_offset(frequency); -} - -bool -vrt_sink_base::set_center_freq(double frequency, vrt::tune_result *tr) -{ - return d_u2->set_tx_center_freq(frequency, tr); -} - -bool -vrt_sink_base::set_interp(int interp_factor) -{ - return d_u2->set_tx_interp(interp_factor); -} - -void -vrt_sink_base::default_scale_iq(int interp_factor, int *scale_i, int *scale_q) -{ - return d_u2->default_tx_scale_iq(interp_factor, scale_i, scale_q); -} - -bool -vrt_sink_base::set_scale_iq(int scale_i, int scale_q) -{ - return d_u2->set_tx_scale_iq(scale_i, scale_q); -} - -int -vrt_sink_base::interp() -{ - return d_u2->tx_interp(); -} - -bool -vrt_sink_base::dac_rate(long *rate) -{ - return d_u2->dac_rate(rate); -} - -double -vrt_sink_base::gain_min() -{ - return d_u2->tx_gain_min(); -} - -double -vrt_sink_base::gain_max() -{ - return d_u2->tx_gain_max(); -} - -double -vrt_sink_base::gain_db_per_step() -{ - return d_u2->tx_gain_db_per_step(); -} - -double -vrt_sink_base::freq_min() -{ - return d_u2->tx_freq_min(); -} - -double -vrt_sink_base::freq_max() -{ - return d_u2->tx_freq_max(); -} - -bool -vrt_sink_base::daughterboard_id(int *dbid) -{ - return d_u2->tx_daughterboard_id(dbid); -} - -bool vrt_sink_base::set_gpio_ddr(uint16_t value, uint16_t mask) -{ - return d_u2->set_gpio_ddr(vrt::GPIO_TX_BANK, value, mask); -} - -bool vrt_sink_base::set_gpio_sels(std::string sels) -{ - return d_u2->set_gpio_sels(vrt::GPIO_TX_BANK, sels); -} - -bool vrt_sink_base::write_gpio(uint16_t value, uint16_t mask) -{ - return d_u2->write_gpio(vrt::GPIO_TX_BANK, value, mask); -} - -bool vrt_sink_base::read_gpio(uint16_t *value) -{ - return d_u2->read_gpio(vrt::GPIO_TX_BANK, value); -} diff --git a/gr-vrt/src/vrt_sink_base.h b/gr-vrt/src/vrt_sink_base.h deleted file mode 100644 index 5f0532d8e..000000000 --- a/gr-vrt/src/vrt_sink_base.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -#ifndef INCLUDED_USRP2_SINK_BASE_H -#define INCLUDED_USRP2_SINK_BASE_H - -#include <vrt_base.h> - -/*! - * Base class for all USRP2 transmit blocks - */ -class vrt_sink_base : public vrt_base -{ -protected: - vrt_sink_base(const char *name, - gr_io_signature_sptr input_signature, - const std::string &ifc, - const std::string &mac) - throw (std::runtime_error); - -public: - ~vrt_sink_base(); - - /*! - * \brief Set transmitter gain - */ - bool set_gain(double gain); - - /*! - * \brief Set transmitter LO offset frequency - */ - bool set_lo_offset(double frequency); - - /*! - * \brief Set transmitter center frequency - */ - bool set_center_freq(double frequency, vrt::tune_result *tr); - - /*! - * \brief Set transmit interpolation rate - */ - bool set_interp(int interp_factor); - - /*! - * \brief Calculate default scale_iq for given interpolation factor - */ - void default_scale_iq(int interpolation_factor, int *scale_i, int *scale_q); - - /*! - * \brief Set transmit IQ scale factors - */ - bool set_scale_iq(int scale_i, int scale_q); - - /*! - * \brief Get transmit interpolation rate - */ - int interp(); - - /*! - * \brief Get DAC sample rate in Hz - */ - bool dac_rate(long *rate); - - /*! - * \brief Returns minimum Tx gain - */ - double gain_min(); - - /*! - * \brief Returns maximum Tx gain - */ - double gain_max(); - - /*! - * \brief Returns Tx gain db_per_step - */ - double gain_db_per_step(); - - /*! - * \brief Returns minimum Tx center frequency - */ - double freq_min(); - - /*! - * \brief Returns maximum Tx center frequency - */ - double freq_max(); - - /*! - * \brief Get Tx daughterboard ID - * - * \param[out] dbid returns the daughterboard id. - * - * daughterboard id >= 0 if successful, -1 if no daugherboard installed, - * -2 if invalid EEPROM on daughterboard. - */ - bool daughterboard_id(int *dbid); - - /*! - * \brief Set daughterboard GPIO data direction register. - */ - bool set_gpio_ddr(uint16_t value, uint16_t mask); - - /*! - * \brief Set daughterboard GPIO output selection register. - */ - bool set_gpio_sels(std::string sels); - - /*! - * \brief Set daughterboard GPIO pin values. - */ - bool write_gpio(uint16_t value, uint16_t mask); - - /*! - * \brief Read daughterboard GPIO pin values - */ - bool read_gpio(uint16_t *value); -}; - -#endif /* INCLUDED_USRP2_SINK_BASE_H */ diff --git a/gr-vrt/src/vrt_source_16sc.cc b/gr-vrt/src/vrt_source_16sc.cc deleted file mode 100644 index f0ea35bb3..000000000 --- a/gr-vrt/src/vrt_source_16sc.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <vrt_source_16sc.h> -#include <rx_16sc_handler.h> -#include <gr_io_signature.h> -#include <iostream> - -vrt_source_16sc_sptr -vrt_make_source_16sc(const std::string &ifc, const std::string &mac_addr) - throw (std::runtime_error) -{ - return gnuradio::get_initial_sptr(new vrt_source_16sc(ifc, mac_addr)); -} - -vrt_source_16sc::vrt_source_16sc(const std::string &ifc, const std::string &mac_addr) - throw (std::runtime_error) - : vrt_source_base("vrt_source_16sc", - gr_make_io_signature(1, 1, sizeof(std::complex<int16_t>)), - ifc, mac_addr) -{ - set_output_multiple(USRP2_MIN_RX_SAMPLES); -} - -vrt_source_16sc::~vrt_source_16sc() -{ - // NOP -} - -int -vrt_source_16sc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - std::complex<int16_t> *out = (std::complex<int16_t> *)output_items[0]; - - rx_16sc_handler::sptr handler = rx_16sc_handler::make(noutput_items, USRP2_MIN_RX_SAMPLES, out); - - bool ok = d_u2->rx_samples(0, handler.get()); // FIXME: channel number instead of 0 - if (!ok){ - std::cerr << "vrt::rx_samples() failed" << std::endl; - return -1; // say we're done - } - - return handler->nsamples(); -} diff --git a/gr-vrt/src/vrt_source_16sc.h b/gr-vrt/src/vrt_source_16sc.h deleted file mode 100644 index 34175b3ca..000000000 --- a/gr-vrt/src/vrt_source_16sc.h +++ /dev/null @@ -1,54 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 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. - */ - -#ifndef INCLUDED_USRP2_SOURCE_16SC_H -#define INCLUDED_USRP2_SOURCE_16SC_H - -#include <vrt_source_base.h> - -class vrt_source_16sc; -typedef boost::shared_ptr<vrt_source_16sc> vrt_source_16sc_sptr; - -vrt_source_16sc_sptr -vrt_make_source_16sc(const std::string &ifc="eth0", - const std::string &mac="") - throw (std::runtime_error); - -class vrt_source_16sc : public vrt_source_base -{ -private: - friend vrt_source_16sc_sptr - vrt_make_source_16sc(const std::string &ifc, - const std::string &mac) throw (std::runtime_error); - -protected: - vrt_source_16sc(const std::string &ifc, const std::string &mac) throw (std::runtime_error); - -public: - ~vrt_source_16sc(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); -}; - -#endif /* INCLUDED_USRP2_SOURCE_16SC_H */ diff --git a/gr-vrt/src/vrt_source_32fc.cc b/gr-vrt/src/vrt_source_32fc.cc deleted file mode 100644 index f9375d31c..000000000 --- a/gr-vrt/src/vrt_source_32fc.cc +++ /dev/null @@ -1,192 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,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. - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include <vrt_source_32fc.h> -#include <vrt/expanded_header.h> -#include <vrt/copiers.h> -#include <vrt/types.h> -#include <vrt/if_context.h> -#include <gr_io_signature.h> -#include <missing_pkt_checker.h> -#include <iostream> -#include <gruel/inet.h> -#include <cstdio> -#include <cstring> - -#define VERBOSE 1 // define to 0 or 1 - - -class rx_32fc_handler : public vrt::rx_packet_handler -{ - int d_noutput_items; - std::complex<float> *d_out; - int *d_oo; // output index - std::vector< std::complex<float> > &d_remainder; - missing_pkt_checker &d_checker; - all_context_t d_if_context; - size_t d_if_context_n32_bit_words; - -public: - - rx_32fc_handler(int noutput_items, std::complex<float> *out, - int *oo, std::vector< std::complex<float> > &remainder, - missing_pkt_checker &checker) - : d_noutput_items(noutput_items), d_out(out), - d_oo(oo), d_remainder(remainder), d_checker(checker), - d_if_context_n32_bit_words(0) {} - - ~rx_32fc_handler(); - - bool operator()(const uint32_t *payload, - size_t n32_bit_words, - const vrt::expanded_header *hdr); - all_context_t* get_if_context(void){ - return d_if_context_n32_bit_words? &d_if_context : NULL;}; -}; - -rx_32fc_handler::~rx_32fc_handler() -{ -} - -bool -rx_32fc_handler::operator()(const uint32_t *payload, - size_t n32_bit_words, - const vrt::expanded_header *hdr) -{ - if (hdr->if_data_p()){ - int nmissing = d_checker.check(hdr); - if (VERBOSE && nmissing != 0){ - std::cerr << "S" << nmissing; - } - - // copy as many as will fit into the output buffer. - - size_t n = std::min(n32_bit_words, (size_t)(d_noutput_items - *d_oo)); - vrt::copy_net_16sc_to_host_32fc(n, payload, &d_out[*d_oo]); - *d_oo += n; - - // if there are any left over, copy them into remainder and tell - // our caller we're had enough for now. - - size_t r = n32_bit_words - n; - if (r > 0){ - assert(d_remainder.size() == 0); - d_remainder.resize(r); - vrt::copy_net_16sc_to_host_32fc(r, &payload[n], &d_remainder[0]); - return false; // Stop calling us. - } - - return true; // Keep calling us, we've got more room - } - else if (hdr->if_context_p()){ - // print the IF-Context packet - fprintf(stderr, "\nIF-Context:\n"); - //for (size_t i = 0; i < n32_bit_words; i++) - // fprintf(stderr, "%04x: %08x\n", (unsigned int) i, ntohl(payload[i])); - memcpy(&d_if_context, payload, sizeof(uint32_t)*n32_bit_words); - d_if_context_n32_bit_words = n32_bit_words; - return true; - } - else { - // It's most likely an Extension Data or Extension Context packet - // (that we don't know how to interpret...) - fprintf(stderr, "\nIF-Extension:\n"); - for (size_t i = 0; i < n32_bit_words; i++) - fprintf(stderr, "%04x: %08x\n", (unsigned int) i, ntohl(payload[i])); - return true; - } -} - - -// ------------------------------------------------------------------------ - -vrt_source_32fc::vrt_source_32fc(const char *name) - - : vrt_source_base(name, - gr_make_io_signature(1, 1, sizeof(gr_complex))) -{ -} - -vrt_source_32fc::~vrt_source_32fc() -{ - if (VERBOSE){ - std::cerr << "\nvrt_source_32fc: npackets = " << d_checker.npackets() - << " nwrong_pkt_cnt = " << d_checker.nwrong_pkt_cnt() - << " nmissing_pkt_est = " << d_checker.nmissing_pkt_est() - << std::endl; - } -} - -int -vrt_source_32fc::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - gr_complex *out = (gr_complex *)output_items[0]; - int oo = 0; - - // Handle any samples left over from the last call. - int t = std::min(noutput_items, (int)d_remainder.size()); - if (t != 0){ - for (int i = 0; i < t; i++) - out[i] = d_remainder[i]; - d_remainder.erase(d_remainder.begin(), d_remainder.begin()+t); - oo = t; - } - if (noutput_items - oo == 0) - return oo; - - // While we've got room, and there are packets, handle them - rx_32fc_handler h(noutput_items, out, &oo, d_remainder, d_checker); - bool ok = vrt_rx()->rx_packets(&h); - - if (!ok){ - std::cerr << "vrt_source_32fc: vrt::rx_packets() failed" << std::endl; - return -1; // say we're done - } - - //we have a context packet, grab its useful information... - //remember that things are in network byte order! - if (h.get_if_context()){ - //extract caldiv stuff - d_lo_freq = vrt_freq_to_double(ntohx(h.get_if_context()->caldiv.lo_freq)); - d_cal_freq = vrt_freq_to_double(ntohx(h.get_if_context()->caldiv.cal_freq)); - d_lo_locked = bool(ntohx(h.get_if_context()->caldiv.lo_locked)); - d_cal_locked = bool(ntohx(h.get_if_context()->caldiv.cal_locked)); - d_cal_enabled = bool(ntohx(h.get_if_context()->caldiv.cal_enabled)); - d_caldiv_temp = vrt_temp_to_double(ntohx(h.get_if_context()->caldiv.temp)); - d_caldiv_rev = ntohx(h.get_if_context()->caldiv.rev); - d_caldiv_ser = ntohx(h.get_if_context()->caldiv.ser); - d_caldiv_mod = ntohx(h.get_if_context()->caldiv.mod); - //extract gps stuff - d_utc_time = ntohx(h.get_if_context()->gps.formatted_gps.integer_secs); - d_altitude = vrt_altitude_to_double(ntohx(h.get_if_context()->gps.formatted_gps.altitude)); - d_longitude = vrt_geo_angle_to_double(ntohx(h.get_if_context()->gps.formatted_gps.longitude)); - d_latitude = vrt_geo_angle_to_double(ntohx(h.get_if_context()->gps.formatted_gps.latitude)); - } - - return oo; -} diff --git a/gr-vrt/src/vrt_source_32fc.h b/gr-vrt/src/vrt_source_32fc.h deleted file mode 100644 index c43170e83..000000000 --- a/gr-vrt/src/vrt_source_32fc.h +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,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. - */ - -#ifndef INCLUDED_VRT_SOURCE_32FC_H -#define INCLUDED_VRT_SOURCE_32FC_H - -#include <vrt_source_base.h> -#include <missing_pkt_checker.h> - -class vrt_source_32fc : public vrt_source_base -{ -protected: - vrt_source_32fc(const char *name); - - std::vector< std::complex<float> > d_remainder; - missing_pkt_checker d_checker; - - //caldiv settings parsed from if context - double d_cal_freq; - bool d_cal_locked; - bool d_cal_enabled; - double d_lo_freq; - bool d_lo_locked; - double d_caldiv_temp; - int d_caldiv_rev; - int d_caldiv_ser; - int d_caldiv_mod; - - //gps settings parsed from if context - int d_utc_time; - double d_altitude; - double d_longitude; - double d_latitude; - -public: - ~vrt_source_32fc(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - void reset() { d_remainder.clear(); } -}; - -#endif /* INCLUDED_VRT_SOURCE_32FC_H */ diff --git a/gr-vrt/src/vrt_source_base.cc b/gr-vrt/src/vrt_source_base.cc deleted file mode 100644 index 40e871653..000000000 --- a/gr-vrt/src/vrt_source_base.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,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. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <vrt_source_base.h> -#include <gr_io_signature.h> -#include <iostream> - -vrt_source_base::vrt_source_base(const char *name, - gr_io_signature_sptr output_signature) - : gr_sync_block(name, - gr_make_io_signature(0, 0, 0), - output_signature) -{ -} - -vrt_source_base::~vrt_source_base() -{ -} diff --git a/gr-vrt/src/vrt_source_base.h b/gr-vrt/src/vrt_source_base.h deleted file mode 100644 index e67778860..000000000 --- a/gr-vrt/src/vrt_source_base.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,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. - */ - -#ifndef INCLUDED_VRT_SOURCE_BASE_H -#define INCLUDED_VRT_SOURCE_BASE_H - -#include <gr_sync_block.h> -#include <vrt/rx.h> -#include <gr_io_signature.h> - -/*! - * Base class for all VRT source blocks - */ -class vrt_source_base : public gr_sync_block -{ -protected: - vrt_source_base(const char *name, - gr_io_signature_sptr output_signature); - -public: - ~vrt_source_base(); - - virtual vrt::rx::sptr vrt_rx() const = 0; -}; - -#endif /* INCLUDED_VRT_SOURCE_BASE_H */ diff --git a/vrt/apps/.gitignore b/vrt/apps/.gitignore index a8e9f886f..dab7a7fd6 100644 --- a/vrt/apps/.gitignore +++ b/vrt/apps/.gitignore @@ -2,4 +2,4 @@ Makefile Makefile.in .deps .libs -simple_rx_samples + diff --git a/vrt/apps/Makefile.am b/vrt/apps/Makefile.am index 631d9020b..45772055b 100644 --- a/vrt/apps/Makefile.am +++ b/vrt/apps/Makefile.am @@ -16,21 +16,3 @@ # include $(top_srcdir)/Makefile.common - -AM_CPPFLAGS = \ - $(VRT_INCLUDES) \ - $(STD_DEFINES_AND_INCLUDES) \ - $(CPPUNIT_INCLUDES) - -LDADD = \ - $(VRT_LA) \ - $(GRUEL_LA) - - -bin_PROGRAMS = - -noinst_PROGRAMS = \ - simple_rx_samples - -simple_rx_samples_SOURCES = simple_rx_samples.cc - diff --git a/vrt/apps/simple_rx_samples.cc b/vrt/apps/simple_rx_samples.cc deleted file mode 100644 index 08f01c9cc..000000000 --- a/vrt/apps/simple_rx_samples.cc +++ /dev/null @@ -1,394 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <vrt/quadradio.h> -#include <vrt/rx.h> -#include <vrt/copiers.h> - -#include <errno.h> -#include <iostream> -#include <boost/scoped_ptr.hpp> -#include <boost/shared_ptr.hpp> -#include <stdexcept> -#include <signal.h> -#include <unistd.h> -#include <stdint.h> -#include <stdio.h> -#include <string.h> -#include <gruel/realtime.h> -#include <complex> - -#define MIN_IP_LOCAL_PORT 32768 -#define MAX_IP_LOCAL_PORT 61000 - -static volatile bool signaled = false; - -static void -sig_handler(int sig) -{ - signaled = true; -} - -static void -install_sig_handler(int signum, - void (*new_handler)(int)) -{ - struct sigaction new_action; - memset (&new_action, 0, sizeof (new_action)); - - new_action.sa_handler = new_handler; - sigemptyset (&new_action.sa_mask); - new_action.sa_flags = 0; - - if (sigaction (signum, &new_action, 0) < 0){ - perror ("sigaction (install new)"); - throw std::runtime_error ("sigaction"); - } -} - -// ------------------------------------------------------------------------ - -class rx_nop_handler : public vrt::rx_packet_handler -{ -private: - uint64_t d_max_samples; - uint64_t d_max_quantum; - uint64_t d_nsamples; - uint64_t d_npackets; - int d_last_pkt_cnt; - uint64_t d_nwrong_pkt_cnt; - -protected: - bool d_err; - -public: - - // Shared pointer to an instance of this class - typedef boost::shared_ptr<rx_nop_handler> sptr; - - /*! - * Constructor - * - * \param max_samples Maximum number of samples to copy. Use zero for no maximum. - * \param max_quantum Maximum number of samples required to accept in one call. - * Use 0 to indicate no maximum. - */ - rx_nop_handler(uint64_t max_samples, uint64_t max_quantum=0) - : d_max_samples(max_samples), d_max_quantum(max_quantum), - d_nsamples(0), d_npackets(0), - d_last_pkt_cnt(0xf), d_nwrong_pkt_cnt(0), - d_err(false){} - - - ~rx_nop_handler(); - - bool operator()(const uint32_t *payload, - size_t n32_bit_words, - const vrt::expanded_header *hdr); - - /*! - * \brief Returns number of packets this copier was called with - */ - uint64_t npackets() const { return d_npackets; } - - /*! - * \brief Returns actual number of samples copied - */ - uint64_t nsamples() const { return d_nsamples; } - - /*! - * \brief Returns maximum number of samples that will be copied - */ - uint64_t max_samples() const { return d_max_samples; } - - /*! - * Returns true if an error has occurred. Derived classes must set d_err to true - * when an error occurs in the () operator - */ - bool has_errored_p() const { return d_err; } - - /*! - * \brief Returns true if this instance has reached the maximum number of samples - */ - bool has_finished_p() const - { return d_max_samples == 0 ? false : d_nsamples >= d_max_samples-d_max_quantum; } - - uint64_t nwrong_pkt_cnt() const { return d_nwrong_pkt_cnt; } - - -}; - - -rx_nop_handler::~rx_nop_handler() -{ -} - -bool -rx_nop_handler::operator()(const uint32_t *payload, - size_t n32_bit_words, - const vrt::expanded_header *hdr) -{ - if (d_npackets != 0 && hdr->pkt_cnt() != ((d_last_pkt_cnt + 1) & 0xf)){ - d_nwrong_pkt_cnt++; - fprintf(stderr, "bad cnt (pkt %lld)\n", d_npackets); - } - d_last_pkt_cnt = hdr->pkt_cnt(); - - d_nsamples += n32_bit_words; - d_npackets++; - - return !has_finished_p(); -} - -// ------------------------------------------------------------------------ - -class file_writer_16sc : public rx_nop_handler -{ - FILE *d_fp; - std::string d_filename; - -public: - - file_writer_16sc(const std::string &filename, uint64_t max_samples) - : rx_nop_handler(max_samples), d_filename(filename) - { - d_fp = fopen(filename.c_str(), "wb"); - if (d_fp == 0){ - perror(filename.c_str()); - throw std::invalid_argument(filename); - } - } - - ~file_writer_16sc(); - - bool - operator()(const uint32_t *items, size_t nitems, const vrt::expanded_header *hdr) - { - bool ok = rx_nop_handler::operator()(items, nitems, hdr); - - size_t host_nitems = nitems; - std::complex<int16_t> host_items[host_nitems]; - - vrt::copy_net_16sc_to_host_16sc(nitems, items, host_items); - - size_t n = 0; - while (n < host_nitems){ - size_t r = fwrite(&host_items[n], sizeof(host_items[0]), host_nitems - n, d_fp); - n += r; - if (r == 0){ // out of space? - d_err = true; - perror(d_filename.c_str()); - ok = false; - break; - } - } - - return ok; - } -}; - -file_writer_16sc::~file_writer_16sc() -{ - fclose(d_fp); -} - -// ------------------------------------------------------------------------ - -class file_writer_32fc : public rx_nop_handler -{ - FILE *d_fp; - std::string d_filename; - -public: - - file_writer_32fc(const std::string &filename, uint64_t max_samples) - : rx_nop_handler(max_samples), d_filename(filename) - { - d_fp = fopen(filename.c_str(), "wb"); - if (d_fp == 0){ - perror(filename.c_str()); - throw std::invalid_argument(filename); - } - } - - ~file_writer_32fc(); - - bool - operator()(const uint32_t *items, size_t nitems, const vrt::expanded_header *hdr) - { - bool ok = rx_nop_handler::operator()(items, nitems, hdr); - - size_t host_nitems = nitems; - std::complex<float> host_items[host_nitems]; - - vrt::copy_net_16sc_to_host_32fc(nitems, items, host_items); - - size_t n = 0; - while (n < host_nitems){ - size_t r = fwrite(&host_items[n], sizeof(host_items[0]), host_nitems - n, d_fp); - n += r; - if (r == 0){ // out of space? - d_err = true; - perror(d_filename.c_str()); - ok = false; - break; - } - } - - return ok; - } -}; - -file_writer_32fc::~file_writer_32fc() -{ - fclose(d_fp); -} - -// ------------------------------------------------------------------------ - -static void -usage(const char *progname) -{ - const char *p = strrchr(progname, '/'); // drop leading directory path - if (p) - p++; - - if (strncmp(p, "lt-", 3) == 0) // drop lt- libtool prefix - p += 3; - - fprintf(stderr, "Usage: %s [options]\n\n", p); - fprintf(stderr, "Options:\n"); - fprintf(stderr, " -h show this message and exit\n"); -//fprintf(stderr, " -e ETH_INTERFACE specify ethernet interface [default=eth0]\n"); -//fprintf(stderr, " -m MAC_ADDR mac address of USRP2 HH:HH [default=first one found]\n"); -//fprintf(stderr, " -f FREQUENCY specify receive center frequency in Hz [default=0.0]\n"); -//fprintf(stderr, " -d DECIM specify receive decimation rate [default=5]\n"); -//fprintf(stderr, " -g GAIN specify receive daughterboard gain [default=0]\n"); - fprintf(stderr, " -N NSAMPLES specify number of samples to receive [default=infinite]\n"); - fprintf(stderr, " -o OUTPUT_FILENAME specify file to receive samples [default=none]\n"); - fprintf(stderr, " -s write complex<short> [default=complex<float>]\n"); - fprintf(stderr, " -S samples_per_pkt specify # of samples per pkt [default=maximum]\n"); -//fprintf(stderr, " -v verbose output\n"); -} - - -int -main(int argc, char **argv) -{ - const char *quad_radio_ip = "192.168.123.123"; - size_t rx_bufsize = 62.5e6; // sizeof memory mapped network buffer - int samples_per_pkt = 0; // use default - uint64_t nsamples = 0; - char *output_filename = 0; - bool output_shorts = false; - int t; - - int ch; - - while ((ch = getopt(argc, argv, "hN:o:sS:")) != EOF){ - switch (ch){ - case 'N': - nsamples = (uint64_t) strtod(optarg, 0); - break; - - case 'o': - output_filename = optarg; - break; - - case 's': - output_shorts = true; - break; - - case 'S': - errno = 0; - t = strtol(optarg, 0, 0); - if (errno != 0){ - usage(argv[0]); - exit(1); - } - samples_per_pkt = t; - break; - - case 'h': - default: - usage(argv[0]); - exit(1); - } - } - - - install_sig_handler(SIGINT, sig_handler); - - gruel::rt_status_t rt = gruel::enable_realtime_scheduling(); - if (rt != gruel::RT_OK) - std::cerr << "Failed to enable realtime scheduling" << std::endl; - - - vrt::quadradio::sptr qr; - try { - qr = vrt::quadradio::sptr(new vrt::quadradio(quad_radio_ip, rx_bufsize)); - } - catch (...){ - std::cerr << "Failed to create vrt::quadradio\n"; - return 1; - } - - - rx_nop_handler::sptr handler; - if (output_filename){ - if (output_shorts) - handler = rx_nop_handler::sptr(new file_writer_16sc(output_filename, nsamples)); - else - handler = rx_nop_handler::sptr(new file_writer_32fc(output_filename, nsamples)); - } - else - handler = rx_nop_handler::sptr(new rx_nop_handler(nsamples)); - - - printf("samples_per_pkt = %d\n", samples_per_pkt); - - if (!qr->start_streaming(0, samples_per_pkt)){ - fprintf(stderr, "failed to send_rx_command\n"); - return 1; - } - - // start receiving packets - - while(1 - && !signaled - && !handler->has_errored_p() - && !handler->has_finished_p()){ - bool ok = qr->vrt_rx()->rx_packets(handler.get()); - if (!ok){ - fprintf(stderr, "vrt->rx_packets failed\n"); - break; - } - } - - qr->stop_streaming(0); - - printf("%llu packets received, %llu bad pkt_cnt field values, %llu samples\n", - handler->npackets(), handler->nwrong_pkt_cnt(), handler->nsamples()); - - //sleep(1); - - return 0; -} diff --git a/vrt/include/vrt/Makefile.am b/vrt/include/vrt/Makefile.am index 2780d79b0..183eaf9ce 100644 --- a/vrt/include/vrt/Makefile.am +++ b/vrt/include/vrt/Makefile.am @@ -25,8 +25,6 @@ vrtinclude_HEADERS = \ bits.h \ copiers.h \ expanded_header.h \ - quadradio.h \ - if_context.h \ rx.h \ rx_packet_handler.h \ types.h diff --git a/vrt/include/vrt/if_context.h b/vrt/include/vrt/if_context.h deleted file mode 100644 index 24aba7a9e..000000000 --- a/vrt/include/vrt/if_context.h +++ /dev/null @@ -1,243 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * 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/>. - */ -#ifndef INCLUDED_VRT_IF_CONTEXT_H -#define INCLUDED_VRT_IF_CONTEXT_H - -#include <stdint.h> - -// Stream ID's for packet streams (low 8-bits) - -#define QR_SID_BEAMFORMER_IF_DATA 0x00 // paired -#define QR_SID_BEAMFORMER_IF_CNTX 0x00 // paired -#define QR_SID_DBOARD_0_IF_CNTX 0x01 // src assoc -#define QR_SID_DBOARD_1_IF_CNTX 0x02 // src assoc -#define QR_SID_DBOARD_2_IF_CNTX 0x03 // src assoc -#define QR_SID_DBOARD_3_IF_CNTX 0x04 // src assoc -#define QR_SID_GPS_IF_CNTX 0x05 // system assoc -#define QR_SID_SYS_INFO_EXT_CNTX 0x06 // system assoc - -// No class id, with 3 words of time. -// Used for all IF-Context packets -typedef struct if_context_hdr_tag { - uint32_t header; // first word of all packets - uint32_t stream_id; // mandatory in context packets - uint32_t integer_secs; // integer seconds timestamp - uint64_t fractional_secs; // fractional seconds timestamp - uint32_t context_indicator; // which context fields follow -} __attribute__((packed)) if_context_hdr_t; - - -// With class id, with 3 words of time. -// Used only with Extension Context packets -typedef struct if_context_hdr_with_classid_tag { - uint32_t header; // first word of all packets - uint32_t stream_id; // mandatory in context packets - uint64_t class_id; // class identifier - uint32_t integer_secs; // integer seconds timestamp - uint64_t fractional_secs; // fractional seconds timestamp - uint32_t context_indicator; // which context fields follow -} __attribute__((packed)) if_context_hdr_with_classid_t; - - -// ------------------------------------------------------------------------ -// Context Indicator field bits (Table 7.1.5.1-1) - -#define CI_CHANGE_INDICATOR (1 << 31) -#define CI_REF_POINT_ID (1 << 30) -#define CI_BANDWIDTH (1 << 29) -#define CI_IF_REF_FREQ (1 << 28) -#define CI_RF_REF_FREQ (1 << 27) -#define CI_RF_REF_FREQ_OFFSET (1 << 26) -#define CI_IF_BAND_OFFSET (1 << 25) -#define CI_REF_LEVEL (1 << 24) -#define CI_GAIN (1 << 23) -#define CI_OVER_RANGE_COUNT (1 << 22) -#define CI_SAMPLE_RATE (1 << 21) -#define CI_TIMESTAMP_ADJ (1 << 20) -#define CI_TIMESTAMP_CAL_TIME (1 << 19) -#define CI_TEMPERATURE (1 << 18) -#define CI_DEVICE_ID (1 << 17) -#define CI_STATE_AND_EVENT_IND (1 << 16) -#define CI_PAYLOAD_FMT (1 << 15) -#define CI_FORMATTED_GPS (1 << 14) -#define CI_FORMATTED_INS (1 << 13) -#define CI_ECEF_EPHEMERIS (1 << 12) -#define CI_REL_EPHEMERIS (1 << 11) -#define CI_EPHEMERIS_REF_ID (1 << 10) -#define CI_ASCII_GPS (1 << 9) -#define CI_CNTX_ASSOC_LISTS (1 << 8) -#define CI_RESERVED_7 (1 << 7) -#define CI_RESERVED_6 (1 << 6) -#define CI_RESERVED_5 (1 << 5) -#define CI_RESERVED_4 (1 << 4) -#define CI_RESERVED_3 (1 << 3) -#define CI_RESERVED_2 (1 << 2) -#define CI_RESERVED_1 (1 << 1) -#define CI_RESERVED_0 (1 << 0) - - -// ------------------------------------------------------------------------ -// Types that may be in the Context Section - - -// 7.1.5.10 Gain -- two Q10.6 dB fields - -static inline uint32_t -vrt_make_gain_field(int16_t stage1, int16_t stage2) -{ - return (((uint32_t) stage2) << 16) | (stage1 & 0xffff); -} - -static inline int16_t -vrt_gain_stage1(uint32_t field) -{ - return (int16_t)(field & 0xffff); -} - -static inline int16_t -vrt_gain_stage2(uint32_t field) -{ - return (int16_t)((field >> 16) & 0xffff); -} - -// See VITA-49.0 section 7.1.5.19 - -#define VRT_GPS_UNKNOWN_VALUE 0x7fffffff // for SOG, heading, track, and mag var - -typedef struct vrt_formatted_gps_tag { - uint32_t tsi_tsf_manuf_oui; - uint32_t integer_secs; // timestamp of position fix - uint64_t fractional_secs; // timestamp of position fix - uint32_t latitude; // degrees Q10.22 - uint32_t longitude; // degrees Q10.22 - uint32_t altitude; // meters Q27.5 - uint32_t speed_over_ground; - uint32_t heading_angle; - uint32_t track_angle; - uint32_t magnetic_variation; -} vrt_formatted_gps_t; - - -// Data Packet Payload Format Field 7.1.5.18 - -typedef struct vrt_payload_format_tag { - uint32_t word0; - uint32_t word1; -} vrt_payload_format_t; - -#define DF0_PACKED (1 << 31) -#define DF0_REAL_CMPLX_TYPE_MASK (0x3 << 29) -#define DF0_REAL_CMPLX_TYPE_REAL (0 << 29) -#define DF0_REAL_CMPLX_TYPE_CMPLX_CART (1 << 29) -#define DF0_REAL_CMPLX_TYPE_CMPLX_POLAR (2 << 29) -#define DF0_REAL_CMPLX_TYPE_RESERVED (3 << 29) -#define DF0_ITEM_FMT_MASK (0x1f << 24) -#define DF0_ITEM_FMT_SIGNED_FIXED_POINT (0x00 << 24) -#define DF0_ITEM_FMT_UNSIGNED_FIXED_POINT (0x10 << 24) -// lots more we're not using -#define DF0_SAMPLE_COMPONENT_REPEATING (1 << 23) -#define DF0_EVENT_TAG_SIZE_SHIFT 20 -#define DF0_EVENT_TAG_SIZE_MASK (0x7 << 20) -#define DF0_CHANNEL_TAG_SIZE_SHIFT 16 -#define DF0_CHANNEL_TAG_SIZE_MASK (0xf << 16) -#define DF0_RESERVED_SHIFT 12 -#define DF0_RESERVED_MASK (0xf << 12) -#define DF0_ITEM_PACKING_FIELD_SIZE_SHIFT 6 -#define DF0_ITEM_PACKING_FIELD_SIZE_MASK (0x3f << 6) -#define DF0_DATA_ITEM_SIZE_SHIFT 0 -#define DF0_DATA_ITEM_SIZE_MASK (0x3f << 0) - -#define DF1_REPEAT_COUNT_SHIFT 16 -#define DF1_REPEAT_COUNT_MASK (0xffff << 16) -#define DF1_VECTOR_SIZE_SHIFT 0 -#define DF1_VECTOR_SIZE_MASK (0xffff << 0) - - -// Composite values - -// 16-bit I & Q, no events, no channel tags -#define DF0_16_BIT_IQ \ - (0 \ - | DF0_REAL_CMPLX_TYPE_CMPLX_CART \ - | DF0_ITEM_FMT_SIGNED_FIXED_POINT \ - | (15 << DF0_ITEM_PACKING_FIELD_SIZE_SHIFT) \ - | (15 << DF0_DATA_ITEM_SIZE_SHIFT)) - -// Vector of length 1 -#define DF1_VECTOR_1 (0 << DF1_VECTOR_SIZE_SHIFT) - -// Vector of length 4 -#define DF1_VECTOR_4 (3 << DF1_VECTOR_SIZE_SHIFT) - - -// ------------------------------------------------------------------------ -// Our context packets - -typedef struct beamformer_if_cntx_tag { - if_context_hdr_t cntx_hdr; - uint64_t rf_ref_freq; // Q44.20 Hz - uint64_t sample_rate; // Q44.20 Hz - vrt_payload_format_t format; - // FIXME context association lists -} __attribute__((packed)) beamformer_if_cntx_t; - -typedef struct gps_if_cntx_tag { - if_context_hdr_t cntx_hdr; - vrt_formatted_gps_t formatted_gps; -} __attribute__((packed)) gps_if_cntx_t; - -typedef struct gain_if_cntx_tag { - if_context_hdr_t cntx_hdr; - uint32_t gain; -} __attribute__((packed)) gain_if_cntx_t; - -typedef struct caldiv_if_cntx_tag { - if_context_hdr_t cntx_hdr; - uint64_t lo_freq; - uint32_t lo_locked; - uint64_t cal_freq; - uint32_t cal_locked; - uint32_t cal_enabled; - uint32_t temp; - uint32_t rev; - uint32_t ser; - uint32_t mod; -} __attribute__((packed)) caldiv_if_cntx_t; - -// FIXME the rest... - -// ------------------------------------------------------------------------ -// All of them concatenated - -#define NCONTEXT_PKTS 7 // number of context pkts aggregated here - -typedef struct all_context_tag { - beamformer_if_cntx_t beamformer; - gain_if_cntx_t db[4]; - - // FIXME add Extension Context for board types, revs, serial numbers, temps - caldiv_if_cntx_t caldiv; - - gps_if_cntx_t gps; // must be last -} __attribute__((packed)) all_context_t; - -#define SIZEOF_ALL_CONTEXT (sizeof(all_context_t)) -#define SIZEOF_ALL_CONTEXT_BUT_GPS (SIZEOF_ALL_CONTEXT - sizeof(gps_if_cntx_t)) - - -#endif /* INCLUDED_IF_CONTEXT_H */ diff --git a/vrt/include/vrt/quadradio.h b/vrt/include/vrt/quadradio.h deleted file mode 100644 index 525a177a8..000000000 --- a/vrt/include/vrt/quadradio.h +++ /dev/null @@ -1,141 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_VRT_QUADRADIO_H -#define INCLUDED_VRT_QUADRADIO_H - -#include <vrt/rx.h> - -#include <arpa/inet.h> -#include <netinet/in.h> -#include <sys/types.h> -#include <sys/socket.h> - -typedef enum{ - VRT_TEST_SIG_NORMAL=0, - VRT_TEST_SIG_ZEROS=1, - VRT_TEST_SIG_ONES=2, - VRT_TEST_SIG_TOGGLE=3, - VRT_TEST_SIG_RAMP=4, - VRT_TEST_SIG_CUSTOM=5, - - } vrt_test_sig_t; - -typedef enum{ - VRT_BAND_SEL_A='A', - VRT_BAND_SEL_B='B', - VRT_BAND_SEL_C='C', - VRT_BAND_SEL_D='D', - - } vrt_band_sel_t; - -namespace vrt { - - /* - * We're not committing to this interface. It's just here so we can make progress... - * - * This implements the ad-hoc control for bringup and has-a vrt::rx - */ - class quadradio - { - int d_ctrl_fd; // socket for control - struct in_addr d_ctrl_port_inaddr; // our ip addr - int d_data_fd; // socket for data (owned by d_rx) - int d_data_port; // our data port number - vrt::rx::sptr d_rx; // has-a rx - - vrt_band_sel_t d_band_select; // band select setting - int d_rx_antenna; // antenna type rf/cal - int d_attenuation0; // attenuation setting - int d_attenuation1; // attenuation setting - bool d_10dB_atten; // 10dB attenuation on/of - - static bool - open_sockets(const char *quad_radio_ip, int quad_radio_ctrl_port, - int *ctrl_fd_ptr, struct in_addr *ctrl_port_inaddr, - int *data_fd_ptr, int *data_port_ptr); - - // dsprxno selects the Rx DSP pipe (0 or 1) to configure - static bool - send_rx_command(int ctrl_fd, int rxdspno, bool start, - struct in_addr addr, int data_port, int samples_per_pkt); - - // dsprxno selects the Rx DSP pipe (0 or 1) to stop - static bool - send_stop_rx_command(int ctrl_fd, int rxdspno); - - static int control_port() { return 790; } - int data_socket_fd() const { return d_data_fd; } - - bool open(const char *ip); - - void update_dboard_pins(void); - - public: - typedef boost::shared_ptr<quadradio> sptr; - - quadradio(const std::string &ip, size_t rx_bufsize = 0); - ~quadradio(); - - vrt::rx::sptr vrt_rx() const { return d_rx; } - - bool start_streaming(int rxdspno, int samples_per_pkt = 0); - - bool stop_streaming(int rxdspno); - - /* convenience methods that ultimately write the dboard pins */ - bool set_center_freq(double target_freq); - bool set_band_select(vrt_band_sel_t band); - vrt_band_sel_t get_band_select(void){return d_band_select;} - //void set_10dB_atten(bool on); - bool set_attenuation0(int attenuation); - bool select_rx_antenna(const std::string &ant); - bool set_attenuation1(int attenuation); - - /* convenience methods that ultimately call set_hsadc_conf */ - void set_adc_gain(bool on); - void set_dc_offset_comp(bool on); - void set_digital_gain(float gain); - void set_test_signal(vrt_test_sig_t type); - - /* primitives */ - bool set_setting_reg(int regno, int value); - bool set_mem32(int addr, int value); // poke a 32-bit value - bool set_lo_freq(double freq); - bool set_cal_freq(double freq); - bool set_beamforming(int32_t gains[8]); - bool set_cal_enb(bool enb); - /* - * The first parameter for these is a bitmask which indicates which - * daughterboard or daughterboards to apply the operation to. - * 0x1 -> dboard 0 - * 0x2 -> dboard 1 - * 0x3 -> dboard 0 and 1... - */ - bool set_dboard_pins(int dboard_bitmask, int v); - bool set_hsadc_conf(int dboard_bitmask, int regno, int value); - bool set_lsdac(int dboard_bitmask, int which_dac, int value); - - }; - -}; - - -#endif /* INCLUDED_QUADRADIO_H */ diff --git a/vrt/lib/Makefile.am b/vrt/lib/Makefile.am index d41343a5d..3a758eeac 100644 --- a/vrt/lib/Makefile.am +++ b/vrt/lib/Makefile.am @@ -32,7 +32,6 @@ libvrt_la_SOURCES = \ copiers.cc \ data_handler.cc \ expanded_header.cc \ - quadradio.cc \ rx.cc \ rx_packet_handler.cc \ socket_rx_buffer.cc diff --git a/vrt/lib/quadradio.cc b/vrt/lib/quadradio.cc deleted file mode 100644 index cc810e683..000000000 --- a/vrt/lib/quadradio.cc +++ /dev/null @@ -1,424 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 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 this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <vrt/quadradio.h> -#include <vrt/types.h> -#include <gruel/inet.h> -#include <errno.h> -#include <string.h> -#include <stdio.h> -#include <stdexcept> -#include <math.h> - -#define MIN_IP_LOCAL_PORT 32768 -#define MAX_IP_LOCAL_PORT 61000 - -#define ALL_DBOARDS 0xf - -static bool -send_and_check(int fd, void *buf, size_t len) -{ - int r = send(fd, buf, len, 0); - if (r < 0){ - perror("send"); - return false; - } - if ((size_t) r != len){ - fprintf(stderr, "send: short return value. expected %zd, got %d\n", len, r); - return false; - } - return true; -} - - -vrt::quadradio::quadradio(const std::string &ip, size_t rx_bufsize) - : d_ctrl_fd(0), d_data_fd(0), d_data_port(0), - d_band_select(VRT_BAND_SEL_A), d_rx_antenna(0), d_attenuation0(0), d_attenuation1(0)//d_10dB_atten(true) -{ - if (!open(ip.c_str())) - throw std::runtime_error("vrt::quadradio: failed to open " + ip + "\n"); - - d_rx = vrt::rx::make(data_socket_fd(), rx_bufsize); - set_test_signal(VRT_TEST_SIG_NORMAL); -} - -vrt::quadradio::~quadradio() -{ - ::close(d_ctrl_fd); -} - -bool -vrt::quadradio::open(const char *ip) -{ - return open_sockets(ip, control_port(), - &d_ctrl_fd, &d_ctrl_port_inaddr, - &d_data_fd, &d_data_port); -} - -bool -vrt::quadradio::start_streaming(int rxdspno, int samples_per_pkt) -{ - return send_rx_command(d_ctrl_fd, rxdspno, true, d_ctrl_port_inaddr, - d_data_port, samples_per_pkt); -} - -bool -vrt::quadradio::stop_streaming(int rxdspno) -{ - return send_stop_rx_command(d_ctrl_fd, rxdspno); -} - -bool -vrt::quadradio::set_center_freq(double target_freq){ - if (target_freq < 700e6) return false; - if (target_freq <= 1.0e9) return set_band_select(VRT_BAND_SEL_A); - if (target_freq <= 1.5e9) return set_band_select(VRT_BAND_SEL_B); - if (target_freq <= 2.2e9) return set_band_select(VRT_BAND_SEL_C); - if (target_freq <= 3.0e9) return set_band_select(VRT_BAND_SEL_D); - return false; -} - -bool -vrt::quadradio::set_band_select(vrt_band_sel_t band){ - d_band_select = band; - update_dboard_pins(); - return true; -} - -//void -//vrt::quadradio::set_10dB_atten(bool on){ -// d_10dB_atten = on; -// update_dboard_pins(); -//} - -bool -vrt::quadradio::select_rx_antenna(const std::string &ant){ - if (ant == "rf") d_rx_antenna = 0; - else if (ant == "cal") d_rx_antenna = 1; - else return true; - update_dboard_pins(); - return true; -} - -bool -vrt::quadradio::set_attenuation0(int attenuation){ - if (attenuation < 0 || attenuation > 31) return false; - d_attenuation0 = attenuation; - update_dboard_pins(); - return true; -} - -bool -vrt::quadradio::set_attenuation1(int attenuation){ - if (attenuation < 0 || attenuation > 31) return false; - d_attenuation1 = attenuation; - update_dboard_pins(); - return true; -} - -//bit reversal, length in bits -static int reverse_bits(int input, int len){ - int reversed = 0; - for (int i = 0; i < len; i++){ - reversed += (input & (1<<i))?(1 << (len-i-1)):0; - } - return reversed; -} - -void -vrt::quadradio::update_dboard_pins(void){ - //convert the band ID to bits - int band_select; - switch (d_band_select){ - case VRT_BAND_SEL_A: band_select = 3; break; - case VRT_BAND_SEL_B: band_select = 2; break; - case VRT_BAND_SEL_C: band_select = 1; break; - case VRT_BAND_SEL_D: band_select = 0; break; - default: band_select = 0; - } - //calculate the control bits - int db_ctrl = \ - ((reverse_bits(d_attenuation0, 5) & 0x1f) << 10) | \ - ((reverse_bits(~d_attenuation1, 5) & 0x1f) << 03) | \ - ((band_select & 0x03) << 01) | \ - ((d_rx_antenna & 0x01) << 00); - set_dboard_pins(ALL_DBOARDS, db_ctrl); // FIXME sets them all -} - -void -vrt::quadradio::set_adc_gain(bool on){ - set_hsadc_conf(ALL_DBOARDS, 0x14, on ? 0x90 : 0x80); -} - -void -vrt::quadradio::set_dc_offset_comp(bool on){ - if (on) { - set_hsadc_conf(ALL_DBOARDS, 0x1B, 0x80); - set_hsadc_conf(ALL_DBOARDS, 0x1A, 0x00); //bits 6:4 set time constant - } - else set_hsadc_conf(ALL_DBOARDS, 0x1B, 0x00); -} - -void -vrt::quadradio::set_digital_gain(float gain){ - int gain_q1 = static_cast<int>(round(gain*2.0)); - set_hsadc_conf(ALL_DBOARDS, 0x17, gain_q1); -} - -void -vrt::quadradio::set_test_signal(vrt_test_sig_t type){ - set_hsadc_conf(ALL_DBOARDS, 0x16, type); -} - -bool -vrt::quadradio::open_sockets(const char *quad_radio_ip, int quad_radio_ctrl_port, - int *ctrl_fd_ptr, struct in_addr *ctrl_port_inaddr, - int *data_fd_ptr, int *data_port_ptr) -{ - int ctrl_fd; // socket for control - int data_fd; // socket fd for data - int data_port; // our port number - - // - // create a udp socket and connect it to the quad radio control port - // - - ctrl_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (ctrl_fd == -1){ - perror("socket: ctrl_fd"); - return false; - } - - struct sockaddr_in si_other; - memset(&si_other, 0, sizeof(si_other)); - si_other.sin_family = AF_INET; - si_other.sin_port = htons(quad_radio_ctrl_port); - if (inet_pton(AF_INET, quad_radio_ip, &si_other.sin_addr) <= 0){ - perror("inet_pton"); - return false; - } - - if (connect(ctrl_fd, (struct sockaddr *) &si_other, sizeof(si_other)) != 0){ - perror("connect"); - return false; - } - - // get our ip address associated with the interface connected to the control port - - struct sockaddr_in si_me; - memset(&si_me, 0, sizeof(si_me)); - socklen_t sockname_len = sizeof(si_me); - if (getsockname(ctrl_fd, (struct sockaddr *) &si_me, &sockname_len) != 0){ - perror("getsockname"); - } - - *ctrl_port_inaddr = si_me.sin_addr; - - if (1){ - char buf[128]; - const char *s = inet_ntop(si_me.sin_family, &si_me.sin_addr, buf, sizeof(buf)); - if (s == 0){ - perror("inet_ntop"); - return false; - } - // printf("our ip addr associated with ctrl port: %s\n", s); - } - - // - // create a udp socket to use to receive data - // - - data_fd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); - if (data_fd == -1){ - perror("socket: data_fd"); - return false; - } - - // bind it to a local port on the interface that connects to the ctrl port. - // FIXME this assumes that interface connected to the control port and the - // interface connected to the data port are the same. If we're using - // both ethernet ports on the quad radio, this may not be the case. - - data_port = -1; - for (int port = MIN_IP_LOCAL_PORT; port <= MAX_IP_LOCAL_PORT; port++){ - struct sockaddr_in si_me; - memset(&si_me, 0, sizeof(si_me)); - si_me.sin_family = AF_INET; - si_me.sin_port = htons(port); - si_me.sin_addr.s_addr = htonl(INADDR_ANY); - - if (bind(data_fd, (struct sockaddr *) &si_me, sizeof(si_me)) == 0){ // found one! - data_port = port; - break; - } - } - - if (data_port == -1){ - fprintf(stderr, "failed to bind to a local port\n"); - return false; - } - - // printf("our data port = %d\n", data_port); - - *ctrl_fd_ptr = ctrl_fd; - *data_fd_ptr = data_fd; - *data_port_ptr = data_port; - - return true; -} - -// ------------------------------------------------------------------------ - -bool -vrt::quadradio::send_rx_command(int ctrl_fd, int rxdspno, bool start, - struct in_addr addr, int data_port, - int samples_per_pkt) -{ - uint32_t cmd[7]; - cmd[0] = htonl(0); // verb: set - cmd[1] = htonl(0); // id: rx_streaming - cmd[2] = htonl(start ? 1: 0); // start or stop? - cmd[3] = addr.s_addr; // ip address to send data to (already network endian) - cmd[4] = htonl(data_port); // port to send data to - cmd[5] = htonl(samples_per_pkt); - cmd[6] = htonl(rxdspno); // the DSP pipeline to configure - - return send_and_check(ctrl_fd, cmd, sizeof(cmd)); -} - -bool -vrt::quadradio::send_stop_rx_command(int ctrl_fd, int rxdspno) -{ - struct in_addr in_addr; - in_addr.s_addr = 0; - return send_rx_command(ctrl_fd, rxdspno, false, in_addr, 0, 0); -} - -bool -vrt::quadradio::set_dboard_pins(int dboard_bitmask, int v) -{ - uint32_t cmd[4]; - cmd[0] = htonl(0); // verb: set - cmd[1] = htonl(1); // id: dboard_pins - cmd[2] = htonl(dboard_bitmask); - cmd[3] = htonl(v); // value - - return send_and_check(d_ctrl_fd, cmd, sizeof(cmd)); -} - -bool -vrt::quadradio::set_setting_reg(int regno, int value) -{ - uint32_t cmd[4]; - cmd[0] = htonl(0); // verb: set - cmd[1] = htonl(2); // id: SR - cmd[2] = htonl(regno); - cmd[3] = htonl(value); - - return send_and_check(d_ctrl_fd, cmd, sizeof(cmd)); -} - -bool -vrt::quadradio::set_hsadc_conf(int dboard_bitmask, int regno, int value) -{ - uint32_t cmd[5]; - cmd[0] = htonl(0); // verb: set - cmd[1] = htonl(3); // id: HSADC_CONF - cmd[2] = htonl(dboard_bitmask); - cmd[3] = htonl(regno); - cmd[4] = htonl(value); - - return send_and_check(d_ctrl_fd, cmd, sizeof(cmd)); -} - -bool -vrt::quadradio::set_lsdac(int dboard_bitmask, int which_dac, int value) -{ - uint32_t cmd[5]; - cmd[0] = htonl(0); // verb: set - cmd[1] = htonl(4); // id: LSDAC - cmd[2] = htonl(dboard_bitmask); - cmd[3] = htonl(which_dac); - cmd[4] = htonl(value); - - return send_and_check(d_ctrl_fd, cmd, sizeof(cmd)); -} - -bool -vrt::quadradio::set_mem32(int addr, int value) -{ - uint32_t cmd[4]; - cmd[0] = htonl(0); // verb: set - cmd[1] = htonl(5); // id: MEM32 - cmd[2] = htonl(addr); - cmd[3] = htonl(value); - - return send_and_check(d_ctrl_fd, cmd, sizeof(cmd)); -} - -bool -vrt::quadradio::set_lo_freq(double freq) -{ - vrt_freq_t lo_freq = htonll(double_to_vrt_freq(freq)); - uint32_t cmd[4]; - cmd[0] = htonl(0); // verb: set - cmd[1] = htonl(6); // id: lo freq - memcpy(cmd+2, &lo_freq, sizeof(lo_freq)); - - return send_and_check(d_ctrl_fd, cmd, sizeof(cmd)); -} - -bool -vrt::quadradio::set_cal_freq(double freq) -{ - vrt_freq_t cal_freq = htonll(double_to_vrt_freq(freq)); - uint32_t cmd[4]; - cmd[0] = htonl(0); // verb: set - cmd[1] = htonl(7); // id: cal freq - memcpy(cmd+2, &cal_freq, sizeof(cal_freq)); - - return send_and_check(d_ctrl_fd, cmd, sizeof(cmd)); -} - -bool -vrt::quadradio::set_beamforming(int32_t gains[8]){ - uint32_t cmd[2+8]; - cmd[0] = htonl(0); // verb: set - cmd[1] = htonl(8); // id: beamformin - for (int i = 0; i < 8; i++){ - //printf("%d\n", gains[i]); - cmd[i+2] = htonl(gains[i]); - } - return send_and_check(d_ctrl_fd, cmd, sizeof(cmd)); -} - -bool -vrt::quadradio::set_cal_enb(bool enb) -{ - uint32_t cmd[3]; - cmd[0] = htonl(0); // verb: set - cmd[1] = htonl(9); // id: cal enb - cmd[2] = htonl(enb); - - return send_and_check(d_ctrl_fd, cmd, sizeof(cmd)); -} |