From: Tom Rondeau Date: Sun, 16 Jan 2011 19:03:30 +0000 (-0500) Subject: Merge branch 'maint' X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=58a1356ed70994c0f24afa8a276b7e62979c28cf;hp=ead0819388bc03555c9182f27176aac6ea2a8bbc;p=debian%2Fgnuradio Merge branch 'maint' * maint: Fixing up fft and constellation plot to better handle zooming. Fixing zooming capabilities. Time axis does not track any longer due to what looks like a matplotlib bug that resets the xlims after the zoom occurs. Fixing up other plotting tools for data read errors. Using .min and .max on scipy arrays instead of min() max(); seems to be more portable. Fix how the end of a file is handled. PFB resampler: fix it this way to avoid the signed/unsigned warning. PFB resampler: fixes bug where filter could be looking past the number of inputs. --- diff --git a/Makefile.common b/Makefile.common index fb83b947..9c36a496 100644 --- a/Makefile.common +++ b/Makefile.common @@ -57,8 +57,8 @@ libspudir = $(libdir)spu # This used to be set in configure.ac but is now defined here for all # Makefiles when this fragment is included. -STD_DEFINES_AND_INCLUDES = $(DEFINES) $(BOOST_CPPFLAGS) \ - $(GNURADIO_INCLUDES) $(GRUEL_INCLUDES) +STD_DEFINES_AND_INCLUDES = $(DEFINES) $(GNURADIO_INCLUDES) \ + $(GRUEL_INCLUDES) $(BOOST_CPPFLAGS) # when including for compilation from pre-installed libraries and such, # need to make sure those are put last on the compile command @@ -112,7 +112,8 @@ grc_blocksdir = $(pkgdatadir)/grc/blocks # Other common defines; use "+=" to add to these STAMPS = -MOSTLYCLEANFILES = $(BUILT_SOURCES) $(STAMPS) *.pyc *.pyo *~ *.tmp *.loT +MOSTLYCLEANFILES = $(BUILT_SOURCES) $(STAMPS) *.pyc *.pyo *~ *.tmp *.loT \ + .unittests/* .unittests/python/* # Don't distribute the files defined in the variable 'no_dist_files' dist-hook: diff --git a/config/usrp_libusb.m4 b/config/usrp_libusb.m4 index a434d379..cc3410f4 100644 --- a/config/usrp_libusb.m4 +++ b/config/usrp_libusb.m4 @@ -24,28 +24,43 @@ dnl Boston, MA 02110-1301, USA. AC_DEFUN([USRP_LIBUSB], [ - dnl Use PKGCONFIG to check for packages first, then check to - dnl make sure the USB_* variables work (whether from PKGCONFIG - dnl or overridden by the user) - - dnl do not use LDFLAGS, since PKGCONFIG will provide everything + dnl do not use LDFLAGS, except on Windows saved_LDFLAGS=${LDFLAGS} - LDFLAGS= - LIBUSB_PKG_CONFIG_NAME= + case "$host_os" in + cygwin* | mingw*) + ;; + *) + LDFLAGS= + ;; + esac - dnl loop over various possible 'libusb' PKGCONFIG names, and choose - dnl the first one that meets both the user's selection (via - dnl configure flags) as well as what is installed + dnl this variable is set in usrp/usrp.pc.in as a requirement + dnl for libusrp; it is OK to be empty. + LIBUSB_PKG_CONFIG_NAME= - dnl create the list of libusb PKGCONFIG modules to test + dnl for Windows (cygin, mingw), do not use PKGCONFIG since LIBUSB + dnl does not install a .pc file. For all other OSs, use + dnl PKGCONFIG to check for various package names first. libusb_list='' - if test x$1 = xyes; then - dnl libusb-1.0 was requested; just test for it - libusb_list="libusb-1.0" - else - dnl test for legacy libusb only - libusb_list="libusb libusb-legacy" - fi + case "$host_os" in + cygwin* | mingw*) + libusb_list='libusb' + ;; + *) + dnl create the list of libusb PKGCONFIG modules to test + if test x$1 = xyes; then + dnl libusb-1.0 was requested; just test for it + libusb_list="libusb-1.0" + else + dnl test for legacy libusb only + libusb_list="libusb libusb-legacy" + fi + ;; + esac + + dnl loop over various possible 'libusb' names, and + dnl choose the first one that meets both the user's selection + dnl (via configure flags) as well as what is installed for libusb_name in ${libusb_list}; do dnl clear internal variables libusbok=no @@ -54,31 +69,45 @@ AC_DEFUN([USRP_LIBUSB], [ usb_lib_func='' usb_lib_name='' - dnl start checks - AC_MSG_NOTICE([Checking for LIBUSB version '${libusb_name}']) - if test ${libusb_name} = "libusb-1.0"; then - dnl see if the pkgconfig module is available - PKG_CHECK_MODULES(USB, ${libusb_name}, [ - libusbok=yes - have_libusb1=yes - usb_header='libusb-1.0/libusb.h' - usb_lib_func='libusb_bulk_transfer' - ], [libusbok=no]) - else - dnl see if the pkgconfig module is available - PKG_CHECK_MODULES(USB, ${libusb_name}, [ - libusbok=yes + case "$host_os" in + cygwin* | mingw*) + USB_INCLUDEDIR= + USB_INCLUDES= + USB_LIBS=-lusb usb_header='usb.h' usb_lib_func='usb_bulk_write' - ], [libusbok=no]) - fi + libusbok=yes + ;; + *) + dnl start checks + AC_MSG_NOTICE([Checking for LIBUSB version '${libusb_name}']) + if test ${libusb_name} = "libusb-1.0"; then + dnl see if the pkgconfig module is available + PKG_CHECK_MODULES(USB, ${libusb_name}, [ + libusbok=yes + have_libusb1=yes + usb_header='libusb-1.0/libusb.h' + usb_lib_func='libusb_bulk_transfer' + ], [libusbok=no]) + else + dnl see if the pkgconfig module is available + PKG_CHECK_MODULES(USB, ${libusb_name}, [ + libusbok=yes + usb_header='usb.h' + usb_lib_func='usb_bulk_write' + ], [libusbok=no]) + fi + ;; + esac if test $libusbok = yes; then - dnl PKGCONFIG found a version of LIBUSB. + dnl PKGCONFIG found a version of LIBUSB, or the info was + dnl provided by the user, or the OS is Windows. + dnl Check it to make sure it meets enough criteria: dnl Verify that $usb_header is a valid header. If so, then dnl verify that $usb_lib_func can be found in the library dnl $usb_lib_name. if so, verify that the symbol 'usb_debug' is - dnl found in the library. + dnl found in the library if not using Windows. dnl Check for the header. Similar to AC_CHECK_HEADERS, dnl but doesn't append to known \#defines. @@ -135,28 +164,43 @@ AC_DEFUN([USRP_LIBUSB], [ if test $libusbok = yes; then if test ${libusb_name} != "libusb-1.0"; then dnl PKGCONFIG found a legacy version of libusb; make sure the - dnl variable _usb_debug is available in the found library - AC_LANG_PUSH(C) - save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$USB_INCLUDES" - save_LIBS="$LIBS" - LIBS="$USB_LIBS" - AC_MSG_CHECKING([$libusb_name for symbol usb_debug in library $usb_lib_name]) - AC_LINK_IFELSE([AC_LANG_PROGRAM([[ - extern int usb_debug;]], - [[usb_debug = 0;]])], - [libusbok=yes],[libusbok=no]) - AC_MSG_RESULT([$libusbok]) - LIBS="$save_LIBS" - CPPFLAGS="$save_CPPFLAGS" - AC_LANG_POP(C) + dnl variable _usb_debug is available in the found library. + dnl Do not test on Windows, since that symbol is not defined. + case "$host_os" in + cygwin* | mingw*) + ;; + *) + AC_LANG_PUSH(C) + save_CPPFLAGS="$CPPFLAGS" + if test x$USB_INCLUDEDIR != x; then + CPPFLAGS="$USB_INCLUDES" + fi + save_LIBS="$LIBS" + LIBS="$USB_LIBS" + AC_MSG_CHECKING([$libusb_name for symbol usb_debug in library $usb_lib_name]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + extern int usb_debug;]], + [[usb_debug = 0;]])], + [libusbok=yes],[libusbok=no]) + AC_MSG_RESULT([$libusbok]) + LIBS="$save_LIBS" + CPPFLAGS="$save_CPPFLAGS" + AC_LANG_POP(C) + ;; + esac fi fi fi fi dnl if everything checks out OK, finish up if test $libusbok = yes; then - LIBUSB_PKG_CONFIG_NAME="${libusb_name}" + case "$host_os" in + cygwin* | mingw*) + ;; + *) + LIBUSB_PKG_CONFIG_NAME="${libusb_name}" + ;; + esac break else dnl something wasn't found in this LIBUSB version. @@ -173,7 +217,9 @@ AC_DEFUN([USRP_LIBUSB], [ dnl final error checking, mostly to create #define's AC_LANG_PUSH(C) save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$USB_INCLUDES" + if test x$USB_INCLUDEDIR != x; then + CPPFLAGS="$USB_INCLUDES" + fi dnl Check for the header. AC_CHECK_HEADERS([$usb_header], [], [libusbok=no]) CPPFLAGS="$save_CPPFLAGS" @@ -185,18 +231,20 @@ AC_DEFUN([USRP_LIBUSB], [ dnl check for the library (again) AC_LANG_PUSH(C) save_CPPFLAGS="$CPPFLAGS" - CPPFLAGS="$USB_INCLUDES" + if test x$USB_INCLUDEDIR != x; then + CPPFLAGS="$USB_INCLUDES" + fi save_LIBS="$LIBS" LIBS="$USB_LIBS" AC_CHECK_LIB([$usb_lib_name], [$usb_lib_func], [], [ libusbok=no AC_MSG_RESULT([USRP requires library '$usb_lib_name' with function '$usb_lib_func', which was either not found or was not usable. See http://www.libusb.org])]) - case "$host_os" in - cygwin* | mingw*) - USB_LIBS="$LIBS" - ;; - *) ;; - esac +# case "$host_os" in +# cygwin* | mingw*) +# USB_LIBS="$LIBS" +# ;; +# *) ;; +# esac LIBS="$save_LIBS" CPPFLAGS="$save_CPPFLAGS" AC_LANG_POP(C) diff --git a/dtools/bin/fix-copyright-years b/dtools/bin/fix-copyright-years new file mode 100755 index 00000000..bb0f3009 --- /dev/null +++ b/dtools/bin/fix-copyright-years @@ -0,0 +1,65 @@ +#!/usr/bin/env python + +import re +import datetime +import subprocess +import multiprocessing + +def command(*args): return subprocess.Popen(args, stdout=subprocess.PIPE).communicate()[0] + +def is_gnuradio_co_source(lines): + for line in lines[:20]: + if 'GNU Radio is free software' in line: return True + return False + +def get_gnuradio_co_line(lines): + for i, line in enumerate(lines[:5]): + if 'Copyright' in line and 'Free Software Foundation' in line: return line, i + return None + +def fix_co_years(files): + for file in files: + print file + lines = open(file).readlines() + if not is_gnuradio_co_source(lines): continue + + #extract the years from the git history + years = set(map( + lambda l: int(l.split()[-2]), + filter( + lambda l: l.startswith('Date'), + command('git', 'log', file).splitlines(), + ), + )) + + #extract line and line number for co line + try: line, num = get_gnuradio_co_line(lines) + except: continue + + #extract years from co string + try: + co_years_str = re.match('^.*Copyright (.*) Free Software Foundation.*$', line).groups()[0] + co_years = set(map(int, co_years_str.split(','))) + except: print ' format error on line %d: "%s"'%(num, line); continue + + #update the years if missing any + all_years = co_years.union(years) + if all_years != co_years: + print ' missing years: %s'%(', '.join(map(str, sorted(all_years - co_years)))) + all_years.add(datetime.datetime.now().year) #add the current year + all_years_str = ', '.join(map(str, sorted(all_years))) + new_text = ''.join(lines[:num] + [line.replace(co_years_str, all_years_str)] + lines[num+1:]) + open(file, 'w').write(new_text) + +if __name__ == "__main__": + #get recursive list of files in the repo + files = command('git', 'ls-tree', '--name-only', 'HEAD', '-r').splitlines() + + #start n+1 processes to handle the files + num_procs = multiprocessing.cpu_count() + procs = [multiprocessing.Process( + target=lambda *files: fix_co_years(files), + args=files[num::num_procs], + ) for num in range(num_procs)] + map(multiprocessing.Process.start, procs) + map(multiprocessing.Process.join, procs) diff --git a/gcell/apps/test_all.cc b/gcell/apps/test_all.cc index 9823960c..0b608e13 100644 --- a/gcell/apps/test_all.cc +++ b/gcell/apps/test_all.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007 Free Software Foundation, Inc. + * Copyright 2007,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,18 +20,25 @@ */ #include +#include +#include #include "../lib/runtime/qa_gcell_runtime.h" #include "../lib/wrapper/qa_gcell_wrapper.h" int main(int argc, char **argv) { - - CppUnit::TextTestRunner runner; + char path[200]; + get_unittest_path ("gcell_all.xml", path, 200); + + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(path); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest(qa_gcell_runtime::suite()); runner.addTest(qa_gcell_wrapper::suite()); + runner.setOutputter(xmlout); bool was_successful = runner.run("", false); diff --git a/gcell/lib/runtime/Makefile.am b/gcell/lib/runtime/Makefile.am index 4d13790c..3ce63763 100644 --- a/gcell/lib/runtime/Makefile.am +++ b/gcell/lib/runtime/Makefile.am @@ -23,8 +23,8 @@ include $(top_srcdir)/Makefile.common IBM_PPU_SYNC_INCLUDES = -I$(top_srcdir)/gcell/ibm/sync/ppu_source -AM_CPPFLAGS = $(DEFINES) $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) \ - $(GCELL_INCLUDES) $(IBM_PPU_SYNC_INCLUDES) $(WITH_INCLUDES) +AM_CPPFLAGS = $(DEFINES) $(GCELL_INCLUDES) $(IBM_PPU_SYNC_INCLUDES) \ + $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES) dist_bin_SCRIPTS = gcell-embedspu-libtool diff --git a/gnuradio-core/src/lib/filter/.gitignore b/gnuradio-core/src/lib/filter/.gitignore index 2d009f15..faaf02cb 100644 --- a/gnuradio-core/src/lib/filter/.gitignore +++ b/gnuradio-core/src/lib/filter/.gitignore @@ -211,4 +211,16 @@ /gr_rational_resampler_base_scc.cc /gr_rational_resampler_base_scc.h /gr_rational_resampler_base_scc.i +/gri_fir_filter_with_buffer_ccc.cc +/gri_fir_filter_with_buffer_ccc.h +/gri_fir_filter_with_buffer_ccf.cc +/gri_fir_filter_with_buffer_ccf.h +/gri_fir_filter_with_buffer_fcc.cc +/gri_fir_filter_with_buffer_fcc.h +/gri_fir_filter_with_buffer_fff.cc +/gri_fir_filter_with_buffer_fff.h +/gri_fir_filter_with_buffer_fsf.cc +/gri_fir_filter_with_buffer_fsf.h +/gri_fir_filter_with_buffer_scc.cc +/gri_fir_filter_with_buffer_scc.h /stamp-* diff --git a/gnuradio-core/src/lib/filter/Makefile.am b/gnuradio-core/src/lib/filter/Makefile.am index 23c1dadc..6d2ec1c7 100644 --- a/gnuradio-core/src/lib/filter/Makefile.am +++ b/gnuradio-core/src/lib/filter/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2001,2002,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. +# Copyright 2001,2002,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -44,6 +44,7 @@ code_generator = \ generate_gr_fir_sysconfig_generic.py \ generate_gr_fir_util.py \ generate_gr_freq_xlating_fir_filter_XXX.py \ + generate_gri_fir_filter_with_buffer_XXX.py \ generate_utils.py \ gr_fir_XXX.cc.t \ gr_fir_XXX.h.t \ @@ -60,7 +61,10 @@ code_generator = \ gr_rational_resampler_base_XXX.i.t \ gr_freq_xlating_fir_filter_XXX.cc.t \ gr_freq_xlating_fir_filter_XXX.h.t \ - gr_freq_xlating_fir_filter_XXX.i.t + gr_freq_xlating_fir_filter_XXX.i.t \ + gri_fir_filter_with_buffer_XXX.cc.t \ + gri_fir_filter_with_buffer_XXX.h.t + # Source built by Python into $(builddir) BUILT_SOURCES = \ @@ -205,6 +209,7 @@ libfilter_la_common_SOURCES = \ float_dotprod_generic.c \ short_dotprod_generic.c \ gr_pfb_channelizer_ccf.cc \ + gr_pfb_synthesis_filterbank_ccf.cc\ gr_pfb_decimator_ccf.cc \ gr_pfb_interpolator_ccf.cc \ gr_pfb_arb_resampler_ccf.cc \ @@ -220,7 +225,13 @@ libfilter_qa_la_common_SOURCES = \ qa_gr_fir_scc.cc \ qa_gr_rotator.cc \ qa_gri_mmse_fir_interpolator.cc \ - qa_gri_mmse_fir_interpolator_cc.cc + qa_gri_mmse_fir_interpolator_cc.cc \ + qa_gri_fir_filter_with_buffer_ccf.cc \ + qa_gri_fir_filter_with_buffer_ccc.cc \ + qa_gri_fir_filter_with_buffer_fcc.cc \ + qa_gri_fir_filter_with_buffer_fff.cc \ + qa_gri_fir_filter_with_buffer_fsf.cc \ + qa_gri_fir_filter_with_buffer_scc.cc if MD_CPU_generic libfilter_la_SOURCES = $(libfilter_la_common_SOURCES) $(generic_CODE) @@ -288,6 +299,7 @@ grinclude_HEADERS = \ short_dotprod_x86.h \ sse_debug.h \ gr_pfb_channelizer_ccf.h \ + gr_pfb_synthesis_filterbank_ccf.h\ gr_pfb_decimator_ccf.h \ gr_pfb_interpolator_ccf.h \ gr_pfb_arb_resampler_ccf.h \ @@ -324,7 +336,13 @@ noinst_HEADERS = \ qa_gr_fir_scc.h \ qa_gr_rotator.h \ qa_gri_mmse_fir_interpolator.h \ - qa_gri_mmse_fir_interpolator_cc.h + qa_gri_mmse_fir_interpolator_cc.h \ + qa_gri_fir_filter_with_buffer_ccf.h \ + qa_gri_fir_filter_with_buffer_ccc.h \ + qa_gri_fir_filter_with_buffer_fcc.h \ + qa_gri_fir_filter_with_buffer_fff.h \ + qa_gri_fir_filter_with_buffer_fsf.h \ + qa_gri_fir_filter_with_buffer_scc.h if PYTHON @@ -344,6 +362,7 @@ swiginclude_HEADERS = \ gr_single_pole_iir_filter_ff.i \ gr_single_pole_iir_filter_cc.i \ gr_pfb_channelizer_ccf.i \ + gr_pfb_synthesis_filterbank_ccf.i\ gr_pfb_decimator_ccf.i \ gr_pfb_interpolator_ccf.i \ gr_pfb_arb_resampler_ccf.i \ diff --git a/gnuradio-core/src/lib/filter/Makefile.gen b/gnuradio-core/src/lib/filter/Makefile.gen index 6809274f..909899c0 100644 --- a/gnuradio-core/src/lib/filter/Makefile.gen +++ b/gnuradio-core/src/lib/filter/Makefile.gen @@ -40,7 +40,14 @@ GENERATED_H = \ gr_rational_resampler_base_fcc.h \ gr_rational_resampler_base_fff.h \ gr_rational_resampler_base_fsf.h \ - gr_rational_resampler_base_scc.h + gr_rational_resampler_base_scc.h \ + gri_fir_filter_with_buffer_ccc.h \ + gri_fir_filter_with_buffer_ccf.h \ + gri_fir_filter_with_buffer_fcc.h \ + gri_fir_filter_with_buffer_fff.h \ + gri_fir_filter_with_buffer_fsf.h \ + gri_fir_filter_with_buffer_scc.h + GENERATED_I = \ gr_fir_filter_ccc.i \ @@ -107,5 +114,11 @@ GENERATED_CC = \ gr_rational_resampler_base_fcc.cc \ gr_rational_resampler_base_fff.cc \ gr_rational_resampler_base_fsf.cc \ - gr_rational_resampler_base_scc.cc + gr_rational_resampler_base_scc.cc \ + gri_fir_filter_with_buffer_ccc.cc \ + gri_fir_filter_with_buffer_ccf.cc \ + gri_fir_filter_with_buffer_fcc.cc \ + gri_fir_filter_with_buffer_fff.cc \ + gri_fir_filter_with_buffer_fsf.cc \ + gri_fir_filter_with_buffer_scc.cc diff --git a/gnuradio-core/src/lib/filter/filter.i b/gnuradio-core/src/lib/filter/filter.i index bdfb8fa8..645607cb 100644 --- a/gnuradio-core/src/lib/filter/filter.i +++ b/gnuradio-core/src/lib/filter/filter.i @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -52,6 +53,7 @@ %include "gr_goertzel_fc.i" %include "gr_cma_equalizer_cc.i" %include "gr_pfb_channelizer_ccf.i" +%include "gr_pfb_synthesis_filterbank_ccf.i" %include "gr_pfb_decimator_ccf.i" %include "gr_pfb_interpolator_ccf.i" %include "gr_pfb_arb_resampler_ccf.i" diff --git a/gnuradio-core/src/lib/filter/generate_all.py b/gnuradio-core/src/lib/filter/generate_all.py index b34e13c7..ceed2b85 100755 --- a/gnuradio-core/src/lib/filter/generate_all.py +++ b/gnuradio-core/src/lib/filter/generate_all.py @@ -30,6 +30,7 @@ import generate_gr_fir_sysconfig_generic import generate_gr_fir_sysconfig import generate_gr_fir_util import generate_gr_fir_XXX +import generate_gri_fir_filter_with_buffer_XXX def generate_all(): generate_gr_fir_XXX.generate() @@ -40,6 +41,7 @@ def generate_all(): generate_gr_fir_sysconfig_generic.generate() generate_gr_fir_sysconfig.generate() generate_gr_fir_util.generate() + generate_gri_fir_filter_with_buffer_XXX.generate() output_glue('filter') if __name__ == '__main__': diff --git a/gnuradio-core/src/lib/filter/generate_gri_fir_filter_with_buffer_XXX.py b/gnuradio-core/src/lib/filter/generate_gri_fir_filter_with_buffer_XXX.py new file mode 100755 index 00000000..f586b0c2 --- /dev/null +++ b/gnuradio-core/src/lib/filter/generate_gri_fir_filter_with_buffer_XXX.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python +# -*- python -*- +# +# Copyright 2010 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. +# + +import re +from generate_utils import * + +roots = ['gri_fir_filter_with_buffer_XXX',] + +def code3_to_acc_code (code3): + if i_code (code3) == 'c' or o_code (code3) == 'c' or tap_code (code3) == 'c': + return 'c' + if i_code (code3) == 'f' or o_code (code3) == 'f' or tap_code (code3) == 'f': + return 'f' + if i_code (code3) == 'i' or o_code (code3) == 'i' or tap_code (code3) == 'i': + return 'i' + return 'i' # even short short short needs int accumulator + +def code3_to_input_cast (code3): + if i_code (code3) == 's' and o_code (code3) == 'c': + return '(float)' + return '' + +def expand_h_cc (root, code3): + d = init_dict (root, code3) + expand_template (d, root + '.h.t') + expand_template (d, root + '.cc.t') + +def init_dict (root, code3): + name = re.sub ('X+', code3, root) + d = standard_dict (name, code3) + d['INPUT_CAST'] = code3_to_input_cast (code3) + acc_code = code3_to_acc_code (code3) + d['ACC_TYPE'] = char_to_type[acc_code] + return d + + +def generate (): + for r in roots: + for s in fir_signatures: + expand_h_cc (r, s) + + +if __name__ == '__main__': + generate () diff --git a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc index add106b6..84b0c578 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_arb_resampler_ccf.cc @@ -35,7 +35,7 @@ gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate, unsigned int filter_size) { return gnuradio::get_initial_sptr(new gr_pfb_arb_resampler_ccf (rate, taps, - filter_size)); + filter_size)); } @@ -71,7 +71,7 @@ gr_pfb_arb_resampler_ccf::gr_pfb_arb_resampler_ccf (float rate, // Create an FIR filter for each channel and zero out the taps std::vector vtaps(0, d_int_rate); - for(int i = 0; i < d_int_rate; i++) { + for(unsigned int i = 0; i < d_int_rate; i++) { d_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); d_diff_filters[i] = gr_fir_util::create_gr_fir_ccf(vtaps); } @@ -81,6 +81,8 @@ gr_pfb_arb_resampler_ccf::gr_pfb_arb_resampler_ccf (float rate, create_diff_taps(taps, dtaps); create_taps(taps, d_taps, d_filters); create_taps(dtaps, d_dtaps, d_diff_filters); + + set_relative_rate(rate); } gr_pfb_arb_resampler_ccf::~gr_pfb_arb_resampler_ccf () @@ -95,8 +97,6 @@ gr_pfb_arb_resampler_ccf::create_taps (const std::vector &newtaps, std::vector< std::vector > &ourtaps, std::vector &ourfilter) { - int i,j; - unsigned int ntaps = newtaps.size(); d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_int_rate); @@ -112,10 +112,10 @@ gr_pfb_arb_resampler_ccf::create_taps (const std::vector &newtaps, } // Partition the filter - for(i = 0; i < d_int_rate; i++) { + for(unsigned int i = 0; i < d_int_rate; i++) { // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out ourtaps[d_int_rate-1-i] = std::vector(d_taps_per_filter, 0); - for(j = 0; j < d_taps_per_filter; j++) { + for(unsigned int j = 0; j < d_taps_per_filter; j++) { ourtaps[d_int_rate - 1 - i][j] = tmp_taps[i + j*d_int_rate]; } @@ -171,7 +171,8 @@ gr_pfb_arb_resampler_ccf::general_work (int noutput_items, return 0; // history requirements may have changed. } - int i = 0, j, count = d_start_index; + int i = 0, count = d_start_index; + unsigned int j; gr_complex o0, o1; // Restore the last filter position diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc index f86782da..db16a634 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc @@ -55,11 +55,12 @@ gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, // This tests the specified input sample rate to see if it conforms to this // requirement within a few significant figures. double intp = 0; - double x = (10000.0*rint(numchans / oversample_rate)) / 10000.0; double fltp = modf(numchans / oversample_rate, &intp); if(fltp != 0.0) throw std::invalid_argument("gr_pfb_channelizer: oversample rate must be N/i for i in [1, N]"); + set_relative_rate(1.0/intp); + d_filters = std::vector(d_numchans); // Create an FIR filter for each channel and zero out the taps diff --git a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc index 8a0ad1c4..e20bc38b 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc @@ -132,7 +132,7 @@ gr_pfb_interpolator_ccf::work (int noutput_items, int i = 0, count = 0; while(i < noutput_items) { - for(int j = 0; j < d_rate; j++) { + for(unsigned int j = 0; j < d_rate; j++) { out[i] = d_filters[j]->filter(&in[count]); i++; } diff --git a/gnuradio-core/src/lib/filter/gr_pfb_synthesis_filterbank_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_synthesis_filterbank_ccf.cc new file mode 100644 index 00000000..9fad1bd0 --- /dev/null +++ b/gnuradio-core/src/lib/filter/gr_pfb_synthesis_filterbank_ccf.cc @@ -0,0 +1,169 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 +#include +#include +#include +#include + +gr_pfb_synthesis_filterbank_ccf_sptr gr_make_pfb_synthesis_filterbank_ccf + (unsigned int numchans, const std::vector &taps) +{ + return gr_pfb_synthesis_filterbank_ccf_sptr + (new gr_pfb_synthesis_filterbank_ccf (numchans, taps)); +} + + +gr_pfb_synthesis_filterbank_ccf::gr_pfb_synthesis_filterbank_ccf + (unsigned int numchans, const std::vector &taps) + : gr_sync_interpolator ("pfb_synthesis_filterbank_ccf", + gr_make_io_signature (1, numchans, sizeof(gr_complex)), + gr_make_io_signature (1, 1, sizeof(gr_complex)), + numchans), + d_updated (false), d_numchans(numchans) +{ + d_filters = std::vector(d_numchans); + + // Create an FIR filter for each channel and zero out the taps + std::vector vtaps(0, d_numchans); + for(unsigned int i = 0; i < d_numchans; i++) { + d_filters[i] = new gri_fir_filter_with_buffer_ccf(vtaps); + } + + // Now, actually set the filters' taps + set_taps(taps); + + // Create the IFFT to handle the input channel rotations + d_fft = new gri_fft_complex (d_numchans, true); +} + +gr_pfb_synthesis_filterbank_ccf::~gr_pfb_synthesis_filterbank_ccf () +{ + for(unsigned int i = 0; i < d_numchans; i++) { + delete d_filters[i]; + } +} + +void +gr_pfb_synthesis_filterbank_ccf::set_taps (const std::vector &taps) +{ + unsigned int i,j; + + unsigned int ntaps = taps.size(); + d_taps_per_filter = (unsigned int)ceil((double)ntaps/(double)d_numchans); + + // Create d_numchan vectors to store each channel's taps + d_taps.resize(d_numchans); + + // Make a vector of the taps plus fill it out with 0's to fill + // each polyphase filter with exactly d_taps_per_filter + std::vector tmp_taps; + tmp_taps = taps; + while((float)(tmp_taps.size()) < d_numchans*d_taps_per_filter) { + tmp_taps.push_back(0.0); + } + + // Partition the filter + for(i = 0; i < d_numchans; i++) { + // Each channel uses all d_taps_per_filter with 0's if not enough taps to fill out + d_taps[i] = std::vector(d_taps_per_filter, 0); + for(j = 0; j < d_taps_per_filter; j++) { + d_taps[i][j] = tmp_taps[i + j*d_numchans]; // add taps to channels in reverse order + } + + // Build a filter for each channel and add it's taps to it + d_filters[i]->set_taps(d_taps[i]); + } + + // Set the history to ensure enough input items for each filter + set_history (d_taps_per_filter+1); + + d_updated = true; +} + +void +gr_pfb_synthesis_filterbank_ccf::print_taps() +{ + unsigned int i, j; + for(i = 0; i < d_numchans; i++) { + printf("filter[%d]: [", i); + for(j = 0; j < d_taps_per_filter; j++) { + printf(" %.4e", d_taps[i][j]); + } + printf("]\n\n"); + } +} + + +int +gr_pfb_synthesis_filterbank_ccf::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]; + gr_complex *out = (gr_complex *) output_items[0]; + int numsigs = input_items.size(); + int ndiff = d_numchans - numsigs; + unsigned int nhalf = (unsigned int)ceil((float)numsigs/2.0f); + + if (d_updated) { + d_updated = false; + return 0; // history requirements may have changed. + } + + unsigned int n, i; + for(n = 0; n < noutput_items/d_numchans; n++) { + // fill up the populated channels based on the + // number of real input streams + for(i = 0; i < nhalf; i++) { + in = (gr_complex*)input_items[i]; + d_fft->get_inbuf()[i] = (in+i)[n]; + } + + // Make the ndiff channels around N/2 0 + for(; i < nhalf+ndiff; i++) { + d_fft->get_inbuf()[i] = gr_complex(0,0); + } + + // Finish off channels with data + for(; i < d_numchans; i++) { + in = (gr_complex*)input_items[i-ndiff]; + d_fft->get_inbuf()[i] = (in+i)[n]; + } + + // spin through IFFT + d_fft->execute(); + + for(i = 0; i < d_numchans; i++) { + out[d_numchans-i-1] = d_filters[d_numchans-i-1]->filter(d_fft->get_outbuf()[i]); + } + + out += d_numchans; + } + + return noutput_items; +} diff --git a/gnuradio-core/src/lib/filter/gr_pfb_synthesis_filterbank_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_synthesis_filterbank_ccf.h new file mode 100644 index 00000000..f5b1cbb9 --- /dev/null +++ b/gnuradio-core/src/lib/filter/gr_pfb_synthesis_filterbank_ccf.h @@ -0,0 +1,98 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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_GR_PFB_SYNTHESIS_FILTERBANK_CCF_H +#define INCLUDED_GR_PFB_SYNTHESIS_FILTERBANK_CCF_H + +#include +#include + +class gr_pfb_synthesis_filterbank_ccf; +typedef boost::shared_ptr gr_pfb_synthesis_filterbank_ccf_sptr; +gr_pfb_synthesis_filterbank_ccf_sptr gr_make_pfb_synthesis_filterbank_ccf + (unsigned int numchans, const std::vector &taps); + +class gri_fft_complex; + + +/*! + * \class gr_pfb_synthesis_filterbank_ccf + * + * \brief Polyphase synthesis filterbank with + * gr_complex input, gr_complex output and float taps + * + * \ingroup filter_blk + */ + +class gr_pfb_synthesis_filterbank_ccf : public gr_sync_interpolator +{ + private: + /*! + * Build the polyphase synthesis filterbank. + * \param numchans (unsigned integer) Specifies the number of + channels M + * \param taps (vector/list of floats) The prototype filter to + populate the filterbank. + */ + friend gr_pfb_synthesis_filterbank_ccf_sptr gr_make_pfb_synthesis_filterbank_ccf + (unsigned int numchans, const std::vector &taps); + + bool d_updated; + unsigned int d_numchans; + unsigned int d_taps_per_filter; + gri_fft_complex *d_fft; + std::vector< gri_fir_filter_with_buffer_ccf*> d_filters; + std::vector< std::vector > d_taps; + + + /*! + * Build the polyphase synthesis filterbank. + * \param numchans (unsigned integer) Specifies the number of + channels M + * \param taps (vector/list of floats) The prototype filter + to populate the filterbank. + */ + gr_pfb_synthesis_filterbank_ccf (unsigned int numchans, + const std::vector &taps); + +public: + ~gr_pfb_synthesis_filterbank_ccf (); + + /*! + * Resets the filterbank's filter taps with the new prototype filter + * \param taps (vector/list of floats) The prototype filter to + populate the filterbank. + */ + void set_taps (const std::vector &taps); + + /*! + * Print all of the filterbank taps to screen. + */ + void print_taps(); + + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_synthesis_filterbank_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_synthesis_filterbank_ccf.i new file mode 100644 index 00000000..02a9f025 --- /dev/null +++ b/gnuradio-core/src/lib/filter/gr_pfb_synthesis_filterbank_ccf.i @@ -0,0 +1,38 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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. + */ + +GR_SWIG_BLOCK_MAGIC(gr,pfb_synthesis_filterbank_ccf); + +gr_pfb_synthesis_filterbank_ccf_sptr gr_make_pfb_synthesis_filterbank_ccf + (unsigned int numchans, const std::vector &taps); + +class gr_pfb_synthesis_filterbank_ccf : public gr_sync_interpolator +{ + private: + gr_pfb_synthesis_filterbank_ccf (unsigned int numchans, + const std::vector &taps); + + public: + ~gr_pfb_synthesis_filterbank_ccf (); + + void set_taps (const std::vector &taps); +}; diff --git a/gnuradio-core/src/lib/filter/gr_sincos.c b/gnuradio-core/src/lib/filter/gr_sincos.c index 240a8485..57b26b22 100644 --- a/gnuradio-core/src/lib/filter/gr_sincos.c +++ b/gnuradio-core/src/lib/filter/gr_sincos.c @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004 Free Software Foundation, Inc. + * Copyright 2004,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,7 +24,9 @@ #include "config.h" #endif +#ifndef _GNU_SOURCE #define _GNU_SOURCE // ask for GNU extensions if available +#endif #include #include diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir.h b/gnuradio-core/src/lib/filter/gr_single_pole_iir.h index bd59e53a..da919b35 100644 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir.h +++ b/gnuradio-core/src/lib/filter/gr_single_pole_iir.h @@ -71,12 +71,12 @@ public: d_prev_output = 0; } - tap_type prev_output () { return d_prev_output; } + o_type prev_output () { return d_prev_output; } protected: tap_type d_alpha; tap_type d_one_minus_alpha; - tap_type d_prev_output; + o_type d_prev_output; }; @@ -87,7 +87,7 @@ template o_type gr_single_pole_iir::filter (const i_type input) { - tap_type output; + o_type output; output = d_alpha * input + d_one_minus_alpha * d_prev_output; d_prev_output = output; diff --git a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.cc.t b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.cc.t new file mode 100644 index 00000000..15406884 --- /dev/null +++ b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.cc.t @@ -0,0 +1,121 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 +#endif + +#include <@NAME@.h> + +@NAME@::@NAME@(const std::vector<@TAP_TYPE@> &taps) +{ + d_buffer = NULL; + set_taps(taps); +} + +@NAME@::~@NAME@() +{ + if(d_buffer != NULL) + free(d_buffer); +} + +void +@NAME@::set_taps (const std::vector<@TAP_TYPE@> &taps) +{ + d_taps = gr_reverse(taps); + + if(d_buffer != NULL) { + free(d_buffer); + d_buffer = NULL; + } + + // FIXME: memalign this to 16-byte boundaries for SIMD later + size_t t = sizeof(@I_TYPE@) * 2 * d_taps.size(); + d_buffer = (@I_TYPE@*)malloc(t); + memset(d_buffer, 0x00, t); + d_idx = 0; +} + +@O_TYPE@ +@NAME@::filter (@I_TYPE@ input) +{ + unsigned int i; + + d_buffer[d_idx] = input; + d_buffer[d_idx+ntaps()] = input; + + // using the later for the case when ntaps=0; + // profiling shows this doesn't make a difference + //d_idx = (d_idx + 1) % ntaps(); + d_idx++; + if(d_idx >= ntaps()) + d_idx = 0; + + @ACC_TYPE@ out = 0; + for(i = 0; i < ntaps(); i++) { + out += @INPUT_CAST@ d_buffer[d_idx + i] * d_taps[i]; + } + return (@O_TYPE@)out; +} + +@O_TYPE@ +@NAME@::filter (const @I_TYPE@ input[], unsigned long dec) +{ + unsigned int i; + + for(i = 0; i < dec; i++) { + d_buffer[d_idx] = input[i]; + d_buffer[d_idx+ntaps()] = input[i]; + d_idx++; + if(d_idx >= ntaps()) + d_idx = 0; + } + + @ACC_TYPE@ out = 0; + for(i = 0; i < ntaps(); i++) { + out += @INPUT_CAST@ d_buffer[d_idx + i] * d_taps[i]; + } + return (@O_TYPE@)out; +} + +void +@NAME@::filterN (@O_TYPE@ output[], + const @I_TYPE@ input[], + unsigned long n) +{ + for(unsigned long i = 0; i < n; i++) { + output[i] = filter(input[i]); + } +} + +void +@NAME@::filterNdec (@O_TYPE@ output[], + const @I_TYPE@ input[], + unsigned long n, + unsigned long decimate) +{ + unsigned long j = 0; + for(unsigned long i = 0; i < n; i++) { + output[i] = filter(&input[j], decimate); + j += decimate; + } +} diff --git a/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.h.t b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.h.t new file mode 100644 index 00000000..23d64b65 --- /dev/null +++ b/gnuradio-core/src/lib/filter/gri_fir_filter_with_buffer_XXX.h.t @@ -0,0 +1,131 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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. + */ + +/* + * WARNING: This file is automatically generated by generate_gri_fir_XXX.py + * Any changes made to this file will be overwritten. + */ + + +#ifndef @GUARD_NAME@ +#define @GUARD_NAME@ + +#include +#include +#include +#include +#include + +/*! + * \brief FIR with internal buffer for @I_TYPE@ input, + @O_TYPE@ output and @TAP_TYPE@ taps + * \ingroup filter + * + */ + +class @NAME@ { + +protected: + std::vector<@TAP_TYPE@> d_taps; // reversed taps + @I_TYPE@ *d_buffer; + unsigned int d_idx; + +public: + + // CONSTRUCTORS + + /*! + * \brief construct new FIR with given taps. + * + * Note that taps must be in forward order, e.g., coefficient 0 is + * stored in new_taps[0], coefficient 1 is stored in + * new_taps[1], etc. + */ + @NAME@ (const std::vector<@TAP_TYPE@> &taps); + + ~@NAME@ (); + + // MANIPULATORS + + /*! + * \brief compute a single output value. + * + * \p input is a single input value of the filter type + * + * \returns the filtered input value. + */ + @O_TYPE@ filter (@I_TYPE@ input); + + + /*! + * \brief compute a single output value; designed for decimating filters. + * + * \p input is a single input value of the filter type. The value of dec is the + * decimating value of the filter, so input[] must have dec valid values. + * The filter pushes dec number of items onto the circ. buffer before computing + * a single output. + * + * \returns the filtered input value. + */ + @O_TYPE@ filter (const @I_TYPE@ input[], unsigned long dec); + + /*! + * \brief compute an array of N output values. + * + * \p input must have (n - 1 + ntaps()) valid entries. + * input[0] .. input[n - 1 + ntaps() - 1] are referenced to compute the output values. + */ + void filterN (@O_TYPE@ output[], const @I_TYPE@ input[], + unsigned long n); + + /*! + * \brief compute an array of N output values, decimating the input + * + * \p input must have (decimate * (n - 1) + ntaps()) valid entries. + * input[0] .. input[decimate * (n - 1) + ntaps() - 1] are referenced to + * compute the output values. + */ + void filterNdec (@O_TYPE@ output[], const @I_TYPE@ input[], + unsigned long n, unsigned long decimate); + + /*! + * \brief install \p new_taps as the current taps. + */ + void set_taps (const std::vector<@TAP_TYPE@> &taps); + + // ACCESSORS + + /*! + * \return number of taps in filter. + */ + unsigned ntaps () const { return d_taps.size (); } + + /*! + * \return current taps + */ + const std::vector<@TAP_TYPE@> get_taps () const + { + return gr_reverse(d_taps); + } +}; + +#endif /* @GUARD_NAME@ */ diff --git a/gnuradio-core/src/lib/filter/qa_filter.cc b/gnuradio-core/src/lib/filter/qa_filter.cc index 878d4802..0d03cb0e 100644 --- a/gnuradio-core/src/lib/filter/qa_filter.cc +++ b/gnuradio-core/src/lib/filter/qa_filter.cc @@ -36,6 +36,12 @@ #include #include #include +#include +#include +#include +#include +#include +#include CppUnit::TestSuite * qa_filter::suite () @@ -51,6 +57,12 @@ qa_filter::suite () s->addTest (qa_gri_mmse_fir_interpolator::suite ()); s->addTest (qa_gri_mmse_fir_interpolator_cc::suite ()); s->addTest (qa_gr_rotator::suite ()); + s->addTest (qa_gri_fir_filter_with_buffer_ccf::suite ()); + s->addTest (qa_gri_fir_filter_with_buffer_ccc::suite ()); + s->addTest (qa_gri_fir_filter_with_buffer_fcc::suite ()); + s->addTest (qa_gri_fir_filter_with_buffer_fff::suite ()); + s->addTest (qa_gri_fir_filter_with_buffer_fsf::suite ()); + s->addTest (qa_gri_fir_filter_with_buffer_scc::suite ()); return s; } diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.cc new file mode 100644 index 00000000..e87d93eb --- /dev/null +++ b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.cc @@ -0,0 +1,160 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef gr_complex i_type; +typedef gr_complex o_type; +typedef gr_complex tap_type; +typedef gr_complex acc_type; + +using std::vector; + +#define ERR_DELTA (1e-5) + +#define NELEM(x) (sizeof (x) / sizeof (x[0])) + +static float +uniform () +{ + return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) +} + +static void +random_complex (gr_complex *buf, unsigned n) +{ + for (unsigned i = 0; i < n; i++){ + float re = rint (uniform () * 32767); + float im = rint (uniform () * 32767); + buf[i] = gr_complex (re, im); + } +} + +static o_type +ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) +{ + acc_type sum = 0; + for (int i = 0; i < ntaps; i++) { + sum += input[i] * taps[i]; + } + + return sum; +} + +void +qa_gri_fir_filter_with_buffer_ccc::t1 () +{ + test_decimate(1); +} + +void +qa_gri_fir_filter_with_buffer_ccc::t2 () +{ + test_decimate(2); +} + +void +qa_gri_fir_filter_with_buffer_ccc::t3 () +{ + test_decimate(5); +} + +// +// Test for ntaps in [0,9], and input lengths in [0,17]. +// This ensures that we are building the shifted taps correctly, +// and exercises all corner cases on input alignment and length. +// +void +qa_gri_fir_filter_with_buffer_ccc::test_decimate(unsigned int decimate) +{ + const int MAX_TAPS = 9; + const int OUTPUT_LEN = 17; + const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; + + // Mem aligned buffer not really necessary, but why not? + i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); + i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); + o_type expected_output[OUTPUT_LEN]; + o_type actual_output[OUTPUT_LEN]; + tap_type taps[MAX_TAPS]; + + srandom (0); // we want reproducibility + memset(dline, 0, INPUT_LEN*sizeof(i_type)); + + for (int n = 0; n <= MAX_TAPS; n++){ + for (int ol = 0; ol <= OUTPUT_LEN; ol++){ + + // cerr << "@@@ n:ol " << n << ":" << ol << endl; + + // build random test case + random_complex (input, INPUT_LEN); + random_complex (taps, MAX_TAPS); + + // compute expected output values + memset(dline, 0, INPUT_LEN*sizeof(i_type)); + for (int o = 0; o < (int)(ol/decimate); o++){ + // use an actual delay line for this test + for(int dd = 0; dd < (int)decimate; dd++) { + for(int oo = INPUT_LEN-1; oo > 0; oo--) + dline[oo] = dline[oo-1]; + dline[0] = input[decimate*o+dd]; + } + expected_output[o] = ref_dotprod (dline, taps, n); + } + + // build filter + vector f1_taps(&taps[0], &taps[n]); + gri_fir_filter_with_buffer_ccc *f1 = new gri_fir_filter_with_buffer_ccc(f1_taps); + + // zero the output, then do the filtering + memset (actual_output, 0, sizeof (actual_output)); + f1->filterNdec (actual_output, input, ol/decimate, decimate); + + // check results + // + // we use a sloppy error margin because on the x86 architecture, + // our reference implementation is using 80 bit floating point + // arithmetic, while the SSE version is using 32 bit float point + // arithmetic. + + for (int o = 0; o < (int)(ol/decimate); o++){ + CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], actual_output[o], + abs (expected_output[o]) * ERR_DELTA); + } + delete f1; + } + } + free16Align(input); +} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.h new file mode 100644 index 00000000..f9f206f6 --- /dev/null +++ b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccc.h @@ -0,0 +1,46 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 _QA_GRI_FIR_FILTER_WITH_BUFFER_CCC_H_ +#define _QA_GRI_FIR_FILTER_WITH_BUFFER_CCC_H_ + +#include +#include + +class qa_gri_fir_filter_with_buffer_ccc : public CppUnit::TestCase { + + CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_ccc); + CPPUNIT_TEST (t1); + CPPUNIT_TEST (t2); + CPPUNIT_TEST (t3); + CPPUNIT_TEST_SUITE_END (); + + private: + void test_decimate(unsigned int decimate); + + void t1 (); + void t2 (); + void t3 (); + +}; + + +#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_CCC_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.cc new file mode 100644 index 00000000..c25853b1 --- /dev/null +++ b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.cc @@ -0,0 +1,167 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef gr_complex i_type; +typedef gr_complex o_type; +typedef float tap_type; +typedef gr_complex acc_type; + +using std::vector; + +#define ERR_DELTA (1e-5) + +#define NELEM(x) (sizeof (x) / sizeof (x[0])) + +static float +uniform () +{ + return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) +} + +static void +random_floats (float *buf, unsigned n) +{ + for (unsigned i = 0; i < n; i++) + buf[i] = (float) rint (uniform () * 32767); +} + +static void +random_complex (gr_complex *buf, unsigned n) +{ + for (unsigned i = 0; i < n; i++){ + float re = rint (uniform () * 32767); + float im = rint (uniform () * 32767); + buf[i] = gr_complex (re, im); + } +} + +static o_type +ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) +{ + acc_type sum = 0; + for (int i = 0; i < ntaps; i++) { + sum += input[i] * taps[i]; + } + + return sum; +} + +void +qa_gri_fir_filter_with_buffer_ccf::t1 () +{ + test_decimate(1); +} + +void +qa_gri_fir_filter_with_buffer_ccf::t2 () +{ + test_decimate(2); +} + +void +qa_gri_fir_filter_with_buffer_ccf::t3 () +{ + test_decimate(5); +} + +// +// Test for ntaps in [0,9], and input lengths in [0,17]. +// This ensures that we are building the shifted taps correctly, +// and exercises all corner cases on input alignment and length. +// +void +qa_gri_fir_filter_with_buffer_ccf::test_decimate (unsigned int decimate) +{ + const int MAX_TAPS = 9; + const int OUTPUT_LEN = 17; + const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; + + // Mem aligned buffer not really necessary, but why not? + i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); + i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); + o_type expected_output[OUTPUT_LEN]; + o_type actual_output[OUTPUT_LEN]; + tap_type taps[MAX_TAPS]; + + srandom (0); // we want reproducibility + memset(dline, 0, INPUT_LEN*sizeof(i_type)); + + for (int n = 0; n <= MAX_TAPS; n++){ + for (int ol = 0; ol <= OUTPUT_LEN; ol++){ + + // cerr << "@@@ n:ol " << n << ":" << ol << endl; + + // build random test case + random_complex (input, INPUT_LEN); + random_floats (taps, MAX_TAPS); + + // compute expected output values + memset(dline, 0, INPUT_LEN*sizeof(i_type)); + for (int o = 0; o < (int)(ol/decimate); o++){ + // use an actual delay line for this test + for(int dd = 0; dd < (int)decimate; dd++) { + for(int oo = INPUT_LEN-1; oo > 0; oo--) + dline[oo] = dline[oo-1]; + dline[0] = input[decimate*o+dd]; + } + expected_output[o] = ref_dotprod (dline, taps, n); + } + + // build filter + vector f1_taps(&taps[0], &taps[n]); + gri_fir_filter_with_buffer_ccf *f1 = new gri_fir_filter_with_buffer_ccf(f1_taps); + + // zero the output, then do the filtering + memset (actual_output, 0, sizeof (actual_output)); + f1->filterNdec (actual_output, input, ol/decimate, decimate); + + // check results + // + // we use a sloppy error margin because on the x86 architecture, + // our reference implementation is using 80 bit floating point + // arithmetic, while the SSE version is using 32 bit float point + // arithmetic. + + for (int o = 0; o < (int)(ol/decimate); o++){ + CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], actual_output[o], + abs (expected_output[o]) * ERR_DELTA); + } + delete f1; + } + } + free16Align(input); +} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.h new file mode 100644 index 00000000..924b4bc2 --- /dev/null +++ b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_ccf.h @@ -0,0 +1,46 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 _QA_GRI_FIR_FILTER_WITH_BUFFER_CCF_H_ +#define _QA_GRI_FIR_FILTER_WITH_BUFFER_CCF_H_ + +#include +#include + +class qa_gri_fir_filter_with_buffer_ccf : public CppUnit::TestCase { + + CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_ccf); + CPPUNIT_TEST (t1); + CPPUNIT_TEST (t2); + CPPUNIT_TEST (t3); + CPPUNIT_TEST_SUITE_END (); + + private: + void test_decimate(unsigned int decimate); + + void t1 (); + void t2 (); + void t3 (); + +}; + + +#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_CCF_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.cc new file mode 100644 index 00000000..19f27020 --- /dev/null +++ b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.cc @@ -0,0 +1,168 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef float i_type; +typedef gr_complex o_type; +typedef gr_complex tap_type; +typedef gr_complex acc_type; + +using std::vector; + +#define ERR_DELTA (1e-5) + +#define NELEM(x) (sizeof (x) / sizeof (x[0])) + +static float +uniform () +{ + return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) +} + +static void +random_floats (float *buf, unsigned n) +{ + for (unsigned i = 0; i < n; i++) + buf[i] = (float) rint (uniform () * 32767); +} + +static void +random_complex (gr_complex *buf, unsigned n) +{ + for (unsigned i = 0; i < n; i++){ + float re = rint (uniform () * 32767); + float im = rint (uniform () * 32767); + buf[i] = gr_complex (re, im); + } +} + +static o_type +ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) +{ + acc_type sum = 0; + for (int i = 0; i < ntaps; i++) { + sum += input[i] * taps[i]; + } + + return sum; +} + +void +qa_gri_fir_filter_with_buffer_fcc::t1() +{ + test_decimate(1); +} + +void +qa_gri_fir_filter_with_buffer_fcc::t2() +{ + test_decimate(2); +} + +void +qa_gri_fir_filter_with_buffer_fcc::t3() +{ + test_decimate(5); +} + + +// +// Test for ntaps in [0,9], and input lengths in [0,17]. +// This ensures that we are building the shifted taps correctly, +// and exercises all corner cases on input alignment and length. +// +void +qa_gri_fir_filter_with_buffer_fcc::test_decimate(unsigned int decimate) +{ + const int MAX_TAPS = 9; + const int OUTPUT_LEN = 17; + const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; + + // Mem aligned buffer not really necessary, but why not? + i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); + i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); + o_type expected_output[OUTPUT_LEN]; + o_type actual_output[OUTPUT_LEN]; + tap_type taps[MAX_TAPS]; + + srandom (0); // we want reproducibility + memset(dline, 0, INPUT_LEN*sizeof(i_type)); + + for (int n = 0; n <= MAX_TAPS; n++){ + for (int ol = 0; ol <= OUTPUT_LEN; ol++){ + + // cerr << "@@@ n:ol " << n << ":" << ol << endl; + + // build random test case + random_floats (input, INPUT_LEN); + random_complex (taps, MAX_TAPS); + + // compute expected output values + memset(dline, 0, INPUT_LEN*sizeof(i_type)); + for (int o = 0; o < (int)(ol/decimate); o++){ + // use an actual delay line for this test + for(int dd = 0; dd < (int)decimate; dd++) { + for(int oo = INPUT_LEN-1; oo > 0; oo--) + dline[oo] = dline[oo-1]; + dline[0] = input[decimate*o+dd]; + } + expected_output[o] = ref_dotprod (dline, taps, n); + } + + // build filter + vector f1_taps(&taps[0], &taps[n]); + gri_fir_filter_with_buffer_fcc *f1 = new gri_fir_filter_with_buffer_fcc(f1_taps); + + // zero the output, then do the filtering + memset (actual_output, 0, sizeof (actual_output)); + f1->filterNdec (actual_output, input, ol/decimate, decimate); + + // check results + // + // we use a sloppy error margin because on the x86 architecture, + // our reference implementation is using 80 bit floating point + // arithmetic, while the SSE version is using 32 bit float point + // arithmetic. + + for (int o = 0; o < (int)(ol/decimate); o++){ + CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], actual_output[o], + abs (expected_output[o]) * ERR_DELTA); + } + delete f1; + } + } + free16Align(input); +} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.h new file mode 100644 index 00000000..6201800f --- /dev/null +++ b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fcc.h @@ -0,0 +1,46 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 _QA_GRI_FIR_FILTER_WITH_BUFFER_FCC_H_ +#define _QA_GRI_FIR_FILTER_WITH_BUFFER_FCC_H_ + +#include +#include + +class qa_gri_fir_filter_with_buffer_fcc : public CppUnit::TestCase { + + CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_fcc); + CPPUNIT_TEST (t1); + CPPUNIT_TEST (t2); + CPPUNIT_TEST (t3); + CPPUNIT_TEST_SUITE_END (); + + private: + void test_decimate(unsigned int decimate); + + void t1 (); + void t2 (); + void t3 (); + +}; + + +#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_FCC_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.cc new file mode 100644 index 00000000..8401e484 --- /dev/null +++ b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.cc @@ -0,0 +1,156 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef float i_type; +typedef float o_type; +typedef float tap_type; +typedef float acc_type; + +using std::vector; + +#define ERR_DELTA (1e-5) + +#define NELEM(x) (sizeof (x) / sizeof (x[0])) + +static float +uniform () +{ + return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) +} + +static void +random_floats (float *buf, unsigned n) +{ + for (unsigned i = 0; i < n; i++) + buf[i] = (float) rint (uniform () * 32767); +} + +static o_type +ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) +{ + acc_type sum = 0; + for (int i = 0; i < ntaps; i++) { + sum += input[i] * taps[i]; + } + return sum; +} + +void +qa_gri_fir_filter_with_buffer_fff::t1 () +{ + test_decimate(1); +} + +void +qa_gri_fir_filter_with_buffer_fff::t2 () +{ + test_decimate(2); +} + +void +qa_gri_fir_filter_with_buffer_fff::t3 () +{ + test_decimate(5); +} + +// +// Test for ntaps in [0,9], and input lengths in [0,17]. +// This ensures that we are building the shifted taps correctly, +// and exercises all corner cases on input alignment and length. +// +void +qa_gri_fir_filter_with_buffer_fff::test_decimate(unsigned int decimate) +{ + const int MAX_TAPS = 9; + const int OUTPUT_LEN = 17; + const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; + + // Mem aligned buffer not really necessary, but why not? + i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); + i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); + o_type expected_output[OUTPUT_LEN]; + o_type actual_output[OUTPUT_LEN]; + tap_type taps[MAX_TAPS]; + + srandom (0); // we want reproducibility + memset(dline, 0, INPUT_LEN*sizeof(i_type)); + + for (int n = 0; n <= MAX_TAPS; n++){ + for (int ol = 0; ol <= OUTPUT_LEN; ol++){ + + // cerr << "@@@ n:ol " << n << ":" << ol << endl; + + // build random test case + random_floats (input, INPUT_LEN); + random_floats (taps, MAX_TAPS); + + // compute expected output values + memset(dline, 0, INPUT_LEN*sizeof(i_type)); + for (int o = 0; o < (int)(ol/decimate); o++){ + // use an actual delay line for this test + for(int dd = 0; dd < (int)decimate; dd++) { + for(int oo = INPUT_LEN-1; oo > 0; oo--) + dline[oo] = dline[oo-1]; + dline[0] = input[decimate*o+dd]; + } + expected_output[o] = ref_dotprod (dline, taps, n); + } + + // build filter + vector f1_taps(&taps[0], &taps[n]); + gri_fir_filter_with_buffer_fff *f1 = new gri_fir_filter_with_buffer_fff(f1_taps); + + // zero the output, then do the filtering + memset (actual_output, 0, sizeof (actual_output)); + f1->filterNdec (actual_output, input, ol/decimate, decimate); + + // check results + // + // we use a sloppy error margin because on the x86 architecture, + // our reference implementation is using 80 bit floating point + // arithmetic, while the SSE version is using 32 bit float point + // arithmetic. + + for (int o = 0; o < (int)(ol/decimate); o++){ + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected_output[o], actual_output[o], + fabsf (expected_output[o]) * ERR_DELTA); + } + delete f1; + } + } + free16Align(input); +} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.h new file mode 100644 index 00000000..54a9cdc5 --- /dev/null +++ b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fff.h @@ -0,0 +1,46 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 _QA_GRI_FIR_FILTER_WITH_BUFFER_FFF_H_ +#define _QA_GRI_FIR_FILTER_WITH_BUFFER_FFF_H_ + +#include +#include + +class qa_gri_fir_filter_with_buffer_fff : public CppUnit::TestCase { + + CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_fff); + CPPUNIT_TEST (t1); + CPPUNIT_TEST (t2); + CPPUNIT_TEST (t3); + CPPUNIT_TEST_SUITE_END (); + + private: + void test_decimate(unsigned int decimate); + + void t1 (); + void t2 (); + void t3 (); + +}; + + +#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_FFF_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.cc new file mode 100644 index 00000000..09150538 --- /dev/null +++ b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.cc @@ -0,0 +1,147 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef float i_type; +typedef short o_type; +typedef float tap_type; +typedef float acc_type; + +using std::vector; + +#define NELEM(x) (sizeof (x) / sizeof (x[0])) + +static float +uniform () +{ + return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) +} + +static void +random_floats (float *buf, unsigned n) +{ + for (unsigned i = 0; i < n; i++) + buf[i] = (float) rint (uniform () * 128); +} + +static o_type +ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) +{ + acc_type sum = 0; + for (int i = 0; i < ntaps; i++) { + sum += input[i] * taps[i]; + } + return (o_type)sum; +} + +void +qa_gri_fir_filter_with_buffer_fsf::t1 () +{ + test_decimate(1); +} + +void +qa_gri_fir_filter_with_buffer_fsf::t2 () +{ + test_decimate(2); +} + +void +qa_gri_fir_filter_with_buffer_fsf::t3 () +{ + test_decimate(5); +} + +// +// Test for ntaps in [0,9], and input lengths in [0,17]. +// This ensures that we are building the shifted taps correctly, +// and exercises all corner cases on input alignment and length. +// +void +qa_gri_fir_filter_with_buffer_fsf::test_decimate (unsigned int decimate) +{ + const int MAX_TAPS = 9; + const int OUTPUT_LEN = 17; + const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; + + // Mem aligned buffer not really necessary, but why not? + i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); + i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); + o_type expected_output[OUTPUT_LEN]; + o_type actual_output[OUTPUT_LEN]; + tap_type taps[MAX_TAPS]; + + srandom (0); // we want reproducibility + memset(dline, 0, INPUT_LEN*sizeof(i_type)); + + for (int n = 0; n <= MAX_TAPS; n++){ + for (int ol = 0; ol <= OUTPUT_LEN; ol++){ + + // cerr << "@@@ n:ol " << n << ":" << ol << endl; + + // build random test case + random_floats (input, INPUT_LEN); + random_floats (taps, MAX_TAPS); + + // compute expected output values + memset(dline, 0, INPUT_LEN*sizeof(i_type)); + for (int o = 0; o < (int)(ol/decimate); o++){ + // use an actual delay line for this test + for(int dd = 0; dd < (int)decimate; dd++) { + for(int oo = INPUT_LEN-1; oo > 0; oo--) + dline[oo] = dline[oo-1]; + dline[0] = input[decimate*o+dd]; + } + expected_output[o] = ref_dotprod (dline, taps, n); + } + + // build filter + vector f1_taps(&taps[0], &taps[n]); + gri_fir_filter_with_buffer_fsf *f1 = new gri_fir_filter_with_buffer_fsf(f1_taps); + + // zero the output, then do the filtering + memset (actual_output, 0, sizeof (actual_output)); + f1->filterNdec (actual_output, input, ol/decimate, decimate); + + // check results + for (int o = 0; o < (int)(ol/decimate); o++){ + CPPUNIT_ASSERT_EQUAL(expected_output[o], actual_output[o]); + } + delete f1; + } + } + free16Align(input); +} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.h new file mode 100644 index 00000000..9c901464 --- /dev/null +++ b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_fsf.h @@ -0,0 +1,46 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 _QA_GRI_FIR_FILTER_WITH_BUFFER_FSF_H_ +#define _QA_GRI_FIR_FILTER_WITH_BUFFER_FSF_H_ + +#include +#include + +class qa_gri_fir_filter_with_buffer_fsf : public CppUnit::TestCase { + + CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_fsf); + CPPUNIT_TEST (t1); + CPPUNIT_TEST (t2); + CPPUNIT_TEST (t3); + CPPUNIT_TEST_SUITE_END (); + + private: + void test_decimate(unsigned int decimate); + + void t1 (); + void t2 (); + void t3 (); + +}; + + +#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_FSF_H_ */ diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.cc b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.cc new file mode 100644 index 00000000..03cd7102 --- /dev/null +++ b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.cc @@ -0,0 +1,167 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 +#endif + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +typedef short i_type; +typedef gr_complex o_type; +typedef gr_complex tap_type; +typedef gr_complex acc_type; + +using std::vector; + +#define ERR_DELTA (1e-5) + +#define NELEM(x) (sizeof (x) / sizeof (x[0])) + +static float +uniform () +{ + return 2.0 * ((float) random () / RANDOM_MAX - 0.5); // uniformly (-1, 1) +} + +static void +random_shorts (short *buf, unsigned n) +{ + for (unsigned i = 0; i < n; i++) + buf[i] = (short) rint (uniform () * 16384); +} + +static void +random_complex (gr_complex *buf, unsigned n) +{ + for (unsigned i = 0; i < n; i++){ + float re = rint (uniform () * 32767); + float im = rint (uniform () * 32767); + buf[i] = gr_complex (re, im); + } +} + +static o_type +ref_dotprod (const i_type input[], const tap_type taps[], int ntaps) +{ + acc_type sum = 0; + for (int i = 0; i < ntaps; i++) { + sum += (float)input[i] * taps[i]; + } + + return sum; +} + +void +qa_gri_fir_filter_with_buffer_scc::t1 () +{ + test_decimate(1); +} + +void +qa_gri_fir_filter_with_buffer_scc::t2 () +{ + test_decimate(2); +} + +void +qa_gri_fir_filter_with_buffer_scc::t3 () +{ + test_decimate(5); +} + +// +// Test for ntaps in [0,9], and input lengths in [0,17]. +// This ensures that we are building the shifted taps correctly, +// and exercises all corner cases on input alignment and length. +// +void +qa_gri_fir_filter_with_buffer_scc::test_decimate (unsigned int decimate) +{ + const int MAX_TAPS = 9; + const int OUTPUT_LEN = 17; + const int INPUT_LEN = MAX_TAPS + OUTPUT_LEN; + + // Mem aligned buffer not really necessary, but why not? + i_type *input = (i_type *)malloc16Align(INPUT_LEN * sizeof(i_type)); + i_type *dline = (i_type*)malloc16Align(INPUT_LEN * sizeof(i_type)); + o_type expected_output[OUTPUT_LEN]; + o_type actual_output[OUTPUT_LEN]; + tap_type taps[MAX_TAPS]; + + srandom (0); // we want reproducibility + memset(dline, 0, INPUT_LEN*sizeof(i_type)); + + for (int n = 0; n <= MAX_TAPS; n++){ + for (int ol = 0; ol <= OUTPUT_LEN; ol++){ + + // cerr << "@@@ n:ol " << n << ":" << ol << endl; + + // build random test case + random_shorts (input, INPUT_LEN); + random_complex (taps, MAX_TAPS); + + // compute expected output values + memset(dline, 0, INPUT_LEN*sizeof(i_type)); + for (int o = 0; o < (int)(ol/decimate); o++){ + // use an actual delay line for this test + for(int dd = 0; dd < (int)decimate; dd++) { + for(int oo = INPUT_LEN-1; oo > 0; oo--) + dline[oo] = dline[oo-1]; + dline[0] = input[decimate*o+dd]; + } + expected_output[o] = ref_dotprod (dline, taps, n); + } + + // build filter + vector f1_taps(&taps[0], &taps[n]); + gri_fir_filter_with_buffer_scc *f1 = new gri_fir_filter_with_buffer_scc(f1_taps); + + // zero the output, then do the filtering + memset (actual_output, 0, sizeof (actual_output)); + f1->filterNdec (actual_output, input, ol/decimate, decimate); + + // check results + // + // we use a sloppy error margin because on the x86 architecture, + // our reference implementation is using 80 bit floating point + // arithmetic, while the SSE version is using 32 bit float point + // arithmetic. + + for (int o = 0; o < (int)(ol/decimate); o++){ + CPPUNIT_ASSERT_COMPLEXES_EQUAL(expected_output[o], actual_output[o], + abs (expected_output[o]) * ERR_DELTA); + } + delete f1; + } + } + free16Align(input); +} diff --git a/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.h b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.h new file mode 100644 index 00000000..970ca374 --- /dev/null +++ b/gnuradio-core/src/lib/filter/qa_gri_fir_filter_with_buffer_scc.h @@ -0,0 +1,46 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 _QA_GRI_FIR_FILTER_WITH_BUFFER_SCC_H_ +#define _QA_GRI_FIR_FILTER_WITH_BUFFER_SCC_H_ + +#include +#include + +class qa_gri_fir_filter_with_buffer_scc : public CppUnit::TestCase { + + CPPUNIT_TEST_SUITE (qa_gri_fir_filter_with_buffer_scc); + CPPUNIT_TEST (t1); + CPPUNIT_TEST (t2); + CPPUNIT_TEST (t3); + CPPUNIT_TEST_SUITE_END (); + + private: + void test_decimate(unsigned int decimate); + + void t1 (); + void t2 (); + void t3 (); + +}; + + +#endif /* _QA_GR_FIR_FILTER_WITH_BUFFER_SCC_H_ */ diff --git a/gnuradio-core/src/lib/general/gr_circular_file.cc b/gnuradio-core/src/lib/general/gr_circular_file.cc index 468b49a1..c9222597 100644 --- a/gnuradio-core/src/lib/general/gr_circular_file.cc +++ b/gnuradio-core/src/lib/general/gr_circular_file.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -66,7 +66,10 @@ gr_circular_file::gr_circular_file (const char *filename, exit (1); } #ifdef HAVE_MMAP /* FIXME */ - ftruncate (d_fd, size + HEADER_SIZE); + if(ftruncate (d_fd, size + HEADER_SIZE) != 0) { + perror (filename); + exit (1); + } #endif } else { diff --git a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc b/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc index ff997e7a..c32398e6 100644 --- a/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc +++ b/gnuradio-core/src/lib/general/gr_fll_band_edge_cc.cc @@ -161,8 +161,9 @@ gr_fll_band_edge_cc::work (int noutput_items, const gr_complex *in = (const gr_complex *) input_items[0]; gr_complex *out = (gr_complex *) output_items[0]; - float *frq, *phs; - gr_complex *err; + float *frq = NULL; + float *phs = NULL; + gr_complex *err = NULL; if(output_items.size() > 2) { frq = (float *) output_items[1]; phs = (float *) output_items[2]; diff --git a/gnuradio-core/src/lib/general/gr_float_to_complex.cc b/gnuradio-core/src/lib/general/gr_float_to_complex.cc index 89ef1886..a392abd0 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_complex.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_complex.cc @@ -52,12 +52,12 @@ gr_float_to_complex::work (int noutput_items, switch (input_items.size ()){ case 1: - for (int j = 0; j < noutput_items*d_vlen; j++) + for (size_t j = 0; j < noutput_items*d_vlen; j++) out[j] = gr_complex (r[j], 0); break; case 2: - for (int j = 0; j < noutput_items*d_vlen; j++) + for (size_t j = 0; j < noutput_items*d_vlen; j++) out[j] = gr_complex (r[j], i[j]); break; diff --git a/gnuradio-core/src/lib/general/gr_skiphead.cc b/gnuradio-core/src/lib/general/gr_skiphead.cc index ea7e9405..1670eb7c 100644 --- a/gnuradio-core/src/lib/general/gr_skiphead.cc +++ b/gnuradio-core/src/lib/general/gr_skiphead.cc @@ -27,7 +27,7 @@ #include #include -gr_skiphead::gr_skiphead (size_t itemsize, size_t nitems_to_skip) +gr_skiphead::gr_skiphead (size_t itemsize, uint64_t nitems_to_skip) : gr_block ("skiphead", gr_make_io_signature(1, 1, itemsize), gr_make_io_signature(1, 1, itemsize)), @@ -36,7 +36,7 @@ gr_skiphead::gr_skiphead (size_t itemsize, size_t nitems_to_skip) } gr_skiphead_sptr -gr_make_skiphead (size_t itemsize, size_t nitems_to_skip) +gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip) { return gnuradio::get_initial_sptr(new gr_skiphead (itemsize, nitems_to_skip)); } @@ -55,11 +55,11 @@ gr_skiphead::general_work(int noutput_items, while (ii < ninput_items){ - long long ni_total = ii + d_nitems; // total items processed so far + uint64_t ni_total = ii + d_nitems; // total items processed so far if (ni_total < d_nitems_to_skip){ // need to skip some more int n_to_skip = (int) std::min(d_nitems_to_skip - ni_total, - (long long)(ninput_items - ii)); + (uint64_t)(ninput_items - ii)); ii += n_to_skip; } diff --git a/gnuradio-core/src/lib/general/gr_skiphead.h b/gnuradio-core/src/lib/general/gr_skiphead.h index 965feff9..933c126e 100644 --- a/gnuradio-core/src/lib/general/gr_skiphead.h +++ b/gnuradio-core/src/lib/general/gr_skiphead.h @@ -39,11 +39,11 @@ typedef boost::shared_ptr gr_skiphead_sptr; class gr_skiphead : public gr_block { - friend gr_skiphead_sptr gr_make_skiphead (size_t itemsize, size_t nitems_to_skip); - gr_skiphead (size_t itemsize, size_t nitems_to_skip); + friend gr_skiphead_sptr gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); + gr_skiphead (size_t itemsize, uint64_t nitems_to_skip); - long long d_nitems_to_skip; - long long d_nitems; // total items seen + uint64_t d_nitems_to_skip; + uint64_t d_nitems; // total items seen public: @@ -54,7 +54,7 @@ class gr_skiphead : public gr_block }; gr_skiphead_sptr -gr_make_skiphead (size_t itemsize, size_t nitems_to_skip); +gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); #endif /* INCLUDED_GR_SKIPHEAD_H */ diff --git a/gnuradio-core/src/lib/general/gr_skiphead.i b/gnuradio-core/src/lib/general/gr_skiphead.i index 52c0808f..45cbd043 100644 --- a/gnuradio-core/src/lib/general/gr_skiphead.i +++ b/gnuradio-core/src/lib/general/gr_skiphead.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005,2007 Free Software Foundation, Inc. + * Copyright 2005,2007,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -22,9 +22,9 @@ GR_SWIG_BLOCK_MAGIC(gr,skiphead); -gr_skiphead_sptr gr_make_skiphead (size_t itemsize, size_t nitems_to_skip); +gr_skiphead_sptr gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); class gr_skiphead : public gr_block { - friend gr_skiphead_sptr gr_make_skiphead (size_t itemsize, size_t nitems_to_skip); - gr_skiphead (size_t itemsize, size_t nitems_to_skip); + friend gr_skiphead_sptr gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip); + gr_skiphead (size_t itemsize, uint64_t nitems_to_skip); }; diff --git a/gnuradio-core/src/lib/general/gri_agc2_cc.i b/gnuradio-core/src/lib/general/gri_agc2_cc.i index e7d6da97..0f97f1d8 100644 --- a/gnuradio-core/src/lib/general/gri_agc2_cc.i +++ b/gnuradio-core/src/lib/general/gri_agc2_cc.i @@ -39,4 +39,9 @@ class gri_agc2_cc { float reference (); float gain (); float max_gain (); + void set_decay_rate (float rate); + void set_attack_rate (float rate); + void set_reference (float reference); + void set_gain (float gain); + void set_max_gain(float max_gain); }; diff --git a/gnuradio-core/src/lib/general/gri_agc2_ff.i b/gnuradio-core/src/lib/general/gri_agc2_ff.i index 3825ce22..d04b638a 100644 --- a/gnuradio-core/src/lib/general/gri_agc2_ff.i +++ b/gnuradio-core/src/lib/general/gri_agc2_ff.i @@ -34,4 +34,14 @@ class gri_agc2_ff { public: gri_agc2_ff (float attack_rate = 1e-1, float decay_rate = 1e-2, float reference = 1.0, float gain = 1.0, float max_gain = 0.0); + float attack_rate (); + float decay_rate (); + float reference (); + float gain (); + float max_gain (); + void set_attack_rate (float rate); + void set_decay_rate (float rate); + void set_reference (float reference); + void set_gain (float gain); + void set_max_gain (float max_gain); }; diff --git a/gnuradio-core/src/lib/gengen/gr_add_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_add_XX.cc.t index 58a25325..0e8b23ee 100644 --- a/gnuradio-core/src/lib/gengen/gr_add_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_add_XX.cc.t @@ -52,7 +52,7 @@ int int ninputs = input_items.size (); - for (int i = 0; i < noutput_items*d_vlen; i++){ + for (size_t i = 0; i < noutput_items*d_vlen; i++){ @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; for (int j = 1; j < ninputs; j++) acc += ((@I_TYPE@ *) input_items[j])[i]; diff --git a/gnuradio-core/src/lib/gengen/gr_divide_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_divide_XX.cc.t index 1200145f..ea245b57 100644 --- a/gnuradio-core/src/lib/gengen/gr_divide_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_divide_XX.cc.t @@ -53,13 +53,13 @@ int int ninputs = input_items.size (); if (ninputs == 1){ // compute reciprocal - for (int i = 0; i < noutput_items*d_vlen; i++) + for (size_t i = 0; i < noutput_items*d_vlen; i++) *optr++ = (@O_TYPE@) ((@O_TYPE@) 1 / ((@I_TYPE@ *) input_items[0])[i]); } else { - for (int i = 0; i < noutput_items*d_vlen; i++){ + for (size_t i = 0; i < noutput_items*d_vlen; i++){ @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; for (int j = 1; j < ninputs; j++) acc /= ((@I_TYPE@ *) input_items[j])[i]; diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_multiply_XX.cc.t index 13ec0c8b..5d270c76 100644 --- a/gnuradio-core/src/lib/gengen/gr_multiply_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_multiply_XX.cc.t @@ -52,7 +52,7 @@ int int ninputs = input_items.size (); - for (int i = 0; i < noutput_items*d_vlen; i++){ + for (size_t i = 0; i < noutput_items*d_vlen; i++){ @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; for (int j = 1; j < ninputs; j++) acc *= ((@I_TYPE@ *) input_items[j])[i]; diff --git a/gnuradio-core/src/lib/gengen/gr_sub_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_sub_XX.cc.t index f0ed7521..1dcdf81a 100644 --- a/gnuradio-core/src/lib/gengen/gr_sub_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_sub_XX.cc.t @@ -53,12 +53,12 @@ int int ninputs = input_items.size (); if (ninputs == 1){ // negate - for (int i = 0; i < noutput_items*d_vlen; i++) + for (size_t i = 0; i < noutput_items*d_vlen; i++) *optr++ = (@O_TYPE@) -((@I_TYPE@ *) input_items[0])[i]; } else { - for (int i = 0; i < noutput_items*d_vlen; i++){ + for (size_t i = 0; i < noutput_items*d_vlen; i++){ @I_TYPE@ acc = ((@I_TYPE@ *) input_items[0])[i]; for (int j = 1; j < ninputs; j++) acc -= ((@I_TYPE@ *) input_items[j])[i]; diff --git a/gnuradio-core/src/lib/io/gr_file_sink.cc b/gnuradio-core/src/lib/io/gr_file_sink.cc index 706837c7..aab0158e 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink.cc +++ b/gnuradio-core/src/lib/io/gr_file_sink.cc @@ -70,5 +70,8 @@ gr_file_sink::work (int noutput_items, nwritten += count; inbuf += count * d_itemsize; } + if (d_unbuffered) + fflush (d_fp); + return nwritten; } diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.cc b/gnuradio-core/src/lib/io/gr_file_sink_base.cc index 5ddeeb4d..c43304b0 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.cc +++ b/gnuradio-core/src/lib/io/gr_file_sink_base.cc @@ -118,3 +118,9 @@ gr_file_sink_base::do_update() d_updated = false; } } + +void +gr_file_sink_base::set_unbuffered(bool unbuffered) +{ + d_unbuffered = unbuffered; +} diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.h b/gnuradio-core/src/lib/io/gr_file_sink_base.h index 0c028d7f..7b96cdb7 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.h +++ b/gnuradio-core/src/lib/io/gr_file_sink_base.h @@ -37,6 +37,7 @@ class gr_file_sink_base bool d_updated; // is there a new FILE pointer? bool d_is_binary; boost::mutex d_mutex; + bool d_unbuffered; protected: gr_file_sink_base(const char *filename, bool is_binary); @@ -61,6 +62,12 @@ class gr_file_sink_base * \brief if we've had an update, do it now. */ void do_update(); + + + /*! + * \brief turn on unbuffered writes for slower outputs + */ + void set_unbuffered(bool unbuffered); }; diff --git a/gnuradio-core/src/lib/io/gr_file_sink_base.i b/gnuradio-core/src/lib/io/gr_file_sink_base.i index 05a3353b..ed434248 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink_base.i +++ b/gnuradio-core/src/lib/io/gr_file_sink_base.i @@ -43,4 +43,9 @@ class gr_file_sink_base * \brief if we've had an update, do it now. */ void do_update(); + + /*! + *\brief turn on unbuffered mode for slow outputs + */ + void set_unbuffered(bool unbuffered); }; diff --git a/gnuradio-core/src/lib/io/gr_oscope_guts.cc b/gnuradio-core/src/lib/io/gr_oscope_guts.cc index 80f78240..ce7feca1 100644 --- a/gnuradio-core/src/lib/io/gr_oscope_guts.cc +++ b/gnuradio-core/src/lib/io/gr_oscope_guts.cc @@ -104,34 +104,49 @@ gr_oscope_guts::process_sample (const float *channel_data) d_decimator_count = d_decimator_count_init; - for (int i = 0; i < d_nchannels; i++) - d_buffer[i][d_obi] = channel_data[i]; // copy data into buffer - - switch (d_state){ - case HOLD_OFF: - d_hold_off_count--; - if (d_hold_off_count <= 0) - enter_look_for_trigger (); - break; - - case LOOK_FOR_TRIGGER: - if (found_trigger ()) - enter_post_trigger (); - break; - - case POST_TRIGGER: - d_post_trigger_count--; - if (d_post_trigger_count <= 0){ - write_output_records (); - enter_hold_off (); - } - break; - - default: - assert (0); + if (d_trigger_mode != gr_TRIG_MODE_STRIPCHART) + { + for (int i = 0; i < d_nchannels; i++) + d_buffer[i][d_obi] = channel_data[i]; // copy data into buffer + + switch (d_state){ + case HOLD_OFF: + d_hold_off_count--; + if (d_hold_off_count <= 0) + enter_look_for_trigger (); + break; + + case LOOK_FOR_TRIGGER: + if (found_trigger ()) + enter_post_trigger (); + break; + + case POST_TRIGGER: + d_post_trigger_count--; + if (d_post_trigger_count <= 0){ + write_output_records (); + enter_hold_off (); + } + break; + + default: + assert (0); + } + + d_obi = incr_bi (d_obi); + } + else + { + for (int i = 0; i < d_nchannels; i++) + { + for (int j = OUTPUT_RECORD_SIZE-1; j >= 0; j--) + { + d_buffer[i][j] = d_buffer[i][j-1]; + } + d_buffer[i][0] = channel_data[i]; + } + write_output_records(); } - - d_obi = incr_bi (d_obi); } /* diff --git a/gnuradio-core/src/lib/io/gr_trigger_mode.h b/gnuradio-core/src/lib/io/gr_trigger_mode.h index 63f6b1c9..8e122285 100644 --- a/gnuradio-core/src/lib/io/gr_trigger_mode.h +++ b/gnuradio-core/src/lib/io/gr_trigger_mode.h @@ -27,6 +27,7 @@ enum gr_trigger_mode { gr_TRIG_MODE_FREE, gr_TRIG_MODE_AUTO, gr_TRIG_MODE_NORM, + gr_TRIG_MODE_STRIPCHART, }; enum gr_trigger_slope { diff --git a/gnuradio-core/src/lib/runtime/Makefile.am b/gnuradio-core/src/lib/runtime/Makefile.am index b0e80427..f67e8843 100644 --- a/gnuradio-core/src/lib/runtime/Makefile.am +++ b/gnuradio-core/src/lib/runtime/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2003,2004,2007,2008,2009 Free Software Foundation, Inc. +# Copyright 2003,2004,2007,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,7 @@ include $(top_srcdir)/Makefile.common -AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) $(GRUEL_INCLUDES) $(WITH_INCLUDES) +AM_CPPFLAGS = $(GRUEL_INCLUDES) $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES) noinst_LTLIBRARIES = libruntime.la libruntime-qa.la @@ -120,6 +120,7 @@ grinclude_HEADERS = \ gr_timer.h \ gr_tmp_path.h \ gr_types.h \ + gr_unittests.h \ gr_vmcircbuf.h noinst_HEADERS = \ diff --git a/gnuradio-core/src/lib/runtime/gr_preferences.cc b/gnuradio-core/src/lib/runtime/gr_preferences.cc index e0be2db6..5f741224 100644 --- a/gnuradio-core/src/lib/runtime/gr_preferences.cc +++ b/gnuradio-core/src/lib/runtime/gr_preferences.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2003 Free Software Foundation, Inc. + * Copyright 2003,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -77,11 +77,20 @@ gr_preferences::get (const char *key) static char buf[1024]; FILE *fp = fopen (pathname (key), "r"); - if (fp == 0) + if (fp == 0) { + perror (pathname (key)); return 0; + } memset (buf, 0, sizeof (buf)); - fread (buf, 1, sizeof (buf) - 1, fp); + size_t ret = fread (buf, 1, sizeof (buf) - 1, fp); + if(ret == 0) { + if(ferror(fp) != 0) { + perror (pathname (key)); + fclose (fp); + return 0; + } + } fclose (fp); return buf; } @@ -97,6 +106,13 @@ gr_preferences::set (const char *key, const char *value) return; } - fwrite (value, 1, strlen (value), fp); + size_t ret = fwrite (value, 1, strlen (value), fp); + if(ret == 0) { + if(ferror(fp) != 0) { + perror (pathname (key)); + fclose (fp); + return; + } + } fclose (fp); }; diff --git a/gnuradio-core/src/lib/runtime/gr_unittests.h b/gnuradio-core/src/lib/runtime/gr_unittests.h new file mode 100644 index 00000000..70aa6f29 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_unittests.h @@ -0,0 +1,67 @@ +/* -*- c++ -*- */ +/* + * Copyright 2010 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 +#include +#include +#include +#include +#include + + +#ifdef MKDIR_TAKES_ONE_ARG +#define gr_mkdir(pathname, mode) mkdir(pathname) +#else +#define gr_mkdir(pathname, mode) mkdir((pathname), (mode)) +#endif + +/* + * Mostly taken from gr_preferences.cc/h + * The simplest thing that could possibly work: + * the key is the filename; the value is the file contents. + */ + +static void +ensure_unittest_path (const char *path) +{ + struct stat statbuf; + if (stat (path, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)) + return; + + // blindly try to make it // FIXME make this robust. C++ SUCKS! + gr_mkdir (path, 0750); +} + +static void +get_unittest_path (const char *filename, char *fullpath, size_t pathsize) +{ + char path[200]; + snprintf (path, sizeof(path), "./.unittests"); + snprintf (fullpath, pathsize, "%s/%s", path, filename); + + ensure_unittest_path(path); +} + diff --git a/gnuradio-core/src/lib/swig/Makefile.am b/gnuradio-core/src/lib/swig/Makefile.am index 242f27d9..1a50b8c8 100644 --- a/gnuradio-core/src/lib/swig/Makefile.am +++ b/gnuradio-core/src/lib/swig/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2001,2003,2004,2005,2006,2007,2008,2009 Free Software Foundation, Inc. +# Copyright 2001,2003,2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,7 +22,7 @@ include $(top_srcdir)/Makefile.common if PYTHON -AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) -I$(srcdir) \ +AM_CPPFLAGS = -I$(srcdir) $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ $(WITH_INCLUDES) EXTRA_DIST = gen-swig-bug-fix diff --git a/gnuradio-core/src/lib/swig/gnuradio.i b/gnuradio-core/src/lib/swig/gnuradio.i index 7d0241f1..e15a0059 100644 --- a/gnuradio-core/src/lib/swig/gnuradio.i +++ b/gnuradio-core/src/lib/swig/gnuradio.i @@ -46,6 +46,8 @@ typedef std::complex gr_complex; typedef std::complex gr_complexd; +typedef unsigned long long uint64_t; +typedef long long int64_t; // instantiate the required template specializations diff --git a/gnuradio-core/src/python/gnuradio/Makefile.am b/gnuradio-core/src/python/gnuradio/Makefile.am index f0516f2f..a3f3518d 100644 --- a/gnuradio-core/src/python/gnuradio/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2004,2007,2008,2009 Free Software Foundation, Inc. +# Copyright 2004,2007,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -34,6 +34,7 @@ grpython_PYTHON = \ ofdm_packet_utils.py \ packet_utils.py \ gr_unittest.py \ + gr_xmlrunner.py \ optfir.py \ usrp_options.py \ window.py diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py index e40d9636..5e4e0687 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr +from gnuradio import gr, optfir class pfb_arb_resampler_ccf(gr.hier_block2): ''' @@ -31,15 +31,36 @@ class pfb_arb_resampler_ccf(gr.hier_block2): streams. This block is provided to be consistent with the interface to the other PFB block. ''' - def __init__(self, rate, taps, flt_size=32): + def __init__(self, rate, taps=None, flt_size=32, atten=100): gr.hier_block2.__init__(self, "pfb_arb_resampler_ccf", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature self._rate = rate - self._taps = taps self._size = flt_size + if taps is not None: + self._taps = taps + else: + # Create a filter that covers the full bandwidth of the input signal + bw = 0.4 + tb = 0.2 + ripple = 0.1 + #self._taps = gr.firdes.low_pass_2(self._size, self._size, bw, tb, atten) + made = False + while not made: + try: + self._taps = optfir.low_pass(self._size, self._size, bw, bw+tb, ripple, atten) + made = True + except RuntimeError: + ripple += 0.01 + made = False + print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) + + # Build in an exit strategy; if we've come this far, it ain't working. + if(ripple >= 1.0): + raise RuntimeError("optfir could not generate an appropriate filter.") + self.pfb = gr.pfb_arb_resampler_ccf(self._rate, self._taps, self._size) self.connect(self, self.pfb) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py index a479ed48..3ddc1749 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr +from gnuradio import gr, optfir class pfb_channelizer_ccf(gr.hier_block2): ''' @@ -29,15 +29,35 @@ class pfb_channelizer_ccf(gr.hier_block2): This simplifies the interface by allowing a single input stream to connect to this block. It will then output a stream for each channel. ''' - def __init__(self, numchans, taps, oversample_rate=1): + def __init__(self, numchans, taps=None, oversample_rate=1, atten=100): gr.hier_block2.__init__(self, "pfb_channelizer_ccf", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(numchans, numchans, gr.sizeof_gr_complex)) # Output signature self._numchans = numchans - self._taps = taps self._oversample_rate = oversample_rate + if taps is not None: + self._taps = taps + else: + # Create a filter that covers the full bandwidth of the input signal + bw = 0.4 + tb = 0.2 + ripple = 0.1 + made = False + while not made: + try: + self._taps = optfir.low_pass(1, self._numchans, bw, bw+tb, ripple, atten) + made = True + except RuntimeError: + ripple += 0.01 + made = False + print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) + + # Build in an exit strategy; if we've come this far, it ain't working. + if(ripple >= 1.0): + raise RuntimeError("optfir could not generate an appropriate filter.") + self.s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, self._numchans) self.pfb = gr.pfb_channelizer_ccf(self._numchans, self._taps, self._oversample_rate) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py index 176d0473..2e36e7bc 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr +from gnuradio import gr, optfir class pfb_decimator_ccf(gr.hier_block2): ''' @@ -29,15 +29,35 @@ class pfb_decimator_ccf(gr.hier_block2): This simplifies the interface by allowing a single input stream to connect to this block. It will then output a stream that is the decimated output stream. ''' - def __init__(self, decim, taps, channel=0): + def __init__(self, decim, taps=None, channel=0, atten=100): gr.hier_block2.__init__(self, "pfb_decimator_ccf", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature self._decim = decim - self._taps = taps self._channel = channel + if taps is not None: + self._taps = taps + else: + # Create a filter that covers the full bandwidth of the input signal + bw = 0.4 + tb = 0.2 + ripple = 0.1 + made = False + while not made: + try: + self._taps = optfir.low_pass(1, self._decim, bw, bw+tb, ripple, atten) + made = True + except RuntimeError: + ripple += 0.01 + made = False + print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) + + # Build in an exit strategy; if we've come this far, it ain't working. + if(ripple >= 1.0): + raise RuntimeError("optfir could not generate an appropriate filter.") + self.s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, self._decim) self.pfb = gr.pfb_decimator_ccf(self._decim, self._taps, self._channel) diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py index db294404..a6094f7f 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py @@ -20,7 +20,7 @@ # Boston, MA 02110-1301, USA. # -from gnuradio import gr +from gnuradio import gr, optfir class pfb_interpolator_ccf(gr.hier_block2): ''' @@ -31,7 +31,7 @@ class pfb_interpolator_ccf(gr.hier_block2): streams. This block is provided to be consistent with the interface to the other PFB block. ''' - def __init__(self, interp, taps): + def __init__(self, interp, taps=None, atten=100): gr.hier_block2.__init__(self, "pfb_interpolator_ccf", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature @@ -39,6 +39,27 @@ class pfb_interpolator_ccf(gr.hier_block2): self._interp = interp self._taps = taps + if taps is not None: + self._taps = taps + else: + # Create a filter that covers the full bandwidth of the input signal + bw = 0.4 + tb = 0.2 + ripple = 0.99 + made = False + while not made: + try: + self._taps = optfir.low_pass(self._interp, self._interp, bw, bw+tb, ripple, atten) + made = True + except RuntimeError: + ripple += 0.01 + made = False + print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) + + # Build in an exit strategy; if we've come this far, it ain't working. + if(ripple >= 1.0): + raise RuntimeError("optfir could not generate an appropriate filter.") + self.pfb = gr.pfb_interpolator_ccf(self._interp, self._taps) self.connect(self, self.pfb) diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_add_and_friends.py b/gnuradio-core/src/python/gnuradio/gr/qa_add_and_friends.py index 2fa97fad..8fb70fb3 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_add_and_friends.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_add_and_friends.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,7 +22,7 @@ from gnuradio import gr, gr_unittest -class test_head (gr_unittest.TestCase): +class test_add_and_friends (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -126,4 +126,4 @@ class test_head (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_add_and_friends, "test_add_and_friends.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_add_v_and_friends.py b/gnuradio-core/src/python/gnuradio/gr/qa_add_v_and_friends.py index 215e0cac..90056e09 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_add_v_and_friends.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_add_v_and_friends.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -350,4 +350,4 @@ class test_add_v_and_friends(gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_add_v_and_friends, "test_add_v_and_friends.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_agc.py b/gnuradio-core/src/python/gnuradio/gr/qa_agc.py index bb3ddb11..c55d191e 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_agc.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_agc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -25,7 +25,7 @@ import math test_output = False -class test_sig_source (gr_unittest.TestCase): +class test_agc (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -430,4 +430,4 @@ class test_sig_source (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_agc, "test_agc.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_argmax.py b/gnuradio-core/src/python/gnuradio/gr/qa_argmax.py index 2e16d879..a9db3295 100644 --- a/gnuradio-core/src/python/gnuradio/gr/qa_argmax.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_argmax.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007 Free Software Foundation, Inc. +# Copyright 2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,7 +24,7 @@ from gnuradio import gr, gr_unittest import math -class test_sig_source (gr_unittest.TestCase): +class test_arg_max (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -73,5 +73,5 @@ class test_sig_source (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_arg_max, "test_arg_max.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_bin_statistics.py b/gnuradio-core/src/python/gnuradio/gr/qa_bin_statistics.py index 29b9796c..b8b718a0 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_bin_statistics.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_bin_statistics.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007 Free Software Foundation, Inc. +# Copyright 2006,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -227,4 +227,4 @@ class xtest_bin_statistics(gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(xtest_bin_statistics, "test_bin_statistics.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_boolean_operators.py b/gnuradio-core/src/python/gnuradio/gr/qa_boolean_operators.py index ee9bae65..8cfb6009 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_boolean_operators.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_boolean_operators.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007,2008 Free Software Foundation, Inc. +# Copyright 2004,2007,2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,7 +22,7 @@ from gnuradio import gr, gr_unittest -class test_head (gr_unittest.TestCase): +class test_boolean_operators (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -159,4 +159,4 @@ class test_head (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_boolean_operators, "test_boolean_operators.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_classify.py b/gnuradio-core/src/python/gnuradio/gr/qa_classify.py index ac17aff2..ac5b53b5 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_classify.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_classify.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -38,7 +38,7 @@ def np2(k): return m -class qa_classify(gr_unittest.TestCase): +class test_classify(gr_unittest.TestCase): def setUp(self): self.tb = gr.top_block() @@ -178,5 +178,4 @@ class qa_classify(gr_unittest.TestCase): assert sum < 1e-6 if __name__ == '__main__': - gr_unittest.main() - + gr_unittest.run(test_classify, "test_classify.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_cma_equalizer.py b/gnuradio-core/src/python/gnuradio/gr/qa_cma_equalizer.py index b1ab8f54..79e9cd09 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_cma_equalizer.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_cma_equalizer.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007 Free Software Foundation, Inc. +# Copyright 2006,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -46,4 +46,4 @@ class test_cma_equalizer_fir(gr_unittest.TestCase): self.assertComplexTuplesAlmostEqual(expected_data, result) if __name__ == "__main__": - gr_unittest.main() \ No newline at end of file + gr_unittest.run(test_cma_equalizer_fir, "test_cma_equalizer_fir.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py b/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py index 10f36687..76627247 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_complex_to_xxx.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -138,5 +138,5 @@ class test_complex_ops (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_complex_ops, "test_complex_ops.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_constellation_decoder_cb.py b/gnuradio-core/src/python/gnuradio/gr/qa_constellation_decoder_cb.py index 13d2840a..27e1802e 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_constellation_decoder_cb.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_constellation_decoder_cb.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import math -class test_head (gr_unittest.TestCase): +class test_constellation_decoder (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -49,5 +49,5 @@ class test_head (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_constellation_decoder, "test_constellation_decoder.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_copy.py b/gnuradio-core/src/python/gnuradio/gr/qa_copy.py index 7f9f72a7..e8ee480c 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_copy.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_copy.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2009 Free Software Foundation, Inc. +# Copyright 2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -55,4 +55,4 @@ class test_copy(gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_copy, "test_copy.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_correlate_access_code.py b/gnuradio-core/src/python/gnuradio/gr/qa_correlate_access_code.py index a436c6ad..b3575f4e 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_correlate_access_code.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_correlate_access_code.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007 Free Software Foundation, Inc. +# Copyright 2006,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -79,5 +79,5 @@ class test_correlate_access_code(gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_correlate_access_code, "test_correlate_access_code.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_delay.py b/gnuradio-core/src/python/gnuradio/gr/qa_delay.py index 8835cba5..7cad0ae7 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_delay.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_delay.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -62,4 +62,4 @@ class test_delay (gr_unittest.TestCase): self.assertEqual (expected_result, dst_data) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_delay, "test_delay.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_diff_encoder.py b/gnuradio-core/src/python/gnuradio/gr/qa_diff_encoder.py index 04c0e2a4..97e9e329 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_diff_encoder.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_diff_encoder.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007 Free Software Foundation, Inc. +# Copyright 2006,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -31,7 +31,7 @@ def make_random_int_tuple(L, min, max): return tuple(result) -class test_encoder (gr_unittest.TestCase): +class test_diff_encoder (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -82,5 +82,5 @@ class test_encoder (gr_unittest.TestCase): self.assertEqual(expected_result, actual_result) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_diff_encoder, "test_diff_encoder.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_diff_phasor_cc.py b/gnuradio-core/src/python/gnuradio/gr/qa_diff_phasor_cc.py index 385ffa51..5ac115e2 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_diff_phasor_cc.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_diff_phasor_cc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import math -class test_complex_ops (gr_unittest.TestCase): +class test_diff_phasor (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -46,5 +46,5 @@ class test_complex_ops (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_diff_phasor, "test_diff_phasor.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_ecc_ccsds_27.py b/gnuradio-core/src/python/gnuradio/gr/qa_ecc_ccsds_27.py index b0dc4706..caf3959f 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_ecc_ccsds_27.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_ecc_ccsds_27.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -47,4 +47,4 @@ class test_ccsds_27 (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_ccsds_27, "test_ccsds_27.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_feval.py b/gnuradio-core/src/python/gnuradio/gr/qa_feval.py index 64bbe45c..a9140953 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_feval.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_feval.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007 Free Software Foundation, Inc. +# Copyright 2006,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -107,4 +107,4 @@ class test_feval(gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_feval, "test_feval.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_fft.py b/gnuradio-core/src/python/gnuradio/gr/qa_fft.py index 412c4c48..98d80fbb 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_fft.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_fft.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -29,7 +29,7 @@ primes = (2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53, 227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311) -class test_fft_filter(gr_unittest.TestCase): +class test_fft(gr_unittest.TestCase): def setUp(self): pass @@ -154,5 +154,5 @@ class test_fft_filter(gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_fft, "test_fft.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py b/gnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py index d4106ee4..b3124ad2 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_fft_filter.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2005,2007 Free Software Foundation, Inc. +# Copyright 2004,2005,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -275,5 +275,5 @@ class test_fft_filter(gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_fft_filter, "test_fft_filter.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_filter_delay_fc.py b/gnuradio-core/src/python/gnuradio/gr/qa_filter_delay_fc.py index b92f143d..a25c65e5 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_filter_delay_fc.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_filter_delay_fc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import math -class qa_filter_delay_fc (gr_unittest.TestCase): +class test_filter_delay_fc (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -314,4 +314,4 @@ class qa_filter_delay_fc (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_filter_delay_fc, "test_filter_delay_fc.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_fractional_interpolator.py b/gnuradio-core/src/python/gnuradio/gr/qa_fractional_interpolator.py index 4466e8aa..c9ba5416 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_fractional_interpolator.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_fractional_interpolator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007 Free Software Foundation, Inc. +# Copyright 2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -35,5 +35,4 @@ class test_fractional_resampler (gr_unittest.TestCase): op2 = gr.fractional_interpolator_cc(0.0, 1.0) if __name__ == '__main__': - gr_unittest.main() - + gr_unittest.run(test_fractional_resampler, "test_fractional_resampler.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_frequency_modulator.py b/gnuradio-core/src/python/gnuradio/gr/qa_frequency_modulator.py index 53d1a89b..829185c3 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_frequency_modulator.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_frequency_modulator.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -52,5 +52,5 @@ class test_frequency_modulator (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_frequency_modulator, "test_frequency_modulator.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_fsk_stuff.py b/gnuradio-core/src/python/gnuradio/gr/qa_fsk_stuff.py index b506e3ed..429e57c3 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_fsk_stuff.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_fsk_stuff.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -71,5 +71,5 @@ class test_bytes_to_syms (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_bytes_to_syms, "test_bytes_to_syms.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_glfsr_source.py b/gnuradio-core/src/python/gnuradio/gr/qa_glfsr_source.py index fc211657..1665d9dd 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_glfsr_source.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_glfsr_source.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007 Free Software Foundation, Inc. +# Copyright 2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -91,4 +91,4 @@ def auto_correlate(data): return R if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_glfsr_source, "test_glfsr_source.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_goertzel.py b/gnuradio-core/src/python/gnuradio/gr/qa_goertzel.py index d5dc595c..dcb3d867 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_goertzel.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_goertzel.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006,2007 Free Software Foundation, Inc. +# Copyright 2006,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -61,4 +61,4 @@ class test_goertzel(gr_unittest.TestCase): self.assertAlmostEqual(expected_result, actual_result, places=4) if __name__ == '__main__': - gr_unittest.main() + gr_unittest.run(test_goertzel, "test_goertzel.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_head.py b/gnuradio-core/src/python/gnuradio/gr/qa_head.py index b7a60597..aae233b5 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_head.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_head.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -44,4 +44,4 @@ class test_head (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_head, "test_head.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py b/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py index cc336a4d..924a0fb5 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_hier_block2.py @@ -366,4 +366,4 @@ class test_hier_block2(gr_unittest.TestCase): if __name__ == "__main__": - gr_unittest.main() + gr_unittest.run(test_hier_block2, "test_hier_block2.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_hilbert.py b/gnuradio-core/src/python/gnuradio/gr/qa_hilbert.py index 817ba940..2235f28b 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_hilbert.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_hilbert.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import math -class test_sig_source (gr_unittest.TestCase): +class test_hilbert (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -113,4 +113,4 @@ class test_sig_source (gr_unittest.TestCase): self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 5) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_hilbert, "test_hilbert.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_iir.py b/gnuradio-core/src/python/gnuradio/gr/qa_iir.py index 83328507..0e522c16 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_iir.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_iir.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -155,5 +155,5 @@ class test_iir (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_iir, "test_iir.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_integrate.py b/gnuradio-core/src/python/gnuradio/gr/qa_integrate.py index fbd601e3..501a89f8 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_integrate.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_integrate.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -72,4 +72,4 @@ class test_integrate (gr_unittest.TestCase): self.assertComplexTuplesAlmostEqual(dst_data, dst.data(), 6) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_integrate, "test_integrate.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_interleave.py b/gnuradio-core/src/python/gnuradio/gr/qa_interleave.py index 3e0b6c5f..1320d0ec 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_interleave.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_interleave.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -77,5 +77,5 @@ class test_interleave (gr_unittest.TestCase): self.assertFloatTuplesAlmostEqual (expected_result3, dst3.data ()) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_interleave, "test_interleave.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_interp_fir_filter.py b/gnuradio-core/src/python/gnuradio/gr/qa_interp_fir_filter.py index ea326ce4..9901b71b 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_interp_fir_filter.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_interp_fir_filter.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -50,5 +50,5 @@ class test_interp_fir_filter (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_interp_fir_filter, "test_interp_fir_filter.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_kludge_copy.py b/gnuradio-core/src/python/gnuradio/gr/qa_kludge_copy.py index cc25d180..2f0bbe33 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_kludge_copy.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_kludge_copy.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006 Free Software Foundation, Inc. +# Copyright 2006,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -87,5 +87,5 @@ class test_kludge_copy(gr_unittest.TestCase): self.assertRaises(ValueError, self.tb.run) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_kludge_copy, "test_kludge_copy.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_kludged_imports.py b/gnuradio-core/src/python/gnuradio/gr/qa_kludged_imports.py index 91ddf7cd..7d29a950 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_kludged_imports.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_kludged_imports.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2008 Free Software Foundation, Inc. +# Copyright 2005,2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,7 +22,7 @@ from gnuradio import gr, gr_unittest -class test_head (gr_unittest.TestCase): +class test_kludged_imports (gr_unittest.TestCase): def setUp(self): pass @@ -40,4 +40,4 @@ class test_head (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_kludged_imports, "test_kludged_imports.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_max.py b/gnuradio-core/src/python/gnuradio/gr/qa_max.py index 0171c93d..5aa23162 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_max.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_max.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007 Free Software Foundation, Inc. +# Copyright 2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,7 +24,7 @@ from gnuradio import gr, gr_unittest import math -class test_sig_source (gr_unittest.TestCase): +class test_max (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -66,5 +66,5 @@ class test_sig_source (gr_unittest.TestCase): self.assertEqual(expected_result, result_data) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_max, "test_max.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_message.py b/gnuradio-core/src/python/gnuradio/gr/qa_message.py index cb6c4c33..e7f2778d 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_message.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_message.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004 Free Software Foundation, Inc. +# Copyright 2004,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -128,4 +128,4 @@ class test_message (gr_unittest.TestCase): self.assertEquals(tuple(map(ord, '0123456789')), dst.data()) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_message, "test_message.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_mute.py b/gnuradio-core/src/python/gnuradio/gr/qa_mute.py index 646f495c..58c5062a 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_mute.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_mute.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2005,2007 Free Software Foundation, Inc. +# Copyright 2004,2005,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,7 +22,7 @@ from gnuradio import gr, gr_unittest -class test_head (gr_unittest.TestCase): +class test_mute (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -86,4 +86,4 @@ class test_head (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_mute, "test_mute.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_nlog10.py b/gnuradio-core/src/python/gnuradio/gr/qa_nlog10.py index 4dca67b2..5a2e6a0d 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_nlog10.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_nlog10.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2007 Free Software Foundation, Inc. +# Copyright 2005,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,7 +22,7 @@ from gnuradio import gr, gr_unittest -class test_single_pole_iir(gr_unittest.TestCase): +class test_nlog10(gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -43,5 +43,5 @@ class test_single_pole_iir(gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_nlog10, "test_nlog10.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_noise.py b/gnuradio-core/src/python/gnuradio/gr/qa_noise.py index f8ed739a..4a575f5d 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_noise.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_noise.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007 Free Software Foundation, Inc. +# Copyright 2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -35,5 +35,5 @@ class test_noise_source(gr_unittest.TestCase): op = gr.noise_source_f(gr.GR_GAUSSIAN, 10, 10) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_noise_source, "test_noise_source.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_ofdm_insert_preamble.py b/gnuradio-core/src/python/gnuradio/gr/qa_ofdm_insert_preamble.py index d45560d3..d69f5ca5 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_ofdm_insert_preamble.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_ofdm_insert_preamble.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007 Free Software Foundation, Inc. +# Copyright 2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest from pprint import pprint -class testing (gr_unittest.TestCase): +class test_ofdm_insert_preamble (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -176,4 +176,4 @@ class testing (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_ofdm_insert_preamble, "test_ofdm_insert_preamble.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_packed_to_unpacked.py b/gnuradio-core/src/python/gnuradio/gr/qa_packed_to_unpacked.py index b1b3a971..8833f755 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_packed_to_unpacked.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_packed_to_unpacked.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2007 Free Software Foundation, Inc. +# Copyright 2005,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -401,5 +401,5 @@ class test_packing(gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_packing, "test_packing.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_pipe_fittings.py b/gnuradio-core/src/python/gnuradio/gr/qa_pipe_fittings.py index 533f4f05..a6683c5c 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_pipe_fittings.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_pipe_fittings.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2007 Free Software Foundation, Inc. +# Copyright 2005,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -139,5 +139,5 @@ class test_pipe_fittings(gr_unittest.TestCase): self.assertEqual(expected_results, dst.data()) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_pipe_fittings, "test_pipe_fittings.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_pll_carriertracking.py b/gnuradio-core/src/python/gnuradio/gr/qa_pll_carriertracking.py index 4a109663..8e4a0eef 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_pll_carriertracking.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_pll_carriertracking.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import math -class test_sig_source (gr_unittest.TestCase): +class test_pll_carriertracking (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block() @@ -155,4 +155,4 @@ class test_sig_source (gr_unittest.TestCase): self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 5) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_pll_carriertracking, "test_pll_carriertracking.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_pll_freqdet.py b/gnuradio-core/src/python/gnuradio/gr/qa_pll_freqdet.py index ac9c1844..5225a9a3 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_pll_freqdet.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_pll_freqdet.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import math -class test_sig_source (gr_unittest.TestCase): +class test_pll_freqdet (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block() @@ -158,4 +158,4 @@ class test_sig_source (gr_unittest.TestCase): self.assertFloatTuplesAlmostEqual (expected_result, dst_data, 3) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_pll_freqdet, "test_pll_freqdet.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_pll_refout.py b/gnuradio-core/src/python/gnuradio/gr/qa_pll_refout.py index 9cafa61e..c40a885a 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_pll_refout.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_pll_refout.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004 Free Software Foundation, Inc. +# Copyright 2004,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import math -class test_sig_source (gr_unittest.TestCase): +class test_pll_refout (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block() @@ -155,4 +155,4 @@ class test_sig_source (gr_unittest.TestCase): self.assertComplexTuplesAlmostEqual (expected_result, dst_data, 5) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_pll_refout, "test_pll_refout.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_pn_correlator_cc.py b/gnuradio-core/src/python/gnuradio/gr/qa_pn_correlator_cc.py index 01d01bde..fbdabb4c 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_pn_correlator_cc.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_pn_correlator_cc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007 Free Software Foundation, Inc. +# Copyright 2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -47,4 +47,4 @@ class test_pn_correlator_cc(gr_unittest.TestCase): self.assertEqual(data[-1], (1.0+0j)) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_pn_correlator_cc, "test_pn_correlator_cc.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_rational_resampler.py b/gnuradio-core/src/python/gnuradio/gr/qa_rational_resampler.py index f8bf4b12..3bd6160d 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_rational_resampler.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_rational_resampler.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2006,2007 Free Software Foundation, Inc. +# Copyright 2005,2006,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -294,5 +294,5 @@ class test_rational_resampler (gr_unittest.TestCase): if __name__ == '__main__': pass # FIXME: Disabled, see ticket:210 - # gr_unittest.main() + # gr_unittest.run(test_rational_resampler, "test_rational_resampler.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_regenerate.py b/gnuradio-core/src/python/gnuradio/gr/qa_regenerate.py index 64e75118..32ecc377 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_regenerate.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_regenerate.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007 Free Software Foundation, Inc. +# Copyright 2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import math -class test_sig_source (gr_unittest.TestCase): +class test_regenerate (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -87,4 +87,4 @@ class test_sig_source (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_regenerate, "test_regenerate.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_repeat.py b/gnuradio-core/src/python/gnuradio/gr/qa_repeat.py index 1ecc7ead..2b142998 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_repeat.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_repeat.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -45,4 +45,4 @@ class test_repeat (gr_unittest.TestCase): self.assertFloatTuplesAlmostEqual(dst_data, dst.data(), 6) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_repeat, "test_repeat.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py b/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py index aecf4929..241d8ec2 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_scrambler.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -61,4 +61,4 @@ class test_scrambler(gr_unittest.TestCase): self.assertEqual(src_data, dst.data()) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_scrambler, "test_scrambler.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_sig_source.py b/gnuradio-core/src/python/gnuradio/gr/qa_sig_source.py index 058890c4..4bb58038 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_sig_source.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_sig_source.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -154,4 +154,4 @@ class test_sig_source (gr_unittest.TestCase): self.assertFloatTuplesAlmostEqual (expected_result, dst_data, 5) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_sig_source, "test_sig_source.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir.py b/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir.py index 8ad0a9bb..1d2e6595 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2007 Free Software Foundation, Inc. +# Copyright 2005,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -68,5 +68,5 @@ class test_single_pole_iir(gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_single_pole_iir, "test_single_pole_iir.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir_cc.py b/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir_cc.py index 865c7c90..47b4948b 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir_cc.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_single_pole_iir_cc.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2006,2007 Free Software Foundation, Inc. +# Copyright 2005,2006,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -68,5 +68,5 @@ class test_single_pole_iir_cc(gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_single_pole_iir_cc, "test_single_pole_iir_cc.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_skiphead.py b/gnuradio-core/src/python/gnuradio/gr/qa_skiphead.py index 106e9731..de2d8fc9 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_skiphead.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_skiphead.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007 Free Software Foundation, Inc. +# Copyright 2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -99,4 +99,4 @@ class test_skiphead (gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_skiphead, "test_skiphead.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_stream_mux.py b/gnuradio-core/src/python/gnuradio/gr/qa_stream_mux.py index 8a76f814..7d6ddf81 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_stream_mux.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_stream_mux.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2005,2007 Free Software Foundation, Inc. +# Copyright 2004,2005,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,7 +22,7 @@ from gnuradio import gr, gr_unittest -class test_head (gr_unittest.TestCase): +class test_stream_mux (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -165,4 +165,4 @@ class test_head (gr_unittest.TestCase): self.assertEqual (exp_data, result_data) if __name__ == '__main__': - gr_unittest.main() + gr_unittest.run(test_stream_mux, "test_stream_mux.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_udp_sink_source.py b/gnuradio-core/src/python/gnuradio/gr/qa_udp_sink_source.py index b00b26bb..097e394c 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_udp_sink_source.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_udp_sink_source.py @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest from threading import Timer -class test_sink_source(gr_unittest.TestCase): +class test_udp_sink_source(gr_unittest.TestCase): def setUp(self): self.tb_snd = gr.top_block() @@ -95,5 +95,5 @@ class test_sink_source(gr_unittest.TestCase): #print "tb_rcv stopped by Timer" if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_udp_sink_source, "test_udp_sink_source.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_unpack_k_bits.py b/gnuradio-core/src/python/gnuradio/gr/qa_unpack_k_bits.py index edb263ad..d1faf9d9 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_unpack_k_bits.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_unpack_k_bits.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006 Free Software Foundation, Inc. +# Copyright 2006,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -53,5 +53,5 @@ class test_unpack(gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_unpack, "test_unpack.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_vector_sink_source.py b/gnuradio-core/src/python/gnuradio/gr/qa_vector_sink_source.py index 149c6690..5d8d85c7 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_vector_sink_source.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_vector_sink_source.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import math -class test_sink_source(gr_unittest.TestCase): +class test_vector_sink_source(gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -61,5 +61,5 @@ class test_sink_source(gr_unittest.TestCase): self.assertRaises(ValueError, lambda : gr.vector_source_f(src_data, False, 3)) if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_vector_sink_source, "test_vector_sink_source.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr/qa_wavefile.py b/gnuradio-core/src/python/gnuradio/gr/qa_wavefile.py index 3ba5dfbc..d9f38e3f 100755 --- a/gnuradio-core/src/python/gnuradio/gr/qa_wavefile.py +++ b/gnuradio-core/src/python/gnuradio/gr/qa_wavefile.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -27,7 +27,7 @@ from os.path import getsize g_in_file = os.path.join (os.getenv ("srcdir"), "test_16bit_1chunk.wav") -class qa_wavefile(gr_unittest.TestCase): +class test_wavefile(gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -66,4 +66,4 @@ class qa_wavefile(gr_unittest.TestCase): if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_wavefile, "test_wavefile.xml") diff --git a/gnuradio-core/src/python/gnuradio/gr_unittest.py b/gnuradio-core/src/python/gnuradio/gr_unittest.py index a48343c6..c2c4df2b 100755 --- a/gnuradio-core/src/python/gnuradio/gr_unittest.py +++ b/gnuradio-core/src/python/gnuradio/gr_unittest.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004 Free Software Foundation, Inc. +# Copyright 2004,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,8 @@ # import unittest -import sys +import gr_xmlrunner +import sys, os, stat class TestCase(unittest.TestCase): """A subclass of unittest.TestCase that adds additional assertions @@ -37,7 +38,7 @@ class TestCase(unittest.TestCase): Note that decimal places (from zero) is usually not the same as significant digits (measured from the most signficant digit). - """ + """ if round(second.real-first.real, places) != 0: raise self.failureException, \ (msg or '%s != %s within %s places' % (`first`, `second`, `places` )) @@ -106,6 +107,58 @@ TextTestRunner = unittest.TextTestRunner TestProgram = unittest.TestProgram main = TestProgram +def run(PUT, filename=None): + ''' + Runs the unittest on a TestCase and produces an optional XML report + PUT: the program under test and should be a gr_unittest.TestCase + filename: an optional filename to save the XML report of the tests + this will live in ./.unittests/python + ''' + + # Run this is given a file name + if(filename is not None): + basepath = "./.unittests" + path = basepath + "/python" + + if not os.path.exists(basepath): + os.makedirs(basepath, 0750) + + xmlrunner = None + # only proceed if .unittests is writable + st = os.stat(basepath)[stat.ST_MODE] + if(st & stat.S_IWUSR > 0): + # Test if path exists; if not, build it + if not os.path.exists(path): + os.makedirs(path, 0750) + + # Just for safety: make sure we can write here, too + st = os.stat(path)[stat.ST_MODE] + if(st & stat.S_IWUSR > 0): + # Create an XML runner to filename + fout = file(path+"/"+filename, "w") + xmlrunner = gr_xmlrunner.XMLTestRunner(fout) + + txtrunner = TextTestRunner(verbosity=1) + + # Run the test; runner also creates XML output file + # FIXME: make xmlrunner output to screen so we don't have to do run and main + suite = TestLoader().loadTestsFromTestCase(PUT) + + # use the xmlrunner if we can write the the directory + if(xmlrunner is not None): + xmlrunner.run(suite) + + main() + + # This will run and fail make check if problem + # but does not output to screen. + #main(testRunner = xmlrunner) + + else: + # If no filename is given, just run the test + main() + + ############################################################################## # Executing this module from the command line ############################################################################## diff --git a/gnuradio-core/src/python/gnuradio/gr_xmlrunner.py b/gnuradio-core/src/python/gnuradio/gr_xmlrunner.py new file mode 100644 index 00000000..ded77f5f --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/gr_xmlrunner.py @@ -0,0 +1,385 @@ +""" +XML Test Runner for PyUnit +""" + +# Written by Sebastian Rittau and placed in +# the Public Domain. With contributions by Paolo Borelli and others. +# Added to GNU Radio Oct. 3, 2010 + +from __future__ import with_statement + +__version__ = "0.1" + +import os.path +import re +import sys +import time +import traceback +import unittest +from xml.sax.saxutils import escape + +try: + from StringIO import StringIO +except ImportError: + from io import StringIO + + +class _TestInfo(object): + + """Information about a particular test. + + Used by _XMLTestResult. + + """ + + def __init__(self, test, time): + (self._class, self._method) = test.id().rsplit(".", 1) + self._time = time + self._error = None + self._failure = None + + @staticmethod + def create_success(test, time): + """Create a _TestInfo instance for a successful test.""" + return _TestInfo(test, time) + + @staticmethod + def create_failure(test, time, failure): + """Create a _TestInfo instance for a failed test.""" + info = _TestInfo(test, time) + info._failure = failure + return info + + @staticmethod + def create_error(test, time, error): + """Create a _TestInfo instance for an erroneous test.""" + info = _TestInfo(test, time) + info._error = error + return info + + def print_report(self, stream): + """Print information about this test case in XML format to the + supplied stream. + + """ + stream.write(' ' % \ + { + "class": self._class, + "method": self._method, + "time": self._time, + }) + if self._failure is not None: + self._print_error(stream, 'failure', self._failure) + if self._error is not None: + self._print_error(stream, 'error', self._error) + stream.write('\n') + + def _print_error(self, stream, tagname, error): + """Print information from a failure or error to the supplied stream.""" + text = escape(str(error[1])) + stream.write('\n') + stream.write(' <%s type="%s">%s\n' \ + % (tagname, _clsname(error[0]), text)) + tb_stream = StringIO() + traceback.print_tb(error[2], None, tb_stream) + stream.write(escape(tb_stream.getvalue())) + stream.write(' \n' % tagname) + stream.write(' ') + + +def _clsname(cls): + return cls.__module__ + "." + cls.__name__ + + +class _XMLTestResult(unittest.TestResult): + + """A test result class that stores result as XML. + + Used by XMLTestRunner. + + """ + + def __init__(self, classname): + unittest.TestResult.__init__(self) + self._test_name = classname + self._start_time = None + self._tests = [] + self._error = None + self._failure = None + + def startTest(self, test): + unittest.TestResult.startTest(self, test) + self._error = None + self._failure = None + self._start_time = time.time() + + def stopTest(self, test): + time_taken = time.time() - self._start_time + unittest.TestResult.stopTest(self, test) + if self._error: + info = _TestInfo.create_error(test, time_taken, self._error) + elif self._failure: + info = _TestInfo.create_failure(test, time_taken, self._failure) + else: + info = _TestInfo.create_success(test, time_taken) + self._tests.append(info) + + def addError(self, test, err): + unittest.TestResult.addError(self, test, err) + self._error = err + + def addFailure(self, test, err): + unittest.TestResult.addFailure(self, test, err) + self._failure = err + + def print_report(self, stream, time_taken, out, err): + """Prints the XML report to the supplied stream. + + The time the tests took to perform as well as the captured standard + output and standard error streams must be passed in.a + + """ + stream.write('\n' % \ + { + "n": self._test_name, + "t": self.testsRun, + "time": time_taken, + }) + for info in self._tests: + info.print_report(stream) + stream.write(' \n' % out) + stream.write(' \n' % err) + stream.write('\n') + + +class XMLTestRunner(object): + + """A test runner that stores results in XML format compatible with JUnit. + + XMLTestRunner(stream=None) -> XML test runner + + The XML file is written to the supplied stream. If stream is None, the + results are stored in a file called TEST-..xml in the + current working directory (if not overridden with the path property), + where and are the module and class name of the test class. + + """ + + def __init__(self, stream=None): + self._stream = stream + self._path = "." + + def run(self, test): + """Run the given test case or test suite.""" + class_ = test.__class__ + classname = class_.__module__ + "." + class_.__name__ + if self._stream == None: + filename = "TEST-%s.xml" % classname + stream = file(os.path.join(self._path, filename), "w") + stream.write('\n') + else: + stream = self._stream + + result = _XMLTestResult(classname) + start_time = time.time() + + with _fake_std_streams(): + test(result) + try: + out_s = sys.stdout.getvalue() + except AttributeError: + out_s = "" + try: + err_s = sys.stderr.getvalue() + except AttributeError: + err_s = "" + + time_taken = time.time() - start_time + result.print_report(stream, time_taken, out_s, err_s) + if self._stream is None: + stream.close() + + return result + + def _set_path(self, path): + self._path = path + + path = property(lambda self: self._path, _set_path, None, + """The path where the XML files are stored. + + This property is ignored when the XML file is written to a file + stream.""") + + +class _fake_std_streams(object): + + def __enter__(self): + self._orig_stdout = sys.stdout + self._orig_stderr = sys.stderr + sys.stdout = StringIO() + sys.stderr = StringIO() + + def __exit__(self, exc_type, exc_val, exc_tb): + sys.stdout = self._orig_stdout + sys.stderr = self._orig_stderr + + +class XMLTestRunnerTest(unittest.TestCase): + + def setUp(self): + self._stream = StringIO() + + def _try_test_run(self, test_class, expected): + + """Run the test suite against the supplied test class and compare the + XML result against the expected XML string. Fail if the expected + string doesn't match the actual string. All time attributes in the + expected string should have the value "0.000". All error and failure + messages are reduced to "Foobar". + + """ + + runner = XMLTestRunner(self._stream) + runner.run(unittest.makeSuite(test_class)) + + got = self._stream.getvalue() + # Replace all time="X.YYY" attributes by time="0.000" to enable a + # simple string comparison. + got = re.sub(r'time="\d+\.\d+"', 'time="0.000"', got) + # Likewise, replace all failure and error messages by a simple "Foobar" + # string. + got = re.sub(r'(?s).*?', r'Foobar', got) + got = re.sub(r'(?s).*?', r'Foobar', got) + # And finally Python 3 compatibility. + got = got.replace('type="builtins.', 'type="exceptions.') + + self.assertEqual(expected, got) + + def test_no_tests(self): + """Regression test: Check whether a test run without any tests + matches a previous run. + + """ + class TestTest(unittest.TestCase): + pass + self._try_test_run(TestTest, """ + + + +""") + + def test_success(self): + """Regression test: Check whether a test run with a successful test + matches a previous run. + + """ + class TestTest(unittest.TestCase): + def test_foo(self): + pass + self._try_test_run(TestTest, """ + + + + +""") + + def test_failure(self): + """Regression test: Check whether a test run with a failing test + matches a previous run. + + """ + class TestTest(unittest.TestCase): + def test_foo(self): + self.assert_(False) + self._try_test_run(TestTest, """ + + Foobar + + + + +""") + + def test_error(self): + """Regression test: Check whether a test run with a erroneous test + matches a previous run. + + """ + class TestTest(unittest.TestCase): + def test_foo(self): + raise IndexError() + self._try_test_run(TestTest, """ + + Foobar + + + + +""") + + def test_stdout_capture(self): + """Regression test: Check whether a test run with output to stdout + matches a previous run. + + """ + class TestTest(unittest.TestCase): + def test_foo(self): + sys.stdout.write("Test\n") + self._try_test_run(TestTest, """ + + + + +""") + + def test_stderr_capture(self): + """Regression test: Check whether a test run with output to stderr + matches a previous run. + + """ + class TestTest(unittest.TestCase): + def test_foo(self): + sys.stderr.write("Test\n") + self._try_test_run(TestTest, """ + + + + +""") + + class NullStream(object): + """A file-like object that discards everything written to it.""" + def write(self, buffer): + pass + + def test_unittests_changing_stdout(self): + """Check whether the XMLTestRunner recovers gracefully from unit tests + that change stdout, but don't change it back properly. + + """ + class TestTest(unittest.TestCase): + def test_foo(self): + sys.stdout = XMLTestRunnerTest.NullStream() + + runner = XMLTestRunner(self._stream) + runner.run(unittest.makeSuite(TestTest)) + + def test_unittests_changing_stderr(self): + """Check whether the XMLTestRunner recovers gracefully from unit tests + that change stderr, but don't change it back properly. + + """ + class TestTest(unittest.TestCase): + def test_foo(self): + sys.stderr = XMLTestRunnerTest.NullStream() + + runner = XMLTestRunner(self._stream) + runner.run(unittest.makeSuite(TestTest)) + + +if __name__ == "__main__": + unittest.main() diff --git a/gnuradio-core/src/tests/test_all.cc b/gnuradio-core/src/tests/test_all.cc index 6dc1a26f..17ee32f3 100644 --- a/gnuradio-core/src/tests/test_all.cc +++ b/gnuradio-core/src/tests/test_all.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,7 +21,9 @@ */ #include +#include +#include #include #include #include @@ -32,13 +34,18 @@ int main (int argc, char **argv) { - - CppUnit::TextTestRunner runner; + char path[200]; + get_unittest_path ("gnuradio_core_all.xml", path, 200); + + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(path); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_runtime::suite ()); runner.addTest (qa_general::suite ()); runner.addTest (qa_filter::suite ()); // runner.addTest (qa_atsc::suite ()); + runner.setOutputter(xmlout); bool was_successful = runner.run ("", false); diff --git a/gnuradio-core/src/tests/test_atsc.cc b/gnuradio-core/src/tests/test_atsc.cc index f744d76e..51642f81 100644 --- a/gnuradio-core/src/tests/test_atsc.cc +++ b/gnuradio-core/src/tests/test_atsc.cc @@ -21,16 +21,24 @@ */ #include +#include + +#include #include int main (int argc, char **argv) { + char path[200]; + get_unittest_path ("gnuradio_core_atsc.xml", path, 200); - CppUnit::TextTestRunner runner; + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(path); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_atsc::suite ()); - + runner.setOutputter(xmlout); + bool was_successful = runner.run ("", false); return was_successful ? 0 : 1; diff --git a/gnuradio-core/src/tests/test_filter.cc b/gnuradio-core/src/tests/test_filter.cc index 56e94523..2781cfb3 100644 --- a/gnuradio-core/src/tests/test_filter.cc +++ b/gnuradio-core/src/tests/test_filter.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,15 +21,23 @@ */ #include +#include + +#include #include int main (int argc, char **argv) { + char path[200]; + get_unittest_path ("gnuradio_core_filter.xml", path, 200); - CppUnit::TextTestRunner runner; + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(path); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_filter::suite ()); + runner.setOutputter(xmlout); bool was_successful = runner.run ("", false); diff --git a/gnuradio-core/src/tests/test_general.cc b/gnuradio-core/src/tests/test_general.cc index 063e2ee4..16ee9c3a 100644 --- a/gnuradio-core/src/tests/test_general.cc +++ b/gnuradio-core/src/tests/test_general.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,15 +21,23 @@ */ #include +#include + +#include #include int main (int argc, char **argv) { - - CppUnit::TextTestRunner runner; + char path[200]; + get_unittest_path ("gnuradio_core_general.xml", path, 200); + + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(path); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_general::suite ()); + runner.setOutputter(xmlout); bool was_successful = runner.run ("", false); diff --git a/gnuradio-core/src/tests/test_runtime.cc b/gnuradio-core/src/tests/test_runtime.cc index 8549f2a9..c7983a23 100644 --- a/gnuradio-core/src/tests/test_runtime.cc +++ b/gnuradio-core/src/tests/test_runtime.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002 Free Software Foundation, Inc. + * Copyright 2002,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,15 +21,23 @@ */ #include +#include + +#include #include int main (int argc, char **argv) { + char path[200]; + get_unittest_path ("gnuradio_core_runtime.xml", path, 200); - CppUnit::TextTestRunner runner; + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(path); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_runtime::suite ()); + runner.setOutputter(xmlout); bool was_successful = runner.run ("", false); diff --git a/gnuradio-examples/c++/dial_tone/Makefile.am b/gnuradio-examples/c++/dial_tone/Makefile.am index ea34beee..188275fc 100644 --- a/gnuradio-examples/c++/dial_tone/Makefile.am +++ b/gnuradio-examples/c++/dial_tone/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2006,2008,2009 Free Software Foundation, Inc. +# Copyright 2006,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,9 +22,10 @@ include $(top_srcdir)/Makefile.common # For compiling within the GNU Radio build tree -AM_CPPFLAGS=$(STD_DEFINES_AND_INCLUDES) \ - -I$(top_srcdir)/gr-audio-alsa/src \ - $(WITH_INCLUDES) +AM_CPPFLAGS = \ + -I$(top_srcdir)/gr-audio-alsa/src \ + $(STD_DEFINES_AND_INCLUDES) \ + $(WITH_INCLUDES) GR_AUDIO_ALSA_LA=$(top_builddir)/gr-audio-alsa/src/libgnuradio-audio-alsa.la diff --git a/gnuradio-examples/python/pfb/channelize.py b/gnuradio-examples/python/pfb/channelize.py index 27d87e55..f845c05c 100755 --- a/gnuradio-examples/python/pfb/channelize.py +++ b/gnuradio-examples/python/pfb/channelize.py @@ -36,7 +36,7 @@ class pfb_top_block(gr.top_block): # Create a set of taps for the PFB channelizer self._taps = gr.firdes.low_pass_2(1, self._fs, 475.50, 50, - attenuation_dB=10, window=gr.firdes.WIN_BLACKMAN_hARRIS) + attenuation_dB=100, window=gr.firdes.WIN_BLACKMAN_hARRIS) # Calculate the number of taps per channel for our own information tpc = scipy.ceil(float(len(self._taps)) / float(self._M)) diff --git a/gnuradio-examples/python/pfb/resampler.py b/gnuradio-examples/python/pfb/resampler.py new file mode 100755 index 00000000..6be7cf14 --- /dev/null +++ b/gnuradio-examples/python/pfb/resampler.py @@ -0,0 +1,95 @@ +#!/usr/bin/env python + +from gnuradio import gr, blks2 +import scipy, pylab + +class mytb(gr.top_block): + def __init__(self, fs_in, fs_out, fc, N=10000): + gr.top_block.__init__(self) + + rerate = float(fs_out) / float(fs_in) + print "Resampling from %f to %f by %f " %(fs_in, fs_out, rerate) + + # Creating our own taps + taps = gr.firdes.low_pass_2(32, 32, 0.25, 0.1, 80) + + self.src = gr.sig_source_c(fs_in, gr.GR_SIN_WAVE, fc, 1) + #self.src = gr.noise_source_c(gr.GR_GAUSSIAN, 1) + self.head = gr.head(gr.sizeof_gr_complex, N) + + # A resampler with our taps + self.resamp_0 = blks2.pfb_arb_resampler_ccf(rerate, taps, + flt_size=32) + + # A resampler that just needs a resampling rate. + # Filter is created for us and designed to cover + # entire bandwidth of the input signal. + # An optional atten=XX rate can be used here to + # specify the out-of-band rejection (default=80). + self.resamp_1 = blks2.pfb_arb_resampler_ccf(rerate) + + self.snk_in = gr.vector_sink_c() + self.snk_0 = gr.vector_sink_c() + self.snk_1 = gr.vector_sink_c() + + self.connect(self.src, self.head, self.snk_in) + self.connect(self.head, self.resamp_0, self.snk_0) + self.connect(self.head, self.resamp_1, self.snk_1) + +def main(): + fs_in = 8000 + fs_out = 20000 + fc = 1000 + N = 10000 + + tb = mytb(fs_in, fs_out, fc, N) + tb.run() + + + # Plot PSD of signals + nfftsize = 2048 + fig1 = pylab.figure(1, figsize=(10,10), facecolor="w") + sp1 = fig1.add_subplot(2,1,1) + sp1.psd(tb.snk_in.data(), NFFT=nfftsize, + noverlap=nfftsize/4, Fs = fs_in) + sp1.set_title(("Input Signal at f_s=%.2f kHz" % (fs_in/1000.0))) + sp1.set_xlim([-fs_in/2, fs_in/2]) + + sp2 = fig1.add_subplot(2,1,2) + sp2.psd(tb.snk_0.data(), NFFT=nfftsize, + noverlap=nfftsize/4, Fs = fs_out, + label="With our filter") + sp2.psd(tb.snk_1.data(), NFFT=nfftsize, + noverlap=nfftsize/4, Fs = fs_out, + label="With auto-generated filter") + sp2.set_title(("Output Signals at f_s=%.2f kHz" % (fs_out/1000.0))) + sp2.set_xlim([-fs_out/2, fs_out/2]) + sp2.legend() + + # Plot signals in time + Ts_in = 1.0/fs_in + Ts_out = 1.0/fs_out + t_in = scipy.arange(0, len(tb.snk_in.data())*Ts_in, Ts_in) + t_out = scipy.arange(0, len(tb.snk_0.data())*Ts_out, Ts_out) + + fig2 = pylab.figure(2, figsize=(10,10), facecolor="w") + sp21 = fig2.add_subplot(2,1,1) + sp21.plot(t_in, tb.snk_in.data()) + sp21.set_title(("Input Signal at f_s=%.2f kHz" % (fs_in/1000.0))) + sp21.set_xlim([t_in[100], t_in[200]]) + + sp22 = fig2.add_subplot(2,1,2) + sp22.plot(t_out, tb.snk_0.data(), + label="With our filter") + sp22.plot(t_out, tb.snk_1.data(), + label="With auto-generated filter") + sp22.set_title(("Output Signals at f_s=%.2f kHz" % (fs_out/1000.0))) + r = float(fs_out)/float(fs_in) + sp22.set_xlim([t_out[r * 100], t_out[r * 200]]) + sp22.legend() + + pylab.show() + +if __name__ == "__main__": + main() + diff --git a/gnuradio-examples/python/pfb/synth_filter.py b/gnuradio-examples/python/pfb/synth_filter.py new file mode 100755 index 00000000..a1562f9e --- /dev/null +++ b/gnuradio-examples/python/pfb/synth_filter.py @@ -0,0 +1,71 @@ +#!/usr/bin/env python +# +# Copyright 2010 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, blks2 +import scipy, pylab + +def main(): + N = 1000000 + fs = 8000 + + freqs = [100, 200, 300, 400, 500] + nchans = 7 + + sigs = list() + for fi in freqs: + s = gr.sig_source_c(fs, gr.GR_SIN_WAVE, fi, 1) + sigs.append(s) + + taps = gr.firdes.low_pass_2(len(freqs), fs, fs/float(nchans)/2, 100, 100) + print "Num. Taps = %d (taps per filter = %d)" % (len(taps), + len(taps)/nchans) + filtbank = gr.pfb_synthesis_filterbank_ccf(nchans, taps) + + head = gr.head(gr.sizeof_gr_complex, N) + snk = gr.vector_sink_c() + + tb = gr.top_block() + tb.connect(filtbank, head, snk) + + for i,si in enumerate(sigs): + tb.connect(si, (filtbank, i)) + + tb.run() + + if 1: + f1 = pylab.figure(1) + s1 = f1.add_subplot(1,1,1) + s1.plot(snk.data()[1000:]) + + fftlen = 2048 + f2 = pylab.figure(2) + s2 = f2.add_subplot(1,1,1) + winfunc = scipy.blackman + s2.psd(snk.data()[10000:], NFFT=fftlen, + Fs = nchans*fs, + noverlap=fftlen/4, + window = lambda d: d*winfunc(fftlen)) + + pylab.show() + +if __name__ == "__main__": + main() diff --git a/gnuradio-examples/python/pfb/synth_to_chan.py b/gnuradio-examples/python/pfb/synth_to_chan.py new file mode 100755 index 00000000..1beda1a5 --- /dev/null +++ b/gnuradio-examples/python/pfb/synth_to_chan.py @@ -0,0 +1,105 @@ +#!/usr/bin/env python +# +# Copyright 2010 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, blks2 +import scipy, pylab + +def main(): + N = 1000000 + fs = 8000 + + freqs = [100, 200, 300, 400, 500] + nchans = 7 + + sigs = list() + fmtx = list() + for fi in freqs: + s = gr.sig_source_f(fs, gr.GR_SIN_WAVE, fi, 1) + fm = blks2.nbfm_tx (fs, 4*fs, max_dev=10000, tau=75e-6) + sigs.append(s) + fmtx.append(fm) + + syntaps = gr.firdes.low_pass_2(len(freqs), fs, fs/float(nchans)/2, 100, 100) + print "Synthesis Num. Taps = %d (taps per filter = %d)" % (len(syntaps), + len(syntaps)/nchans) + chtaps = gr.firdes.low_pass_2(len(freqs), fs, fs/float(nchans)/2, 100, 100) + print "Channelizer Num. Taps = %d (taps per filter = %d)" % (len(chtaps), + len(chtaps)/nchans) + filtbank = gr.pfb_synthesis_filterbank_ccf(nchans, syntaps) + channelizer = blks2.pfb_channelizer_ccf(nchans, chtaps) + + noise_level = 0.01 + head = gr.head(gr.sizeof_gr_complex, N) + noise = gr.noise_source_c(gr.GR_GAUSSIAN, noise_level) + addnoise = gr.add_cc() + snk_synth = gr.vector_sink_c() + + tb = gr.top_block() + + tb.connect(noise, (addnoise,0)) + tb.connect(filtbank, head, (addnoise, 1)) + tb.connect(addnoise, channelizer) + tb.connect(addnoise, snk_synth) + + snk = list() + for i,si in enumerate(sigs): + tb.connect(si, fmtx[i], (filtbank, i)) + + for i in xrange(nchans): + snk.append(gr.vector_sink_c()) + tb.connect((channelizer, i), snk[i]) + + tb.run() + + if 1: + channel = 1 + data = snk[channel].data()[1000:] + + f1 = pylab.figure(1) + s1 = f1.add_subplot(1,1,1) + s1.plot(data[10000:10200] ) + s1.set_title(("Output Signal from Channel %d" % channel)) + + fftlen = 2048 + winfunc = scipy.blackman + #winfunc = scipy.hamming + + f2 = pylab.figure(2) + s2 = f2.add_subplot(1,1,1) + s2.psd(data, NFFT=fftlen, + Fs = nchans*fs, + noverlap=fftlen/4, + window = lambda d: d*winfunc(fftlen)) + s2.set_title(("Output PSD from Channel %d" % channel)) + + f3 = pylab.figure(3) + s3 = f3.add_subplot(1,1,1) + s3.psd(snk_synth.data()[1000:], NFFT=fftlen, + Fs = nchans*fs, + noverlap=fftlen/4, + window = lambda d: d*winfunc(fftlen)) + s3.set_title("Output of Synthesis Filter") + + pylab.show() + +if __name__ == "__main__": + main() diff --git a/gr-atsc/src/lib/test_atsci.cc b/gr-atsc/src/lib/test_atsci.cc index 5267e0d4..184895a9 100644 --- a/gr-atsc/src/lib/test_atsci.cc +++ b/gr-atsc/src/lib/test_atsci.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2002,2006 Free Software Foundation, Inc. + * Copyright 2002,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -20,16 +20,23 @@ * Boston, MA 02110-1301, USA. */ +#include #include +#include #include int main (int argc, char **argv) { - - CppUnit::TextTestRunner runner; + char path[200]; + get_unittest_path ("gr_atsc.xml", path, 200); + + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(path); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest (qa_atsc::suite ()); + runner.setOutputter(xmlout); bool was_successful = runner.run ("", false); diff --git a/gr-audio-alsa/src/audio_alsa_sink.cc b/gr-audio-alsa/src/audio_alsa_sink.cc index d6b7f84c..d44a93b3 100644 --- a/gr-audio-alsa/src/audio_alsa_sink.cc +++ b/gr-audio-alsa/src/audio_alsa_sink.cc @@ -90,7 +90,7 @@ audio_alsa_sink::audio_alsa_sink (int sampling_rate, d_period_size (0), d_buffer_size_bytes (0), d_buffer (0), d_worker (0), d_special_case_mono_to_stereo (false), - d_nunderuns (0), d_nsuspends (0) + d_nunderuns (0), d_nsuspends (0), d_ok_to_block(ok_to_block) { CHATTY_DEBUG = gr_prefs::singleton()->get_bool("audio_alsa", "verbose", false); @@ -100,6 +100,8 @@ audio_alsa_sink::audio_alsa_sink (int sampling_rate, // open the device for playback error = snd_pcm_open(&d_pcm_handle, d_device_name.c_str (), SND_PCM_STREAM_PLAYBACK, 0); + if (ok_to_block == false) + snd_pcm_nonblock(d_pcm_handle, !ok_to_block); if (error < 0){ fprintf (stderr, "audio_alsa_sink[%s]: %s\n", d_device_name.c_str(), snd_strerror(error)); @@ -219,9 +221,15 @@ audio_alsa_sink::check_topology (int ninputs, int noutputs) int nchan = ninputs; int err; - // FIXME check_topology may be called more than once. + // Check the state of the stream // Ensure that the pcm is in a state where we can still mess with the hw_params - + snd_pcm_state_t state; + state=snd_pcm_state(d_pcm_handle); + if ( state== SND_PCM_STATE_RUNNING) + return true; // If stream is running, don't change any parameters + else if(state == SND_PCM_STATE_XRUN ) + snd_pcm_prepare ( d_pcm_handle ); // Prepare stream on underrun, and we can set parameters; + bool special_case = nchan == 1 && d_special_case_mono_to_stereo; if (special_case) nchan = 2; @@ -287,7 +295,6 @@ audio_alsa_sink::check_topology (int ninputs, int noutputs) default: assert (0); } - return true; } @@ -489,7 +496,12 @@ audio_alsa_sink::write_buffer (const void *vbuffer, while (nframes > 0){ int r = snd_pcm_writei (d_pcm_handle, buffer, nframes); if (r == -EAGAIN) - continue; // try again + { + if (d_ok_to_block == true) + continue; // try again + + break; + } else if (r == -EPIPE){ // underrun d_nunderuns++; diff --git a/gr-audio-alsa/src/audio_alsa_sink.h b/gr-audio-alsa/src/audio_alsa_sink.h index d4b54038..f3007f60 100644 --- a/gr-audio-alsa/src/audio_alsa_sink.h +++ b/gr-audio-alsa/src/audio_alsa_sink.h @@ -83,6 +83,7 @@ class audio_alsa_sink : public gr_sync_block { // random stats int d_nunderuns; // count of underruns int d_nsuspends; // count of suspends + bool d_ok_to_block; // defaults to "true", controls blocking/non-block I/O void output_error_msg (const char *msg, int err); void bail (const char *msg, int err) throw (std::runtime_error); diff --git a/gr-audio-alsa/src/qa_alsa.py b/gr-audio-alsa/src/qa_alsa.py index f2a480a5..52dbfdc7 100755 --- a/gr-audio-alsa/src/qa_alsa.py +++ b/gr-audio-alsa/src/qa_alsa.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2007 Free Software Foundation, Inc. +# Copyright 2005,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import audio_alsa -class qa_alsa (gr_unittest.TestCase): +class test_audio_alsa (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -37,4 +37,4 @@ class qa_alsa (gr_unittest.TestCase): pass if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_audio_alsa, "test_audio_alsa.xml") diff --git a/gr-audio-jack/src/audio_jack_sink.cc b/gr-audio-jack/src/audio_jack_sink.cc index 6e39135c..f28fddc3 100644 --- a/gr-audio-jack/src/audio_jack_sink.cc +++ b/gr-audio-jack/src/audio_jack_sink.cc @@ -105,12 +105,17 @@ audio_jack_sink::audio_jack_sink (int sampling_rate, d_nunderuns (0) { #ifndef NO_PTHREAD - pthread_cond_init(&d_ringbuffer_ready, NULL);; - pthread_mutex_init(&d_jack_process_lock, NULL); + pthread_cond_init(&d_ringbuffer_ready, NULL);; + pthread_mutex_init(&d_jack_process_lock, NULL); #endif - + // try to become a client of the JACK server - if ((d_jack_client = jack_client_new (d_device_name.c_str ())) == 0) { + jack_options_t options = JackNullOption; + jack_status_t status; + const char *server_name = NULL; + if ((d_jack_client = jack_client_open (d_device_name.c_str (), + options, &status, + server_name)) == NULL) { fprintf (stderr, "audio_jack_sink[%s]: jack server not running?\n", d_device_name.c_str()); throw std::runtime_error ("audio_jack_sink"); diff --git a/gr-audio-jack/src/audio_jack_source.cc b/gr-audio-jack/src/audio_jack_source.cc index ca3df51d..a92e970f 100644 --- a/gr-audio-jack/src/audio_jack_source.cc +++ b/gr-audio-jack/src/audio_jack_source.cc @@ -110,7 +110,12 @@ audio_jack_source::audio_jack_source (int sampling_rate, #endif // try to become a client of the JACK server - if ((d_jack_client = jack_client_new (d_device_name.c_str ())) == 0) { + jack_options_t options = JackNullOption; + jack_status_t status; + const char *server_name = NULL; + if ((d_jack_client = jack_client_open (d_device_name.c_str (), + options, &status, + server_name)) == NULL) { fprintf (stderr, "audio_jack_source[%s]: jack server not running?\n", d_device_name.c_str()); throw std::runtime_error ("audio_jack_source"); diff --git a/gr-audio-jack/src/qa_jack.py b/gr-audio-jack/src/qa_jack.py index d8a3aba8..ad6bee27 100755 --- a/gr-audio-jack/src/qa_jack.py +++ b/gr-audio-jack/src/qa_jack.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005 Free Software Foundation, Inc. +# Copyright 2005,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import audio_jack -class qa_jack (gr_unittest.TestCase): +class test_audio_jack (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -37,4 +37,4 @@ class qa_jack (gr_unittest.TestCase): pass if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_audio_jack, "test_audio_jack.xml") diff --git a/gr-audio-oss/src/qa_oss.py b/gr-audio-oss/src/qa_oss.py index 5427b50e..365dabc2 100755 --- a/gr-audio-oss/src/qa_oss.py +++ b/gr-audio-oss/src/qa_oss.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005,2007 Free Software Foundation, Inc. +# Copyright 2005,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import audio_oss -class qa_oss (gr_unittest.TestCase): +class test_audio_oss (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -37,4 +37,4 @@ class qa_oss (gr_unittest.TestCase): pass if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_audio_oss, "test_audio_oss.xml") diff --git a/gr-audio-portaudio/src/audio_portaudio_sink.cc b/gr-audio-portaudio/src/audio_portaudio_sink.cc index 9a3baf40..64e64ccf 100644 --- a/gr-audio-portaudio/src/audio_portaudio_sink.cc +++ b/gr-audio-portaudio/src/audio_portaudio_sink.cc @@ -102,7 +102,10 @@ portaudio_sink_callback (const void *inputBuffer, else { // underrun self->d_nunderuns++; - ::write(2, "aU", 2); // FIXME change to non-blocking call + ssize_t r = ::write(2, "aU", 2); // FIXME change to non-blocking call + if(r == -1) { + perror("audio_portaudio_source::portaudio_source_callback write error to stderr."); + } // FIXME we should transfer what we've got and pad the rest memset(outputBuffer, 0, nreqd_samples * sizeof(sample_t)); diff --git a/gr-audio-portaudio/src/audio_portaudio_source.cc b/gr-audio-portaudio/src/audio_portaudio_source.cc index 23801a8b..e508fda2 100644 --- a/gr-audio-portaudio/src/audio_portaudio_source.cc +++ b/gr-audio-portaudio/src/audio_portaudio_source.cc @@ -105,7 +105,10 @@ portaudio_source_callback (const void *inputBuffer, else { // overrun self->d_noverruns++; - ::write(2, "aO", 2); // FIXME change to non-blocking call + ssize_t r = ::write(2, "aO", 2); // FIXME change to non-blocking call + if(r == -1) { + perror("audio_portaudio_source::portaudio_source_callback write error to stderr."); + } self->d_ringbuffer_ready = false; self->d_ringbuffer_cond.notify_one(); // Tell the sink to get going! diff --git a/gr-audio-portaudio/src/qa_portaudio.py b/gr-audio-portaudio/src/qa_portaudio.py index f6a54061..20731f38 100755 --- a/gr-audio-portaudio/src/qa_portaudio.py +++ b/gr-audio-portaudio/src/qa_portaudio.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2005 Free Software Foundation, Inc. +# Copyright 2005,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import audio_portaudio -class qa_portaudio (gr_unittest.TestCase): +class test_audio_portaudio (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -37,4 +37,4 @@ class qa_portaudio (gr_unittest.TestCase): pass if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_audio_portaudio, "test_audio_portaudio.xml") diff --git a/gr-cvsd-vocoder/src/python/qa_cvsd_vocoder.py b/gr-cvsd-vocoder/src/python/qa_cvsd_vocoder.py index 1a39f636..99a38d94 100755 --- a/gr-cvsd-vocoder/src/python/qa_cvsd_vocoder.py +++ b/gr-cvsd-vocoder/src/python/qa_cvsd_vocoder.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2007 Free Software Foundation, Inc. +# Copyright 2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest, blks2 import cvsd_vocoder -class qa_cvsd_test (gr_unittest.TestCase): +class test_cvsd_vocoder (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block() @@ -112,4 +112,4 @@ class qa_cvsd_test (gr_unittest.TestCase): """ if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_cvsd_vocoder, "test_cvsd_vocoder.xml") diff --git a/gr-gcell/src/Makefile.am b/gr-gcell/src/Makefile.am index 63dc156b..60ec6cc7 100644 --- a/gr-gcell/src/Makefile.am +++ b/gr-gcell/src/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2008,2009 Free Software Foundation, Inc. +# Copyright 2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,7 +22,7 @@ include $(top_srcdir)/Makefile.common SUBDIRS = . examples -AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(GCELL_INCLUDES) \ +AM_CPPFLAGS = $(GCELL_INCLUDES) $(STD_DEFINES_AND_INCLUDES) \ $(PYTHON_CPPFLAGS) $(WITH_INCLUDES) # ---------------------------------------------------------------- diff --git a/gr-gsm-fr-vocoder/src/python/qa_gsm_full_rate.py b/gr-gsm-fr-vocoder/src/python/qa_gsm_full_rate.py index ac508407..4164a196 100755 --- a/gr-gsm-fr-vocoder/src/python/qa_gsm_full_rate.py +++ b/gr-gsm-fr-vocoder/src/python/qa_gsm_full_rate.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2007 Free Software Foundation, Inc. +# Copyright 2004,2007,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import gsm_full_rate -class qa_howto (gr_unittest.TestCase): +class test_gsm_vocoder (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -32,4 +32,4 @@ class qa_howto (gr_unittest.TestCase): self.tb = None if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_gsm_vocoder, "test_gsm_vocoder.xml") diff --git a/gr-howto-write-a-block/lib/test_all.cc b/gr-howto-write-a-block/lib/test_all.cc index 192c537b..ac1e8383 100644 --- a/gr-howto-write-a-block/lib/test_all.cc +++ b/gr-howto-write-a-block/lib/test_all.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Free Software Foundation, Inc. + * Copyright 2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,16 +21,23 @@ */ #include +#include +#include #include int main (int argc, char **argv) { - + char path[200]; + get_unittest_path ("gr_howto_write_a_block.xml", path, 200); + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(path); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest(qa_howto::suite ()); + runner.setOutputter(xmlout); bool was_successful = runner.run("", false); diff --git a/gr-msdd6000/src/msdd_rs_source_simple.cc b/gr-msdd6000/src/msdd_rs_source_simple.cc index c44808f5..70e692d8 100644 --- a/gr-msdd6000/src/msdd_rs_source_simple.cc +++ b/gr-msdd6000/src/msdd_rs_source_simple.cc @@ -64,7 +64,10 @@ msdd_rs_source_simple::work (int noutput_items, /* Read a buffer out -- looking at UDP payload at this point.*/ rcv->read( &buffer[0], BUF_LEN ); - int seq = *((int*) &buffer[2]); + //int seq = *((int*) &buffer[2]); + int seq; + memcpy(&seq, &buffer[2], 4*sizeof(char)); + char type = buffer[0]; //printf("Sequence %d\n",seq); diff --git a/gr-msdd6000/src/msdd_source_simple.cc b/gr-msdd6000/src/msdd_source_simple.cc index 076a305f..20b15c43 100644 --- a/gr-msdd6000/src/msdd_source_simple.cc +++ b/gr-msdd6000/src/msdd_source_simple.cc @@ -64,7 +64,9 @@ msdd_source_simple::work (int noutput_items, char buffer[BUF_LEN]; rcv->read( &buffer[0], BUF_LEN ); - int seq = *((int*) &buffer[2]); + //int seq = *((int*) &buffer[2]); + int seq; + memcpy(&seq, &buffer[2], 4*sizeof(char)); if(d_lastseq == -MSDD_COMPLEX_SAMPLES_PER_PACKET){ // not started case diff --git a/gr-noaa/swig/Makefile.am b/gr-noaa/swig/Makefile.am index 73645e92..410b23fe 100644 --- a/gr-noaa/swig/Makefile.am +++ b/gr-noaa/swig/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2004,2005,2006,2008,2009 Free Software Foundation, Inc. +# Copyright 2004,2005,2006,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,10 +22,10 @@ include $(top_srcdir)/Makefile.common AM_CPPFLAGS = \ + -I$(top_srcdir)/gr-noaa/lib \ $(STD_DEFINES_AND_INCLUDES) \ $(PYTHON_CPPFLAGS) \ - $(WITH_INCLUDES) \ - -I$(top_srcdir)/gr-noaa/lib + $(WITH_INCLUDES) if PYTHON # ---------------------------------------------------------------- diff --git a/gr-pager/python/qa_pager.py b/gr-pager/python/qa_pager.py index 5bf72b56..12a45d4c 100755 --- a/gr-pager/python/qa_pager.py +++ b/gr-pager/python/qa_pager.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2006 Free Software Foundation, Inc. +# Copyright 2004,2006,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import pager_swig -class qa_pgr(gr_unittest.TestCase): +class test_pager(gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -32,4 +32,4 @@ class qa_pgr(gr_unittest.TestCase): self.tb = None if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_pager, "test_pager.xml") diff --git a/gr-pager/swig/Makefile.am b/gr-pager/swig/Makefile.am index 9e1a4521..c59bdb0f 100644 --- a/gr-pager/swig/Makefile.am +++ b/gr-pager/swig/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2004,2005,2006,2008,2009 Free Software Foundation, Inc. +# Copyright 2004,2005,2006,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,10 +22,10 @@ include $(top_srcdir)/Makefile.common AM_CPPFLAGS = \ + -I$(top_srcdir)/gr-pager/lib \ $(STD_DEFINES_AND_INCLUDES) \ $(PYTHON_CPPFLAGS) \ - $(WITH_INCLUDES) \ - -I$(top_srcdir)/gr-pager/lib + $(WITH_INCLUDES) ############################## # SWIG interface and library diff --git a/gr-qtgui/src/lib/Makefile.am b/gr-qtgui/src/lib/Makefile.am index 4ba637ad..1ee3c8e3 100644 --- a/gr-qtgui/src/lib/Makefile.am +++ b/gr-qtgui/src/lib/Makefile.am @@ -21,8 +21,8 @@ include $(top_srcdir)/Makefile.common -AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ - $(QT_INCLUDES) -I. $(WITH_INCLUDES) +AM_CPPFLAGS = -I. $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ + $(QT_INCLUDES) $(WITH_INCLUDES) # Only include these files in the build if qtgui passes configure checks # This is mostly to help make distcheck pass diff --git a/gr-qtgui/src/lib/highResTimeFunctions.h b/gr-qtgui/src/lib/highResTimeFunctions.h index b85b1aca..251bbad8 100644 --- a/gr-qtgui/src/lib/highResTimeFunctions.h +++ b/gr-qtgui/src/lib/highResTimeFunctions.h @@ -8,41 +8,74 @@ static const long NSEC_PER_SEC = 1000000000L; -static inline bool timespec_greater(const struct timespec* t1, const struct timespec* t0){ - return ((t1->tv_sec > t0->tv_sec) || ((t1->tv_sec == t0->tv_sec) && (t1->tv_nsec > t0->tv_nsec))); +static inline bool +timespec_greater(const struct timespec* t1, + const struct timespec* t0) +{ + return ((t1->tv_sec > t0->tv_sec) || + ((t1->tv_sec == t0->tv_sec) && + (t1->tv_nsec > t0->tv_nsec))); } -static inline bool timespec_greater(const struct timespec t1, const struct timespec t0){ - return ((t1.tv_sec > t0.tv_sec) || ((t1.tv_sec == t0.tv_sec) && (t1.tv_nsec > t0.tv_nsec))); +static inline bool +timespec_greater(const struct timespec t1, + const struct timespec t0) +{ + return ((t1.tv_sec > t0.tv_sec) || + ((t1.tv_sec == t0.tv_sec) && + (t1.tv_nsec > t0.tv_nsec))); } -static inline bool timespec_less(const struct timespec* t1, const struct timespec* t0){ - return ((t1->tv_sec < t0->tv_sec) || ((t1->tv_sec == t0->tv_sec) && (t1->tv_nsec < t0->tv_nsec))); +static inline bool +timespec_less(const struct timespec* t1, + const struct timespec* t0) +{ + return ((t1->tv_sec < t0->tv_sec) || + ((t1->tv_sec == t0->tv_sec) && + (t1->tv_nsec < t0->tv_nsec))); } -static inline bool timespec_less(const struct timespec t1, const struct timespec t0){ - return ((t1.tv_sec < t0.tv_sec) || ((t1.tv_sec == t0.tv_sec) && (t1.tv_nsec < t0.tv_nsec))); +static inline bool +timespec_less(const struct timespec t1, + const struct timespec t0) +{ + return ((t1.tv_sec < t0.tv_sec) || + ((t1.tv_sec == t0.tv_sec) && + (t1.tv_nsec < t0.tv_nsec))); } -static inline bool timespec_equal(const struct timespec* t1, const struct timespec* t0){ - return ((t1->tv_sec == t0->tv_sec) && (t1->tv_nsec == t0->tv_nsec)); +static inline bool +timespec_equal(const struct timespec* t1, + const struct timespec* t0) +{ + return ((t1->tv_sec == t0->tv_sec) && + (t1->tv_nsec == t0->tv_nsec)); } -static inline bool timespec_equal(const struct timespec t1, const struct timespec t0){ - return ((t1.tv_sec == t0.tv_sec) && (t1.tv_nsec == t0.tv_nsec)); +static inline bool +timespec_equal(const struct timespec t1, + const struct timespec t0) +{ + return ((t1.tv_sec == t0.tv_sec) && + (t1.tv_nsec == t0.tv_nsec)); } -static inline void timespec_reset(struct timespec* ret){ +static inline void +timespec_reset(struct timespec* ret) +{ ret->tv_sec = 0; ret->tv_nsec = 0; } -static inline void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec){ - while (nsec > NSEC_PER_SEC){ +static inline void +set_normalized_timespec(struct timespec *ts, + time_t sec, long nsec) +{ + while (nsec > NSEC_PER_SEC) { nsec -= NSEC_PER_SEC; ++sec; } - while(nsec < 0){ + while(nsec < 0) { nsec += NSEC_PER_SEC; --sec; } @@ -50,10 +83,13 @@ static inline void set_normalized_timespec(struct timespec *ts, time_t sec, long ts->tv_nsec = nsec; } -static inline struct timespec convert_to_timespec(const double timeValue){ +static inline struct timespec +convert_to_timespec(const double timeValue) +{ struct timespec ret; double seconds = 0; - long nsec = static_cast(modf(timeValue, &seconds) * static_cast(NSEC_PER_SEC)); + long nsec = static_cast(modf(timeValue, &seconds) * + static_cast(NSEC_PER_SEC)); time_t sec = static_cast(seconds); set_normalized_timespec(&ret, sec, nsec); @@ -61,28 +97,46 @@ static inline struct timespec convert_to_timespec(const double timeValue){ return ret; } -static inline double convert_from_timespec(const timespec actual){ - return (static_cast(actual.tv_sec) + (static_cast(actual.tv_nsec) / static_cast(NSEC_PER_SEC))); +static inline double +convert_from_timespec(const timespec actual) +{ + return (static_cast(actual.tv_sec) + + (static_cast(actual.tv_nsec) / + static_cast(NSEC_PER_SEC))); } -static inline void timespec_add(struct timespec *ret, const struct timespec* t1, const struct timespec* t0){ +static inline void +timespec_add(struct timespec *ret, + const struct timespec* t1, + const struct timespec* t0) +{ time_t sec = t1->tv_sec + t0->tv_sec; long nsec = t1->tv_nsec + t0->tv_nsec; set_normalized_timespec(ret, sec, nsec); } -static inline void timespec_add(struct timespec *ret, const struct timespec t1, const struct timespec t0){ +static inline void +timespec_add(struct timespec *ret, + const struct timespec t1, + const struct timespec t0) +{ return timespec_add(ret, &t1, &t0); } -static inline struct timespec timespec_add(const struct timespec t1, const struct timespec t0){ +static inline struct timespec +timespec_add(const struct timespec t1, + const struct timespec t0) +{ struct timespec ret; timespec_add(&ret, &t1, &t0); return ret; } -static inline struct timespec timespec_add(const struct timespec t1, const double time0){ +static inline struct timespec +timespec_add(const struct timespec t1, + const double time0) +{ struct timespec ret; struct timespec t0; t0 = convert_to_timespec(time0); @@ -92,24 +146,38 @@ static inline struct timespec timespec_add(const struct timespec t1, const doubl return ret; } -static inline void timespec_subtract(struct timespec *ret, const struct timespec* t1, const struct timespec* t0){ +static inline void +timespec_subtract(struct timespec *ret, + const struct timespec* t1, + const struct timespec* t0) +{ time_t sec = t1->tv_sec - t0->tv_sec; long nsec = t1->tv_nsec - t0->tv_nsec; set_normalized_timespec(ret, sec, nsec); } -static inline void timespec_subtract(struct timespec *ret, const struct timespec t1, const struct timespec t0){ +static inline void +timespec_subtract(struct timespec *ret, + const struct timespec t1, + const struct timespec t0) +{ return timespec_subtract(ret, &t1, &t0); } -static inline struct timespec timespec_subtract(const struct timespec t1, const struct timespec t0){ +static inline struct timespec +timespec_subtract(const struct timespec t1, + const struct timespec t0) +{ struct timespec ret; timespec_subtract(&ret, &t1, &t0); return ret; } -static inline struct timespec timespec_subtract(const struct timespec t1, const double time0){ +static inline struct timespec +timespec_subtract(const struct timespec t1, + const double time0) +{ struct timespec ret; struct timespec t0; t0 = convert_to_timespec(time0); @@ -119,7 +187,11 @@ static inline struct timespec timespec_subtract(const struct timespec t1, const return ret; } -static inline double diff_timespec(struct timespec* ret, const struct timespec *t1, const struct timespec* t0){ +static inline double +diff_timespec(struct timespec* ret, + const struct timespec *t1, + const struct timespec* t0) +{ struct timespec actual; time_t sec = 0; long nsec = 0; @@ -141,7 +213,8 @@ static inline double diff_timespec(struct timespec* ret, const struct timespec * sec = t0->tv_sec - t1->tv_sec; nsec = t0->tv_nsec - t1->tv_nsec; - // Do nothing with the ret value as the ret value would have to store a negative, which it can't. + // Do nothing with the ret value as the ret value + // would have to store a negative, which it can't. set_normalized_timespec(&actual, sec, nsec); @@ -149,23 +222,39 @@ static inline double diff_timespec(struct timespec* ret, const struct timespec * } } -static inline double diff_timespec(struct timespec* ret, const struct timespec t1, const struct timespec t0){ +static inline double +diff_timespec(struct timespec* ret, + const struct timespec t1, + const struct timespec t0) +{ return diff_timespec(ret, &t1, &t0); } -static inline double diff_timespec(const struct timespec t1, const struct timespec t0){ +static inline double +diff_timespec(const struct timespec t1, + const struct timespec t0) +{ return diff_timespec(NULL, &t1, &t0); } -static inline double diff_timespec(const struct timespec* t1, const struct timespec* t0){ +static inline double +diff_timespec(const struct timespec* t1, + const struct timespec* t0) +{ return diff_timespec(NULL, t1, t0); } -static inline void get_highres_clock(struct timespec* ret){ +#ifdef CLOCK_REALTIME +// If we can use clock_gettime, use it; +// otherwise, use gettimeofday +static inline void +get_highres_clock(struct timespec* ret) +{ if(clock_gettime(CLOCK_REALTIME, ret) != 0){ - // Unable to get high resolution time - fail over to low resolution time + // Unable to get high resolution time - + // fail over to low resolution time timeval lowResTime; gettimeofday(&lowResTime, NULL); ret->tv_sec = lowResTime.tv_sec; @@ -173,17 +262,37 @@ static inline void get_highres_clock(struct timespec* ret){ } } -static inline struct timespec get_highres_clock(){ +#else + +// Trick timer functions into thinking it has an nsec timer +// but only use the low resolution (usec) timer. +static inline void +get_highres_clock(struct timespec* ret) +{ + timeval lowResTime; + gettimeofday(&lowResTime, NULL); + ret->tv_sec = lowResTime.tv_sec; + ret->tv_nsec = lowResTime.tv_usec*1000; +} +#endif + +static inline struct timespec +get_highres_clock() +{ struct timespec ret; get_highres_clock(&ret); return ret; } -static inline bool timespec_empty(const struct timespec* ret){ +static inline bool +timespec_empty(const struct timespec* ret) +{ return ( (ret->tv_sec == 0 ) && (ret->tv_nsec == 0) ); } -static inline bool timespec_empty(const struct timespec ret){ +static inline bool +timespec_empty(const struct timespec ret) +{ return timespec_empty(&ret); } diff --git a/gr-radio-astronomy/src/python/qa_ra.py b/gr-radio-astronomy/src/python/qa_ra.py index 1c44e23a..2cb0f42b 100755 --- a/gr-radio-astronomy/src/python/qa_ra.py +++ b/gr-radio-astronomy/src/python/qa_ra.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2004,2006 Free Software Foundation, Inc. +# Copyright 2004,2006,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import ra -class qa_ra (gr_unittest.TestCase): +class test_radio_astronomy (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -35,4 +35,4 @@ class qa_ra (gr_unittest.TestCase): pass if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_radio_astronomy, "test_radio_astronomy.xml") diff --git a/gr-trellis/src/lib/fsm.cc b/gr-trellis/src/lib/fsm.cc index c65b1345..5950b56b 100644 --- a/gr-trellis/src/lib/fsm.cc +++ b/gr-trellis/src/lib/fsm.cc @@ -86,16 +86,30 @@ fsm::fsm(const char *name) if((fsmfile=fopen(name,"r"))==NULL) throw std::runtime_error ("fsm::fsm(const char *name): file open error\n"); //printf("file open error in fsm()\n"); + + if(fscanf(fsmfile,"%d %d %d\n",&d_I,&d_S,&d_O) == EOF) { + if(ferror(fsmfile) != 0) + throw std::runtime_error ("fsm::fsm(const char *name): file read error\n"); + } - fscanf(fsmfile,"%d %d %d\n",&d_I,&d_S,&d_O); d_NS.resize(d_I*d_S); d_OS.resize(d_I*d_S); for(int i=0;i %include +%include %template(uint32_t_vector) std::vector; @@ -163,6 +164,7 @@ public: bool write_gpio(uint16_t value, uint16_t mask); %rename(_real_read_gpio) read_gpio; bool read_gpio(uint16_t *value); + bool start_streaming_at(usrp2::fpga_timestamp time); }; // ---------------------------------------------------------------- diff --git a/gr-usrp2/src/usrp2_sink_16sc.cc b/gr-usrp2/src/usrp2_sink_16sc.cc index 1e7c54dc..75cc1f4a 100644 --- a/gr-usrp2/src/usrp2_sink_16sc.cc +++ b/gr-usrp2/src/usrp2_sink_16sc.cc @@ -67,12 +67,20 @@ usrp2_sink_16sc::work(int noutput_items, return 0; usrp2::tx_metadata metadata; - metadata.timestamp = -1; - metadata.send_now = 1; + + // Set TX metadata to either start time or now + if (d_should_wait == true) { + metadata.timestamp = d_tx_time; + metadata.send_now = 0; + d_should_wait = false; + } + else { + 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); + bool ok = d_u2->tx_16sc(0, in, noutput_items, &metadata); if (!ok){ std::cerr << "usrp2_sink_16sc: tx_16sc failed" << std::endl; return -1; // say we're done diff --git a/gr-usrp2/src/usrp2_sink_32fc.cc b/gr-usrp2/src/usrp2_sink_32fc.cc index b1e28a82..fa75b380 100644 --- a/gr-usrp2/src/usrp2_sink_32fc.cc +++ b/gr-usrp2/src/usrp2_sink_32fc.cc @@ -67,12 +67,20 @@ usrp2_sink_32fc::work(int noutput_items, return 0; usrp2::tx_metadata metadata; - metadata.timestamp = -1; - metadata.send_now = 1; + + // Set TX metadata to either start time or now + if (d_should_wait == true) { + metadata.timestamp = d_tx_time; + metadata.send_now = 0; + d_should_wait = false; + } + else { + 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); + bool ok = d_u2->tx_32fc(0, in, noutput_items, &metadata); if (!ok){ std::cerr << "usrp2_sink_32fc: tx_32fc failed" << std::endl; return -1; // say we're done diff --git a/gr-usrp2/src/usrp2_sink_base.cc b/gr-usrp2/src/usrp2_sink_base.cc index ce473f23..c9b34a54 100644 --- a/gr-usrp2/src/usrp2_sink_base.cc +++ b/gr-usrp2/src/usrp2_sink_base.cc @@ -36,7 +36,9 @@ usrp2_sink_base::usrp2_sink_base(const char *name, : usrp2_base(name, input_signature, gr_make_io_signature(0, 0, 0), - ifc, mac) + ifc, mac), + d_should_wait(false), + d_tx_time(0) { // NOP } @@ -155,3 +157,10 @@ bool usrp2_sink_base::read_gpio(uint16_t *value) { return d_u2->read_gpio(usrp2::GPIO_TX_BANK, value); } + +bool usrp2_sink_base::start_streaming_at(usrp2::fpga_timestamp time) +{ + d_should_wait = true; + d_tx_time = time; + return true; +} diff --git a/gr-usrp2/src/usrp2_sink_base.h b/gr-usrp2/src/usrp2_sink_base.h index 38dc4f23..d831d4df 100644 --- a/gr-usrp2/src/usrp2_sink_base.h +++ b/gr-usrp2/src/usrp2_sink_base.h @@ -37,6 +37,9 @@ protected: const std::string &mac) throw (std::runtime_error); + bool d_should_wait; + usrp2::fpga_timestamp d_tx_time; + public: ~usrp2_sink_base(); @@ -139,6 +142,11 @@ public: * \brief Read daughterboard GPIO pin values */ bool read_gpio(uint16_t *value); + + /*! + * \brief First samples begin streaming to USRP2 at given time + */ + bool start_streaming_at(usrp2::fpga_timestamp time); }; #endif /* INCLUDED_USRP2_SINK_BASE_H */ diff --git a/gr-video-sdl/src/qa_video_sdl.py b/gr-video-sdl/src/qa_video_sdl.py index 98da85f6..8f82a60b 100755 --- a/gr-video-sdl/src/qa_video_sdl.py +++ b/gr-video-sdl/src/qa_video_sdl.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2006 Free Software Foundation, Inc. +# Copyright 2006,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import video_sdl -class qa_video_sdl (gr_unittest.TestCase): +class test_video_sdl (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -37,4 +37,4 @@ class qa_video_sdl (gr_unittest.TestCase): pass if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_video_sdl, "test_video_sdl.xml") diff --git a/gr-wxgui/src/python/common.py b/gr-wxgui/src/python/common.py index 17a7dc0d..3641ae64 100644 --- a/gr-wxgui/src/python/common.py +++ b/gr-wxgui/src/python/common.py @@ -25,6 +25,8 @@ import wx from gnuradio import gr +RUN_ALWAYS = gr.prefs().get_bool ('wxgui', 'run_always', False) + class wxgui_hb(object): """ The wxgui hier block helper/wrapper class: @@ -47,7 +49,10 @@ class wxgui_hb(object): assert points[0] == self or points[0][0] == self copy = gr.copy(self._hb.input_signature().sizeof_stream_item(0)) handler = self._handler_factory(copy.set_enabled) - handler(False) #initially disable the copy block + if RUN_ALWAYS == False: + handler(False) #initially disable the copy block + else: + handler(True) #initially enable the copy block self._bind_to_visible_event(win=self.win, handler=handler) points = list(points) points.insert(1, copy) #insert the copy block into the chain @@ -67,7 +72,10 @@ class wxgui_hb(object): if cache[0] == visible: return cache[0] = visible #print visible, handler - handler(visible) + if RUN_ALWAYS == False: + handler(visible) + else: + handler(True) return callback @staticmethod diff --git a/gr-wxgui/src/python/constants.py b/gr-wxgui/src/python/constants.py index 9612f36d..070be080 100644 --- a/gr-wxgui/src/python/constants.py +++ b/gr-wxgui/src/python/constants.py @@ -66,6 +66,7 @@ X_PER_DIV_KEY = 'x_per_div' Y_DIVS_KEY = 'y_divs' Y_OFF_KEY = 'y_off' Y_PER_DIV_KEY = 'y_per_div' +Y_AXIS_LABEL = 'y_axis_label' MAXIMUM_KEY = 'maximum' MINIMUM_KEY = 'minimum' NUM_BINS_KEY = 'num_bins' diff --git a/gr-wxgui/src/python/scope_window.py b/gr-wxgui/src/python/scope_window.py index c03b71f1..89a808ce 100644 --- a/gr-wxgui/src/python/scope_window.py +++ b/gr-wxgui/src/python/scope_window.py @@ -38,6 +38,7 @@ import forms DEFAULT_FRAME_RATE = gr.prefs().get_long('wxgui', 'scope_rate', 30) PERSIST_ALPHA_MIN_EXP, PERSIST_ALPHA_MAX_EXP = -2, 0 SLIDER_STEPS = 100 +DEFAULT_TRIG_MODE = gr.prefs().get_long('wxgui', 'trig_mode', gr.gr_TRIG_MODE_AUTO) DEFAULT_WIN_SIZE = (600, 300) COUPLING_MODES = ( ('DC', False), @@ -47,6 +48,7 @@ TRIGGER_MODES = ( ('Freerun', gr.gr_TRIG_MODE_FREE), ('Auto', gr.gr_TRIG_MODE_AUTO), ('Normal', gr.gr_TRIG_MODE_NORM), + ('Stripchart', gr.gr_TRIG_MODE_STRIPCHART), ) TRIGGER_SLOPES = ( ('Pos +', gr.gr_TRIG_SLOPE_POS), @@ -432,6 +434,8 @@ class scope_window(wx.Panel, pubsub.pubsub): msg_key, use_persistence, persist_alpha, + trig_mode, + y_axis_label, ): pubsub.pubsub.__init__(self) #check num inputs @@ -468,14 +472,20 @@ class scope_window(wx.Panel, pubsub.pubsub): self[T_DIVS_KEY] = 8 self[X_DIVS_KEY] = 8 self[Y_DIVS_KEY] = 8 + self[Y_AXIS_LABEL] = y_axis_label self[FRAME_RATE_KEY] = frame_rate self[TRIGGER_LEVEL_KEY] = 0 self[TRIGGER_CHANNEL_KEY] = 0 - self[TRIGGER_MODE_KEY] = gr.gr_TRIG_MODE_AUTO + self[TRIGGER_MODE_KEY] = trig_mode + self[TRIGGER_SLOPE_KEY] = gr.gr_TRIG_SLOPE_POS self[T_FRAC_OFF_KEY] = 0.5 self[USE_PERSISTENCE_KEY] = use_persistence self[PERSIST_ALPHA_KEY] = persist_alpha + + if self[TRIGGER_MODE_KEY] == gr.gr_TRIG_MODE_STRIPCHART: + self[T_FRAC_OFF_KEY] = 0.0 + for i in range(num_inputs): self.proxy(common.index_key(AC_COUPLE_KEY, i), controller, common.index_key(ac_couple_key, i)) #init panel and plot @@ -668,7 +678,7 @@ class scope_window(wx.Panel, pubsub.pubsub): self.plotter.set_x_label('Time', 's') self.plotter.set_x_grid(self.get_t_min(), self.get_t_max(), self[T_PER_DIV_KEY], True) #update the y axis - self.plotter.set_y_label('Counts') + self.plotter.set_y_label(self[Y_AXIS_LABEL]) self.plotter.set_y_grid(self.get_y_min(), self.get_y_max(), self[Y_PER_DIV_KEY]) #redraw current sample self.handle_samples() diff --git a/gr-wxgui/src/python/scopesink_gl.py b/gr-wxgui/src/python/scopesink_gl.py index ebf9b293..5ae89740 100644 --- a/gr-wxgui/src/python/scopesink_gl.py +++ b/gr-wxgui/src/python/scopesink_gl.py @@ -76,6 +76,8 @@ class _scope_sink_base(gr.hier_block2, common.wxgui_hb): xy_mode=False, ac_couple=False, num_inputs=1, + trig_mode=scope_window.DEFAULT_TRIG_MODE, + y_axis_label='Counts', frame_rate=scope_window.DEFAULT_FRAME_RATE, use_persistence=False, persist_alpha=None, @@ -132,6 +134,8 @@ class _scope_sink_base(gr.hier_block2, common.wxgui_hb): v_scale=v_scale, v_offset=v_offset, xy_mode=xy_mode, + trig_mode=trig_mode, + y_axis_label=y_axis_label, ac_couple_key=AC_COUPLE_KEY, trigger_level_key=TRIGGER_LEVEL_KEY, trigger_mode_key=TRIGGER_MODE_KEY, diff --git a/gr-wxgui/src/python/waterfall_window.py b/gr-wxgui/src/python/waterfall_window.py index b7904e4d..6536ada1 100644 --- a/gr-wxgui/src/python/waterfall_window.py +++ b/gr-wxgui/src/python/waterfall_window.py @@ -38,6 +38,7 @@ import forms SLIDER_STEPS = 100 AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP = -3, 0 DEFAULT_FRAME_RATE = gr.prefs().get_long('wxgui', 'waterfall_rate', 30) +DEFAULT_COLOR_MODE = gr.prefs().get_string('wxgui', 'waterfall_color', 'rgb1') DEFAULT_WIN_SIZE = (600, 300) DIV_LEVELS = (1, 2, 5, 10, 20) MIN_DYNAMIC_RANGE, MAX_DYNAMIC_RANGE = 10, 200 @@ -156,6 +157,9 @@ class control_panel(wx.Panel): def _on_incr_time_scale(self, event): old_rate = self.parent[FRAME_RATE_KEY] self.parent[FRAME_RATE_KEY] *= 0.75 + if self.parent[FRAME_RATE_KEY] < 1.0: + self.parent[FRAME_RATE_KEY] = 1.0 + if self.parent[FRAME_RATE_KEY] == old_rate: self.parent[DECIMATION_KEY] += 1 def _on_decr_time_scale(self, event): @@ -217,6 +221,7 @@ class waterfall_window(wx.Panel, pubsub.pubsub): self[REF_LEVEL_KEY] = ref_level self[BASEBAND_FREQ_KEY] = baseband_freq self[COLOR_MODE_KEY] = COLOR_MODES[0][1] + self[COLOR_MODE_KEY] = DEFAULT_COLOR_MODE self[RUNNING_KEY] = True #setup the box with plot and controls self.control_panel = control_panel(self) @@ -280,6 +285,8 @@ class waterfall_window(wx.Panel, pubsub.pubsub): #grid parameters sample_rate = self[SAMPLE_RATE_KEY] frame_rate = self[FRAME_RATE_KEY] + if frame_rate < 1.0 : + frame_rate = 1.0 baseband_freq = self[BASEBAND_FREQ_KEY] num_lines = self[NUM_LINES_KEY] y_divs = self[Y_DIVS_KEY] diff --git a/grc/blocks/Makefile.am b/grc/blocks/Makefile.am index 2596eae4..18420a01 100644 --- a/grc/blocks/Makefile.am +++ b/grc/blocks/Makefile.am @@ -71,6 +71,7 @@ dist_ourdata_DATA = \ gr_agc2_xx.xml \ gr_agc_xx.xml \ gr_and_xx.xml \ + gr_and_const_xx.xml \ gr_argmax_xx.xml \ gr_binary_slicer_fb.xml \ gr_channel_model.xml \ diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index 8d91258e..610a8810 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -58,6 +58,7 @@ gr_add_const_vxx gr_multiply_const_vxx + gr_and_const_xx gr_not_xx gr_and_xx diff --git a/grc/blocks/gr_agc2_xx.xml b/grc/blocks/gr_agc2_xx.xml index fb3ae570..55b20d4e 100644 --- a/grc/blocks/gr_agc2_xx.xml +++ b/grc/blocks/gr_agc2_xx.xml @@ -9,6 +9,11 @@ gr_agc2_xx from gnuradio import gr gr.agc2_$(type.fcn)($attack_rate, $decay_rate, $reference, $gain, $max_gain) + set_attack_rate($attack_rate) + set_decay_rate($decay_rate) + set_reference($reference) + set_gain($gain) + set_max_gain($max_gain) Type type diff --git a/grc/blocks/gr_and_const_xx.xml b/grc/blocks/gr_and_const_xx.xml new file mode 100644 index 00000000..dc964931 --- /dev/null +++ b/grc/blocks/gr_and_const_xx.xml @@ -0,0 +1,48 @@ + + + + And Const + gr_and_const_xx + from gnuradio import gr + gr.and_const_$(type.fcn)($const) + set_k($const) + + IO Type + type + enum + + + + + + Constant + const + 0 + int + + + in + $type + + + out + $type + + diff --git a/grc/blocks/gr_file_sink.xml b/grc/blocks/gr_file_sink.xml index 880dc275..0081c93f 100644 --- a/grc/blocks/gr_file_sink.xml +++ b/grc/blocks/gr_file_sink.xml @@ -8,7 +8,9 @@ File Sink gr_file_sink from gnuradio import gr - gr.file_sink($type.size*$vlen, $file) + gr.file_sink($type.size*$vlen, $file) +self.$(id).set_unbuffered($unbuffered) + set_unbuffered($unbuffered) File file @@ -51,6 +53,21 @@ 1 int + + Unbuffered + unbuffered + False + bool + + + + $vlen > 0 in diff --git a/grc/blocks/wxgui_scopesink2.xml b/grc/blocks/wxgui_scopesink2.xml index eba45f48..ef037737 100644 --- a/grc/blocks/wxgui_scopesink2.xml +++ b/grc/blocks/wxgui_scopesink2.xml @@ -20,6 +20,8 @@ scopesink2.$(type.fcn)( ac_couple=$ac_couple, xy_mode=$xy_mode, num_inputs=$num_inputs, + trig_mode=$trig_mode, + y_axis_label=$y_axis_label, #if $win_size() size=$win_size, #end if @@ -134,6 +136,33 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos())))) notebook + + Trigger Mode + trig_mode + enum + + + + + + + Y Axis Label + y_axis_label + Counts + string + not $win_size or len($win_size) == 2 not $xy_mode or '$type' == 'complex' or $num_inputs != 1 diff --git a/grc/freedesktop/Makefile.am b/grc/freedesktop/Makefile.am index 23bb70bf..f6aa97a9 100644 --- a/grc/freedesktop/Makefile.am +++ b/grc/freedesktop/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2008,2009 Free Software Foundation, Inc. +# Copyright 2008, 2009, 2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -22,7 +22,6 @@ include $(top_srcdir)/Makefile.common ourdatadir = $(pkgdatadir)/grc/freedesktop - dist_ourdata_DATA = \ grc-icon-256.png \ grc-icon-128.png \ @@ -30,11 +29,12 @@ dist_ourdata_DATA = \ grc-icon-48.png \ grc-icon-32.png \ gnuradio-grc.xml \ - gnuradio-gnuradio-companion.desktop \ + gnuradio-grc.desktop \ gnuradio-usrp2_probe.desktop \ gnuradio-usrp_probe.desktop -dist_bin_SCRIPTS = grc_setup_freedesktop +pkglibexecdir = $(libexecdir)/$(PACKAGE) +dist_pkglibexec_SCRIPTS = grc_setup_freedesktop grc_setup_freedesktop: $(srcdir)/grc_setup_freedesktop.in Makefile sed -e 's|@SRCDIR[@]|$(ourdatadir)|g' $< > $@ @@ -46,10 +46,10 @@ install-data-hook: @printf "\n*** GRC Post-Install Message ***\ \nTo install icons, mime type, and menu items\ \nfor a freedesktop.org system (Gnome/KDE/Xfce):\ - \n >>> sudo grc_setup_freedesktop install\n\n" + \n >>> sudo $(pkglibexecdir)/grc_setup_freedesktop install\n\n" uninstall-hook: @printf "\n*** GRC Post-Uninstall Message ***\ \nTo uninstall icons, mime type, and menu items\ \nfor a freedesktop.org system (Gnome/KDE/Xfce):\ - \n >>> sudo grc_setup_freedesktop uninstall\n\n" + \n >>> sudo $(pkglibexecdir)/grc_setup_freedesktop uninstall\n\n" diff --git a/grc/freedesktop/gnuradio-gnuradio-companion.desktop b/grc/freedesktop/gnuradio-gnuradio-companion.desktop deleted file mode 100644 index 5fd04978..00000000 --- a/grc/freedesktop/gnuradio-gnuradio-companion.desktop +++ /dev/null @@ -1,8 +0,0 @@ -[Desktop Entry] -Version=1.0 -Type=Application -Name=GRC -Exec=gnuradio-companion %F -Categories=Development; -MimeType=application/gnuradio-grc; -Icon=gnuradio-grc diff --git a/grc/freedesktop/gnuradio-grc.desktop b/grc/freedesktop/gnuradio-grc.desktop new file mode 100644 index 00000000..5fd04978 --- /dev/null +++ b/grc/freedesktop/gnuradio-grc.desktop @@ -0,0 +1,8 @@ +[Desktop Entry] +Version=1.0 +Type=Application +Name=GRC +Exec=gnuradio-companion %F +Categories=Development; +MimeType=application/gnuradio-grc; +Icon=gnuradio-grc diff --git a/grc/freedesktop/grc_setup_freedesktop.in b/grc/freedesktop/grc_setup_freedesktop.in index a0c5ac19..ab4ce82e 100644 --- a/grc/freedesktop/grc_setup_freedesktop.in +++ b/grc/freedesktop/grc_setup_freedesktop.in @@ -1,4 +1,24 @@ #!/bin/bash +# +# Copyright 2008, 2009, 2010 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. +# ################################################## # setup grc on a freedesktop platform # $1 should be install or uninstall @@ -8,7 +28,7 @@ ################################################## ICON_SIZES="32 48 64 128 256" -MENU_ITEMS="gnuradio-companion usrp2_probe usrp_probe" +MENU_ITEMS="grc usrp2_probe usrp_probe" if [ -n "$2" ]; then SRCDIR="$2" else @@ -39,11 +59,12 @@ case "$1" in echo "Begin freedesktop uninstall..." for size in ${ICON_SIZES}; do \ echo "Uninstall icon: ${size}x${size}" - xdg-icon-resource uninstall --context mimetypes --theme gnome --size ${size} application-gnuradio-grc; \ - xdg-icon-resource uninstall --context mimetypes --size ${size} application-gnuradio-grc; \ - xdg-icon-resource uninstall --context apps --theme gnome --size ${size} gnuradio-grc; \ - xdg-icon-resource uninstall --context apps --size ${size} gnuradio-grc; \ + xdg-icon-resource uninstall --noupdate --context mimetypes --theme gnome --size ${size} application-gnuradio-grc; \ + xdg-icon-resource uninstall --noupdate --context mimetypes --size ${size} application-gnuradio-grc; \ + xdg-icon-resource uninstall --noupdate --context apps --theme gnome --size ${size} gnuradio-grc; \ + xdg-icon-resource uninstall --noupdate --context apps --size ${size} gnuradio-grc; \ done + xdg-icon-resource forceupdate echo "Uninstall mime type" xdg-mime uninstall ${SRCDIR}/gnuradio-grc.xml echo "Uninstall menu items" diff --git a/grc/python/Block.py b/grc/python/Block.py index dd39b095..bd03eb5c 100644 --- a/grc/python/Block.py +++ b/grc/python/Block.py @@ -75,42 +75,48 @@ class Block(_Block, _GUIBlock): Add and remove ports to adjust for the nports. """ _Block.rewrite(self) + + def insert_port(get_ports, get_port, key): + prev_port = get_port(str(int(key)-1)) + get_ports().insert( + get_ports().index(prev_port)+1, + prev_port.copy(new_key=key), + ) + #restore integer contiguity after insertion + for i, port in enumerate(get_ports()): port._key = str(i) + + def remove_port(get_ports, get_port, key): + port = get_port(key) + for connection in port.get_connections(): + self.get_parent().remove_element(connection) + get_ports().remove(port) + #restore integer contiguity after insertion + for i, port in enumerate(get_ports()): port._key = str(i) + #adjust nports for get_ports, get_port in ( (self.get_sources, self.get_source), (self.get_sinks, self.get_sink), ): - #how many streaming (non-message) ports? - num_ports = len(filter(lambda p: p.get_type() != 'msg', get_ports())) - #do nothing for 0 ports - if not num_ports: continue - #get the nports setting - port0 = get_port(str(0)) - nports = port0.get_nports() - #do nothing for no nports - if not nports: continue - #do nothing if nports is already num ports - if nports == num_ports: continue - #remove excess ports and connections - if nports < num_ports: - #remove the connections - for key in map(str, range(nports, num_ports)): - port = get_port(key) - for connection in port.get_connections(): - self.get_parent().remove_element(connection) - #remove the ports - for key in map(str, range(nports, num_ports)): - get_ports().remove(get_port(key)) - continue - #add more ports - if nports > num_ports: - for key in map(str, range(num_ports, nports)): - prev_port = get_port(str(int(key)-1)) - get_ports().insert( - get_ports().index(prev_port)+1, - prev_port.copy(new_key=key), - ) - continue + master_ports = filter(lambda p: p.get_nports(), get_ports()) + for i, master_port in enumerate(master_ports): + nports = master_port.get_nports() + index_first = get_ports().index(master_port) + try: index_last = get_ports().index(master_ports[i+1]) + except IndexError: index_last = len(get_ports()) + num_ports = index_last - index_first + #do nothing if nports is already num ports + if nports == num_ports: continue + #remove excess ports and connections + if nports < num_ports: + for key in map(str, range(index_first+nports, index_first+num_ports)): + remove_port(get_ports, get_port, key) + continue + #add more ports + if nports > num_ports: + for key in map(str, range(index_first+num_ports, index_first+nports)): + insert_port(get_ports, get_port, key) + continue def port_controller_modify(self, direction): """ @@ -119,10 +125,8 @@ class Block(_Block, _GUIBlock): @return true for change """ changed = False - #concat the nports string from the private nports settings of both port0 - nports_str = \ - (self.get_sinks() and self.get_sinks()[0]._nports or '') + \ - (self.get_sources() and self.get_sources()[0]._nports or '') + #concat the nports string from the private nports settings of all ports + nports_str = ' '.join([port._nports for port in self.get_ports()]) #modify all params whose keys appear in the nports string for param in self.get_params(): if param.is_enum() or param.get_key() not in nports_str: continue diff --git a/grc/python/Port.py b/grc/python/Port.py index 6965371d..6e5a5c59 100644 --- a/grc/python/Port.py +++ b/grc/python/Port.py @@ -167,5 +167,7 @@ class Port(_Port, _GUIPort): def copy(self, new_key=None): n = self._n.copy() + #remove nports from the key so the copy cannot be a duplicator + if n.has_key('nports'): n.pop('nports') if new_key: n['key'] = new_key return self.__class__(self.get_parent(), n, self._dir) diff --git a/gruel/src/include/gruel/pmt.h b/gruel/src/include/gruel/pmt.h index c371b023..514b24d8 100644 --- a/gruel/src/include/gruel/pmt.h +++ b/gruel/src/include/gruel/pmt.h @@ -163,6 +163,27 @@ pmt_t pmt_from_long(long x); */ long pmt_to_long(pmt_t x); +/* + * ------------------------------------------------------------------------ + * uint64_t + * ------------------------------------------------------------------------ + */ + +//! Return true if \p x is an uint64 number, else false +bool pmt_is_uint64(pmt_t x); + +//! Return the pmt value that represents the uint64 \p x. +pmt_t pmt_from_uint64(uint64_t x); + +/*! + * \brief Convert pmt to uint64 if possible. + * + * When \p x represents an exact integer that fits in a uint64, + * return that uint64. Else raise an exception, either wrong_type + * when x is not an exact uint64, or out_of_range when it doesn't fit. + */ +uint64_t pmt_to_uint64(pmt_t x); + /* * ------------------------------------------------------------------------ * Reals diff --git a/gruel/src/lib/Makefile.am b/gruel/src/lib/Makefile.am index 1bcd26e9..5c3302f1 100644 --- a/gruel/src/lib/Makefile.am +++ b/gruel/src/lib/Makefile.am @@ -23,8 +23,8 @@ include $(top_srcdir)/Makefile.common SUBDIRS = pmt msg -AM_CPPFLAGS = $(DEFINES) $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) $(GRUEL_INCLUDES) $(WITH_INCLUDES) - +AM_CPPFLAGS = $(DEFINES) $(GRUEL_INCLUDES) $(BOOST_CPPFLAGS) \ + $(CPPUNIT_INCLUDES) $(WITH_INCLUDES) TESTS = test_gruel diff --git a/gruel/src/lib/msg/Makefile.am b/gruel/src/lib/msg/Makefile.am index 13a65706..9dbaf10f 100644 --- a/gruel/src/lib/msg/Makefile.am +++ b/gruel/src/lib/msg/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2009 Free Software Foundation, Inc. +# Copyright 2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,7 +21,8 @@ include $(top_srcdir)/Makefile.common -AM_CPPFLAGS = $(DEFINES) $(BOOST_CPPFLAGS) $(GRUEL_INCLUDES) $(WITH_INCLUDES) +AM_CPPFLAGS = $(DEFINES) $(GRUEL_INCLUDES) \ + $(BOOST_CPPFLAGS) $(WITH_INCLUDES) noinst_LTLIBRARIES = libmsg.la diff --git a/gruel/src/lib/pmt/Makefile.am b/gruel/src/lib/pmt/Makefile.am index 8750cbdf..d3efc1af 100644 --- a/gruel/src/lib/pmt/Makefile.am +++ b/gruel/src/lib/pmt/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2008,2009 Free Software Foundation, Inc. +# Copyright 2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -21,8 +21,8 @@ include $(top_srcdir)/Makefile.common -AM_CPPFLAGS = $(DEFINES) $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) $(GRUEL_INCLUDES) $(WITH_INCLUDES) - +AM_CPPFLAGS = $(DEFINES) $(GRUEL_INCLUDES) $(BOOST_CPPFLAGS) \ + $(CPPUNIT_INCLUDES) $(WITH_INCLUDES) noinst_LTLIBRARIES = libpmt.la diff --git a/gruel/src/lib/pmt/pmt.cc b/gruel/src/lib/pmt/pmt.cc index aa1688d2..f9cf6b4b 100644 --- a/gruel/src/lib/pmt/pmt.cc +++ b/gruel/src/lib/pmt/pmt.cc @@ -105,6 +105,12 @@ _integer(pmt_t x) return dynamic_cast(x.get()); } +static pmt_uint64 * +_uint64(pmt_t x) +{ + return dynamic_cast(x.get()); +} + static pmt_real * _real(pmt_t x) { @@ -304,6 +310,40 @@ pmt_to_long(pmt_t x) throw pmt_wrong_type("pmt_to_long", x); } +//////////////////////////////////////////////////////////////////////////// +// Uint64 +//////////////////////////////////////////////////////////////////////////// + +pmt_uint64::pmt_uint64(uint64_t value) : d_value(value) {} + +bool +pmt_is_uint64(pmt_t x) +{ + return x->is_uint64(); +} + + +pmt_t +pmt_from_uint64(uint64_t x) +{ + return pmt_t(new pmt_uint64(x)); +} + +uint64_t +pmt_to_uint64(pmt_t x) +{ + if(x->is_uint64()) + return _uint64(x)->value(); + if(x->is_integer()) + { + long tmp = _integer(x)->value(); + if(tmp >= 0) + return (uint64_t) tmp; + } + + throw pmt_wrong_type("pmt_to_uint64", x); +} + //////////////////////////////////////////////////////////////////////////// // Real //////////////////////////////////////////////////////////////////////////// @@ -929,6 +969,9 @@ pmt_eqv(const pmt_t& x, const pmt_t& y) if (x->is_integer() && y->is_integer()) return _integer(x)->value() == _integer(y)->value(); + if (x->is_uint64() && y->is_uint64()) + return _uint64(x)->value() == _uint64(y)->value(); + if (x->is_real() && y->is_real()) return _real(x)->value() == _real(y)->value(); @@ -947,6 +990,9 @@ pmt_eqv_raw(pmt_base *x, pmt_base *y) if (x->is_integer() && y->is_integer()) return _integer(x)->value() == _integer(y)->value(); + if (x->is_uint64() && y->is_uint64()) + return _uint64(x)->value() == _uint64(y)->value(); + if (x->is_real() && y->is_real()) return _real(x)->value() == _real(y)->value(); @@ -1328,6 +1374,7 @@ pmt_dump_sizeof() printf("sizeof(pmt_bool) = %3zd\n", sizeof(pmt_bool)); printf("sizeof(pmt_symbol) = %3zd\n", sizeof(pmt_symbol)); printf("sizeof(pmt_integer) = %3zd\n", sizeof(pmt_integer)); + printf("sizeof(pmt_uint64) = %3zd\n", sizeof(pmt_uint64)); printf("sizeof(pmt_real) = %3zd\n", sizeof(pmt_real)); printf("sizeof(pmt_complex) = %3zd\n", sizeof(pmt_complex)); printf("sizeof(pmt_null) = %3zd\n", sizeof(pmt_null)); diff --git a/gruel/src/lib/pmt/pmt_int.h b/gruel/src/lib/pmt/pmt_int.h index 50683ffb..ea28e37b 100644 --- a/gruel/src/lib/pmt/pmt_int.h +++ b/gruel/src/lib/pmt/pmt_int.h @@ -47,6 +47,7 @@ public: virtual bool is_symbol() const { return false; } virtual bool is_number() const { return false; } virtual bool is_integer() const { return false; } + virtual bool is_uint64() const { return false; } virtual bool is_real() const { return false; } virtual bool is_complex() const { return false; } virtual bool is_null() const { return false; } @@ -118,6 +119,19 @@ public: long value() const { return d_value; } }; +class pmt_uint64 : public pmt_base +{ +public: + uint64_t d_value; + + pmt_uint64(uint64_t value); + //~pmt_uint64(){} + + bool is_number() const { return true; } + bool is_uint64() const { return true; } + uint64_t value() const { return d_value; } +}; + class pmt_real : public pmt_base { public: diff --git a/gruel/src/lib/pmt/pmt_io.cc b/gruel/src/lib/pmt/pmt_io.cc index 179e6b72..b909c1b6 100644 --- a/gruel/src/lib/pmt/pmt_io.cc +++ b/gruel/src/lib/pmt/pmt_io.cc @@ -64,6 +64,8 @@ pmt_write(pmt_t obj, std::ostream &port) else if (pmt_is_number(obj)){ if (pmt_is_integer(obj)) port << pmt_to_long(obj); + else if (pmt_is_uint64(obj)) + port << pmt_to_uint64(obj); else if (pmt_is_real(obj)) port << pmt_to_double(obj); else if (pmt_is_complex(obj)){ diff --git a/gruel/src/lib/pmt/qa_pmt_prims.cc b/gruel/src/lib/pmt/qa_pmt_prims.cc index f2414c72..985361f1 100644 --- a/gruel/src/lib/pmt/qa_pmt_prims.cc +++ b/gruel/src/lib/pmt/qa_pmt_prims.cc @@ -103,6 +103,19 @@ qa_pmt_prims::test_integers() CPPUNIT_ASSERT_EQUAL(1L, pmt_to_long(p1)); } +void +qa_pmt_prims::test_uint64s() +{ + pmt_t p1 = pmt_from_uint64((uint64_t)1); + pmt_t m1 = pmt_from_uint64((uint64_t)8589934592ULL); + CPPUNIT_ASSERT(!pmt_is_uint64(PMT_T)); + CPPUNIT_ASSERT(pmt_is_uint64(p1)); + CPPUNIT_ASSERT(pmt_is_uint64(m1)); + CPPUNIT_ASSERT_THROW(pmt_to_uint64(PMT_T), pmt_wrong_type); + CPPUNIT_ASSERT_EQUAL((uint64_t)8589934592ULL, (uint64_t)pmt_to_uint64(m1)); + CPPUNIT_ASSERT_EQUAL((uint64_t)1ULL, (uint64_t)pmt_to_uint64(p1)); +} + void qa_pmt_prims::test_reals() { diff --git a/gruel/src/lib/pmt/qa_pmt_prims.h b/gruel/src/lib/pmt/qa_pmt_prims.h index 29ba02f1..efc5c605 100644 --- a/gruel/src/lib/pmt/qa_pmt_prims.h +++ b/gruel/src/lib/pmt/qa_pmt_prims.h @@ -31,6 +31,7 @@ class qa_pmt_prims : public CppUnit::TestCase { CPPUNIT_TEST(test_symbols); CPPUNIT_TEST(test_booleans); CPPUNIT_TEST(test_integers); + CPPUNIT_TEST(test_uint64s); CPPUNIT_TEST(test_reals); CPPUNIT_TEST(test_complexes); CPPUNIT_TEST(test_pairs); @@ -52,6 +53,7 @@ class qa_pmt_prims : public CppUnit::TestCase { void test_symbols(); void test_booleans(); void test_integers(); + void test_uint64s(); void test_reals(); void test_complexes(); void test_pairs(); diff --git a/gruel/src/lib/test_gruel.cc b/gruel/src/lib/test_gruel.cc index 66930344..2c9528b0 100644 --- a/gruel/src/lib/test_gruel.cc +++ b/gruel/src/lib/test_gruel.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2009 Free Software Foundation, Inc. + * Copyright 2006,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -21,17 +21,67 @@ */ #include +#include + +#include +#include + #include "pmt/qa_pmt.h" +static void get_unittest_path (const char *filename, char *fullpath, size_t pathsize); + int main(int argc, char **argv) { + char path[200]; + get_unittest_path ("gruel.xml", path, 200); - CppUnit::TextTestRunner runner; + CppUnit::TextTestRunner runner; + std::ofstream xmlfile(path); + CppUnit::XmlOutputter *xmlout = new CppUnit::XmlOutputter(&runner.result(), xmlfile); runner.addTest(qa_pmt::suite ()); + runner.setOutputter(xmlout); bool was_successful = runner.run("", false); return was_successful ? 0 : 1; } + + +// NOTE: These are defined in gr_unittest.h for the rest of the project; +// rewriting here since we don't depend on gnuradio-core in gruel + +#ifdef MKDIR_TAKES_ONE_ARG +#define gr_mkdir(pathname, mode) mkdir(pathname) +#else +#define gr_mkdir(pathname, mode) mkdir((pathname), (mode)) +#endif + +/* + * Mostly taken from gr_preferences.cc/h + * The simplest thing that could possibly work: + * the key is the filename; the value is the file contents. + */ + +static void +ensure_unittest_path (const char *path) +{ + struct stat statbuf; + if (stat (path, &statbuf) == 0 && S_ISDIR (statbuf.st_mode)) + return; + + // blindly try to make it // FIXME make this robust. C++ SUCKS! + gr_mkdir (path, 0750); +} + +static void +get_unittest_path (const char *filename, char *fullpath, size_t pathsize) +{ + char path[200]; + snprintf (path, sizeof(path), "./.unittests"); + snprintf (fullpath, pathsize, "%s/%s", path, filename); + + ensure_unittest_path(path); +} + diff --git a/usrp/doc/Doxyfile.in b/usrp/doc/Doxyfile.in index 5043b147..33c5bcf0 100644 --- a/usrp/doc/Doxyfile.in +++ b/usrp/doc/Doxyfile.in @@ -73,16 +73,6 @@ CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English -# This tag can be used to specify the encoding used in the generated output. -# The encoding is not always determined by the language that is chosen, -# but also whether or not the output is meant for Windows or non-Windows users. -# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES -# forces the Windows encoding (this is the default for the Windows binary), -# whereas setting the tag to NO uses a Unix-style encoding (the default for -# all platforms other than Windows). - -USE_WINDOWS_ENCODING = NO - # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). @@ -167,13 +157,6 @@ JAVADOC_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = YES - # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. @@ -1118,32 +1101,40 @@ DOT_PATH = DOTFILE_DIRS = -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. -MAX_DOT_GRAPH_WIDTH = 1024 +DOT_GRAPH_MAX_NODES = 50 -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. +# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the +# graphs generated by dot. A depth value of 3 means that only nodes reachable +# from the root by following a path via at most 3 edges will be shown. Nodes +# that lay further from the root node will be omitted. Note that setting this +# option to 1 or 2 may greatly reduce the computation time needed for large +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. -MAX_DOT_GRAPH_HEIGHT = 1024 +MAX_DOT_GRAPH_DEPTH = 0 -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes that -# lay further from the root node will be omitted. Note that setting this option to -# 1 or 2 may greatly reduce the computation time needed for large code bases. Also -# note that a graph may be further truncated if the graph's image dimensions are -# not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH and MAX_DOT_GRAPH_HEIGHT). -# If 0 is used for the depth value (the default), the graph is not depth-constrained. +# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). -MAX_DOT_GRAPH_DEPTH = 0 +DOT_TRANSPARENT = NO + +# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output +# files in one run (i.e. multiple -o and -T options on the command line). This +# makes dot run faster, but since only newer versions of dot (>1.8.10) +# support this, this feature is disabled by default. + +DOT_MULTI_TARGETS = YES # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and diff --git a/usrp/host/apps/burn-db-eeprom b/usrp/host/apps/burn-db-eeprom index 8fb9143e..0c908e3d 100755 --- a/usrp/host/apps/burn-db-eeprom +++ b/usrp/host/apps/burn-db-eeprom @@ -65,6 +65,7 @@ daughterboards = { 'rfx900_mimo_b' : ((FLEX_900_TX_MIMO_B, 0x0000), (FLEX_900_RX_MIMO_B, 0x0000)), 'rfx1200_mimo_b' : ((FLEX_1200_TX_MIMO_B, 0x0000), (FLEX_1200_RX_MIMO_B, 0x0000)), 'rfx1800_mimo_b' : ((FLEX_1800_TX_MIMO_B, 0x0000), (FLEX_1800_RX_MIMO_B, 0x0000)), + 'rfx2200_mimo_b' : ((FLEX_2200_TX_MIMO_B, 0x0000), (FLEX_2200_RX_MIMO_B, 0x0000)), 'rfx2400_mimo_b' : ((FLEX_2400_TX_MIMO_B, 0x0000), (FLEX_2400_RX_MIMO_B, 0x0000)), 'lftx' : ((LF_TX, 0x0000), None), 'lfrx' : (None, (LF_RX, 0x0000)), diff --git a/usrp/host/include/usrp/db_flexrf.h b/usrp/host/include/usrp/db_flexrf.h index 0c834402..70a55514 100644 --- a/usrp/host/include/usrp/db_flexrf.h +++ b/usrp/host/include/usrp/db_flexrf.h @@ -138,6 +138,18 @@ protected: //---------------------------------------------------------------------- +class _2200_common : public _AD4360_common +{ + public: + _2200_common(); + ~_2200_common() {} + + double freq_min(); + double freq_max(); +}; + +//---------------------------------------------------------------------- + class _2400_common : public _AD4360_common { public: @@ -212,6 +224,34 @@ public: //------------------------------------------------------------ +class db_flexrf_2200_tx : public flexrf_base_tx +{ + public: + db_flexrf_2200_tx(usrp_basic_sptr usrp, int which); + ~db_flexrf_2200_tx(); + + // Wrapper calls to d_common functions + bool _compute_regs(double freq, int &retR, int &retcontrol, + int &retN, double &retfreq); +}; + +class db_flexrf_2200_rx : public flexrf_base_rx +{ +public: + db_flexrf_2200_rx(usrp_basic_sptr usrp, int which); + ~db_flexrf_2200_rx(); + + float gain_min(); + float gain_max(); + float gain_db_per_step(); + bool i_and_q_swapped(); + + bool _compute_regs(double freq, int &retR, int &retcontrol, + int &retN, double &retfreq); +}; + +//------------------------------------------------------------ + class db_flexrf_2400_tx : public flexrf_base_tx { public: diff --git a/usrp/host/lib/Makefile.am b/usrp/host/lib/Makefile.am index 23889fc8..b8b60fa9 100644 --- a/usrp/host/lib/Makefile.am +++ b/usrp/host/lib/Makefile.am @@ -33,7 +33,7 @@ libusrp_la_common_LIBADD = \ # darwin fusb requires gruel (for threading) if FUSB_TECH_darwin -AM_CPPFLAGS = $(common_INCLUDES) $(GRUEL_INCLUDES) $(BOOST_CPPFLAGS) $(WITH_INCLUDES) +AM_CPPFLAGS = $(GRUEL_INCLUDES) $(common_INCLUDES) $(BOOST_CPPFLAGS) $(WITH_INCLUDES) libusrp_la_LIBADD = $(libusrp_la_common_LIBADD) $(GRUEL_LA) libusrp_la_LDFLAGS = $(libusrp_la_common_LDFLAGS) -framework CoreFoundation else diff --git a/usrp/host/lib/db_flexrf.cc b/usrp/host/lib/db_flexrf.cc index 07ac2be3..2819c19b 100644 --- a/usrp/host/lib/db_flexrf.cc +++ b/usrp/host/lib/db_flexrf.cc @@ -639,6 +639,38 @@ _AD4360_common::_prescaler() //---------------------------------------------------------------------- +_2200_common::_2200_common() + : _AD4360_common() +{ + // Band-specific R-Register Values + d_R_DIV = 16; // bits 15:2 + + // Band-specific C-Register values + d_P = 1; // bits 23,22 Div by 16/17 + d_CP2 = 7; // bits 19:17 + d_CP1 = 7; // bits 16:14 + + // Band specifc N-Register Values + d_DIVSEL = 0; // bit 23 + d_DIV2 = 0; // bit 22 + d_CPGAIN = 0; // bit 21 + d_freq_mult = 1; +} + +double +_2200_common::freq_min() +{ + return 2000e6; +} + +double +_2200_common::freq_max() +{ + return 2400e6; +} + +//---------------------------------------------------------------------- + _2400_common::_2400_common() : _AD4360_common() { @@ -811,6 +843,72 @@ _400_rx::_400_rx() //------------------------------------------------------------ +db_flexrf_2200_tx::db_flexrf_2200_tx(usrp_basic_sptr usrp, int which) + : flexrf_base_tx(usrp, which) +{ + d_common = new _2200_common(); +} + +db_flexrf_2200_tx::~db_flexrf_2200_tx() +{ +} + +bool +db_flexrf_2200_tx::_compute_regs(double freq, int &retR, int &retcontrol, + int &retN, double &retfreq) +{ + return d_common->_compute_regs(_refclk_freq(), freq, retR, + retcontrol, retN, retfreq); +} + + + +db_flexrf_2200_rx::db_flexrf_2200_rx(usrp_basic_sptr usrp, int which) + : flexrf_base_rx(usrp, which) +{ + d_common = new _2200_common(); + set_gain((gain_min() + gain_max()) / 2.0); // initialize gain +} + +db_flexrf_2200_rx::~db_flexrf_2200_rx() +{ +} + +float +db_flexrf_2200_rx::gain_min() +{ + return usrp()->pga_min(); +} + +float +db_flexrf_2200_rx::gain_max() +{ + return usrp()->pga_max()+70; +} + +float +db_flexrf_2200_rx::gain_db_per_step() +{ + return 0.05; +} + + +bool +db_flexrf_2200_rx::i_and_q_swapped() +{ + return true; +} + +bool +db_flexrf_2200_rx::_compute_regs(double freq, int &retR, int &retcontrol, + int &retN, double &retfreq) +{ + return d_common->_compute_regs(_refclk_freq(), freq, retR, + retcontrol, retN, retfreq); +} + +//------------------------------------------------------------ + db_flexrf_2400_tx::db_flexrf_2400_tx(usrp_basic_sptr usrp, int which) : flexrf_base_tx(usrp, which) { diff --git a/usrp/host/lib/usrp_dbid.dat b/usrp/host/lib/usrp_dbid.dat index 5193a5fa..2548d737 100644 --- a/usrp/host/lib/usrp_dbid.dat +++ b/usrp/host/lib/usrp_dbid.dat @@ -61,6 +61,9 @@ "Flex 1200 Tx MIMO B" 0x002a "Flex 2400 Tx MIMO B" 0x002b +"Flex 2200 Rx MIMO B" 0x002c +"Flex 2200 Tx MIMO B" 0x002d + "Flex 1800 Rx" 0x0030 "Flex 1800 Tx" 0x0031 "Flex 1800 Rx MIMO A" 0x0032 diff --git a/usrp/host/swig/Makefile.am b/usrp/host/swig/Makefile.am index d2e6b8bc..c846f267 100644 --- a/usrp/host/swig/Makefile.am +++ b/usrp/host/swig/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2001,2003,2004,2006,2007,2008,2009 Free Software Foundation, Inc. +# Copyright 2001,2003,2004,2006,2007,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,8 +23,8 @@ include $(top_srcdir)/Makefile.common AM_CPPFLAGS = \ $(USRP_INCLUDES) \ - $(PYTHON_CPPFLAGS) \ -I$(srcdir) \ + $(PYTHON_CPPFLAGS) \ $(USB_INCLUDES) \ $(WITH_INCLUDES) diff --git a/usrp2/firmware/lib/db_rfx.c b/usrp2/firmware/lib/db_rfx.c index 54655901..d07d3c1f 100644 --- a/usrp2/firmware/lib/db_rfx.c +++ b/usrp2/firmware/lib/db_rfx.c @@ -120,6 +120,16 @@ struct db_rfx_1800_tx { struct db_rfx_common common; }; +struct db_rfx_2200_rx { + struct db_base base; + struct db_rfx_common common; +}; + +struct db_rfx_2200_tx { + struct db_base base; + struct db_rfx_common common; +}; + struct db_rfx_2400_rx { struct db_base base; struct db_rfx_common common; @@ -387,6 +397,70 @@ struct db_rfx_1800_tx db_rfx_1800_tx = { }; +struct db_rfx_2200_rx db_rfx_2200_rx = { + .base.dbid = 0x002c, + .base.is_tx = false, + .base.output_enables = 0x00E0, + .base.used_pins = 0x00FF, + .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(2000e6), + .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(2400e6), + .base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(0), + .base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(70), + .base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(0.034), + .base.is_quadrature = true, + .base.i_and_q_swapped = true, + .base.spectrum_inverted = false, + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(0), + .base.init = rfx_init_rx, + .base.set_freq = rfx_set_freq, + .base.set_gain = rfx_set_gain_rx, + .base.set_tx_enable = 0, + .base.atr_mask = 0x00E0, + .base.atr_txval = 0, + .base.atr_rxval = MIX_EN, + // .base.atr_tx_delay = + // .base.atr_rx_delay = + .base.set_antenna = 0, + .common.DIV2 = 0, + .common.CP1 = 7, + .common.CP2 = 7, + .common.spi_mask = SPI_SS_RX_DB, + .common.freq_mult = 1 +}; + + +struct db_rfx_2200_tx db_rfx_2200_tx = { + .base.dbid = 0x002d, + .base.is_tx = true, + .base.output_enables = 0x00E0, + .base.used_pins = 0x00FF, + .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(2000e6), + .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(2400e6), + //.base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(xxx), + //.base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(xxx), + //.base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(xxx), + .base.is_quadrature = true, + .base.i_and_q_swapped = false, + .base.spectrum_inverted = false, + .base.default_lo_offset = U2_DOUBLE_TO_FXPT_FREQ(12.5e6), + .base.init = rfx_init_tx, + .base.set_freq = rfx_set_freq, + .base.set_gain = rfx_set_gain_tx, + .base.set_tx_enable = rfx_set_tx_enable, + .base.atr_mask = 0x00E0, + .base.atr_txval = MIX_EN, + .base.atr_rxval = ANT_SW, + // .base.atr_tx_delay = + // .base.atr_rx_delay = + .base.set_antenna = 0, + .common.DIV2 = 0, + .common.CP1 = 7, + .common.CP2 = 7, + .common.spi_mask = SPI_SS_TX_DB, + .common.freq_mult = 1 +}; + + struct db_rfx_2400_rx db_rfx_2400_rx = { .base.dbid = 0x0027, .base.is_tx = false, diff --git a/usrp2/host/apps/Makefile.am b/usrp2/host/apps/Makefile.am index 4a26898f..087ab9e3 100644 --- a/usrp2/host/apps/Makefile.am +++ b/usrp2/host/apps/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2007, 2008 Free Software Foundation, Inc. +# Copyright 2007,2008,2010 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 @@ -19,9 +19,9 @@ include $(top_srcdir)/Makefile.common AM_CPPFLAGS = \ $(USRP2_INCLUDES) \ + $(GRUEL_INCLUDES) \ $(STD_DEFINES_AND_INCLUDES) \ - $(CPPUNIT_INCLUDES) \ - $(GRUEL_INCLUDES) + $(CPPUNIT_INCLUDES) LDADD = \ $(USRP2_LA) \ diff --git a/usrp2/host/lib/Makefile.am b/usrp2/host/lib/Makefile.am index 209cb709..85bec467 100644 --- a/usrp2/host/lib/Makefile.am +++ b/usrp2/host/lib/Makefile.am @@ -19,10 +19,10 @@ include $(top_srcdir)/Makefile.common AM_CPPFLAGS = \ $(USRP2_INCLUDES) \ - $(BOOST_CPPFLAGS) \ + $(GRUEL_INCLUDES) \ $(STD_DEFINES_AND_INCLUDES) \ - $(CPPUNIT_INCLUDES) \ - $(GRUEL_INCLUDES) + $(BOOST_CPPFLAGS) \ + $(CPPUNIT_INCLUDES) bin_PROGRAMS = usrp2_socket_opener usrp2_socket_opener_SOURCES = usrp2_socket_opener.cc diff --git a/version.sh b/version.sh index 01a47b5d..70d6d74f 100644 --- a/version.sh +++ b/version.sh @@ -1,4 +1,4 @@ MAJOR_VERSION=3 API_COMPAT=3 -MINOR_VERSION=0 -MAINT_VERSION=0 +MINOR_VERSION=1 +MAINT_VERSION=git