diff options
710 files changed, 7119 insertions, 36259 deletions
diff --git a/Makefile.common b/Makefile.common index 64891345b..fb83b9470 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1,6 +1,6 @@ # -*- Makefile -*- # -# Copyright 2004,2006,2007,2008,2009 Free Software Foundation, Inc. +# Copyright 2004,2006,2007,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -23,6 +23,9 @@ AM_CFLAGS = @autoconf_default_CFLAGS@ @lf_CFLAGS@ AM_CXXFLAGS = @autoconf_default_CXXFLAGS@ @lf_CXXFLAGS@ +# Sets ABI version in SONAME and appends -LIBVER to filename +LTVERSIONFLAGS = -version-info 0:0:0 -release $(LIBVER) + # includes grincludedir = $(includedir)/gnuradio @@ -55,17 +58,13 @@ 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) \ - $(OMNITHREAD_INCLUDES) $(GNURADIO_INCLUDES) $(GRUEL_INCLUDES) + $(GNURADIO_INCLUDES) $(GRUEL_INCLUDES) # when including for compilation from pre-installed libraries and such, # need to make sure those are put last on the compile command WITH_INCLUDES = @with_INCLUDES@ WITH_SWIG_INCLUDES = @with_SWIG_INCLUDES@ -# How to link in the top-level omnithreads library from inside the tree -OMNITHREAD_INCLUDES = @omnithread_INCLUDES@ -OMNITHREAD_LA = @omnithread_LA@ - # Where to find gnuradio include files in the current build tree # top_srcdir for original stuff, top_builddir for generated files GNURADIO_INCLUDES = @gnuradio_core_INCLUDES@ @@ -81,10 +80,6 @@ GRUEL_LA = @gruel_LA@ USRP_INCLUDES = @usrp_INCLUDES@ USRP_LA = @usrp_LA@ -# How to link the mblock library from inside the tree -MBLOCK_INCLUDES = @mblock_INCLUDES@ -MBLOCK_LA = @mblock_LA@ - # How to link the gcell library from inside the tree (the PPU part) GCELL_INCLUDES = @gcell_INCLUDES@ GCELL_LA = @gcell_LA@ @@ -100,8 +95,7 @@ GCELL_EMBEDSPU_LIBTOOL = @abs_top_srcdir@/gcell/lib/runtime/gcell-embedspu-libto # using AM_PATH_PROG, but now here have to add a -f to be like GNU make RM=$(RM_PROG) -f -RUN_GUILE = GUILE_LOAD_PATH="@abs_top_srcdir@/gruel/src/scheme:@abs_top_srcdir@/mblock/src/scheme" @GUILE@ -e main -s -COMPILE_MBH = $(RUN_GUILE) $(top_srcdir)/mblock/src/scheme/gnuradio/compile-mbh.scm +RUN_GUILE = GUILE_LOAD_PATH="@abs_top_srcdir@/gruel/src/scheme" @GUILE@ -e main -s # Base directory for example applications exampledir = $(datadir)/gnuradio/examples diff --git a/README.components b/README.components deleted file mode 100755 index 996f2ee54..000000000 --- a/README.components +++ /dev/null @@ -1,150 +0,0 @@ -#!/bin/sh - -# $Id$ - -# Copyright 2008 Free Software Foundation. -# -# DO NOT RUN THIS SCRIPT UNTIL YOU UNDERSTAND IT!!! IT WILL REMOVE -# FILES ON YOUR SYSTEM. -# -# Read the script thoroughly before running it; it will *remove* -# /usr/local/gnuradio and repopulate it. -# -# This script provides a way to build GNU Radio modules individually, -# and both serves as an example of using the component build system -# and provides a way to test the build system. When run, it will -# build and install each GNU Radio module in turn, using the -# just-installed modules as prerequisites. It places the output of -# each build in a separate file BUILD.NNN.options, so that one can do -# 'tail -f BUILD.*' to see which components were successfully built. - -# This script is intended to be broadly portable; be careful when -# modifying not to cause problems on systems that place dependencies -# in other than /usr -# -# Besides GNU Radio dependencies, this program requires sudo, with a -# timer long enough to build each module (or no password requirement). -# - -set -x - -# Do not use /opt, because many systems do not have /opt and that -# risks running out of space in /. /usr/local/gnuradio is believed to -# be reasonable on all of *BSD and GNU/Linux. Probably this needs -# OS-specific overrides. -PREFIX=/usr/local/gnuradio - -echo "ABOUT TO COMPLETELY REMOVE $PREFIX in 10 SECONDS!" -sleep 10 - -echo -n "README.components START "; date - -# This file provides an example of how to build GNU Radio under pkgsrc. - -# Avoid using rm -rf with $PREFIX, which could be /. Make a backup of -# the old prefix. -sudo rm -rf $PREFIX.old -if [ -d $PREFIX ]; then - sudo mv $PREFIX $PREFIX.old -fi -rm -rf BUILD.* - -# Bootstrap just once, rather than once per module. -./bootstrap - -# Determine where prereqs come from. -export LDFLAGS= -export CPPFLAGS= -export PKG_CONFIG_PATH= -if [ -d /usr/pkg ]; then - # pkgsrc - LDFLAGS="$LDFLAGS -L/usr/pkg/lib -R/usr/pkg/lib" - CPPFLAGS="$CPPFLAGS -I/usr/pkg/include" - - # pkg-config is from pkgsrc, so already knows about /usr/pkg/lib/pkgconfig - PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PREFIX/lib/pkgconfig" -fi - -echo LDFLAGS ,$LDFLAGS, -echo CPPFLAGS ,$CPPFLAGS, -echo PKG_CONFIG_PATH ,$PKG_CONFIG_PATH, - -# Determine number of cpus and thus how many jobs to run. -ncpus=1 -case x`uname` in - xNetBSD) - ncpus=`sysctl hw.ncpu|awk '{print $3}'` - ;; -esac -jflag=-j`expr $ncpus \* 2` - -# These are currently ignored. -CONF_DOC_ARGS=" ---enable-doxygen ---enable-dot ---enable-latex-docs -" -CONF_DISABLE_ALL="--disable-all-components" - -# We use % instead of ' ' to be able to iterate with /bin/sh's for. -# This variable should list all possible arguments, in tsorted order. -CONF_ENABLE_ARGS=" ---enable-omnithread ---with-omnithread%--enable-gnuradio-core ---with-omnithread%--enable-pmt ---with-omnithread%--with-pmt%--enable-mblock ---with-omnithread%--with-pmt%--with-mblock%--enable-usrp ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--with-usrp%--enable-gr-usrp ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-msdd6000 ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-audio-alsa ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-audio-jack ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-audio-oss ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-audio-osx ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-audio-portaudio ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-audio-windows ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-atsc ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-comedi ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-cvsd-vocoder ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--with-usrp%--enable-gr-gpio ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-gsm-fr-vocoder ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-pager ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--with-usrp%--enable-gr-radar-mono ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-radio-astronomy ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-trellis ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-video-sdl ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gr-wxgui ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--with-usrp%--enable-gr-sounder ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--with-usrp%--with-gr-usrp%--with-gr-wxgui%--enable-gr-utils ---with-omnithread%--with-gnuradio-core%--with-pmt%--with-mblock%--enable-gnuradio-examples -" - -seq=0 -for arg in $CONF_ENABLE_ARGS; do - - # Convert sequence numbers and arguments to usable values. - seqprint=`printf "%03d" $seq` - argspace=`echo $arg | sed -e 's/%/ /g'` - - echo "BUILDING WITH $argspace" - - ( - # configure with just one module - ./configure --prefix=$PREFIX $CONF_DISABLE_ALL $argspace && - - # remove all prior objects - make clean && - - # build - make $jflag && - - # install - sudo make install && - - echo "SUCCEEDED $argspace" - - ) > BUILD.$seqprint.$arg 2>&1 - - seq=`expr $seq + 1` -done - -echo -n "README.components FINISH "; date diff --git a/README.organization b/README.organization deleted file mode 100644 index 138d90189..000000000 --- a/README.organization +++ /dev/null @@ -1,239 +0,0 @@ -[This file is currently not baked and does not claim to represent -consensus.] - -* Introduction - -This file describes the current organization of the GNU Radio source -tree. It is intended to be both descriptive and normative. - -* Unresolved issues in organization - -The big issues are: - -1) Should we separate by "code needed to implement protocol/modulation -foo", or related blocks. to (that are therefore not so likely to be -used together). - -2) How do m-blocks impact organization? If m-blocks are in a separate -module, which seems reasonable, then do we have most modules depend on -m-blocks rather than just core, or do we have two versions of blocks - -the classic continuous block and the m-block wrapped block? If -m-blocks become the main path, what will be less awkward? - -3) Because some (ADROIT at BBN) have proposed to implement MACs in -click instead of GNU Radio, should we have a clean separation of -MAC/PHY within GNU Radio, to facilitate using MACs implemented in -various places? - -4) Examples abound, and many are in gnuradio-examples. It might be -better to put examples near the code they use, and to separate useful -programs (like USRP benchmarks) from true examples. Examples should -probably be installed in $prefix/share/examples/gnuradio. - -* Plan (normative) [[NOT BAKED!!! NO CONSENSUS!!!]] - -Create a new module gr-packet, to hold blocks generally relevant to -sending blocks of data. Create subdirectories within gr-packet for -specific protocols (e.g. 802.11, GNU Radio's GMSK "protocol"). - -Convert tunnel.py to be OS-independent and a general source/sink -block, decoupling modulation from OS plumbing. - -* Pointers to code to be integrated - -The immediate question is how to integrate the 802.11 implementation -done by BBN (and assigned to FSF), available at: - - http://acert.ir.bbn.com/viewvc/adroitgrdevel/adroitgrdevel/gr-bbn/ - -This contains blocks at various places in the stack, and gdt believs -that putting them in an 802.11 module will lead to less reuse and less -of a tendency to generalize. - -* Organization of the GNU Radio source tree (mostly descriptive) - -The GNU Radio source tree is rooted at the directory containing this -file; see README for how to get it if you're using a release or -tarball. - -Within this directory, there are a number of subdirectories, most of -which can be enabled or disabled independently. See README for how to -do that; this document is concerned with describing what each module -does enough to help someone who is familiar enough with GNU Radio to -write new code to choose where to put it. The list is not exhaustive. -The description of some modules also lists things that don't belong, -tagged with ?M. - -** gnuradio-core [foundational code for the rest of GNU Radio] - -(gen_interpolator_taps is not installed. Why? How is it used?) - -doc: glue to use with doxygen - -?M doc/other/tv-channel-frequencies: (TV specific) - -?M src/lib/g72x: - G.711 family codec - -src/lib/filter: - implementation and coefficient generation -src/lib/general: - foundational blocks not specific to any technology: - type conversion, {de,}vectorization, add, sub - rms power, throttle, sources, sinks, squelch base class - - general blocks: - agc, pll, sync, costas loop, power squelch, quadrature demod - - ?M framer/correlator - ?M packet source/sink - -src/lib/io: - basic file io, message io - oscope (trigger support) - i2c bus - ?M microtune eval board (like USRP; should probably have own module) - ?M SDR1000 - -src/lib/omnithread: - portable threading library (for when POSIX isn't portable enough) - -src/lib/reed-solomon: - reed-solomon implementation. Unclear how/whether it's wrapped into - blocks. - -src/lib/runtime: - blocks (basic, hier) and associated buffering - flowgraphs - timers - doubly-mapped circular buffers - -src/lib/swig: - code to wrap the rest in python - ?M atsc.i (cruft? moved?) - -src/python: - build utilities - -src/python/bin: - ?M microtune.py: microtune control program (installed and EXTRA_DIST!) - -src/python/gnuradio: - audio base class - engineering notation support - test harness support - test code (not installed) - basic block/flow_graph - -src/tests: - test code - ?M test_atsc.cc (# in Makefile.am, but still present) - -src/utils: - octave and Scheme scripts (not installed) - -** usrp - -This contains code to deal with the USRP, but not GNU Radio support. - -?M fusb - The "fusb" abstraction is arguably useful for all interface devices - that use USB, not just the USRP. - -** gr-usrp - -Code to use the USRP with GNU Radio. - -?M Arguably the Gnu Radio/USRP benchmarks belong here, but are in -examples - -** gr-audio-alsa -** gr-audio-jack -** gr-audio-oss -** gr-audio-osx -** gr-audio-portaudio -** gr-audio-windows - [All of these support audio for some particular audio backend. - -** gr-atsc - ATSC (HDTV) transmitter and receiver. - All blocks seem to be specific to ATSC. - ?M Perhaps some blocks should be abstracted out for reuse with other - than ATSC parameters. - -** gr-comedi - This module is missing a README that explains what it does. - http://www.comedi.org/ - -** gr-gsm-fr-vocoder - GSM 06.10 full rate vocoder, and gsm library - (Note that the presence of this argues for moving the G.711 code discussed above.) - -** gr-pager - POCSAG and FLEX - (gdt suspects there are blocks in here that could be generalized.) - -** gr-radio-astronomy - seems to use only standard blocks from python - -** gr-trellis - This module provides trellis code support, and appears generic. - -** gr-video-sdl - This appears to be like the audio modules, but for video and - specifically for SDL. Unlike audio which has a base class, there - does not appear to be an abstract video class in gnuradio-core. - -** gr-wxgui - Support for using wxwidgets from python. - ?M (Linux-specific??) code to use the Griffin Powermate (and hook it to a GUI) - glue to connect FFT and scope to gui - -** pmt - polymorphic types (building block) - -** mblock - Message block implementation. - Note that mblock being a module means that signal processing blocks - that are mblock-aware must depend on this module and thus probably - cannot be in gnuradio-core. Thus, m-block wrappers for the blocks - in gnuradio-core must be elsewhere and it is maybe a good idea to - move them to someplace like gnuradio-common where the streaming and - m-block versions can be together. - -** ezdop - Code to deal with the ezdop direction-finding hardware. - -** gr-ezdop - Glue code to use the ezdop from GNU Radio. - -** gr-rdf - (Currently empty) code to perform direction finding. - -** gnuradio-examples - - It's arguable that all of these are misplaced, and that examples - belong with the code that they use. - - Bona fide examples (code not intended to be useful except for reading): - c++/dial_tone (how to do things only in C++) - python/audio - - Test programs: - python/channel-coding - python/digital-voice - python/multi-antenna (?) - - Programs in between test and useful: - python/digital - ?M tunnel.py: glue to get packets to Linux, conflates modulation - and packet handling - python/multi_usrp - python/networking/measurement_slave (goes with what?) - - ?M Programs intended to be useful - python/apps/hf_{explorer,radio} - - ?M Kitchen sink: - python/usrp - benchmarks, test, basic fm/wfm/tv receivers, spectrum sensing, - fft, oscope diff --git a/config.guess b/config.guess index f32079abd..285237846 100755 --- a/config.guess +++ b/config.guess @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 # Free Software Foundation, Inc. -timestamp='2008-01-23' +timestamp='2010-08-21' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -27,16 +27,16 @@ timestamp='2008-01-23' # the same distribution terms that you use for the rest of that program. -# Originally written by Per Bothner <per@bothner.com>. -# Please send patches to <config-patches@gnu.org>. Submit a context -# diff and a properly formatted ChangeLog entry. +# Originally written by Per Bothner. Please send patches (context +# diff format) to <config-patches@gnu.org> and include a ChangeLog +# entry. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # -# The plan is that this can be called by configure scripts if you -# don't specify an explicit build system type. +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD me=`echo "$0" | sed -e 's,.*/,,'` @@ -56,8 +56,9 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free +Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -91,7 +92,7 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' 1 2 15 +trap 'exit 1' HUP INT TERM # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires @@ -105,7 +106,7 @@ trap 'exit 1' 1 2 15 set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" HUP INT PIPE TERM ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || @@ -170,7 +171,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in arm*|i386|m68k|ns32k|sh3*|sparc|vax) eval $set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ - | grep __ELF__ >/dev/null + | grep -q __ELF__ then # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout). # Return netbsd for either. FIX? @@ -324,14 +325,33 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in case `/usr/bin/uname -p` in sparc) echo sparc-icl-nx7; exit ;; esac ;; + s390x:SunOS:*:*) + echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit ;; sun4H:SunOS:5.*:*) echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; + i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*) + echo i386-pc-auroraux${UNAME_RELEASE} + exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + eval $set_cc_for_build + SUN_ARCH="i386" + # If there is a compiler, see if it is configured for 64-bit objects. + # Note that the Sun cc does not turn __LP64__ into 1 like gcc does. + # This test works for both compilers. + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + SUN_ARCH="x86_64" + fi + fi + echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize @@ -532,7 +552,7 @@ EOF echo rs6000-ibm-aix3.2 fi exit ;; - *:AIX:*:[456]) + *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 @@ -640,7 +660,7 @@ EOF # => hppa64-hp-hpux11.23 if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | - grep __LP64__ >/dev/null + grep -q __LP64__ then HP_ARCH="hppa2.0w" else @@ -791,12 +811,12 @@ EOF i*:PW*:*) echo ${UNAME_MACHINE}-pc-pw32 exit ;; - *:Interix*:[3456]*) + *:Interix*:*) case ${UNAME_MACHINE} in x86) echo i586-pc-interix${UNAME_RELEASE} exit ;; - EM64T | authenticamd) + authenticamd | genuineintel | EM64T) echo x86_64-unknown-interix${UNAME_RELEASE} exit ;; IA64) @@ -806,6 +826,9 @@ EOF [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*) echo i${UNAME_MACHINE}-pc-mks exit ;; + 8664:Windows_NT:*) + echo x86_64-pc-mks + exit ;; i*:Windows_NT*:* | Pentium*:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we @@ -835,6 +858,20 @@ EOF i*86:Minix:*:*) echo ${UNAME_MACHINE}-pc-minix exit ;; + alpha:Linux:*:*) + case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + EV5) UNAME_MACHINE=alphaev5 ;; + EV56) UNAME_MACHINE=alphaev56 ;; + PCA56) UNAME_MACHINE=alphapca56 ;; + PCA57) UNAME_MACHINE=alphapca56 ;; + EV6) UNAME_MACHINE=alphaev6 ;; + EV67) UNAME_MACHINE=alphaev67 ;; + EV68*) UNAME_MACHINE=alphaev68 ;; + esac + objdump --private-headers /bin/sh | grep -q ld.so.1 + if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi + echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + exit ;; arm*:Linux:*:*) eval $set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ @@ -857,6 +894,17 @@ EOF frv:Linux:*:*) echo frv-unknown-linux-gnu exit ;; + i*86:Linux:*:*) + LIBC=gnu + eval $set_cc_for_build + sed 's/^ //' << EOF >$dummy.c + #ifdef __dietlibc__ + LIBC=dietlibc + #endif +EOF + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'` + echo "${UNAME_MACHINE}-pc-linux-${LIBC}" + exit ;; ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; @@ -866,74 +914,33 @@ EOF m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; - mips:Linux:*:*) - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #undef CPU - #undef mips - #undef mipsel - #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mipsel - #else - #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips - #else - CPU= - #endif - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" - test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } - ;; - mips64:Linux:*:*) + mips:Linux:*:* | mips64:Linux:*:*) eval $set_cc_for_build sed 's/^ //' << EOF >$dummy.c #undef CPU - #undef mips64 - #undef mips64el + #undef ${UNAME_MACHINE} + #undef ${UNAME_MACHINE}el #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=mips64el + CPU=${UNAME_MACHINE}el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=mips64 + CPU=${UNAME_MACHINE} #else CPU= #endif #endif EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^CPU/{ - s: ::g - p - }'`" + eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'` test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; } ;; or32:Linux:*:*) echo or32-unknown-linux-gnu exit ;; - ppc:Linux:*:*) - echo powerpc-unknown-linux-gnu - exit ;; - ppc64:Linux:*:*) - echo powerpc64-unknown-linux-gnu + padre:Linux:*:*) + echo sparc-unknown-linux-gnu exit ;; - alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in - EV5) UNAME_MACHINE=alphaev5 ;; - EV56) UNAME_MACHINE=alphaev56 ;; - PCA56) UNAME_MACHINE=alphapca56 ;; - PCA57) UNAME_MACHINE=alphapca56 ;; - EV6) UNAME_MACHINE=alphaev6 ;; - EV67) UNAME_MACHINE=alphaev67 ;; - EV68*) UNAME_MACHINE=alphaev68 ;; - esac - objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null - if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi - echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} + parisc64:Linux:*:* | hppa64:Linux:*:*) + echo hppa64-unknown-linux-gnu exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level @@ -943,8 +950,11 @@ EOF *) echo hppa-unknown-linux-gnu ;; esac exit ;; - parisc64:Linux:*:* | hppa64:Linux:*:*) - echo hppa64-unknown-linux-gnu + ppc64:Linux:*:*) + echo powerpc64-unknown-linux-gnu + exit ;; + ppc:Linux:*:*) + echo powerpc-unknown-linux-gnu exit ;; s390:Linux:*:* | s390x:Linux:*:*) echo ${UNAME_MACHINE}-ibm-linux @@ -958,6 +968,9 @@ EOF sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-tilera-linux-gnu + exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; @@ -967,69 +980,6 @@ EOF xtensa*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; - i*86:Linux:*:*) - # The BFD linker knows what the default object file format is, so - # first see if it will tell us. cd to the root directory to prevent - # problems with other programs or directories called `ld' in the path. - # Set LC_ALL=C to ensure ld outputs messages in English. - ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \ - | sed -ne '/supported targets:/!d - s/[ ][ ]*/ /g - s/.*supported targets: *// - s/ .*// - p'` - case "$ld_supported_targets" in - elf32-i386) - TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu" - ;; - a.out-i386-linux) - echo "${UNAME_MACHINE}-pc-linux-gnuaout" - exit ;; - coff-i386) - echo "${UNAME_MACHINE}-pc-linux-gnucoff" - exit ;; - "") - # Either a pre-BFD a.out linker (linux-gnuoldld) or - # one that does not give us useful --help. - echo "${UNAME_MACHINE}-pc-linux-gnuoldld" - exit ;; - esac - # Determine whether the default compiler is a.out or elf - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include <features.h> - #ifdef __ELF__ - # ifdef __GLIBC__ - # if __GLIBC__ >= 2 - LIBC=gnu - # else - LIBC=gnulibc1 - # endif - # else - LIBC=gnulibc1 - # endif - #else - #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__SUNPRO_C) || defined(__SUNPRO_CC) - LIBC=gnu - #else - LIBC=gnuaout - #endif - #endif - #ifdef __dietlibc__ - LIBC=dietlibc - #endif -EOF - eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n ' - /^LIBC/{ - s: ::g - p - }'`" - test x"${LIBC}" != x && { - echo "${UNAME_MACHINE}-pc-linux-${LIBC}" - exit - } - test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; } - ;; i*86:DYNIX/ptx:4*:*) # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. # earlier versions are messed up and put the nodename in both @@ -1058,7 +1008,7 @@ EOF i*86:syllable:*:*) echo ${UNAME_MACHINE}-pc-syllable exit ;; - i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*) + i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit ;; i*86:*DOS:*:*) @@ -1102,8 +1052,11 @@ EOF pc:*:*:*) # Left here for compatibility: # uname -m prints for DJGPP always 'pc', but it prints nothing about - # the processor, so we play safe by assuming i386. - echo i386-pc-msdosdjgpp + # the processor, so we play safe by assuming i586. + # Note: whatever this is, it MUST be the same as what config.sub + # prints for the "djgpp" host, or else GDB configury will decide that + # this is a cross-build. + echo i586-pc-msdosdjgpp exit ;; Intel:Mach:3*:*) echo i386-pc-mach3 @@ -1141,6 +1094,16 @@ EOF 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && { echo i486-ncr-sysv4; exit; } ;; + NCR*:*:4.2:* | MPRAS*:*:4.2:*) + OS_REL='.3' + test -r /etc/.relid \ + && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` + /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ + && { echo i486-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } + /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \ + && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;; m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit ;; @@ -1153,7 +1116,7 @@ EOF rs6000:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit ;; - PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*) + PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*) echo powerpc-unknown-lynxos${UNAME_RELEASE} exit ;; SM[BE]S:UNIX_SV:*:*) @@ -1216,6 +1179,9 @@ EOF BePC:BeOS:*:*) # BeOS running on Intel PC compatible. echo i586-pc-beos exit ;; + BePC:Haiku:*:*) # Haiku running on Intel PC compatible. + echo i586-pc-haiku + exit ;; SX-4:SUPER-UX:*:*) echo sx4-nec-superux${UNAME_RELEASE} exit ;; @@ -1243,6 +1209,16 @@ EOF *:Darwin:*:*) UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown case $UNAME_PROCESSOR in + i386) + eval $set_cc_for_build + if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then + if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ + (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_64BIT_ARCH >/dev/null + then + UNAME_PROCESSOR="x86_64" + fi + fi ;; unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} @@ -1324,6 +1300,9 @@ EOF i*86:rdos:*:*) echo ${UNAME_MACHINE}-pc-rdos exit ;; + i*86:AROS:*:*) + echo ${UNAME_MACHINE}-pc-aros + exit ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 diff --git a/config.sub b/config.sub index 6759825a5..320e30388 100755 --- a/config.sub +++ b/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 # Free Software Foundation, Inc. -timestamp='2008-01-16' +timestamp='2010-09-11' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -32,13 +32,16 @@ timestamp='2008-01-16' # Please send patches to <config-patches@gnu.org>. Submit a context -# diff and a properly formatted ChangeLog entry. +# diff and a properly formatted GNU ChangeLog entry. # # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. +# You can get the latest version of this script from: +# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD + # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. @@ -72,8 +75,9 @@ Report bugs and patches to <config-patches@gnu.org>." version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free +Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -120,8 +124,10 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ - uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ + kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` @@ -148,10 +154,13 @@ case $os in -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis | -knuth | -cray) + -apple | -axis | -knuth | -cray | -microblaze) os= basic_machine=$1 ;; + -bluegene*) + os=-cnk + ;; -sim | -cisco | -oki | -wec | -winbond) os= basic_machine=$1 @@ -249,13 +258,16 @@ case $basic_machine in | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ + | lm32 \ | m32c | m32r | m32rle | m68000 | m68k | m88k \ - | maxq | mb | microblaze | mcore | mep \ + | maxq | mb | microblaze | mcore | mep | metag \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ - | mips64vr | mips64vrel \ + | mips64octeon | mips64octeonel \ | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ | mips64vr4100 | mips64vr4100el \ | mips64vr4300 | mips64vr4300el \ | mips64vr5000 | mips64vr5000el \ @@ -268,28 +280,41 @@ case $basic_machine in | mipsisa64sr71k | mipsisa64sr71kel \ | mipstx39 | mipstx39el \ | mn10200 | mn10300 \ + | moxie \ | mt \ | msp430 \ + | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | or32 \ | pdp10 | pdp11 | pj | pjl \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | pyramid \ + | rx \ | score \ - | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ + | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ + | tahoe | thumb | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ + | ubicom32 \ | v850 | v850e \ | we32k \ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \ - | z8k) + | z8k | z80) basic_machine=$basic_machine-unknown ;; - m6811 | m68hc11 | m6812 | m68hc12) + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; + m6811 | m68hc11 | m6812 | m68hc12 | picochip) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown os=-none @@ -320,7 +345,7 @@ case $basic_machine in | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ @@ -329,14 +354,17 @@ case $basic_machine in | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ + | lm32-* \ | m32c-* | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* \ + | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips16-* \ | mips64-* | mips64el-* \ - | mips64vr-* | mips64vrel-* \ + | mips64octeon-* | mips64octeonel-* \ | mips64orion-* | mips64orionel-* \ + | mips64r5900-* | mips64r5900el-* \ + | mips64vr-* | mips64vrel-* \ | mips64vr4100-* | mips64vr4100el-* \ | mips64vr4300-* | mips64vr4300el-* \ | mips64vr5000-* | mips64vr5000el-* \ @@ -351,27 +379,30 @@ case $basic_machine in | mmix-* \ | mt-* \ | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | pyramid-* \ - | romp-* | rs6000-* \ - | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ + | romp-* | rs6000-* | rx-* \ + | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \ | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile-* | tilegx-* \ | tron-* \ + | ubicom32-* \ | v850-* | v850e-* | vax-* \ | we32k-* \ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \ | xstormy16-* | xtensa*-* \ | ymp-* \ - | z8k-*) + | z8k-* | z80-*) ;; # Recognize the basic CPU types without company name, with glob match. xtensa*) @@ -439,6 +470,10 @@ case $basic_machine in basic_machine=m68k-apollo os=-bsd ;; + aros) + basic_machine=i386-pc + os=-aros + ;; aux) basic_machine=m68k-apple os=-aux @@ -455,10 +490,27 @@ case $basic_machine in basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'` os=-linux ;; + bluegene*) + basic_machine=powerpc-ibm + os=-cnk + ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; c90) basic_machine=c90-cray os=-unicos ;; + cegcc) + basic_machine=arm-unknown + os=-cegcc + ;; convex-c1) basic_machine=c1-convex os=-bsd @@ -526,6 +578,10 @@ case $basic_machine in basic_machine=m88k-motorola os=-sysv3 ;; + dicos) + basic_machine=i686-pc + os=-dicos + ;; djgpp) basic_machine=i586-pc os=-msdosdjgpp @@ -699,6 +755,9 @@ case $basic_machine in basic_machine=ns32k-utek os=-sysv ;; + microblaze) + basic_machine=microblaze-xilinx + ;; mingw32) basic_machine=i386-pc os=-mingw32 @@ -803,6 +862,12 @@ case $basic_machine in np1) basic_machine=np1-gould ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -1037,17 +1102,10 @@ case $basic_machine in basic_machine=t90-cray os=-unicos ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff + # This must be matched before tile*. + tilegx*) + basic_machine=tilegx-unknown + os=-linux-gnu ;; tile*) basic_machine=tile-unknown @@ -1128,6 +1186,10 @@ case $basic_machine in basic_machine=z8k-unknown os=-sim ;; + z80-*-coff) + basic_machine=z80-unknown + os=-sim + ;; none) basic_machine=none-none os=-none @@ -1166,7 +1228,7 @@ case $basic_machine in we32k) basic_machine=we32k-att ;; - sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele) + sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele) basic_machine=sh-unknown ;; sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v) @@ -1216,6 +1278,9 @@ case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. + -auroraux) + os=-auroraux + ;; -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; @@ -1236,10 +1301,11 @@ case $os in # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ - | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ - | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ + | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\ + | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \ + | -sym* | -kopensolaris* \ | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \ - | -aos* \ + | -aos* | -aros* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \ @@ -1248,9 +1314,10 @@ case $os in | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ - | -chorusos* | -chorusrdb* \ + | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -mingw32* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ @@ -1258,7 +1325,7 @@ case $os in | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \ - | -skyos* | -haiku* | -rdos* | -toppers* | -drops*) + | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) @@ -1388,6 +1455,11 @@ case $os in -zvmoe) os=-zvmoe ;; + -dicos*) + os=-dicos + ;; + -nacl*) + ;; -none) ;; *) @@ -1428,6 +1500,15 @@ case $basic_machine in c4x-* | tic4x-*) os=-coff ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 @@ -1585,7 +1666,7 @@ case $basic_machine in -sunos*) vendor=sun ;; - -aix*) + -cnk*|-aix*) vendor=ibm ;; -beos*) diff --git a/config/Makefile.am b/config/Makefile.am index 527aefa7e..4dc7216f1 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2001,2006,2008,2009 Free Software Foundation, Inc. +# Copyright 2001,2006,2008,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -69,9 +69,7 @@ m4macros = \ grc_gr_usrp.m4 \ grc_gr_video_sdl.m4 \ grc_gr_wxgui.m4 \ - grc_mblock.m4 \ grc_gruel.m4 \ - grc_vrt.m4 \ gr_check_createfilemapping.m4 \ gr_check_mc4020.m4 \ gr_check_shm_open.m4 \ @@ -87,7 +85,6 @@ m4macros = \ gr_lib64.m4 \ gr_libgnuradio_core_extra_ldflags.m4 \ gr_no_undefined.m4 \ - gr_omnithread.m4 \ gr_pwin32.m4 \ gr_python.m4 \ gr_require_mc4020.m4 \ diff --git a/config/gr_git.m4 b/config/gr_git.m4 index e27460713..c4f1ea0c0 100644 --- a/config/gr_git.m4 +++ b/config/gr_git.m4 @@ -1,4 +1,4 @@ -dnl Copyright 2009 Free Software Foundation, Inc. +dnl Copyright 2009,2010 Free Software Foundation, Inc. dnl dnl This file is part of GNU Radio dnl @@ -29,14 +29,35 @@ AC_DEFUN([GR_GIT],[ AC_MSG_RESULT([ok]) AC_MSG_CHECKING([git description of current commit]) if (cd $srcdir && $GIT describe >/dev/null 2>&1); then - GIT_VERSION=`cd $srcdir && $GIT describe --abbrev=8 | cut -f 2- -d '-'` - AC_MSG_RESULT([$GIT_DESCRIBE]) + GIT_DESCRIBE=`cd $srcdir && $GIT describe --abbrev=8 --long` + # Release candidate tags create an extra -rcX field + case $GIT_DESCRIBE in + *-*-*-*) + GIT_TAG=`echo $GIT_DESCRIBE | cut -f -2 -d '-'` + GIT_SEQNO=`echo $GIT_DESCRIBE | cut -f 3 -d '-'` + GIT_COMMIT=`echo $GIT_DESCRIBE | cut -f 4 -d '-' | cut -f 2- -d 'g'` + ;; + *-*-*) + GIT_TAG=`echo $GIT_DESCRIBE | cut -f 1 -d '-'` + GIT_SEQNO=`echo $GIT_DESCRIBE | cut -f 2 -d '-'` + GIT_COMMIT=`echo $GIT_DESCRIBE | cut -f 3 -d '-' | cut -f 2- -d 'g'` + ;; + esac + + AC_MSG_RESULT([$GIT_DESCRIBE]) else - AC_MSG_RESULT([unable to find, using current commit]) - GIT_VERSION=`cd $srcdir && $GIT describe --always --abbrev=8` + AC_MSG_RESULT([no tag in history, using current commit]) + GIT_TAG='' + GIT_SEQNO='' + GIT_COMMIT=`cd $srcdir && $GIT describe --always --abbrev=8` fi else AC_MSG_RESULT([not found]) fi + + AC_SUBST([GIT_DESCRIBE]) + AC_SUBST([GIT_TAG]) + AC_SUBST([GIT_SEQNO]) + AC_SUBST([GIT_COMMIT]) fi ]) diff --git a/config/gr_omnithread.m4 b/config/gr_omnithread.m4 deleted file mode 100644 index 054f07824..000000000 --- a/config/gr_omnithread.m4 +++ /dev/null @@ -1,52 +0,0 @@ -# Check for Omnithread (pthread/NT) thread support. -*- Autoconf -*- - -# Copyright 2003,2007 Free Software Foundation, Inc. - -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. - -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. - -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Boston, MA -# 02110-1301, USA. - -AC_DEFUN([GR_OMNITHREAD], -[ - # Check first for POSIX - ACX_PTHREAD( - [ AC_DEFINE(HAVE_PTHREAD,1,[Define if you have POSIX threads libraries and header files.]) - ot_posix="yes" - DEFINES="$DEFINES -DOMNITHREAD_POSIX=1" - ],[ - # If no POSIX support found, then check for NT threads - AC_MSG_CHECKING([for NT threads]) - - AC_LINK_IFELSE([ - #include <windows.h> - #include <winbase.h> - int main() { InitializeCriticalSection(NULL); return 0; } - ], - [ - ot_nt="yes" - DEFINES="$DEFINES -DOMNITHREAD_NT=1" - ], - [AC_MSG_FAILURE([GNU Radio requires POSIX threads. pthreads not found.])] - ) - AC_MSG_RESULT(yes) - ]) - AM_CONDITIONAL(OMNITHREAD_POSIX, test "x$ot_posix" = xyes) - AM_CONDITIONAL(OMNITHREAD_NT, test "x$ot_nt" = xyes) - - save_LIBS="$LIBS" - AC_SEARCH_LIBS([clock_gettime], [rt], [PTHREAD_LIBS="$PTHREAD_LIBS $LIBS"]) - AC_CHECK_FUNCS([clock_gettime gettimeofday nanosleep]) - LIBS="$save_LIBS" -]) - diff --git a/config/gr_python.m4 b/config/gr_python.m4 index 43ccfc015..7aef1662e 100644 --- a/config/gr_python.m4 +++ b/config/gr_python.m4 @@ -153,14 +153,16 @@ AC_DEFUN([PYTHON_CHECK_MODULE],[ try: import $1 assert $5 -except: exit(1)' +except ImportError, AssertionError: exit(1) +except: pass' dnl ######################################## dnl # import checking only dnl ######################################## else python_cmd=' try: import $1 -except: exit(1)' +except ImportError: exit(1) +except: pass' fi if ! $PYTHON -c "$python_cmd" 2> /dev/null; then AC_MSG_RESULT([no]) diff --git a/config/gr_version.m4 b/config/gr_version.m4 index 3360b7d54..a7a202238 100644 --- a/config/gr_version.m4 +++ b/config/gr_version.m4 @@ -1,4 +1,4 @@ -dnl Copyright 2009 Free Software Foundation, Inc. +dnl Copyright 2009,2010 Free Software Foundation, Inc. dnl dnl This file is part of GNU Radio dnl @@ -25,50 +25,49 @@ AC_DEFUN([GR_VERSION],[ dnl dnl MAJOR_VERSION Major release generation (2.x, 3.x, etc.) dnl API_COMPAT API compatibility version (3.2.x, 3.3.x, etc.) - dnl MINOR_VERSION Minor release version + dnl MINOR_VERSION Minor release version (3.3.0, 3.3.1, etc.) dnl MAINT_VERSION Pure bugfix additions to make maintenance release dnl dnl The last two fields can have 'git' instead of a number to indicate dnl that this branch is between versions. . $srcdir/version.sh - RELEASE=$MAJOR_VERSION.$API_COMPAT dnl Get git version if available GR_GIT dnl Test if we should use git version if test "$MINOR_VERSION" == "git"; then - dnl 3.3git-xxx-gxxxxxxxx - RELEASE=$RELEASE$MINOR_VERSION - DOCVER=$RELEASE - if test "$GIT_VERSION" != "" ; then - RELEASE=$RELEASE-$GIT_VERSION - fi + dnl RELEASE: 3.3git-xxx-gxxxxxxxx + dnl DOCVER: 3.3git + dnl LIBVER: 3.3git + RELEASE=$GIT_DESCRIBE + DOCVER=$MAJOR_VERSION.$API_COMPAT$MINOR_VERSION + LIBVER=$MAJOR_VERSION.$API_COMPAT$MINOR_VERSION else if test "$MAINT_VERSION" == "git" ; then - dnl 3.3.1git-xxx-gxxxxxxxx - RELEASE=$RELEASE.$MINOR_VERSION$MAINT_VERSION - DOCVER=$RELEASE - if test "$GIT_VERSION" != "" ; then - RELEASE=$RELEASE-$GIT_VERSION - fi + dnl RELEASE: 3.3.1git-xxx-gxxxxxxxx + dnl DOCVER: 3.3.1git + dnl LIBVER: 3.3.1git + RELEASE=$GIT_DESCRIBE + DOCVER=$MAJOR_VERSION.$API_COMPAT.$MINOR_VERSION$MAINT_VERSION + LIBVER=$MAJOR_VERSION.$API_COMPAT.$MINOR_VERSION$MAINT_VERSION else - dnl This is a numbered reelase. - dnl Test if minor version is 0, which we don't encode, unless it is also - dnl a maintenance release - if test "$MINOR_VERSION" != "0" -o "$MAINT_VERSION" != "0"; then - dnl 3.3.1 - RELEASE=$RELEASE.$MINOR_VERSION - if test "$MAINT_VERSION" != "0"; then - dnl 3.3.0.1, 3.3.1.1 - RELEASE=$RELEASE.$MAINT_VERSION - fi - DOCVER=$RELEASE + dnl This is a numbered release. + dnl RELEASE: 3.3.1{.x} + dnl DOCVER: 3.3.1{.x} + dnl LIBVER: 3.3.1{.x} + RELEASE=$MAJOR_VERSION.$API_COMPAT.$MINOR_VERSION + if test "$MAINT_VERSION" != "0"; then + RELEASE=$RELEASE.$MAINT_VERSION fi + + DOCVER=$RELEASE + LIBVER=$RELEASE fi fi AC_MSG_NOTICE([GNU Radio Release $RELEASE]) AC_SUBST(RELEASE) AC_SUBST(DOCVER) + AC_SUBST(LIBVER) ]) diff --git a/config/grc_gr_audio_portaudio.m4 b/config/grc_gr_audio_portaudio.m4 index 08d71f8fb..ff551b38a 100644 --- a/config/grc_gr_audio_portaudio.m4 +++ b/config/grc_gr_audio_portaudio.m4 @@ -22,7 +22,6 @@ AC_DEFUN([GRC_GR_AUDIO_PORTAUDIO],[ dnl Don't do gr-audio-portaudio if gnuradio-core skipped GRC_CHECK_DEPENDENCY(gr-audio-portaudio, gnuradio-core) - GRC_CHECK_DEPENDENCY(gr-audio-portaudio, omnithread) dnl If execution gets to here, $passed will be: dnl with : if the --with code didn't error out diff --git a/config/grc_gr_qtgui.m4 b/config/grc_gr_qtgui.m4 index 84514d7ce..4027bb332 100644 --- a/config/grc_gr_qtgui.m4 +++ b/config/grc_gr_qtgui.m4 @@ -42,10 +42,9 @@ AC_DEFUN([GRC_GR_QTGUI],[ # QtGui # QtCore # qwt -# qwtplot3d # qt4 -# qt4-core, qt4-gui, qwt5-qt4, qwt5-qt4-dev, libqwtplot3d-qt4, libqwtplot3d-qt4-dev, qt4-dev-tools +# qt4-core, qt4-gui, qwt5-qt4, qwt5-qt4-dev, qt4-dev-tools if test $passed = yes; then dnl Check for package qt or qt-mt, set QT_CFLAGS and QT_LIBS @@ -59,20 +58,15 @@ AC_DEFUN([GRC_GR_QTGUI],[ dnl Fetch QWT variables GR_QWT([], [passed=no]) - dnl Process QWT Plot3D only if QWT passed - if test "$passed" = "yes"; then - GR_QWTPLOT3D([], [passed=no]) - fi - dnl Export the include dirs and libraries (note: QTOPENGL_LIBS includes links dnl to QtCore and QtGui libraries) - QT_INCLUDES="$QWT_CFLAGS $QWTPLOT3D_CFLAGS $QTCORE_CFLAGS $QTGUI_CFLAGS" - QT_LIBS="$QWT_LIBS $QWTPLOT3D_LIBS $QTOPENGL_LIBS" + QT_INCLUDES="$QWT_CFLAGS $QTCORE_CFLAGS $QTGUI_CFLAGS" + QT_LIBS="$QWT_LIBS $QTOPENGL_LIBS" dnl Build an includes variable specifically for running qmake by extracting - dnl all includes from the QWT and QWTPLOT3D, without the -I; + dnl all includes from the QWT, without the -I; dnl qmake appends the -I when processing the project file INCLUDEPATH - for i in $QWT_CFLAGS $QWTPLOT3D_CFLAGS; do + for i in $QWT_CFLAGS; do QMAKE_INCLUDES="$QMAKE_INCLUDES ${i##-I}" done diff --git a/config/grc_mblock.m4 b/config/grc_mblock.m4 deleted file mode 100644 index e3ae1817f..000000000 --- a/config/grc_mblock.m4 +++ /dev/null @@ -1,59 +0,0 @@ -dnl Copyright 2001,2002,2003,2004,2005,2006,2008 Free Software Foundation, Inc. -dnl -dnl This file is part of GNU Radio -dnl -dnl GNU Radio is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 3, or (at your option) -dnl any later version. -dnl -dnl GNU Radio is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with GNU Radio; see the file COPYING. If not, write to -dnl the Free Software Foundation, Inc., 51 Franklin Street, -dnl Boston, MA 02110-1301, USA. - -AC_DEFUN([GRC_MBLOCK],[ - GRC_ENABLE(mblock) - - GRC_WITH(mblock) - - dnl Don't do mblock if omnithread or pmt skipped - GRC_CHECK_DEPENDENCY(mblock, pmt) - GRC_CHECK_DEPENDENCY(mblock, omnithread) - - dnl If execution gets to here, $passed will be: - dnl with : if the --with code didn't error out - dnl yes : if the --enable code passed muster and all dependencies are met - dnl no : otherwise - if test $passed = yes; then - dnl Don't do mblock if guile not available - GRC_CHECK_GUILE(mblock) - fi - if test $passed != with; then - dnl how and where to find INCLUDES and LA - mblock_INCLUDES="-I\${abs_top_srcdir}/mblock/src/include" - mblock_LA="\${abs_top_builddir}/mblock/src/lib/libmblock.la" - fi - - AC_CONFIG_FILES([\ - mblock/Makefile \ - mblock/mblock.pc \ - mblock/doc/Makefile \ - mblock/src/Makefile \ - mblock/src/include/Makefile \ - mblock/src/include/mblock/Makefile \ - mblock/src/lib/Makefile \ - mblock/src/scheme/Makefile \ - mblock/src/scheme/gnuradio/Makefile \ - ]) - - GRC_BUILD_CONDITIONAL(mblock,[ - dnl run_tests is created from run_tests.in. Make it executable. - dnl AC_CONFIG_COMMANDS([run_tests_mblock], [chmod +x mblock/src/python/run_tests]) - ]) -]) diff --git a/config/grc_omnithread.m4 b/config/grc_omnithread.m4 deleted file mode 100644 index 1bcedebe1..000000000 --- a/config/grc_omnithread.m4 +++ /dev/null @@ -1,46 +0,0 @@ -dnl Copyright 2001,2002,2003,2004,2005,2006,2007,2008 Free Software Foundation, Inc. -dnl -dnl This file is part of GNU Radio -dnl -dnl GNU Radio is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 3, or (at your option) -dnl any later version. -dnl -dnl GNU Radio is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with GNU Radio; see the file COPYING. If not, write to -dnl the Free Software Foundation, Inc., 51 Franklin Street, -dnl Boston, MA 02110-1301, USA. - -AC_DEFUN([GRC_OMNITHREAD],[ - GRC_ENABLE(omnithread) - - GRC_WITH(omnithread, [], gnuradio-omnithread) - - dnl If execution gets to here, $passed will be: - dnl with : if the --with code didn't error out - dnl yes : if the --enable code passed muster and all dependencies are met - dnl no : otherwise - if test $passed != with; then - dnl how and where to find INCLUDES and LA and such - omnithread_INCLUDES="-I\${abs_top_srcdir}/omnithread" - omnithread_LA="\${abs_top_builddir}/omnithread/libgromnithread.la" - omnithread_LIBDIRPATH="\${abs_top_builddir}/omnithread:\${abs_top_builddir}/omnithread/.libs" - fi - - AC_CONFIG_FILES([ \ - omnithread/Makefile \ - omnithread/gnuradio/Makefile \ - omnithread/gnuradio-omnithread.pc - ]) - - GRC_BUILD_CONDITIONAL(omnithread,[ - dnl run_tests is created from run_tests.in. Make it executable. - dnl AC_CONFIG_COMMANDS([run_tests_omnithread], [chmod +x omnithread/run_tests]) - ]) -]) diff --git a/config/grc_vrt.m4 b/config/grc_vrt.m4 deleted file mode 100644 index 982c8863a..000000000 --- a/config/grc_vrt.m4 +++ /dev/null @@ -1,64 +0,0 @@ -dnl Copyright 2008,2009 Free Software Foundation, Inc. -dnl -dnl This file is part of GNU Radio -dnl -dnl GNU Radio is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 3, or (at your option) -dnl any later version. -dnl -dnl GNU Radio is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with GNU Radio; see the file COPYING. If not, write to -dnl the Free Software Foundation, Inc., 51 Franklin Street, -dnl Boston, MA 02110-1301, USA. - -AC_DEFUN([GRC_VRT],[ - GRC_ENABLE(vrt) - - dnl If execution gets to here, $passed will be: - dnl with : if the --with code didn't error out - dnl yes : if the --enable code passed muster and all dependencies are met - dnl no : otherwise - if test $passed = yes; then - dnl Needed for vrt_socket_opener - AC_CHECK_HEADERS(arpa/inet.h byteswap.h linux/if_packet.h sys/socket.h sys/un.h) - fi - if test $passed != with; then - dnl how and where to find INCLUDES and LA - VRT_INCLUDES="-I\${abs_top_srcdir}/vrt/include" - VRT_LA="\${abs_top_builddir}/vrt/lib/libvrt.la" - fi - - # Test host OS compatibility - AC_MSG_CHECKING([whether host_os is linux*]) - case "$host_os" in - linux*) - AC_MSG_RESULT([yes]) - ;; - *) - AC_MSG_RESULT([no]) - AC_MSG_NOTICE([libvrt currently requires Linux host OS, not found]) - passed="no" - ;; - esac - - dnl Include the vrt INCLUDES and LA - AC_SUBST(VRT_INCLUDES) - AC_SUBST(VRT_LA) - - AC_CONFIG_FILES([ - vrt/Makefile - vrt/vrt.pc - vrt/include/Makefile - vrt/include/vrt/Makefile - vrt/lib/Makefile - vrt/apps/Makefile - ]) - - GRC_BUILD_CONDITIONAL(vrt) -]) diff --git a/config/usrp_libusb.m4 b/config/usrp_libusb.m4 index 251f7df10..a434d379d 100755..100644 --- a/config/usrp_libusb.m4 +++ b/config/usrp_libusb.m4 @@ -28,64 +28,153 @@ AC_DEFUN([USRP_LIBUSB], [ dnl make sure the USB_* variables work (whether from PKGCONFIG dnl or overridden by the user) - libusbok=no - have_libusb1=no - LIBUSB_PKG_CONFIG_NAME='' + dnl do not use LDFLAGS, since PKGCONFIG will provide everything + saved_LDFLAGS=${LDFLAGS} + LDFLAGS= + LIBUSB_PKG_CONFIG_NAME= + + 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 create the list of libusb PKGCONFIG modules to test + libusb_list='' if test x$1 = xyes; then - PKG_CHECK_MODULES(USB, libusb-1.0, [ - libusbok=yes - have_libusb1=yes - usb_header='libusb-1.0/libusb.h' - usb_lib_func='libusb_bulk_transfer' - usb_lib_name='usb-1.0' - LIBUSB_PKG_CONFIG_NAME='libusb-1.0' - ]) + dnl libusb-1.0 was requested; just test for it + libusb_list="libusb-1.0" else - dnl not using libusb1 (for now); see if legacy version is found. - dnl it might be installed under the name either 'libusb' or - dnl 'libusb-legacy', or just available via the - dnl user's shell environment - - dnl see if the pkgconfig module 'libusb' is available - PKG_CHECK_MODULES(USB, libusb, [ - libusbok=yes - LIBUSB_PKG_CONFIG_NAME='libusb' + dnl test for legacy libusb only + libusb_list="libusb libusb-legacy" + fi + for libusb_name in ${libusb_list}; do + dnl clear internal variables + libusbok=no + have_libusb1=no + usb_header='' + 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]) - dnl PKG_CHECK_MODULES does not work correctly when embedded - if test $libusbok = no; then - dnl if not, see if the pkgconfig module 'libusb-legacy' is available - PKG_CHECK_MODULES(USB, [libusb-legacy], [ + else + dnl see if the pkgconfig module is available + PKG_CHECK_MODULES(USB, ${libusb_name}, [ libusbok=yes - LIBUSB_PKG_CONFIG_NAME='libusb-legacy' - ], [libusbok=no]) + usb_header='usb.h' + usb_lib_func='usb_bulk_write' + ], [libusbok=no]) fi - dnl set variables for further testing - usb_header='usb.h' - usb_lib_func='usb_bulk_write' - usb_lib_name='usb' - fi - AC_SUBST(LIBUSB_PKG_CONFIG_NAME) - if test x$1 != xyes || test $have_libusb1 = yes; then - dnl Either (1) libusb1 was specified and found; or - dnl (2) libusb1 was not specified. Restart checking. - libusbok=yes + if test $libusbok = yes; then + dnl PKGCONFIG found a version of LIBUSB. + 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 Check for the header. Similar to AC_CHECK_HEADERS, + dnl but doesn't append to known \#defines. + dnl If PKGCONFIG found variable USB_INCLUDEDIR, and it is + dnl not empty, use it for checking for $usb_header. + dnl Otherwise, maybe the user's shell environment is already + dnl configured to find this header. + AC_LANG_PUSH(C) + save_CPPFLAGS="$CPPFLAGS" + if test x$USB_INCLUDEDIR != x; then + USB_INCLUDES="-I$USB_INCLUDEDIR" + CPPFLAGS="$USB_INCLUDES" + fi + AC_MSG_CHECKING([$libusb_name for header $usb_header]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #include "$usb_header" + ]], [])], + [libusbok=yes],[libusbok=no]) + AC_MSG_RESULT([$libusbok]) + CPPFLAGS="$save_CPPFLAGS" + AC_LANG_POP(C) + + if test $libusbok = yes; then + dnl found the header; now make sure the library is OK + dnl On Darwin, need to include the IOKit library. - dnl Verify that $usb_header is a valid header, and if so, - dnl then verify that $usb_lib_func can be found in the - dnl library $usb_lib_name. + AC_LANG_PUSH(C) + save_LIBS="$LIBS" + case "$host_os" in + darwin*) + USB_LIBS="$USB_LIBS -lIOKit" + ;; + *) ;; + esac + LIBS="$USB_LIBS" - dnl If PKGCONFIG found variable USB_INCLUDEDIR, and it is - dnl not empty, use it for checking for $usb_header. - dnl Otherwise, maybe the user's shell environment is already - dnl configured to find this header. + dnl find the library link name + usb_lib_name=`echo $USB_LIBS | sed -e "s@.*-l\(usb[[^ ]]*\).*@\1@"` + dnl Check for the function in the library. Similar to + dnl AC_CHECK_LIB, but doesn't append to known \#defines. + AC_MSG_CHECKING([$libusb_name for function $usb_lib_func in library $usb_lib_name]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[ + #ifdef __cplusplus + extern "C" + #endif + char $usb_lib_func (); + ]], [[return $usb_lib_func ();]])], + [libusbok=yes],[libusbok=no]) + AC_MSG_RESULT([$libusbok]) + LIBS="$save_LIBS" + AC_LANG_POP(C) + + 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) + fi + fi + fi + fi + dnl if everything checks out OK, finish up + if test $libusbok = yes; then + LIBUSB_PKG_CONFIG_NAME="${libusb_name}" + break + else + dnl something wasn't found in this LIBUSB version. + dnl HACK: clear cache variables for header and library + unset USB_INCLUDEDIR + unset USB_INCLUDES + unset USB_LIBS + unset $as_ac_Header + unset $as_ac_Lib + fi + done + + if test $libusbok = yes; then + dnl final error checking, mostly to create #define's AC_LANG_PUSH(C) save_CPPFLAGS="$CPPFLAGS" - if test x$USB_INCLUDEDIR != x; then - USB_INCLUDES="-I$USB_INCLUDEDIR" - CPPFLAGS="$CPPFLAGS $USB_INCLUDES" - AC_SUBST(USB_INCLUDES) - fi + CPPFLAGS="$USB_INCLUDES" + dnl Check for the header. AC_CHECK_HEADERS([$usb_header], [], [libusbok=no]) CPPFLAGS="$save_CPPFLAGS" AC_LANG_POP(C) @@ -93,24 +182,15 @@ AC_DEFUN([USRP_LIBUSB], [ if test $libusbok = no; then AC_MSG_RESULT([USRP requires libusb header '$usb_header' which was not found or was not usable. See http://www.libusb.org]) else - - dnl found the header; now make sure the library is OK - dnl On Darwin, need to include the IOKit library. - + dnl check for the library (again) AC_LANG_PUSH(C) + save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$USB_INCLUDES" save_LIBS="$LIBS" - LIBS="" - case "$host_os" in - darwin*) - USB_LIBS="$USB_LIBS -lIOKit" - LIBS="$USB_LIBS" - ;; - *) ;; - esac + 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]) - ]) + 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" @@ -118,15 +198,28 @@ AC_DEFUN([USRP_LIBUSB], [ *) ;; esac LIBS="$save_LIBS" + CPPFLAGS="$save_CPPFLAGS" AC_LANG_POP(C) fi fi + if test $libusbok = yes; then - AC_SUBST(USB_LIBS) + dnl success + AC_MSG_NOTICE([Using LIBUSB version '${libusb_name}']) ifelse([$2], , :, [$2]) else + dnl not found; clear substitution variables + LIBUSB_PKG_CONFIG_NAME= USB_INCLUDES= USB_LIBS= ifelse([$3], , :, [$3]) fi + + dnl create substitution variables + AC_SUBST(USB_INCLUDES) + AC_SUBST(USB_LIBS) + AC_SUBST(LIBUSB_PKG_CONFIG_NAME) + + dnl restore LDFLAGS + LDFLAGS=${saved_LDFLAGS} ]) diff --git a/configure.ac b/configure.ac index 3abdfbfcf..19d193172 100644 --- a/configure.ac +++ b/configure.ac @@ -124,7 +124,7 @@ dnl AC_DISABLE_SHARED dnl don't build shared libraries AC_ENABLE_SHARED dnl do build shared libraries AC_DISABLE_STATIC dnl don't build static libraries m4_ifdef([LT_INIT],[LT_INIT],[AC_PROG_LIBTOOL]) -GR_FORTRAN +dnl GR_FORTRAN GR_NO_UNDEFINED dnl do we need the -no-undefined linker flag GR_SCRIPTING @@ -149,9 +149,6 @@ AM_CONDITIONAL([HAS_XMLTO], [test x$XMLTO = xyes]) dnl Checks for libraries. AC_CHECK_LIB(socket,socket) -dnl check for omnithreads (will soon be removed) -GR_OMNITHREAD - dnl Set the c++ compiler that we use for the build system when cross compiling if test x$CXX_FOR_BUILD = x then @@ -173,9 +170,9 @@ AC_HEADER_SYS_WAIT AC_CHECK_HEADERS(fcntl.h limits.h strings.h time.h sys/ioctl.h sys/time.h unistd.h) AC_CHECK_HEADERS(linux/ppdev.h dev/ppbus/ppi.h sys/mman.h sys/select.h sys/types.h) AC_CHECK_HEADERS(sys/resource.h stdint.h sched.h signal.h sys/syscall.h malloc.h) -AC_CHECK_HEADERS(netinet/in.h) AC_CHECK_HEADERS(windows.h) AC_CHECK_HEADERS(vec_types.h) +AC_CHECK_HEADERS(netdb.h netinet/in.h arpa/inet.h sys/types.h sys/socket.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST @@ -296,7 +293,7 @@ dnl AX_BOOST_TEST_EXEC_MONITOR dnl AX_BOOST_UNIT_TEST_FRAMEWORK dnl AX_BOOST_WSERIALIZATION -BUILD_DATE=`date -R -u` +BUILD_DATE=`date -u +"%a, %d %b %Y %R:%S"` AC_SUBST(BUILD_DATE) dnl SYSCONFDIR substitution @@ -339,16 +336,12 @@ AC_ARG_ENABLE( build_dirs="config" GRC_GRUEL dnl must come first -GRC_OMNITHREAD dnl must come before gnuradio-core and mblock GRC_GCELL GRC_GNURADIO_CORE -GRC_MBLOCK dnl this must come after GRC_GRUEL GRC_USRP GRC_USRP2 -GRC_VRT GRC_GR_USRP dnl this must come after GRC_USRP GRC_GR_USRP2 -dnl GRC_GR_VRT GRC_GR_GCELL dnl this must come after GRC_GCELL and GRC_GNURADIO_CORE GRC_GR_MSDD6000 GRC_GR_AUDIO_ALSA diff --git a/docs/doxygen/Doxyfile.in b/docs/doxygen/Doxyfile.in index bf9b0ef47..243fa00bf 100644 --- a/docs/doxygen/Doxyfile.in +++ b/docs/doxygen/Doxyfile.in @@ -648,8 +648,6 @@ EXCLUDE = @abs_top_builddir@/docs/doxygen/html \ @abs_top_builddir@/gr-video-sdl/src/video_sdl.py \ @abs_top_builddir@/gr-wxgui/src/python \ @abs_top_builddir@/grc \ - @abs_top_builddir@/omnithread/mach.cc \ - @abs_top_builddir@/omnithread/nt.cc \ @abs_top_builddir@/usrp/doc \ @abs_top_builddir@/usrp/firmware \ @abs_top_builddir@/usrp/fpga \ @@ -689,7 +687,6 @@ EXCLUDE_PATTERNS = */.deps/* \ */__init__.py \ */gr-atsc/src/lib/Gr* \ */moc_*.cc \ - */omnithread/ot_* \ */qa_*.cc \ */qa_*.h \ */qa_*.py diff --git a/docs/doxygen/other/Makefile.am b/docs/doxygen/other/Makefile.am index 5e05d5d36..eb5f170af 100644 --- a/docs/doxygen/other/Makefile.am +++ b/docs/doxygen/other/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2001,2004 Free Software Foundation, Inc. +# Copyright 2001,2004,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -24,9 +24,6 @@ include $(top_srcdir)/Makefile.common EXTRA_DIST = \ doxypy.py \ group_defs.dox \ - omnithread.html \ - omnithread.pdf \ - omnithread.ps \ shared_ptr_docstub.h \ tv-channel-frequencies \ vector_docstub.h diff --git a/docs/doxygen/other/omnithread.html b/docs/doxygen/other/omnithread.html deleted file mode 100644 index 5682d1d0b..000000000 --- a/docs/doxygen/other/omnithread.html +++ /dev/null @@ -1,411 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" - "http://www.w3.org/TR/REC-html40/loose.dtd"> -<HTML> -<HEAD><TITLE>The OMNI Thread Abstraction</TITLE> - -<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> -<META name="GENERATOR" content="hevea 1.06"> -</HEAD> -<BODY > -<!--HEVEA command line is: /usr/local/bin/hevea omnithread --> -<!--HTMLHEAD--> -<!--ENDHTML--> -<!--PREFIX <ARG ></ARG>--> -<!--CUT DEF section 1 --> - - -<H1 ALIGN=center>The OMNI Thread Abstraction</H1> - -<H3 ALIGN=center>Tristan Richardson<BR> -AT&T Laboratories Cambridge<BR> -</H3> - -<H3 ALIGN=center><I>Revised</I> November 2001</H3> -<!--TOC section Introduction--> - -<H2><A NAME="htoc1">1</A> Introduction</H2><!--SEC END --> - -The OMNI thread abstraction is designed to provide a common set of -thread operations for use in programs written in C++. Programs -written using the abstraction should be much easier to port between -different architectures with different underlying threads primitives.<BR> -<BR> -The programming interface is designed to be similar to the C language -interface to POSIX threads (IEEE draft standard 1003.1c --- previously -1003.4a, often known as ``pthreads'' [<A HREF="#pthreads"><CITE>POSIX94</CITE></A>]).<BR> -<BR> -Much of the abstraction consists of simple C++ object wrappers around -pthread calls. However for some features such as thread-specific -data, a better interface can be offered because of the use of C++.<BR> -<BR> -Some of the more complex features of pthreads are not supported -because of the difficulty of ensuring the same features can be offered -on top of other thread systems. Such features include thread -cancellation and complex scheduling control (though simple thread -priorities are supported).<BR> -<BR> -The abstraction layer is currently implemented for the following -architectures / thread systems: -<UL><LI>Solaris 2.x using pthreads draft 10 -<LI>Solaris 2.x using solaris threads (but pthreads version is now standard) -<LI>Alpha OSF1 using pthreads draft 4 -<LI>Windows NT using NT threads -<LI>Linux 2.x using Linuxthread 0.5 (which is based on pthreads draft 10) -<LI>Linux 2.x using MIT pthreads (which is based on draft 8) -<LI>ATMos using pthreads draft 6 (but not Virata ATMos)</UL> -See the <TT>omnithread.h</TT> header file for full details of the API. -The descriptions below assume you have some previous knowledge of -threads, mutexes, condition variables and semaphores. Also refer to -other documentation ([<A HREF="#birrell"><CITE>Birrell89</CITE></A>], [<A HREF="#pthreads"><CITE>POSIX94</CITE></A>]) for further -explanation of these ideas (particularly condition variables, the use -of which may not be particularly intuitive when first encountered).<BR> -<BR> -<!--TOC section Synchronisation objects--> - -<H2><A NAME="htoc2">2</A> Synchronisation objects</H2><!--SEC END --> - -Synchronisation objects are used to synchronise threads within the -same process. There is no inter-process synchronisation provided. -The synchronisation objects provided are mutexes, condition variables -and counting semaphores.<BR> -<BR> -<!--TOC subsection Mutex--> - -<H3><A NAME="htoc3">2.1</A> Mutex</H3><!--SEC END --> - -An object of type <TT>omni_mutex</TT> is used for mutual exclusion. -It provides two operations, <TT>lock()</TT> and <TT>unlock()</TT>. -The alternative names <TT>acquire()</TT> and <TT>release()</TT> can be -used if preferred. Behaviour is undefined when a thread attempts to -lock the same mutex again or when a mutex is locked by one thread and -unlocked by a different thread.<BR> -<BR> -<!--TOC subsection Condition Variable--> - -<H3><A NAME="htoc4">2.2</A> Condition Variable</H3><!--SEC END --> - -A condition variable is represented by an <TT>omni_condition</TT> and -is used for signalling between threads. A call to <TT>wait()</TT> -causes a thread to wait on the condition variable. A call to -<TT>signal()</TT> wakes up at least one thread if any are waiting. A -call to <TT>broadcast()</TT> wakes up all threads waiting on the -condition variable.<BR> -<BR> -When constructed, a pointer to an <TT>omni_mutex</TT> must be given. -A condition variable <TT>wait()</TT> has an implicit mutex -<TT>unlock()</TT> and <TT>lock()</TT> around it. The link between -condition variable and mutex lasts for the lifetime of the condition -variable (unlike pthreads where the link is only for the duration of -the wait). The same mutex may be used with several condition -variables.<BR> -<BR> -A wait with a timeout can be achieved by calling -<TT>timed_wait()</TT>. This is given an absolute time to wait until. -The routine <TT>omni_thread::get_time()</TT> can be used to turn a -relative time into an absolute time. <TT>timed_wait()</TT> returns -<TT>true</TT> if the condition was signalled, <TT>false</TT> if the -time expired before the condition variable was signalled.<BR> -<BR> -<!--TOC subsection Counting semaphores--> - -<H3><A NAME="htoc5">2.3</A> Counting semaphores</H3><!--SEC END --> - -An <TT>omni_semaphore</TT> is a counting semaphore. When created it -is given an initial unsigned integer value. When <TT>wait()</TT> is -called, the value is decremented if non-zero. If the value is zero -then the thread blocks instead. When <TT>post()</TT> is called, if -any threads are blocked in <TT>wait()</TT>, exactly one thread is -woken. If no threads were blocked then the value of the semaphore is -incremented.<BR> -<BR> -If a thread calls <TT>try_wait()</TT>, then the thread won't block if -the semaphore's value is 0, returning <TT>false</TT> instead.<BR> -<BR> -There is no way of querying the value of the semaphore.<BR> -<BR> -<!--TOC section Thread object--> - -<H2><A NAME="htoc6">3</A> Thread object</H2><!--SEC END --> - -A thread is represented by an <TT>omni_thread</TT> object. There are -broadly two different ways in which it can be used.<BR> -<BR> -The first way is simply to create an <TT>omni_thread</TT> object, -giving a particular function which the thread should execute. This is -like the POSIX (or any other) C language interface.<BR> -<BR> -The second method of use is to create a new class which inherits from -<TT>omni_thread</TT>. In this case the thread will execute the -<TT>run()</TT> member function of the new class. One advantage of -this scheme is that thread-specific data can be implemented simply by -having data members of the new class.<BR> -<BR> -When constructed a thread is in the "new" state and has not actually -started. A call to <TT>start()</TT> causes the thread to begin -executing. A static member function <TT>create()</TT> is provided to -construct and start a thread in a single call. A thread exits by -calling <TT>exit()</TT> or by returning from the thread function.<BR> -<BR> -Threads can be either detached or undetached. Detached threads are -threads for which all state will be lost upon exit. Other threads -cannot determine when a detached thread will disappear, and therefore -should not attempt to access the thread object unless some explicit -synchronisation with the detached thread guarantees that it still -exists.<BR> -<BR> -Undetached threads are threads for which storage is not reclaimed -until another thread waits for its termination by calling -<TT>join()</TT>. An exit value can be passed from an undetached -thread to the thread which joins it.<BR> -<BR> -Detached / undetached threads are distinguished on creation by the -type of function they execute. Undetached threads execute a function -which has a <TT>void*</TT> return type, whereas detached threads -execute a function which has a <TT>void</TT> return type. -Unfortunately C++ member functions are not allowed to be distinguished -simply by their return type. Thus in the case of a derived class of -<TT>omni_thread</TT> which needs an undetached thread, the member -function executed by the thread is called <TT>run_undetached()</TT> -rather than <TT>run()</TT>, and it is started by calling -<TT>start_undetached()</TT> instead of <TT>start()</TT>.<BR> -<BR> -The abstraction currently supports three priorities of thread, but no -guarantee is made of how this will affect underlying thread -scheduling. The three priorities are <TT>PRIORITY_LOW</TT>, -<TT>PRIORITY_NORMAL</TT> and <TT>PRIORITY_HIGH</TT>. By default all -threads run at <TT>PRIORITY_NORMAL</TT>. A different priority can be -specified on thread creation, or while the thread is running using -<TT>set_priority().</TT> A thread's current priority is returned by -<TT>priority()</TT>.<BR> -<BR> -Other functions provided are <TT>self()</TT> which returns the calling -thread's <TT>omni_thread</TT> object, <TT>yield()</TT> which -requests that other threads be allowed to run, <TT>id()</TT> which -returns an integer id for the thread for use in debugging, -<TT>state()</TT>, <TT>sleep()</TT> and <TT>get_time()</TT>.<BR> -<BR> -<!--TOC section Per-thread data--> - -<H2><A NAME="htoc7">4</A> Per-thread data</H2><!--SEC END --> - -omnithread supports per-thread data, via member functions of the -<TT>omni_thread</TT> object.<BR> -<BR> -First, you must allocate a key for with the -<TT>omni_thread::allocate_key()</TT> function. Then, any object -whose class is derived from <TT>omni_thread::value_t</TT> can be -stored using the <TT>set_value()</TT> function. Values are retrieved -or removed with <TT>get_value()</TT> and <TT>remove_value()</TT> -respectively.<BR> -<BR> -When the thread exits, all per-thread data is deleted (hence the base -class with virtual destructor).<BR> -<BR> -Note that the per-thread data functions are <B>not</B> thread safe, -so although you can access one thread's storage from another thread, -there is no concurrency control. Unless you really know what you are -doing, it is best to only access per-thread data from the thread it is -attached to.<BR> -<BR> -<!--TOC section Using OMNI threads in your program--> - -<H2><A NAME="htoc8">5</A> Using OMNI threads in your program</H2><!--SEC END --> - -Obviously you need to include the <TT>omnithread.h</TT> header file in -your source code, and link in the omnithread library with your -executable. Because there is a single <TT>omnithread.h</TT> for all -platforms, certain preprocessor defines must be given as compiler -options. The easiest way to do this is to study the makefiles given -in the examples provided with this distribution. If you are to -include OMNI threads in your own development environment, these are -the necessary preprocessor defines:<BR> -<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=1> -<TR><TD ALIGN=left NOWRAP>Platform</TD> -<TD ALIGN=left NOWRAP>Preprocessor Defines</TD> -</TR> -<TR><TD ALIGN=left NOWRAP>Sun Solaris 2.x</TD> -<TD ALIGN=left NOWRAP><CODE>-D__sunos__ -D__sparc__ -D__OSVERSION__=5</CODE></TD> -</TR> -<TR><TD ALIGN=left NOWRAP> </TD> -<TD ALIGN=left NOWRAP><CODE>-DSVR4 -DUsePthread -D_REENTRANT</CODE></TD> -</TR> -<TR><TD ALIGN=left NOWRAP>x86 Linux 2.0</TD> -<TD ALIGN=left NOWRAP><CODE>-D__linux__ -D__i86__ -D__OSVERSION__=2</CODE></TD> -</TR> -<TR><TD ALIGN=left NOWRAP>with linuxthreads 0.5</TD> -<TD ALIGN=left NOWRAP><CODE>-D_REENTRANT</CODE></TD> -</TR> -<TR><TD ALIGN=left NOWRAP>Digital Unix 3.2</TD> -<TD ALIGN=left NOWRAP><CODE>-D__osf1__ -D__alpha__ -D__OSVERSION__=3</CODE></TD> -</TR> -<TR><TD ALIGN=left NOWRAP> </TD> -<TD ALIGN=left NOWRAP><CODE>-D_REENTRANT</CODE></TD> -</TR> -<TR><TD ALIGN=left NOWRAP>Windows NT</TD> -<TD ALIGN=left NOWRAP><CODE>-D__NT__ -MD</CODE></TD> -</TR></TABLE><BR> -<!--TOC section Threaded I/O shutdown for Unix--> - -<H2><A NAME="htoc9">6</A> Threaded I/O shutdown for Unix</H2><!--SEC END --> - -or, how one thread should tell another thread to shut down when it -might be doing a blocking call on a socket.<BR> -<BR> -<B>If you are using omniORB, you don't need to worry about all -this, since omniORB does it for you.</B> This section is only relevant -if you are using omnithread in your own socket-based programming. It -is also seriously out of date.<BR> -<BR> -Unfortunately there doesn't seem to be a standard way of doing this -which works across all Unix systems. I have investigated the -behaviour of Solaris 2.5 and Digital Unix 3.2. On Digital Unix -everything is fine, as the obvious method using shutdown() seems to -work OK. Unfortunately on Solaris shutdown can only be used on a -connected socket, so we need devious means to get around this -limitation. The details are summarised below:<BR> -<BR> -<!--TOC subsection read()--> - -<H3><A NAME="htoc10">6.1</A> read()</H3><!--SEC END --> - -Thread A is in a loop, doing <CODE>read(sock)</CODE>, processing the data, -then going back into the read.<BR> -<BR> -Thread B comes along and wants to shut it down --- it can't cancel -thread A since (i) working out how to clean up according to where A is -in its loop is a nightmare, and (ii) this isn't available in -omnithread anyway.<BR> -<BR> -On Solaris 2.5 and Digital Unix 3.2 the following strategy works:<BR> -<BR> -Thread B does <CODE>shutdown(sock,2)</CODE>.<BR> -<BR> -At this point thread A is either blocked inside <CODE>read(sock)</CODE>, or -is elsewhere in the loop. If the former then read will return 0, -indicating that the socket is closed. If the latter then eventually -thread A will call <CODE>read(sock)</CODE> and then this will return 0. -Thread A should <CODE>close(sock)</CODE>, do any other tidying up, and exit.<BR> -<BR> -If there is another point in the loop that thread A can block then -obviously thread B needs to be aware of this and be able to wake it up -in the appropriate way from that point.<BR> -<BR> -<!--TOC subsection accept()--> - -<H3><A NAME="htoc11">6.2</A> accept()</H3><!--SEC END --> - -Again thread A is in a loop, this time doing an accept on listenSock, -dealing with a new connection and going back into accept. Thread B -wants to cancel it.<BR> -<BR> -On Digital Unix 3.2 the strategy is identical to that for read:<BR> -<BR> -Thread B does <CODE>shutdown(listenSock,2)</CODE>. Wherever thread A is in -the loop, eventually it will return <CODE>ECONNABORTED</CODE> from the -accept call. It should <CODE>close(listenSock)</CODE>, tidy up as necessary -and exit.<BR> -<BR> -On Solaris 2.5 thread B can't do <CODE>shutdown(listenSock,2)</CODE> --- -this returns <CODE>ENOTCONN</CODE>. Instead the following strategy can be -used:<BR> -<BR> -First thread B sets some sort of "shutdown flag" associated with -listenSock. Then it does <CODE>getsockaddr(listenSock)</CODE> to find out -which port listenSock is on (or knows already), sets up a socket -dummySock, does <CODE>connect(dummySock,</CODE> <CODE>this host, port)</CODE> and -finally does <CODE>close(dummySock)</CODE>.<BR> -<BR> -Wherever thread A is in the loop, eventually it will call -<CODE>accept(listenSock)</CODE>. This will return successfully with a new -socket, say connSock. Thread A then checks to see if the "shutdown -flag" is set. If not, then it's a normal connection. If it is set, -then thread A closes listenSock and connSock, tidies up and exits.<BR> -<BR> -<!--TOC subsection write()--> - -<H3><A NAME="htoc12">6.3</A> write()</H3><!--SEC END --> - -Thread A may be blocked in write, or about to go in to a -potentially-blocking write. Thread B wants to shut it down.<BR> -<BR> -On Solaris 2.5:<BR> -<BR> -Thread B does <CODE>shutdown(sock,2)</CODE>.<BR> -<BR> -If thread A is already in <CODE>write(sock)</CODE> then it will return with -<CODE>ENXIO</CODE>. If thread A calls write after thread B calls shutdown -this will return <CODE>EIO</CODE>.<BR> -<BR> -On Digital Unix 3.2:<BR> -<BR> -Thread B does <CODE>shutdown(sock,2)</CODE>.<BR> -<BR> -If thread A is already in <CODE>write(sock)</CODE> then it will return the -number of bytes written before it became blocked. A subsequent call -to write will then generate <CODE>SIGPIPE</CODE> (or <CODE>EPIPE</CODE> will be -returned if <CODE>SIGPIPE</CODE> is ignored by the thread).<BR> -<BR> -<!--TOC subsection connect()--> - -<H3><A NAME="htoc13">6.4</A> connect()</H3><!--SEC END --> - -Thread A may be blocked in connect, or about to go in to a -potentially-blocking connect. Thread B wants to shut it down.<BR> -<BR> -On Digital Unix 3.2:<BR> -<BR> -Thread B does <CODE>shutdown(sock,2)</CODE>.<BR> -<BR> -If thread A is already in <CODE>connect(sock)</CODE> then it will return a -successful connection. Subsequent reading or writing will show that -the socket has been shut down (i.e. read returns 0, write generates -<CODE>SIGPIPE</CODE> or returns <CODE>EPIPE</CODE>). If thread A calls connect -after thread B calls shutdown this will return <CODE>EINVAL</CODE>.<BR> -<BR> -On Solaris 2.5:<BR> -<BR> -There is no way to wake up a thread which is blocked in connect. -Instead Solaris forces us through a ridiculous procedure whichever way -we try it. One way is this:<BR> -<BR> -First thread A creates a pipe in addition to the socket. Instead of -shutting down the socket, thread B simply writes a byte to the pipe.<BR> -<BR> -Thread A meanwhile sets the socket to non-blocking mode using -<CODE>fcntl(sock,</CODE> <CODE>F_SETFL, O_NONBLOCK)</CODE>. Then it calls connect -on the socket --- this will return <CODE>EINPROGRESS</CODE>. Then it must -call <CODE>select()</CODE>, waiting for either sock to become writable or -for the pipe to become readable. If select returns that just sock is -writable then the connection has succeeded. It then needs to set the -socket back to blocking mode using <CODE>fcntl(sock, F_SETFL, 0)</CODE>. If -instead select returns that the pipe is readable, thread A closes the -socket, tidies up and exits.<BR> -<BR> -An alternative method is similar but to use polling instead of the -pipe. Thread B justs sets a flag and thread A calls select with a -timeout, periodically waking up to see if the flag has been set.<BR> -<BR> -<!--TOC section References--> - -<H2>References</H2><!--SEC END --> -<DL COMPACT=compact><DT><A NAME="pthreads"><FONT COLOR=purple>[POSIX94]</FONT></A><DD> -<EM>Portable Operating System Interface (POSIX) Threads Extension</EM>, -P1003.1c Draft 10, -IEEE, -September 1994.<BR> -<BR> -<DT><A NAME="birrell"><FONT COLOR=purple>[Birrell89]</FONT></A><DD> -<EM>An Introduction to Programming with Threads</EM>, -Research Report 35, -DEC Systems Research Center, -Palo Alto, CA, -January 1989.</DL> -<!--HTMLFOOT--> -<!--ENDHTML--> -<!--FOOTER--> -<HR SIZE=2> -<BLOCKQUOTE><EM>This document was translated from L<sup>A</sup>T<sub>E</sub>X by -</EM><A HREF="http://pauillac.inria.fr/~maranget/hevea/index.html"><EM>H<FONT SIZE=2><sup>E</sup></FONT>V<FONT SIZE=2><sup>E</sup></FONT>A</EM></A><EM>. -</EM></BLOCKQUOTE> -</BODY> -</HTML> diff --git a/docs/doxygen/other/omnithread.pdf b/docs/doxygen/other/omnithread.pdf Binary files differdeleted file mode 100644 index b0033072f..000000000 --- a/docs/doxygen/other/omnithread.pdf +++ /dev/null diff --git a/docs/doxygen/other/omnithread.ps b/docs/doxygen/other/omnithread.ps deleted file mode 100644 index 9e858f0b7..000000000 --- a/docs/doxygen/other/omnithread.ps +++ /dev/null @@ -1,730 +0,0 @@ -%!PS-Adobe-2.0 -%%Creator: dvipsk 5.86 p1.5d Copyright 1996-2001 ASCII Corp.(www-ptex@ascii.co.jp) -%%based on dvipsk 5.86 Copyright 1999 Radical Eye Software (www.radicaleye.com) -%%Title: omnithread.dvi -%%Pages: 7 -%%PageOrder: Ascend -%%BoundingBox: 0 0 596 842 -%%DocumentFonts: Palatino-Roman Palatino-Italic Palatino-Bold Courier -%%EndComments -%DVIPSWebPage: (www.radicaleye.com) -%DVIPSCommandLine: dvips omnithread -%DVIPSParameters: dpi=600, compressed -%DVIPSSource: TeX output 2002.08.15:1756 -%%BeginProcSet: texc.pro -%! -/TeXDict 300 dict def TeXDict begin/N{def}def/B{bind def}N/S{exch}N/X{S -N}B/A{dup}B/TR{translate}N/isls false N/vsize 11 72 mul N/hsize 8.5 72 -mul N/landplus90{false}def/@rigin{isls{[0 landplus90{1 -1}{-1 1}ifelse 0 -0 0]concat}if 72 Resolution div 72 VResolution div neg scale isls{ -landplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div hsize -mul 0}ifelse TR}if Resolution VResolution vsize -72 div 1 add mul TR[ -matrix currentmatrix{A A round sub abs 0.00001 lt{round}if}forall round -exch round exch]setmatrix}N/@landscape{/isls true N}B/@manualfeed{ -statusdict/manualfeed true put}B/@copies{/#copies X}B/FMat[1 0 0 -1 0 0] -N/FBB[0 0 0 0]N/nn 0 N/IEn 0 N/ctr 0 N/df-tail{/nn 8 dict N nn begin -/FontType 3 N/FontMatrix fntrx N/FontBBox FBB N string/base X array -/BitMaps X/BuildChar{CharBuilder}N/Encoding IEn N end A{/foo setfont}2 -array copy cvx N load 0 nn put/ctr 0 N[}B/sf 0 N/df{/sf 1 N/fntrx FMat N -df-tail}B/dfs{div/sf X/fntrx[sf 0 0 sf neg 0 0]N df-tail}B/E{pop nn A -definefont setfont}B/Cw{Cd A length 5 sub get}B/Ch{Cd A length 4 sub get -}B/Cx{128 Cd A length 3 sub get sub}B/Cy{Cd A length 2 sub get 127 sub} -B/Cdx{Cd A length 1 sub get}B/Ci{Cd A type/stringtype ne{ctr get/ctr ctr -1 add N}if}B/id 0 N/rw 0 N/rc 0 N/gp 0 N/cp 0 N/G 0 N/CharBuilder{save 3 -1 roll S A/base get 2 index get S/BitMaps get S get/Cd X pop/ctr 0 N Cdx -0 Cx Cy Ch sub Cx Cw add Cy setcachedevice Cw Ch true[1 0 0 -1 -.1 Cx -sub Cy .1 sub]/id Ci N/rw Cw 7 add 8 idiv string N/rc 0 N/gp 0 N/cp 0 N{ -rc 0 ne{rc 1 sub/rc X rw}{G}ifelse}imagemask restore}B/G{{id gp get/gp -gp 1 add N A 18 mod S 18 idiv pl S get exec}loop}B/adv{cp add/cp X}B -/chg{rw cp id gp 4 index getinterval putinterval A gp add/gp X adv}B/nd{ -/cp 0 N rw exit}B/lsh{rw cp 2 copy get A 0 eq{pop 1}{A 255 eq{pop 254}{ -A A add 255 and S 1 and or}ifelse}ifelse put 1 adv}B/rsh{rw cp 2 copy -get A 0 eq{pop 128}{A 255 eq{pop 127}{A 2 idiv S 128 and or}ifelse} -ifelse put 1 adv}B/clr{rw cp 2 index string putinterval adv}B/set{rw cp -fillstr 0 4 index getinterval putinterval adv}B/fillstr 18 string 0 1 17 -{2 copy 255 put pop}for N/pl[{adv 1 chg}{adv 1 chg nd}{1 add chg}{1 add -chg nd}{adv lsh}{adv lsh nd}{adv rsh}{adv rsh nd}{1 add adv}{/rc X nd}{ -1 add set}{1 add clr}{adv 2 chg}{adv 2 chg nd}{pop nd}]A{bind pop} -forall N/D{/cc X A type/stringtype ne{]}if nn/base get cc ctr put nn -/BitMaps get S ctr S sf 1 ne{A A length 1 sub A 2 index S get sf div put -}if put/ctr ctr 1 add N}B/I{cc 1 add D}B/bop{userdict/bop-hook known{ -bop-hook}if/SI save N @rigin 0 0 moveto/V matrix currentmatrix A 1 get A -mul exch 0 get A mul add .99 lt{/QV}{/RV}ifelse load def pop pop}N/eop{ -SI restore userdict/eop-hook known{eop-hook}if showpage}N/@start{ -userdict/start-hook known{start-hook}if pop/VResolution X/Resolution X -1000 div/DVImag X/IEn 256 array N 2 string 0 1 255{IEn S A 360 add 36 4 -index cvrs cvn put}for pop 65781.76 div/vsize X 65781.76 div/hsize X}N -/dir 0 def/dyy{/dir 0 def}B/dyt{/dir 1 def}B/dty{/dir 2 def}B/dtt{/dir 3 -def}B/p{dir 2 eq{-90 rotate show 90 rotate}{dir 3 eq{-90 rotate show 90 -rotate}{show}ifelse}ifelse}N/RMat[1 0 0 -1 0 0]N/BDot 260 string N/Rx 0 -N/Ry 0 N/V{}B/RV/v{/Ry X/Rx X V}B statusdict begin/product where{pop -false[(Display)(NeXT)(LaserWriter 16/600)]{A length product length le{A -length product exch 0 exch getinterval eq{pop true exit}if}{pop}ifelse} -forall}{false}ifelse end{{gsave TR -.1 .1 TR 1 1 scale Rx Ry false RMat{ -BDot}imagemask grestore}}{{gsave TR -.1 .1 TR Rx Ry scale 1 1 false RMat -{BDot}imagemask grestore}}ifelse B/QV{gsave newpath transform round exch -round exch itransform moveto Rx 0 rlineto 0 Ry neg rlineto Rx neg 0 -rlineto fill grestore}B/a{moveto}B/delta 0 N/tail{A/delta X 0 rmoveto}B -/M{S p delta add tail}B/b{S p tail}B/c{-4 M}B/d{-3 M}B/e{-2 M}B/f{-1 M} -B/g{0 M}B/h{1 M}B/i{2 M}B/j{3 M}B/k{4 M}B/w{0 rmoveto}B/l{p -4 w}B/m{p --3 w}B/n{p -2 w}B/o{p -1 w}B/q{p 1 w}B/r{p 2 w}B/s{p 3 w}B/t{p 4 w}B/x{ -0 S rmoveto}B/y{3 2 roll p a}B/bos{/SS save N}B/eos{SS restore}B end - -%%EndProcSet -%%BeginProcSet: 8r.enc -% @@psencodingfile@{ -% author = "S. Rahtz, P. MacKay, Alan Jeffrey, B. Horn, K. Berry", -% version = "0.6", -% date = "1 July 1998", -% filename = "8r.enc", -% email = "tex-fonts@@tug.org", -% docstring = "Encoding for TrueType or Type 1 fonts -% to be used with TeX." -% @} -% -% Idea is to have all the characters normally included in Type 1 fonts -% available for typesetting. This is effectively the characters in Adobe -% Standard Encoding + ISO Latin 1 + extra characters from Lucida. -% -% Character code assignments were made as follows: -% -% (1) the Windows ANSI characters are almost all in their Windows ANSI -% positions, because some Windows users cannot easily reencode the -% fonts, and it makes no difference on other systems. The only Windows -% ANSI characters not available are those that make no sense for -% typesetting -- rubout (127 decimal), nobreakspace (160), softhyphen -% (173). quotesingle and grave are moved just because it's such an -% irritation not having them in TeX positions. -% -% (2) Remaining characters are assigned arbitrarily to the lower part -% of the range, avoiding 0, 10 and 13 in case we meet dumb software. -% -% (3) Y&Y Lucida Bright includes some extra text characters; in the -% hopes that other PostScript fonts, perhaps created for public -% consumption, will include them, they are included starting at 0x12. -% -% (4) Remaining positions left undefined are for use in (hopefully) -% upward-compatible revisions, if someday more characters are generally -% available. -% -% (5) hyphen appears twice for compatibility with both -% ASCII and Windows. -% -/TeXBase1Encoding [ -% 0x00 (encoded characters from Adobe Standard not in Windows 3.1) - /.notdef /dotaccent /fi /fl - /fraction /hungarumlaut /Lslash /lslash - /ogonek /ring /.notdef - /breve /minus /.notdef -% These are the only two remaining unencoded characters, so may as -% well include them. - /Zcaron /zcaron -% 0x10 - /caron /dotlessi -% (unusual TeX characters available in, e.g., Lucida Bright) - /dotlessj /ff /ffi /ffl - /.notdef /.notdef /.notdef /.notdef - /.notdef /.notdef /.notdef /.notdef - % very contentious; it's so painful not having quoteleft and quoteright - % at 96 and 145 that we move the things normally found there to here. - /grave /quotesingle -% 0x20 (ASCII begins) - /space /exclam /quotedbl /numbersign - /dollar /percent /ampersand /quoteright - /parenleft /parenright /asterisk /plus /comma /hyphen /period /slash -% 0x30 - /zero /one /two /three /four /five /six /seven - /eight /nine /colon /semicolon /less /equal /greater /question -% 0x40 - /at /A /B /C /D /E /F /G /H /I /J /K /L /M /N /O -% 0x50 - /P /Q /R /S /T /U /V /W - /X /Y /Z /bracketleft /backslash /bracketright /asciicircum /underscore -% 0x60 - /quoteleft /a /b /c /d /e /f /g /h /i /j /k /l /m /n /o -% 0x70 - /p /q /r /s /t /u /v /w - /x /y /z /braceleft /bar /braceright /asciitilde - /.notdef % rubout; ASCII ends -% 0x80 - /.notdef /.notdef /quotesinglbase /florin - /quotedblbase /ellipsis /dagger /daggerdbl - /circumflex /perthousand /Scaron /guilsinglleft - /OE /.notdef /.notdef /.notdef -% 0x90 - /.notdef /.notdef /.notdef /quotedblleft - /quotedblright /bullet /endash /emdash - /tilde /trademark /scaron /guilsinglright - /oe /.notdef /.notdef /Ydieresis -% 0xA0 - /.notdef % nobreakspace - /exclamdown /cent /sterling - /currency /yen /brokenbar /section - /dieresis /copyright /ordfeminine /guillemotleft - /logicalnot - /hyphen % Y&Y (also at 45); Windows' softhyphen - /registered - /macron -% 0xD0 - /degree /plusminus /twosuperior /threesuperior - /acute /mu /paragraph /periodcentered - /cedilla /onesuperior /ordmasculine /guillemotright - /onequarter /onehalf /threequarters /questiondown -% 0xC0 - /Agrave /Aacute /Acircumflex /Atilde /Adieresis /Aring /AE /Ccedilla - /Egrave /Eacute /Ecircumflex /Edieresis - /Igrave /Iacute /Icircumflex /Idieresis -% 0xD0 - /Eth /Ntilde /Ograve /Oacute - /Ocircumflex /Otilde /Odieresis /multiply - /Oslash /Ugrave /Uacute /Ucircumflex - /Udieresis /Yacute /Thorn /germandbls -% 0xE0 - /agrave /aacute /acircumflex /atilde - /adieresis /aring /ae /ccedilla - /egrave /eacute /ecircumflex /edieresis - /igrave /iacute /icircumflex /idieresis -% 0xF0 - /eth /ntilde /ograve /oacute - /ocircumflex /otilde /odieresis /divide - /oslash /ugrave /uacute /ucircumflex - /udieresis /yacute /thorn /ydieresis -] def - -%%EndProcSet -%%BeginProcSet: texps.pro -%! -TeXDict begin/rf{findfont dup length 1 add dict begin{1 index/FID ne 2 -index/UniqueID ne and{def}{pop pop}ifelse}forall[1 index 0 6 -1 roll -exec 0 exch 5 -1 roll VResolution Resolution div mul neg 0 0]/Metrics -exch def dict begin 0 1 255{exch dup type/integertype ne{pop pop 1 sub -dup 0 le{pop}{[}ifelse}{FontMatrix 0 get div Metrics 0 get div def} -ifelse}for Metrics/Metrics currentdict end def[2 index currentdict end -definefont 3 -1 roll makefont/setfont cvx]cvx def}def/ObliqueSlant{dup -sin S cos div neg}B/SlantFont{4 index mul add}def/ExtendFont{3 -1 roll -mul exch}def/ReEncodeFont{CharStrings rcheck{/Encoding false def dup[ -exch{dup CharStrings exch known not{pop/.notdef/Encoding true def}if} -forall Encoding{]exch pop}{cleartomark}ifelse}if/Encoding exch def}def -end - -%%EndProcSet -TeXDict begin 39158280 55380996 1000 600 600 (omnithread.dvi) -@start /Fa 134[ 45 45 66 1[ 51 30 35 35 1[ 45 40 51 71 -25 2[ 25 45 45 25 35 45 37 42 40 8[ 66 3[ 56 51 2[ 56 -71 5[ 30 3[ 56 3[ 66 23[ 30 30 40[{ TeXBase1Encoding ReEncodeFont} 31 -90.9091 /Palatino-Italic rf /Fb 134[ 51 1[ 76 1[ 56 30 -40 35 2[ 51 56 81 30 2[ 30 56 51 35 45 56 40 56 45 14[ 66 -2[ 76 5[ 35 6[ 61 19[ 23 30 23 4[ 25 39[{ TeXBase1Encoding ReEncodeFont} -27 90.9091 /Palatino-Bold rf /Fc 135[ 50 83 1[ 61 33 -44 39 1[ 61 55 61 89 33 2[ 33 61 55 1[ 50 61 44 61 50 -10[ 78 8[ 100 9[ 72 12[ 50 1[ 50 50 50 50 2[ 25 4[ 33 -33 40[{ TeXBase1Encoding ReEncodeFont} 30 99.6264 /Palatino-Bold -rf /Fd 134[ 55 55 55 55 55 55 55 55 55 55 55 55 55 55 -55 55 55 55 55 55 55 55 55 55 55 1[ 55 5[ 55 55 55 55 -55 55 55 55 1[ 55 55 55 55 55 55 1[ 55 55 55 55 55 55 -55 55 55 3[ 55 2[ 55 1[ 55 1[ 55 55 55 55 55 55 55 1[ 55 -55 55 1[ 55 55 55 40[{ TeXBase1Encoding ReEncodeFont} 65 -90.9091 /Courier rf /Fe 141[ 36 12[ 44 56 2[ 45 7[ 61 -61 91 1[ 71 56 48 61 2[ 71 76 3[ 30 31 76 1[ 51 56 70 -64 56 71 10[ 45 3[ 45 45 1[ 55 23 4[ 30 30 40[{ -.167 SlantFont TeXBase1Encoding ReEncodeFont} 29 90.9091 -/Palatino-Roman rf -%DVIPSBitmapFont: Ff cmsy10 10.95 1 -/Ff 1 16 df<EB0FFCEB3FFF90B512C0000314F04880488048804880A2481580A3B712C0 -AA6C1580A36C1500A26C5C6C5C6C5C6C5CC614C0013F90C7FCEB0FFC22227BA72D> 15 -D E -%EndDVIPSBitmapFont -/Fg 104[ 91 2[ 45 45 24[ 45 51 47 76 51 55 30 39 36 51 -55 50 53 80 26 51 21 26 53 51 30 44 56 40 50 45 3[ 30 -1[ 30 2[ 61 91 66 71 56 48 61 1[ 55 71 76 86 56 66 30 -31 76 1[ 51 56 70 64 56 71 6[ 23 45 45 45 45 45 45 45 -45 45 45 55 23 30 23 55 1[ 30 30 25 4[ 34 30[ 55 55 2[{ -TeXBase1Encoding ReEncodeFont} 75 90.9091 /Palatino-Roman -rf /Fh 134[ 66 60 100 1[ 73 40 53 47 1[ 73 66 73 106 -2[ 40 40 73 66 47 60 73 53 73 60 11[ 93 80 73 86 1[ 73 -100 100 120 3[ 47 18[ 60 60 60 60 60 60 1[ 35 1[ 40 45[{ -TeXBase1Encoding ReEncodeFont} 38 119.552 /Palatino-Bold -rf /Fi 137[ 50 2[ 39 9[ 28 3[ 39 50 17[ 66 82[{ -TeXBase1Encoding ReEncodeFont} 6 99.6264 /Palatino-Italic -rf /Fj 137[ 56 1[ 32 42 39 2[ 54 58 88 3[ 29 58 55 1[ 48 -61 44 55 50 12[ 61 1[ 67 3[ 83 1[ 61 8[ 71 1[ 78 14[ 50 -50 50 9[ 78 38[{ TeXBase1Encoding ReEncodeFont} 25 99.6264 -/Palatino-Roman rf /Fk 139[ 47 61 57 2[ 78 83 4[ 42 83 -2[ 69 88 64 79 72 12[ 88 4[ 113 119 136 3[ 48 7[ 112 -65[{ TeXBase1Encoding ReEncodeFont} 18 143.462 /Palatino-Roman -rf end -%%EndProlog -%%BeginSetup -%%Feature: *Resolution 600dpi -TeXDict begin -%%PaperSize: A4 - -%%EndSetup -%%Page: 1 1 -1 0 bop Fk 728 918 a(The) 36 b(OMNI) g(Thr) m(ead) f(Abstracti) n(on) p -Fj 1293 1176 a(T) -9 b(ristan) 26 b(Richar) n(dson) 1022 -1293 y(A) -7 b(T&T) 24 b(Laboratories) i(Cambridge) p -Fi 1192 1504 a(Revised) p Fj 24 w(November) f(2001) p -Fh 63 1961 a(1) 119 b(Introduction) p Fg 63 2183 a(The) 20 -b(OMNI) h(thr) n(ead) g(abstraction) g(is) h(des) n(igned) f(to) f(pr) n -(ovide) h(a) h(common) f(set) f(of) h(thr) n(ead) g(oper) n(-) 63 -2296 y(ations) h(for) g(use) g(in) h(pr) n(ograms) f(written) f(in) i -(C++.) 29 b(Pr) n(ograms) 22 b(written) g(using) f(the) h(abstraction) -63 2409 y(should) 30 b(be) g(much) i(easier) e(to) g(port) g(betwee) n -(n) h(dif) n(fer) n(ent) g(ar) n(chi) r(tectur) l(es) g(with) g(dif) n -(fer) n(ent) f(un-) 63 2522 y(derlying) 21 b(thr) n(eads) h -(primitives.) 204 2640 y(The) 17 b(pr) n(ogramming) h(interface) g(is) f -(designed) f(to) h(be) h(similar) h(to) e(the) g(C) i(language) e -(interface) 63 2753 y(to) k(POSIX) h(thr) n(eads) f(\(IEEE) g(draft) h -(standar) n(d) f(100) r(3.1c) i(\227) f(pr) n(eviously) g(1003) r(.4a,) -g(often) g(known) 63 2866 y(as) g(\223pthr) n(eads\224) h([POSIX94]\).) -204 2985 y(Much) 18 b(of) f(the) g(abstraction) i(consists) d(of) i -(simple) g(C++) g(object) g(wrappers) e(ar) n(ound) h(pthr) n(ead) 63 -3098 y(calls.) 28 b(Howe) n(ver) 20 b(for) f(some) f(featur) n(es) g -(such) h(as) h(thr) n(ead-spe) n(ci\002c) h(data,) f(a) f(better) f -(interface) i(can) 63 3211 y(be) i(of) n(fer) n(ed) g(because) h(of) f -(the) g(use) g(of) g(C++.) 204 3329 y(Some) 28 b(of) h(the) f(mor) n(e) -h(complex) f(featur) n(es) g(of) h(pthr) n(eads) f(ar) n(e) h(not) f -(suppo) n(rted) g(because) h(of) 63 3442 y(the) e(dif) n(\002culty) i -(of) f(ensuring) g(the) f(same) h(featur) n(es) g(can) h(be) f(of) n -(fer) n(ed) g(on) g(top) g(of) g(other) f(thr) n(ead) 63 -3555 y(sys) n(tems.) f(Such) 17 b(featur) n(es) g(include) h(thr) n -(ead) f(cancell) r(ation) g(and) h(complex) g(schedu) n(ling) h(contr) n -(ol) 63 3668 y(\(thoug) n(h) k(simple) g(thr) n(ead) f(priorities) g -(ar) n(e) h(supp) n(orted\).) 204 3787 y(The) i(abstraction) h(layer) h -(is) f(curr) n(ently) f(implemented) g(for) h(the) f(following) i(ar) n -(chitectur) n(es) 63 3900 y(/) 22 b(thr) n(ead) h(sys) n(tems:) p -Ff 199 4141 a(\017) p Fg 46 w(Solaris) g(2.x) g(using) f(pthr) n(eads) f -(draft) h(10) p Ff 199 4351 a(\017) p Fg 46 w(Solaris) h(2.x) g(using) f -(solaris) g(thr) n(eads) g(\(but) h(pthr) n(eads) e(version) h(is) h -(now) f(standar) n(d\)) p Ff 199 4561 a(\017) p Fg 46 -w(Alpha) h(OSF1) g(using) f(pthr) n(eads) f(draft) i(4) p -Ff 199 4772 a(\017) p Fg 46 w(W) -5 b(indows) 21 b(NT) h(using) g(NT) g -(thr) n(eads) p Ff 199 4982 a(\017) p Fg 46 w(Linux) g(2.x) h(using) f -(Linuxthr) n(ead) g(0.5) h(\(which) h(is) e(based) g(on) h(pthr) n -(eads) e(draft) i(10\)) p Ff 199 5193 a(\017) p Fg 46 -w(Linux) f(2.x) h(using) f(MIT) g(pthr) n(eads) f(\(which) j(is) f -(based) f(on) g(draft) h(8\)) p Ff 199 5403 a(\017) p -Fg 46 w(A) -7 b(TMos) 22 b(using) g(pthr) n(eads) f(draft) h(6) i -(\(but) e(not) g(V) -5 b(irata) 23 b(A) -7 b(TMos\)) 1684 -5652 y(1) p 90 rotate dyy eop -%%Page: 2 2 -2 1 bop Fg 221 249 a(2) p Fe 1797 w(2) 91 b(SYNCHRONI) n(SA) -7 -b(TION) 22 b(OBJECTS) p Fg 362 548 a(See) h(the) p Fd -22 w(omni) n(thre) n(ad.h) p Fg 22 w(header) f(\002le) i(for) f(full) i -(det) n(ail) r(s) e(of) g(the) g(API.) f(The) h(des) n(criptions) 221 -661 y(below) 35 b(assume) g(you) g(have) h(some) e(pr) n(evious) h -(knowled) n(ge) g(of) h(thr) n(eads) n(,) j(mutexes) n(,) g(condi-) 221 -774 y(tion) f(varia) r(bles) g(and) g(semaphor) n(es) n(.) 75 -b(Also) 38 b(r) n(efer) f(to) h(other) f(document) n(ation) i(\([Birr) n -(ell89) r(],) 221 887 y([POSIX94) q(]\)) 22 b(for) g(further) f -(explanation) i(of) f(thes) n(e) g(ideas) g(\(particularly) h -(condition) f(variab) r(les,) 221 1000 y(the) g(use) g(of) g(which) h -(may) g(not) f(be) h(particularly) h(intuitive) f(when) f(\002rst) f -(encounter) n(ed) n(\).) p Fh 221 1299 a(2) 119 b(Synchronisation) 31 -b(objects) p Fg 221 1510 a(Synchr) n(onisation) 26 b(objects) h(ar) n -(e) g(used) e(to) h(synchr) n(onise) g(thr) n(eads) g(within) h(the) f -(same) h(pr) n(ocess) n(.) 221 1623 y(Ther) n(e) j(is) i(no) f(inter) n -(-pr) n(ocess) f(synchr) n(onisation) g(pr) n(ovided.) 53 -b(The) 30 b(synchr) n(onisation) h(objects) 221 1735 -y(pr) n(ovided) 22 b(ar) n(e) h(mutexes) n(,) g(condition) f(variab) r -(les) g(and) h(counting) f(semaphor) n(e) n(s.) p Fc -221 1991 a(2.1) 99 b(Mutex) p Fg 221 2168 a(An) 26 b(object) g(of) h -(typ) n(e) p Fd 26 w(omni) n(_mute) n(x) p Fg 26 w(is) g(use) n(d) f -(for) h(mutual) f(exclusion.) 39 b(It) 26 b(pr) n(ovides) f(two) g(op-) -221 2281 y(erations,) p Fd 37 w(lock\() n(\)) p Fg 35 -w(and) p Fd 35 w(unloc) n(k\(\)) p Fg(.) 64 b(The) 35 -b(alternative) h(names) p Fd 35 w(acq) n(uire\() n(\)) p -Fg 35 w(and) p Fd 35 w(re-) 221 2393 y(leas) n(e\(\)) p -Fg 19 w(can) 21 b(be) f(used) f(if) i(pr) n(eferr) n(ed) n(.) 27 -b(Behaviour) 20 b(is) g(unde\002ne) n(d) g(when) f(a) i(thr) n(ead) f -(attempt) n(s) 221 2506 y(to) 30 b(lock) h(the) e(same) i(mutex) f -(again) h(or) f(when) g(a) h(mutex) f(is) h(locked) e(by) i(one) e(thr) -n(ead) h(and) h(un-) 221 2619 y(locked) 22 b(by) h(a) g(dif) n(fer) n -(ent) f(thr) n(ead.) p Fc 221 2874 a(2.2) 99 b(Condition) 26 -b(V) -11 b(ariable) p Fg 221 3051 a(A) 28 b(condition) f(varia) r(ble) h -(is) g(r) n(epr) n(ese) n(nted) f(by) h(an) p Fd 28 w(omn) n(i_con) n -(diti) n(on) p Fg 27 w(and) g(is) g(used) e(for) i(sig-) 221 -3164 y(nalli) r(ng) 20 b(betwee) n(n) g(thr) n(eads.) 26 -b(A) 21 b(call) h(to) p Fd 19 w(wait\() n(\)) p Fg 20 -w(causes) e(a) h(thr) n(ead) e(to) h(wait) h(on) f(the) f(condition) 221 -3277 y(varia) r(ble.) 45 b(A) 28 b(call) i(to) p Fd 27 -w(sign) n(al\(\)) p Fg 27 w(wakes) d(up) h(at) g(least) g(one) f(thr) n -(ead) h(if) h(any) f(ar) n(e) g(waiting.) 45 b(A) 221 -3390 y(call) 25 b(to) p Fd 22 w(bro) n(adca) n(st\(\)) p -Fg 21 w(wakes) d(up) g(all) i(thr) n(eads) e(waiting) h(on) f(the) g -(condition) g(varia) r(ble.) 362 3503 y(When) 30 b(constr) o(ucte) n -(d,) i(a) e(pointer) f(to) h(an) p Fd 30 w(omni) n(_mute) n(x) p -Fg 30 w(must) f(be) h(given.) 50 b(A) 30 b(condition) 221 -3616 y(varia) r(ble) p Fd 33 w(wait\() n(\)) p Fg 33 -w(has) j(an) h(implic) r(it) f(mutex) p Fd 33 w(unlo) n(ck\(\)) p -Fg 32 w(and) p Fd 33 w(lock) n(\(\)) p Fg 33 w(ar) n(ound) g(it.) 60 -b(The) 221 3729 y(link) 30 b(between) f(condition) g(varia) r(ble) h -(and) g(mutex) f(lasts) g(for) h(the) f(lifetime) i(of) e(the) g -(condition) 221 3842 y(varia) r(ble) c(\(unlike) h(pthr) n(eads) e -(wher) n(e) g(the) h(link) h(is) f(only) g(for) g(the) g(duration) f -(of) i(the) e(wait\).) 37 b(The) 221 3955 y(same) 23 -b(mutex) f(may) h(be) f(used) f(with) i(several) f(condition) h(variab) -r(les.) 362 4068 y(A) c(wait) g(with) g(a) g(timeout) f(can) i(be) e -(achieved) h(by) g(call) r(ing) p Fd 19 w(tim) n(ed_w) n(ait\(\)) p -Fg -2 w(.) 27 b(This) 18 b(is) h(given) 221 4181 y(an) 27 -b(absolute) e(time) h(to) f(wait) h(until.) 38 b(The) 26 -b(r) n(outine) p Fd 25 w(omn) n(i_thr) n(ead:) n(:get_) n(time) n(\(\)) -p Fg 25 w(can) h(be) 221 4293 y(used) 21 b(to) h(turn) g(a) h(r) n -(elativ) r(e) f(time) g(into) h(an) g(absolute) f(time.) p -Fd 28 w(tim) n(ed_wa) n(it\(\)) p Fg 21 w(r) n(eturns) p -Fd 21 w(true) p Fg 21 w(if) 221 4406 y(the) 27 b(condition) h(was) g -(signalled,) p Fd 29 w(false) p Fg 26 w(if) h(the) f(time) g(expir) n -(ed) f(befor) n(e) g(the) h(condition) f(vari) r(-) 221 -4519 y(able) d(was) e(signalled.) p Fc 221 4774 a(2.3) 99 -b(Counting) 26 b(semaphores) p Fg 221 4951 a(An) p Fd -21 w(omn) n(i_sem) n(apho) n(re) p Fg 20 w(is) 21 b(a) h(counting) e -(semaphor) n(e) n(.) 28 b(When) 20 b(cr) n(eated) g(it) h(is) g(given) g -(an) g(initial) 221 5064 y(unsigned) j(intege) n(r) i(value.) 36 -b(When) p Fd 25 w(wai) n(t\(\)) p Fg 24 w(is) 26 b(called,) g(the) f -(value) h(is) f(decr) n(emente) n(d) g(if) h(non-) 221 -5177 y(zer) n(o.) 43 b(If) 27 b(the) g(value) h(is) f(zer) n(o) h(then) -f(the) f(thr) n(ead) h(blocks) h(instead.) 41 b(When) p -Fd 27 w(post) n(\(\)) p Fg 27 w(is) 27 b(cal) r(led,) 221 -5290 y(if) h(any) g(thr) n(eads) e(ar) n(e) i(blocked) f(in) p -Fd 27 w(wait\() n(\)) p Fg(,) h(exactly) f(one) g(thr) n(ead) g(is) g -(woken.) 41 b(If) 27 b(no) g(thr) n(eads) 221 5403 y(wer) n(e) 22 -b(blocked) g(then) g(the) g(value) h(of) g(the) e(semaphor) n(e) h(is) h -(incr) n(emented.) p 90 rotate dyy eop -%%Page: 3 3 -3 2 bop Fg 3306 249 a(3) 204 548 y(If) 27 b(a) h(thr) n(ead) e(cal) r -(ls) p Fd 27 w(try) n(_wait) n(\(\)) p Fg(,) h(then) g(the) f(thr) n -(ead) g(won't) h(block) h(if) f(the) g(semaphor) n(e's) 63 -661 y(value) c(is) g(0,) g(r) n(eturning) p Fd 21 w(false) p -Fg 21 w(instead.) 204 777 y(Ther) n(e) f(is) g(no) h(way) f(of) h -(query) n(ing) g(the) f(value) h(of) g(the) f(semaphor) n(e) n(.) p -Fh 63 1095 a(3) 119 b(Thread) 29 b(object) p Fg 63 1313 -a(A) 23 b(thr) n(ead) g(is) h(r) n(epr) n(ese) n(nted) e(by) i(an) p -Fd 24 w(omni) n(_thr) n(ead) p Fg 23 w(object.) 30 b(Ther) n(e) 23 -b(ar) n(e) h(br) n(oadly) g(two) e(dif) n(fer) n(-) 63 -1426 y(ent) f(ways) i(in) g(which) g(it) g(can) g(be) g(used) n(.) 204 -1542 y(The) 28 b(\002rst) g(way) h(is) h(simply) f(to) f(cr) n(eate) h -(an) p Fd 30 w(omn) n(i_thr) n(ead) p Fg 28 w(object,) h(giving) g(a) f -(particula) r(r) 63 1655 y(function) c(which) h(the) e(thr) n(ead) h -(should) f(execute) n(.) 36 b(This) 25 b(is) g(like) g(the) g(POSIX) f -(\(or) i(any) f(other) n(\)) h(C) 63 1768 y(language) c(interface.) 204 -1884 y(The) k(second) f(method) h(of) h(use) e(is) i(to) f(cr) n(eate) h -(a) g(new) g(class) g(which) g(inherits) f(fr) n(om) p -Fd 28 w(omn) n(i_) 63 1997 y(thr) n(ead) p Fg(.) 50 b(In) 31 -b(this) f(case) g(the) g(thr) n(ead) g(will) i(execute) d(the) p -Fd 29 w(run\(\)) p Fg 29 w(member) h(function) h(of) f(the) 63 -2109 y(new) 22 b(class.) 29 b(One) 23 b(advantage) g(of) g(this) g -(scheme) f(is) h(that) g(thr) n(ead-speci\002c) g(data) g(can) h(be) f -(imple-) 63 2222 y(mented) e(simply) h(by) h(having) g(data) g(members) -f(of) h(the) f(new) g(class.) 204 2339 y(When) f(constr) o(ucted) g(a) i -(thr) n(ead) f(is) g(in) h(the) e("new") h(state) f(and) h(has) g(not) g -(actuall) r(y) g(starte) n(d.) 28 b(A) 63 2451 y(call) j(to) p -Fd 29 w(sta) n(rt\(\)) p Fg 28 w(causes) e(the) g(thr) n(ead) g(to) g -(begin) g(executing.) 47 b(A) 29 b(static) h(member) f(function) p -Fd 63 2564 a(cre) n(ate\() n(\)) p Fg 32 w(is) j(pr) n(ovided) f(to) g -(constr) o(uct) g(and) g(start) g(a) i(thr) n(ead) e(in) h(a) g(single) -g(call.) 57 b(A) 31 b(thr) n(ead) 63 2677 y(exits) 21 -b(by) i(call) r(ing) p Fd 22 w(exit\() n(\)) p Fg 22 -w(or) g(by) f(r) n(eturning) g(fr) n(om) h(the) f(thr) n(ead) g -(function.) 204 2793 y(Thr) n(eads) 27 b(can) j(be) e(either) g -(detached) f(or) h(undetached) n(.) 46 b(Detached) 28 -b(thr) n(eads) g(ar) n(e) h(thr) n(eads) 63 2906 y(for) h(which) i(all) -g(state) e(will) i(be) f(lost) f(upon) g(exit.) 52 b(Other) 30 -b(thr) n(eads) g(cannot) h(dete) n(rmine) g(when) 63 -3019 y(a) e(detached) f(thr) n(ead) h(will) h(disappear) -7 -b(,) 31 b(and) e(ther) n(efor) n(e) f(should) g(not) h(attempt) f(to) g -(access) h(the) 63 3132 y(thr) n(ead) 23 b(object) g(unless) f(some) h -(explicit) h(synchr) n(onisation) f(with) g(the) g(detached) f(thr) n -(ead) h(guar) n(-) 63 3245 y(antees) e(that) h(it) h(still) g(exists.) -204 3361 y(Undet) n(ached) 33 b(thr) n(eads) f(ar) n(e) i(thr) n(eads) e -(for) h(which) g(storage) f(is) h(not) f(r) n(eclai) r(med) g(until) i -(an-) 63 3474 y(othe) n(r) g(thr) n(ead) g(waits) g(for) g(its) g -(termination) g(by) g(call) r(ing) p Fd 34 w(joi) n(n\(\)) p -Fg(.) 61 b(An) 34 b(exit) g(value) h(can) g(be) 63 3587 -y(passe) n(d) 23 b(fr) n(om) g(an) g(undet) n(ached) g(thr) n(ead) f -(to) g(the) g(thr) n(ead) g(which) h(joins) g(it.) 204 -3703 y(Detached) 31 b(/) h(undetached) e(thr) n(eads) h(ar) n(e) i -(distinguish) n(ed) f(on) f(cr) n(eation) h(by) g(the) f(type) g(of) 63 -3816 y(function) 24 b(they) e(execute.) 30 b(Undetached) 22 -b(thr) n(eads) h(execute) g(a) h(function) g(which) g(has) g(a) p -Fd 25 w(voi) n(d*) p Fg 63 3929 a(r) n(eturn) c(typ) n(e,) h(wher) n -(eas) f(detached) f(thr) n(eads) h(execute) f(a) j(function) f(which) g -(has) g(a) p Fd 21 w(void) p Fg 19 w(r) n(eturn) 63 4042 -y(typ) n(e.) 52 b(Unfortunate) n(ly) 31 b(C++) g(member) g(functions) f -(ar) n(e) h(not) f(allowed) g(to) g(be) h(distingu) n(ished) 63 -4155 y(simply) 26 b(by) h(their) f(r) n(eturn) g(type) n(.) 40 -b(Thus) 26 b(in) h(the) f(case) h(of) g(a) g(derived) f(class) h(of) p -Fd 26 w(omni_) n(thre) n(ad) p Fg 63 4268 a(which) 20 -b(needs) e(an) j(undet) n(ached) f(thr) n(ead,) g(the) f(member) h -(function) g(execute) n(d) g(by) g(the) f(thr) n(ead) g(is) 63 -4380 y(called) p Fd 19 w(run_u) n(ndet) n(ache) n(d\(\)) p -Fg 18 w(rather) f(than) p Fd 19 w(run\() n(\)) p Fg(,) h(and) g(it) g -(is) g(started) e(by) i(calli) r(ng) p Fd 18 w(star) n(t_) 63 -4493 y(und) n(etac) n(hed\(\)) p Fg 21 w(instead) j(of) p -Fd 22 w(start) n(\(\)) p Fg(.) 204 4610 y(The) i(abstraction) i(curr) n -(ently) e(suppo) n(rts) h(thr) n(ee) f(priorities) g(of) h(thr) n(ead,) -g(but) g(no) g(guarantee) 63 4722 y(is) 33 b(made) g(of) h(how) f(this) -g(will) h(af) n(f) r(ect) f(underlying) f(thr) n(ead) h(scheduling.) 59 -b(The) 33 b(thr) n(ee) f(priori-) 63 4835 y(ties) 18 -b(ar) n(e) p Fd 20 w(PRIO) n(RITY) n(_LOW) p Fg(,) p -Fd 18 w(PRIO) n(RITY) n(_NOR) n(MAL) p Fg 19 w(and) p -Fd 19 w(PRIO) n(RITY) n(_HIG) n(H) p Fg(.) h(By) g(default) g(all) 63 -4948 y(thr) n(eads) i(r) o(un) i(at) p Fd 23 w(PRIO) n(RITY) n(_NORM) n -(AL) p Fg(.) f(A) g(dif) n(fer) n(ent) h(priority) f(can) i(be) e -(speci\002ed) g(on) g(thr) n(ead) 63 5061 y(cr) n(eation,) h(or) f -(while) h(the) f(thr) n(ead) g(is) h(r) o(unning) g(using) p -Fd 22 w(set_) n(prio) n(rity\() n(\).) p Fg 28 w(A) g(thr) n(ead's) f -(cur) n(-) 63 5174 y(r) n(ent) g(priority) g(is) g(r) n(eturned) f(by) p -Fd 23 w(pri) n(ority) n(\(\)) p Fg(.) 204 5290 y(Other) d(functions) g -(pr) n(ovided) g(ar) n(e) p Fd 19 w(sel) n(f\(\)) p Fg -18 w(which) h(r) n(eturns) e(the) h(calli) r(ng) g(thr) n(ead's) p -Fd 18 w(omn) n(i_) 63 5403 y(thr) n(ead) p Fg 36 w(object,) p -Fd 40 w(yie) n(ld\(\)) p Fg 35 w(which) 38 b(r) n(eques) n(ts) e(that) h -(other) e(thr) n(eads) h(be) h(allowed) g(to) f(r) o(un,) p -90 rotate dyy eop -%%Page: 4 4 -4 3 bop Fg 221 249 a(4) p Fe 1367 w(6) 91 b(THRE) n(ADED) 23 -b(I/O) g(SHUTDOWN) f(FOR) g(UNIX) p Fd 221 548 a(id\(\)) p -Fg 27 w(which) 29 b(r) n(eturns) e(an) i(intege) n(r) g(id) f(for) h -(the) e(thr) n(ead) h(for) g(use) g(in) h(debug) n(ging,) p -Fd 29 w(state) n(\(\)) p Fg(,) p Fd 221 661 a(slee) n(p\(\)) p -Fg 22 w(and) p Fd 22 w(get_t) n(ime\() n(\)) p Fg(.) p -Fh 221 953 a(4) 119 b(Per) n(-threa) n(d) 30 b(data) p -Fg 221 1164 a(omnithr) n(ead) 22 b(suppo) n(rts) g(per) n(-thr) n(ead) f -(data,) h(via) i(member) e(functions) f(of) i(the) p -Fd 21 w(omni) n(_thr) n(ead) p Fg 221 1277 a(object.) 362 -1390 y(First,) d(you) g(must) h(allocate) h(a) f(key) f(for) g(with) h -(the) p Fd 20 w(omni) n(_thre) n(ad::) n(allo) n(cate_) n(key\() n(\)) p -Fg 221 1502 a(function.) 28 b(Then,) 21 b(any) h(object) g(whose) f -(class) h(is) g(derived) f(fr) n(om) p Fd 23 w(omni) n(_thr) n(ead::) n -(valu) n(e_t) p Fg 221 1615 a(can) 27 b(be) f(stor) n(e) n(d) g(using) f -(the) p Fd 26 w(set) n(_val) n(ue\(\)) p Fg 25 w(function.) 38 -b(V) -8 b(alues) 25 b(ar) n(e) h(r) n(etrieved) f(or) h(r) n(emoved) 221 -1728 y(with) p Fd 23 w(get) n(_valu) n(e\(\)) p Fg 21 -w(and) p Fd 23 w(remo) n(ve_v) n(alue\() n(\)) p Fg 22 -w(r) n(espectively) -10 b(.) 362 1841 y(When) 23 b(the) g(thr) n(ead) g -(exits,) g(all) i(per) n(-thr) n(ead) e(data) h(is) g(delet) n(ed) f -(\(hence) h(the) e(base) i(class) g(with) 221 1954 y(virtual) g(dest) n -(r) o(uctor\).) 362 2067 y(Note) 17 b(that) i(the) f(per) n(-thr) n -(ead) f(data) i(functions) f(ar) n(e) p Fb 19 w(not) p -Fg 18 w(thr) n(ead) g(safe,) i(so) d(although) i(you) e(can) 221 -2180 y(access) 29 b(one) e(thr) n(ead's) h(storage) f(fr) n(om) i -(another) f(thr) n(ead,) h(ther) n(e) e(is) i(no) f(concurr) n(ency) g -(contr) n(ol.) 221 2293 y(Unless) j(you) g(r) n(eall) r(y) h(know) f -(what) h(you) f(ar) n(e) i(doing,) g(it) g(is) f(best) f(to) h(only) g -(access) g(per) n(-thr) n(ead) 221 2406 y(data) 23 b(fr) n(om) g(the) f -(thr) n(ead) g(it) h(is) g(attached) f(to.) p Fh 221 -2698 a(5) 119 b(Using) 31 b(OMNI) d(threads) h(in) h(your) g(program) p -Fg 221 2909 a(Obvi) r(ously) 16 b(you) h(need) g(to) g(include) h(the) p -Fd 16 w(omnit) n(hrea) n(d.h) p Fg 17 w(header) e(\002le) i(in) g(your) -f(sour) n(ce) g(code,) 221 3021 y(and) 25 b(link) g(in) h(the) e -(omnithr) n(ead) g(libra) r(ry) g(with) h(your) f(execut) n(abl) r(e.) -34 b(Because) 23 b(ther) n(e) h(is) h(a) g(single) p -Fd 221 3134 a(omni) n(threa) n(d.h) p Fg 30 w(for) 32 -b(all) h(platforms,) h(certain) e(pr) n(epr) n(oces) n(sor) f -(de\002nes) f(must) h(be) g(given) h(as) 221 3247 y(compiler) 25 -b(options) n(.) 33 b(The) 23 b(easiest) g(way) h(to) g(do) f(this) h -(is) g(to) g(stud) n(y) g(the) g(make\002les) f(given) h(in) h(the) 221 -3360 y(examples) i(pr) n(ovided) g(with) g(this) g(distribution.) 42 -b(If) 27 b(you) g(ar) n(e) g(to) g(include) h(OMNI) f(thr) n(eads) g -(in) 221 3473 y(your) 18 b(own) g(development) g(envir) n(onment,) h -(thes) n(e) g(ar) n(e) g(the) f(necessary) g(pr) n(epr) n(oce) n(ssor) g -(de\002nes) n(:) p 362 3567 3287 4 v 360 3680 4 113 v -412 3646 a(Platform) p 1312 3680 V 599 w(Pr) n(epr) n(ocess) n(or) 23 -b(De\002nes) p 3648 3680 V 362 3683 3287 4 v 362 3700 -V 360 3813 4 113 v 412 3779 a(Sun) f(Solaris) h(2.x) p -1312 3813 V Fd 365 w(-D__) n(suno) n(s__) 54 b(-D_) n(_spa) n(rc__) f -(-D__) n(OSVER) n(SION) n(__=5) p 3648 3813 V 360 3926 -V 1312 3926 V 1363 3892 a(-DSV) n(R4) h(-DUs) n(ePth) n(read) f(-D_R) n -(EENT) n(RANT) p 3648 3926 V 362 3929 3287 4 v 360 4042 -4 113 v Fg 412 4008 a(x86) 24 b(Linux) e(2.0) p 1312 -4042 V Fd 418 w(-D__) n(linu) n(x__) 54 b(-D_) n(_i86) n(__) g(-D__) n -(OSVE) n(RSION) n(__=2) p 3648 4042 V 360 4155 V Fg 412 -4121 a(with) 23 b(linuxthr) n(eads) f(0.5) p 1312 4155 -V Fd 100 w(-D_R) n(EENT) n(RANT) p 3648 4155 V 362 4158 -3287 4 v 360 4271 4 113 v Fg 412 4237 a(Digital) i(Unix) f(3.2) p -1312 4271 V Fd 320 w(-D__) n(osf1) n(__) 54 b(-D__) n(alph) n(a__) g -(-D_) n(_OSV) n(ERSIO) n(N__=) n(3) p 3648 4271 V 360 -4384 V 1312 4384 V 1363 4350 a(-D_R) n(EENT) n(RANT) p -3648 4384 V 362 4387 3287 4 v 360 4500 4 113 v Fg 412 -4466 a(W) -5 b(indows) 22 b(NT) p 1312 4500 V Fd 411 -w(-D__) n(NT__) 53 b(-MD) p 3648 4500 V 362 4503 3287 -4 v Fh 221 4740 a(6) 119 b(Threaded) 29 b(I/O) g(shutdown) h(for) g -(Unix) p Fg 221 4951 a(or) -7 b(,) 20 b(how) e(one) g(thr) n(ead) h -(shou) n(ld) h(tell) f(another) f(thr) n(ead) g(to) h(shut) f(down) g -(when) g(it) h(might) g(be) g(doing) 221 5064 y(a) k(blocking) g(cal) r -(l) g(on) f(a) h(socket) n(.) p Fb 362 5177 a(If) h(you) e(are) i -(using) e(omniOR) n(B,) h(you) e(don') n(t) i(need) g(to) g(worry) f -(about) g(all) i(this,) f(since) h(om-) 221 5290 y(niORB) i(does) h(it) -h(for) f(you) n(.) p Fg 41 w(This) g(section) f(is) h(only) g(r) n -(elevant) g(if) h(you) e(ar) n(e) h(using) f(omnithr) n(ead) 221 -5403 y(in) d(your) f(own) g(socket) n(-based) h(pr) n(ogramming.) k(It) -22 b(is) h(also) g(serious) n(ly) g(out) f(of) h(date.) p -90 rotate dyy eop -%%Page: 5 5 -5 4 bop Fe 63 249 a(6.1) 91 b(r) n(ead\(\)) p Fg 2800 -w(5) 204 548 y(Unfortunate) n(ly) 35 b(ther) n(e) e(doe) n(sn't) h -(seem) f(to) h(be) g(a) h(standar) n(d) e(way) i(of) f(doing) f(this) h -(which) 63 661 y(works) 19 b(acr) n(oss) i(all) i(Unix) e(syst) n(ems.) -27 b(I) 21 b(have) g(investigated) f(the) h(behaviour) g(of) g(Solaris) -h(2.5) g(and) 63 774 y(Digital) k(Unix) g(3.2.) 36 b(On) 26 -b(Digital) h(Unix) e(everyth) n(ing) h(is) f(\002ne,) g(as) h(the) e -(obvious) h(method) f(using) 63 887 y(shutd) n(own\(\)) 32 -b(seems) f(to) h(work) f(OK.) h(Unfortunately) f(on) h(Solaris) h(shut) -n(down) f(can) h(only) f(be) 63 1000 y(used) 25 b(on) h(a) h(connected) -e(socke) n(t,) i(so) f(we) g(need) f(devious) h(means) g(to) g(get) f -(ar) n(ound) h(this) g(lim) r(ita-) 63 1112 y(tion.) h(The) 22 -b(details) g(ar) n(e) h(summarised) g(below:) p Fc 63 -1429 a(6.1) 99 b(read\(\)) p Fg 63 1627 a(Thr) n(ead) 28 -b(A) h(is) g(in) h(a) g(loop,) g(doing) p Fd 28 w(rea) n(d\(soc) n(k\)) -p Fg(,) g(pr) n(ocess) n(ing) f(the) g(data,) h(then) f(going) f(back) -63 1739 y(into) 22 b(the) g(r) n(ead.) 204 1862 y(Thr) n(ead) 30 -b(B) h(comes) f(along) h(and) g(wants) f(to) g(shut) g(it) h(down) f -(\227) h(it) g(can't) g(cancel) h(thr) n(ead) f(A) 63 -1975 y(since) 21 b(\(i\)) h(working) e(out) g(how) g(to) h(clean) h(up) -e(accor) n(ding) i(to) e(wher) n(e) g(A) h(is) g(in) h(its) f(loop) f -(is) h(a) h(night-) 63 2088 y(mar) n(e,) h(and) f(\(ii\)) i(this) f -(isn't) f(ava) r(ilabl) r(e) g(in) h(omnithr) n(ead) f(anyway) -10 -b(.) 204 2211 y(On) 23 b(Solaris) g(2.5) g(and) g(Digital) h(Unix) f -(3.2) g(the) f(following) h(strate) n(gy) f(works:) 204 -2334 y(Thr) n(ead) g(B) g(does) p Fd 21 w(shut) n(down\() n(sock) n -(,2\)) p Fg(.) 204 2457 y(At) g(this) g(point) h(thr) n(ead) f(A) g(is) -h(either) f(blocked) g(inside) p Fd 23 w(rea) n(d\(so) n(ck\)) p -Fg(,) g(or) g(is) h(elsewhe) n(r) n(e) g(in) 63 2570 -y(the) 18 b(loop.) 26 b(If) 18 b(the) g(former) h(then) f(r) n(ead) h -(will) h(r) n(eturn) e(0,) i(indicating) f(that) g(the) f(socke) n(t) h -(is) g(closed.) 26 b(If) 63 2683 y(the) 21 b(latter) h(then) f -(eventually) h(thr) n(ead) g(A) g(will) i(call) p Fd -24 w(rea) n(d\(so) n(ck\)) p Fg 21 w(and) f(then) e(this) h(will) h(r) n -(eturn) 63 2796 y(0.) 28 b(Thr) n(ead) 22 b(A) h(should) p -Fd 21 w(clos) n(e\(soc) n(k\)) p Fg(,) f(do) g(any) g(other) g(tidying) -f(up,) h(and) h(exit.) 204 2919 y(If) 34 b(ther) n(e) g(is) h(another) f -(point) g(in) h(the) e(loop) i(that) f(thr) n(ead) g(A) h(can) g(block) -g(then) f(obviously) 63 3032 y(thr) n(ead) 19 b(B) h(needs) f(to) h(be) -g(awar) n(e) h(of) f(this) g(and) g(be) h(able) g(to) e(wake) h(it) h -(up) f(in) g(the) g(appr) n(opriate) g(way) 63 3145 y(fr) n(om) j(that) -f(point.) p Fc 63 3462 a(6.2) 99 b(accept\(\)) p Fg 63 -3659 a(Again) 25 b(thr) n(ead) g(A) h(is) f(in) h(a) g(loop,) g(this) f -(time) h(doing) e(an) i(acc) r(ept) e(on) h(listenSock,) g(dealing) h -(with) 63 3772 y(a) d(new) f(connection) g(and) h(going) e(back) j -(into) e(accept.) 28 b(Thr) n(ead) 22 b(B) g(wants) h(to) f(cancel) h -(it.) 204 3895 y(On) g(Digital) h(Unix) f(3.2) g(the) f(strateg) n(y) g -(is) h(identical) h(to) e(that) g(for) h(r) n(ead:) 204 -4018 y(Thr) n(ead) 39 b(B) g(does) p Fd 38 w(shut) n(down) n(\(list) n -(enSo) n(ck,2) n(\)) p Fg(.) 79 b(Wher) n(ever) 38 b(thr) n(ead) h(A) h -(is) f(in) h(the) 63 4131 y(loop,) i(eventually) c(it) h(will) h(r) n -(eturn) p Fd 38 w(ECONN) n(ABOR) n(TED) p Fg 38 w(fr) n(om) f(the) f -(accept) h(call) r(.) 76 b(It) 39 b(shou) n(ld) p Fd -63 4244 a(clo) n(se\(l) n(isten) n(Sock) n(\)) p Fg(,) 22 -b(tidy) g(up) g(as) h(necessary) e(and) i(exit.) 204 -4367 y(On) 30 b(Solaris) f(2.5) i(thr) n(ead) e(B) g(can't) h(do) p -Fd 29 w(shu) n(tdow) n(n\(lis) n(tenS) n(ock,2) n(\)) p -Fg 29 w(\227) g(this) f(r) n(eturns) p Fd 63 4480 a(ENO) n(TCON) n(N) p -Fg(.) 22 b(Instead) f(the) h(following) h(strateg) n(y) g(can) g(be) g -(used) n(:) 204 4603 y(First) 35 b(thr) n(ead) h(B) g(set) n(s) g(some) -f(sort) g(of) h("shutdo) n(wn) g(\003ag") g(associated) g(with) g -(listenSock.) 63 4716 y(Then) 31 b(it) h(does) p Fd 30 -w(gets) n(ocka) n(ddr\(l) n(iste) n(nSock) n(\)) p Fg -32 w(to) f(\002nd) g(out) g(which) i(port) e(listenSock) f(is) 63 -4828 y(on) 18 b(\(or) h(knows) e(alr) n(eady\),) j(sets) d(up) h(a) h -(socket) e(dummySock,) i(doe) n(s) p Fd 19 w(con) n(nect) n(\(dumm) n -(ySoc) n(k,) 63 4941 y(thi) n(s) 54 b(host,) f(por) n(t\)) p -Fg 22 w(and) 23 b(\002nally) g(does) p Fd 21 w(clos) n(e\(dum) n(mySo) n -(ck\)) p Fg(.) 204 5064 y(Wher) n(ever) 16 b(thr) n(ead) h(A) g(is) g -(in) h(the) e(loop,) h(eventually) g(it) h(will) g(call) p -Fd 19 w(acce) n(pt\(li) n(sten) n(Sock) n(\)) p Fg(.) 63 -5177 y(This) 35 b(will) j(r) n(eturn) d(successfully) g(with) h(a) h -(new) e(socket,) j(say) e(connSock.) 67 b(Thr) n(ead) 36 -b(A) f(then) 63 5290 y(checks) 20 b(to) h(see) f(if) i(the) f("shutd) n -(own) g(\003ag") h(is) f(set.) 26 b(If) c(not,) e(then) h(it's) g(a) h -(normal) g(connection.) 27 b(If) 21 b(it) 63 5403 y(is) h(set,) g(then) -f(thr) n(ead) h(A) h(closes) f(listenSock) f(and) i(connSock,) e -(tidies) h(up) g(and) h(exits.) p 90 rotate dyy eop -%%Page: 6 6 -6 5 bop Fg 221 249 a(6) p Fe 1367 w(6) 91 b(THRE) n(ADED) 23 -b(I/O) g(SHUTDOWN) f(FOR) g(UNIX) p Fc 221 548 a(6.3) 99 -b(write\(\)) p Fg 221 768 a(Thr) n(ead) 19 b(A) f(may) h(be) g(blocked) -f(in) i(write,) f(or) f(about) h(to) f(go) g(in) h(to) g(a) g(poten) n -(tiall) r(y-blocking) g(write.) 221 881 y(Thr) n(ead) j(B) h(wants) f -(to) g(shut) f(it) i(down.) 362 1016 y(On) g(Solaris) g(2.5:) 362 -1150 y(Thr) n(ead) f(B) h(doe) n(s) p Fd 23 w(shu) n(tdown) n(\(soc) n -(k,2\)) p Fg -2 w(.) 362 1285 y(If) c(thr) n(ead) f(A) h(is) g(alr) n -(eady) g(in) p Fd 20 w(wri) n(te\(s) n(ock\)) p Fg 17 -w(then) f(it) h(will) i(r) n(eturn) d(with) p Fd 18 w(ENXIO) p -Fg -2 w(.) h(If) g(thr) n(ead) 221 1398 y(A) k(calls) h(write) e(after) -g(thr) n(ead) g(B) h(calls) h(shut) n(down) e(this) g(will) i(r) n -(eturn) p Fd 22 w(EIO) p Fg(.) 362 1532 y(On) f(Digital) h(Unix) f -(3.2:) 362 1666 y(Thr) n(ead) f(B) h(doe) n(s) p Fd 23 -w(shu) n(tdown) n(\(soc) n(k,2\)) p Fg -2 w(.) 362 1801 -y(If) h(thr) n(ead) f(A) g(is) h(alr) n(eady) g(in) p -Fd 24 w(writ) n(e\(so) n(ck\)) p Fg 23 w(then) e(it) i(will) h(r) n -(eturn) e(the) f(number) i(of) f(bytes) 221 1914 y(written) 31 -b(befor) n(e) h(it) g(became) g(blocked.) 55 b(A) 32 -b(subseq) n(uent) f(cal) r(l) h(to) f(write) h(will) h(then) e(gene) n -(rate) p Fd 221 2027 a(SIGP) n(IPE) p Fg 22 w(\(or) p -Fd 22 w(EPIP) n(E) p Fg 23 w(will) 24 b(be) e(r) n(eturned) f(if) p -Fd 24 w(SIG) n(PIPE) p Fg 21 w(is) i(ignor) n(ed) e(by) i(the) f(thr) n -(ead\).) p Fc 221 2413 a(6.4) 99 b(connect\(\)) p Fg -221 2634 a(Thr) n(ead) 30 b(A) f(may) h(be) g(blocked) f(in) i -(connect,) g(or) e(about) h(to) f(go) g(in) i(to) e(a) h(poten) n -(tiall) r(y-blocking) 221 2747 y(connect.) d(Thr) n(ead) c(B) f(wants) g -(to) g(shut) g(it) g(down.) 362 2881 y(On) h(Digital) h(Unix) f(3.2:) -362 3016 y(Thr) n(ead) f(B) h(doe) n(s) p Fd 23 w(shu) n(tdown) n -(\(soc) n(k,2\)) p Fg -2 w(.) 362 3150 y(If) j(thr) n(ead) f(A) g(is) h -(alr) n(eady) g(in) p Fd 26 w(conn) n(ect\() n(sock) n(\)) p -Fg 26 w(then) e(it) i(will) h(r) n(eturn) e(a) h(successful) f(con-) 221 -3263 y(nection.) 54 b(Subsequ) n(ent) 31 b(r) n(eading) g(or) g -(writing) g(will) i(show) d(that) i(the) e(socket) g(has) h(been) g -(shut) 221 3376 y(down) 22 b(\(i.e.) 28 b(r) n(ead) 23 -b(r) n(eturns) e(0,) i(write) f(generate) n(s) p Fd 23 -w(SIG) n(PIPE) p Fg 21 w(or) g(r) n(eturns) p Fd 22 w(EPI) n(PE) p -Fg(\).) g(If) h(thr) n(ead) f(A) 221 3489 y(call) r(s) g(connect) g -(after) h(thr) n(ead) f(B) g(call) r(s) g(shutdo) n(wn) h(this) f(will) -i(r) n(eturn) p Fd 22 w(EIN) n(VAL) p Fg(.) 362 3623 -y(On) f(Solaris) g(2.5:) 362 3758 y(Ther) n(e) 35 b(is) h(no) f(way) g -(to) g(wake) g(up) g(a) h(thr) n(ead) f(which) h(is) g(blocked) f(in) h -(connect.) 66 b(Inst) n(ead) 221 3871 y(Solaris) 33 b(for) n(ces) g(us) -f(thr) n(ough) g(a) i(ridiculous) f(pr) n(oced) n(ur) n(e) g(whichever) -g(way) g(we) f(try) g(it.) 59 b(One) 221 3984 y(way) 23 -b(is) f(this:) 362 4118 y(First) d(thr) n(ead) h(A) g(cr) n(eates) f(a) -h(pipe) g(in) g(addition) g(to) f(the) g(socket) n(.) 27 -b(Instead) 19 b(of) h(shut) n(ting) g(down) 221 4231 -y(the) i(socket) n(,) h(thr) n(ead) f(B) g(simply) h(writes) e(a) i -(byte) f(to) g(the) g(pipe.) 362 4365 y(Thr) n(ead) 17 -b(A) g(meanwhile) h(set) n(s) f(the) g(socke) n(t) g(to) g -(non-blocking) g(mode) f(using) p Fd 17 w(fcn) n(tl\(s) n(ock,) 221 -4478 y(F_SE) n(TFL,) 53 b(O_NO) n(NBLO) n(CK\)) p Fg(.) 26 -b(Then) h(it) g(cal) r(ls) g(connect) g(on) g(the) f(socket) g(\227) h -(this) g(will) i(r) n(eturn) p Fd 221 4591 a(EINP) n(ROGRE) n(SS) p -Fg(.) k(Then) h(it) h(must) e(cal) r(l) p Fd 35 w(sel) n(ect\() n(\)) p -Fg(,) k(waiting) e(for) f(either) g(sock) g(to) f(become) 221 -4704 y(writable) 39 b(or) f(for) h(the) e(pipe) h(to) g(become) g(r) n -(eadable.) 75 b(If) 39 b(select) e(r) n(eturns) g(that) i(just) e(sock) -h(is) 221 4817 y(writable) 30 b(then) f(the) g(connection) g(has) h -(succeede) n(d.) 49 b(It) 29 b(then) g(need) n(s) h(to) f(set) f(the) h -(socket) f(back) 221 4930 y(to) i(blocking) h(mode) f(using) p -Fd 30 w(fcnt) n(l\(so) n(ck,) 54 b(F_S) n(ETFL) n(,) h(0\)) p -Fg(.) c(If) 31 b(instead) e(select) h(r) n(eturns) 221 -5043 y(that) 23 b(the) e(pipe) h(is) h(r) n(eadable,) g(thr) n(ead) f -(A) h(closes) e(the) h(socket) n(,) h(tidies) f(up) g(and) h(exits.) 362 -5177 y(An) g(alternative) h(method) e(is) i(similar) h(but) e(to) g -(use) f(polling) i(instead) e(of) i(the) e(pipe.) 29 -b(Thr) n(ead) 221 5290 y(B) 24 b(justs) e(sets) g(a) j(\003ag) f(and) g -(thr) n(ead) f(A) h(calls) h(select) e(with) g(a) i(timeout,) e(period) -n(ica) r(lly) h(waking) f(up) 221 5403 y(to) f(see) g(if) h(the) f -(\003ag) h(has) f(been) g(set.) p 90 rotate dyy eop -%%Page: 7 7 -7 6 bop Fe 63 249 a(REF) n(ERENCES) p Fg 2660 w(7) p -Fh 63 548 a(Refere) n(nces) p Fg 63 759 a([POSIX94]) p -Fa 46 w(Portable) 29 b(Operat) r(ing) f(System) g(Interface) h -(\(POSIX\)) e(Thr) n(ea) r(ds) h(Extension) p Fg(,) h(P1003) r(.1c) 245 -872 y(Draft) 23 b(10,) g(IEEE,) e(Septe) n(mber) i(1994) r(.) 63 -1059 y([Birr) n(ell89]) p Fa 47 w(An) 28 b(Intr) n(od) r(uction) g(to) h -(Pr) n(ogr) r(amming) g(with) g(Thr) n(ead) r(s) p Fg(,) h(Rese) n(ar) n -(ch) g(Repo) n(rt) e(35,) j(DEC) 245 1172 y(Syst) n(ems) 22 -b(Resear) n(ch) g(Center) -7 b(,) 22 b(Palo) h(Alto,) f(CA,) h(January) -g(1989) r(.) p 90 rotate dyy eop -%%Trailer -end -userdict /end-hook known{end-hook}if -%%EOF diff --git a/dtools/bin/fix-copyright-years b/dtools/bin/fix-copyright-years new file mode 100755 index 000000000..bb0f3009d --- /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/dtools/bin/get-config-files b/dtools/bin/get-config-files index d9e8811ac..343bca26b 100755 --- a/dtools/bin/get-config-files +++ b/dtools/bin/get-config-files @@ -2,9 +2,5 @@ # fetch latest config.guess and config.sub -# They've moved... -# wget -O config.guess 'http://savannah.gnu.org/cgi-bin/viewcvs/config/config/config.guess?rev=HEAD&content-type=text/plain' -# wget -O config.sub 'http://savannah.gnu.org/cgi-bin/viewcvs/config/config/config.sub?rev=HEAD&content-type=text/plain' - -wget -O config.guess 'http://cvs.savannah.gnu.org/viewvc/*checkout*/config/config/config.guess?content-type=text%2Fplain&revision=HEAD' -wget -O config.sub 'http://cvs.savannah.gnu.org/viewvc/*checkout*/config/config/config.sub?content-type=text%2Fplain&revision=HEAD' +wget -O config.guess 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD' +wget -O config.sub 'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD' diff --git a/gcell/apps/Makefile.am b/gcell/apps/Makefile.am index 7cf9122a3..c3a2092a3 100644 --- a/gcell/apps/Makefile.am +++ b/gcell/apps/Makefile.am @@ -22,9 +22,7 @@ include $(top_srcdir)/Makefile.common SUBDIRS = spu . -AM_CPPFLAGS = $(DEFINES) $(OMNITHREAD_INCLUDES) \ - $(GCELL_INCLUDES) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES) - +AM_CPPFLAGS = $(DEFINES) $(GCELL_INCLUDES) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES) GCELL_QA_LA = $(top_builddir)/gcell/lib/libgcell-qa.la diff --git a/gcell/apps/test_all.cc b/gcell/apps/test_all.cc index 9823960c4..0b608e13b 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 <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> +#include <gr_unittests.h> #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/gcell.pc.in b/gcell/gcell.pc.in index d88d0fb67..1a3cd9c26 100644 --- a/gcell/gcell.pc.in +++ b/gcell/gcell.pc.in @@ -6,7 +6,7 @@ gcell_embedspu_libtool=@bindir@/gcell-embedspu-libtool Name: gcell Description: The GNU Radio SPE scheduler and RPC mechanism -Requires: gnuradio-omnithread -Version: @VERSION@ +Requires: +Version: @LIBVER@ Libs: -L${libdir} -lgcell Cflags: -I${includedir} @DEFINES@ diff --git a/gcell/lib/Makefile.am b/gcell/lib/Makefile.am index fa9c4a003..7a727ea84 100644 --- a/gcell/lib/Makefile.am +++ b/gcell/lib/Makefile.am @@ -27,10 +27,10 @@ SUBDIRS = spu runtime general wrapper . lib_LTLIBRARIES = libgcell.la libgcell-qa.la libgcell_la_SOURCES = -libgcell_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 +libgcell_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) libgcell_qa_la_SOURCES = -libgcell_qa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 +libgcell_qa_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) libgcell_la_LIBADD = \ runtime/libruntime.la \ @@ -42,9 +42,3 @@ libgcell_qa_la_LIBADD = \ runtime/libruntime-qa.la \ wrapper/libwrapper-qa.la \ $(CPPUNIT_LIBS) - - - - - - diff --git a/gnuradio-core/gnuradio-core.pc.in b/gnuradio-core/gnuradio-core.pc.in index dc06fcf89..5d743a4e9 100644 --- a/gnuradio-core/gnuradio-core.pc.in +++ b/gnuradio-core/gnuradio-core.pc.in @@ -5,8 +5,8 @@ includedir=@includedir@/gnuradio Name: gnuradio-core Description: GNU Software Radio toolkit -Requires: gruel fftw3f gsl gnuradio-omnithread -Version: @VERSION@ +Requires: gruel fftw3f gsl +Version: @LIBVER@ Libs.private: @BOOST_LDFLAGS@ @BOOST_THREAD_LIB@ @BOOST_DATE_TIME_LIB@ Libs: -L${libdir} -lgnuradio-core Cflags: @BOOST_CPPFLAGS@ @BOOST_CXXFLAGS@ -I${includedir} diff --git a/gnuradio-core/src/gen_interpolator_taps/Makefile.am b/gnuradio-core/src/gen_interpolator_taps/Makefile.am index 5f3a6cb25..d244e7f54 100644 --- a/gnuradio-core/src/gen_interpolator_taps/Makefile.am +++ b/gnuradio-core/src/gen_interpolator_taps/Makefile.am @@ -21,13 +21,13 @@ include $(top_srcdir)/Makefile.common -EXTRA_DIST = praxis.txt simpson.h +EXTRA_DIST = praxis.txt simpson.h objective_fct.c gen_interpolator_taps.c simpson.c praxis.f -if ENABLE_FORTRAN -noinst_PROGRAMS = gen_interpolator_taps -noinst_HEADERS = simpson.h - -gen_interpolator_taps_SOURCES = gen_interpolator_taps.c objective_fct.c simpson.c praxis.f -gen_interpolator_taps_LDADD = $(FLIBS) -lm - -endif +# if ENABLE_FORTRAN +# noinst_PROGRAMS = gen_interpolator_taps +# noinst_HEADERS = simpson.h +# +# gen_interpolator_taps_SOURCES = gen_interpolator_taps.c objective_fct.c simpson.c praxis.f +# gen_interpolator_taps_LDADD = $(FLIBS) -lm +# +# endif diff --git a/gnuradio-core/src/lib/Makefile.am b/gnuradio-core/src/lib/Makefile.am index 477ba6725..f3a3accdb 100644 --- a/gnuradio-core/src/lib/Makefile.am +++ b/gnuradio-core/src/lib/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2001,2004,2009 Free Software Foundation, Inc. +# Copyright 2001,2004,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -33,10 +33,11 @@ AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES) # generate libgnuradio-core.la from the convenience libraries in subdirs -lib_LTLIBRARIES = libgnuradio-core.la libgnuradio-core-qa.la +lib_LTLIBRARIES = libgnuradio-core.la +noinst_LTLIBRARIES = libgnuradio-core-qa.la libgnuradio_core_la_SOURCES = bug_work_around_6.cc -libgnuradio_core_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 +libgnuradio_core_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) libgnuradio_core_qa_la_SOURCES = bug_work_around_6.cc libgnuradio_core_qa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 \ @@ -68,4 +69,4 @@ libgnuradio_core_qa_la_LIBADD = \ bin_PROGRAMS = gnuradio-config-info gnuradio_config_info_SOURCES = gnuradio-config-info.cc -gnuradio_config_info_LDADD = libgnuradio-core.la $(BOOST_PROGRAM_OPTIONS_LIB)
\ No newline at end of file +gnuradio_config_info_LDADD = libgnuradio-core.la $(BOOST_LDFLAGS) $(BOOST_PROGRAM_OPTIONS_LIB) diff --git a/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.cc b/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.cc index 6a6fe1c26..8252509bb 100644 --- a/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.cc +++ b/gnuradio-core/src/lib/filter/gr_cma_equalizer_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -29,7 +29,7 @@ gr_cma_equalizer_cc_sptr gr_make_cma_equalizer_cc(int num_taps, float modulus, float mu) { - return gr_cma_equalizer_cc_sptr(new gr_cma_equalizer_cc(num_taps, modulus, mu)); + return gnuradio::get_initial_sptr(new gr_cma_equalizer_cc(num_taps, modulus, mu)); } gr_cma_equalizer_cc::gr_cma_equalizer_cc(int num_taps, float modulus, float mu) diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.cc b/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.cc index 4540c6e4a..02bfaf105 100644 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.cc +++ b/gnuradio-core/src/lib/filter/gr_fft_filter_ccc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -45,7 +45,7 @@ gr_fft_filter_ccc_sptr gr_make_fft_filter_ccc (int decimation, const std::vector<gr_complex> &taps) { - return gr_fft_filter_ccc_sptr (new gr_fft_filter_ccc (decimation, taps)); + return gnuradio::get_initial_sptr(new gr_fft_filter_ccc (decimation, taps)); } diff --git a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.cc b/gnuradio-core/src/lib/filter/gr_fft_filter_fff.cc index e8857fe8c..e5b218f20 100644 --- a/gnuradio-core/src/lib/filter/gr_fft_filter_fff.cc +++ b/gnuradio-core/src/lib/filter/gr_fft_filter_fff.cc @@ -37,7 +37,7 @@ gr_fft_filter_fff_sptr gr_make_fft_filter_fff (int decimation, const std::vector<float> &taps) { - return gr_fft_filter_fff_sptr (new gr_fft_filter_fff (decimation, taps)); + return gnuradio::get_initial_sptr(new gr_fft_filter_fff (decimation, taps)); } diff --git a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.cc b/gnuradio-core/src/lib/filter/gr_filter_delay_fc.cc index 49a1e0eb3..7974da934 100644 --- a/gnuradio-core/src/lib/filter/gr_filter_delay_fc.cc +++ b/gnuradio-core/src/lib/filter/gr_filter_delay_fc.cc @@ -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 * @@ -32,7 +32,7 @@ gr_filter_delay_fc_sptr gr_make_filter_delay_fc (const std::vector<float> &taps) { - return gr_filter_delay_fc_sptr (new gr_filter_delay_fc (taps)); + return gnuradio::get_initial_sptr(new gr_filter_delay_fc (taps)); } gr_filter_delay_fc::gr_filter_delay_fc (const std::vector<float> &taps) diff --git a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.cc.t b/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.cc.t index b99de5073..29e351925 100644 --- a/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.cc.t +++ b/gnuradio-core/src/lib/filter/gr_fir_filter_XXX.cc.t @@ -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 * @@ -36,7 +36,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps) { - return @SPTR_NAME@ (new @NAME@ (decimation, taps)); + return gnuradio::get_initial_sptr (new @NAME@ (decimation, taps)); } diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.cc b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.cc index 56a1a31aa..500958e3d 100644 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.cc +++ b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2007 Free Software Foundation, Inc. + * Copyright 2004,2007,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ // Public constructor gr_fractional_interpolator_cc_sptr gr_make_fractional_interpolator_cc(float phase_shift, float interp_ratio) { - return gr_fractional_interpolator_cc_sptr(new gr_fractional_interpolator_cc(phase_shift, interp_ratio)); + return gnuradio::get_initial_sptr(new gr_fractional_interpolator_cc(phase_shift, interp_ratio)); } gr_fractional_interpolator_cc::gr_fractional_interpolator_cc(float phase_shift, float interp_ratio) diff --git a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.cc b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.cc index 0e0fdad7f..9cbe31635 100644 --- a/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.cc +++ b/gnuradio-core/src/lib/filter/gr_fractional_interpolator_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2007 Free Software Foundation, Inc. + * Copyright 2004,2007,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ // Public constructor gr_fractional_interpolator_ff_sptr gr_make_fractional_interpolator_ff(float phase_shift, float interp_ratio) { - return gr_fractional_interpolator_ff_sptr(new gr_fractional_interpolator_ff(phase_shift, interp_ratio)); + return gnuradio::get_initial_sptr(new gr_fractional_interpolator_ff(phase_shift, interp_ratio)); } gr_fractional_interpolator_ff::gr_fractional_interpolator_ff(float phase_shift, float interp_ratio) diff --git a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.cc.t b/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.cc.t index f51e046af..656b3402a 100644 --- a/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.cc.t +++ b/gnuradio-core/src/lib/filter/gr_freq_xlating_fir_filter_XXX.cc.t @@ -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 * @@ -39,7 +39,7 @@ gr_make_@BASE_NAME@ (int decimation, const std::vector<@TAP_TYPE@> &taps, double center_freq, double sampling_freq) { - return @SPTR_NAME@ (new @NAME@ (decimation, taps, center_freq, sampling_freq)); + return gnuradio::get_initial_sptr (new @NAME@ (decimation, taps, center_freq, sampling_freq)); } diff --git a/gnuradio-core/src/lib/filter/gr_goertzel_fc.cc b/gnuradio-core/src/lib/filter/gr_goertzel_fc.cc index aee8df844..a93751b2f 100644 --- a/gnuradio-core/src/lib/filter/gr_goertzel_fc.cc +++ b/gnuradio-core/src/lib/filter/gr_goertzel_fc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_goertzel_fc_sptr gr_make_goertzel_fc(int rate, int len, float freq) { - return gr_goertzel_fc_sptr (new gr_goertzel_fc(rate, len, freq)); + return gnuradio::get_initial_sptr(new gr_goertzel_fc(rate, len, freq)); } gr_goertzel_fc::gr_goertzel_fc(int rate, int len, float freq) diff --git a/gnuradio-core/src/lib/filter/gr_hilbert_fc.cc b/gnuradio-core/src/lib/filter/gr_hilbert_fc.cc index 65343916c..7445f051e 100644 --- a/gnuradio-core/src/lib/filter/gr_hilbert_fc.cc +++ b/gnuradio-core/src/lib/filter/gr_hilbert_fc.cc @@ -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 * @@ -33,7 +33,7 @@ gr_hilbert_fc_sptr gr_make_hilbert_fc (unsigned int ntaps) { - return gr_hilbert_fc_sptr (new gr_hilbert_fc (ntaps)); + return gnuradio::get_initial_sptr(new gr_hilbert_fc (ntaps)); } gr_hilbert_fc::gr_hilbert_fc (unsigned int ntaps) diff --git a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.cc b/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.cc index 0c2d38630..a41a4f7db 100644 --- a/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.cc +++ b/gnuradio-core/src/lib/filter/gr_iir_filter_ffd.cc @@ -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 * @@ -33,7 +33,7 @@ gr_iir_filter_ffd_sptr gr_make_iir_filter_ffd (const std::vector<double> &fftaps, const std::vector<double> &fbtaps) throw (std::invalid_argument) { - return gr_iir_filter_ffd_sptr (new gr_iir_filter_ffd (fftaps, fbtaps)); + return gnuradio::get_initial_sptr(new gr_iir_filter_ffd (fftaps, fbtaps)); } gr_iir_filter_ffd::gr_iir_filter_ffd (const std::vector<double> &fftaps, diff --git a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.cc.t b/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.cc.t index 274aee727..b90450c65 100644 --- a/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.cc.t +++ b/gnuradio-core/src/lib/filter/gr_interp_fir_filter_XXX.cc.t @@ -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 * @@ -38,7 +38,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (unsigned interpolation, const std::vector<@TAP_TYPE@> &taps) { - return @SPTR_NAME@ (new @NAME@ (interpolation, taps)); + return gnuradio::get_initial_sptr (new @NAME@ (interpolation, taps)); } 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 5a6e753ab..399632003 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 @@ -34,8 +34,8 @@ gr_pfb_arb_resampler_ccf_sptr gr_make_pfb_arb_resampler_ccf (float rate, const std::vector<float> &taps, unsigned int filter_size) { - return gr_pfb_arb_resampler_ccf_sptr (new gr_pfb_arb_resampler_ccf (rate, taps, - filter_size)); + return gnuradio::get_initial_sptr(new gr_pfb_arb_resampler_ccf (rate, taps, + filter_size)); } @@ -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 () 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 5fda47880..cb67b8104 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc @@ -36,7 +36,7 @@ gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, const std::vector<float> &taps, float oversample_rate) { - return gr_pfb_channelizer_ccf_sptr (new gr_pfb_channelizer_ccf (numchans, taps, + return gnuradio::get_initial_sptr(new gr_pfb_channelizer_ccf (numchans, taps, oversample_rate)); } @@ -60,6 +60,8 @@ gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, 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<gr_fir_ccf*>(d_numchans); // Create an FIR filter for each channel and zero out the taps diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc index ff4fb70a3..937899c0d 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_ccf.cc @@ -39,7 +39,7 @@ gr_pfb_clock_sync_ccf_sptr gr_make_pfb_clock_sync_ccf (double sps, float gain, float init_phase, float max_rate_deviation) { - return gr_pfb_clock_sync_ccf_sptr (new gr_pfb_clock_sync_ccf (sps, gain, taps, + return gnuradio::get_initial_sptr(new gr_pfb_clock_sync_ccf (sps, gain, taps, filter_size, init_phase, max_rate_deviation)); diff --git a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.cc b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.cc index 86de3b5a1..5d7f7a0d0 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_clock_sync_fff.cc @@ -39,7 +39,7 @@ gr_pfb_clock_sync_fff_sptr gr_make_pfb_clock_sync_fff (double sps, float gain, float init_phase, float max_rate_deviation) { - return gr_pfb_clock_sync_fff_sptr (new gr_pfb_clock_sync_fff (sps, gain, taps, + return gnuradio::get_initial_sptr(new gr_pfb_clock_sync_fff (sps, gain, taps, filter_size, init_phase, max_rate_deviation)); diff --git a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc index e05e18ff2..28c6a611a 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_decimator_ccf.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 * @@ -36,7 +36,7 @@ gr_pfb_decimator_ccf_sptr gr_make_pfb_decimator_ccf (unsigned int decim, const std::vector<float> &taps, unsigned int channel) { - return gr_pfb_decimator_ccf_sptr (new gr_pfb_decimator_ccf (decim, taps, channel)); + return gnuradio::get_initial_sptr(new gr_pfb_decimator_ccf (decim, taps, channel)); } 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 6a9598f34..8a0ad1c4c 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_interpolator_ccf.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 * @@ -33,7 +33,7 @@ gr_pfb_interpolator_ccf_sptr gr_make_pfb_interpolator_ccf (unsigned int interp, const std::vector<float> &taps) { - return gr_pfb_interpolator_ccf_sptr (new gr_pfb_interpolator_ccf (interp, taps)); + return gnuradio::get_initial_sptr(new gr_pfb_interpolator_ccf (interp, taps)); } diff --git a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.cc.t b/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.cc.t index 69276f58e..3e9a34cdc 100644 --- a/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.cc.t +++ b/gnuradio-core/src/lib/filter/gr_rational_resampler_base_XXX.cc.t @@ -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 * @@ -42,7 +42,7 @@ gr_make_@BASE_NAME@ (unsigned interpolation, unsigned decimation, const std::vector<@TAP_TYPE@> &taps) { - return @SPTR_NAME@ (new @NAME@ (interpolation, decimation, taps)); + return gnuradio::get_initial_sptr (new @NAME@ (interpolation, decimation, taps)); } @NAME@::@NAME@ (unsigned interpolation, unsigned decimation, diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.cc b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.cc index e4269798b..8f8efb7e6 100644 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.cc +++ b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ gr_single_pole_iir_filter_cc_sptr gr_make_single_pole_iir_filter_cc (double alpha, unsigned int vlen) { - return gr_single_pole_iir_filter_cc_sptr(new gr_single_pole_iir_filter_cc(alpha, vlen)); + return gnuradio::get_initial_sptr(new gr_single_pole_iir_filter_cc(alpha, vlen)); } gr_single_pole_iir_filter_cc::gr_single_pole_iir_filter_cc ( diff --git a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.cc b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.cc index a71861ba8..3282f1fc3 100644 --- a/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.cc +++ b/gnuradio-core/src/lib/filter/gr_single_pole_iir_filter_ff.cc @@ -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 * @@ -32,7 +32,7 @@ gr_single_pole_iir_filter_ff_sptr gr_make_single_pole_iir_filter_ff (double alpha, unsigned int vlen) { - return gr_single_pole_iir_filter_ff_sptr(new gr_single_pole_iir_filter_ff(alpha, vlen)); + return gnuradio::get_initial_sptr(new gr_single_pole_iir_filter_ff(alpha, vlen)); } gr_single_pole_iir_filter_ff::gr_single_pole_iir_filter_ff ( diff --git a/gnuradio-core/src/lib/general/Makefile.am b/gnuradio-core/src/lib/general/Makefile.am index b5f5c346b..3d8a42805 100644 --- a/gnuradio-core/src/lib/general/Makefile.am +++ b/gnuradio-core/src/lib/general/Makefile.am @@ -60,7 +60,6 @@ libgeneral_la_SOURCES = \ gr_cpfsk_bc.cc \ gr_crc32.cc \ gr_ctcss_squelch_ff.cc \ - gr_dd_mpsk_sync_cc.cc \ gr_decode_ccsds_27_fb.cc \ gr_deinterleave.cc \ gr_delay.cc \ @@ -215,7 +214,6 @@ grinclude_HEADERS = \ gr_cpfsk_bc.h \ gr_crc32.h \ gr_ctcss_squelch_ff.h \ - gr_dd_mpsk_sync_cc.h \ gr_decode_ccsds_27_fb.h \ gr_diff_decoder_bb.h \ gr_diff_encoder_bb.h \ @@ -386,7 +384,6 @@ swiginclude_HEADERS = \ gr_cpfsk_bc.i \ gr_crc32.i \ gr_ctcss_squelch_ff.i \ - gr_dd_mpsk_sync_cc.i \ gr_decode_ccsds_27_fb.i \ gr_diff_decoder_bb.i \ gr_diff_encoder_bb.i \ diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i index 6929f1e6e..68cafce2e 100644 --- a/gnuradio-core/src/lib/general/general.i +++ b/gnuradio-core/src/lib/general/general.i @@ -80,7 +80,6 @@ #include <gr_threshold_ff.h> #include <gr_clock_recovery_mm_ff.h> #include <gr_clock_recovery_mm_cc.h> -#include <gr_dd_mpsk_sync_cc.h> #include <gr_packet_sink.h> #include <gr_lms_dfe_cc.h> #include <gr_lms_dfe_ff.h> @@ -202,7 +201,6 @@ %include "gr_threshold_ff.i" %include "gr_clock_recovery_mm_ff.i" %include "gr_clock_recovery_mm_cc.i" -%include "gr_dd_mpsk_sync_cc.i" %include "gr_packet_sink.i" %include "gr_lms_dfe_cc.i" %include "gr_lms_dfe_ff.i" diff --git a/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.cc b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.cc index 91e02c2d3..f390df6d5 100644 --- a/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.cc +++ b/gnuradio-core/src/lib/general/gr_additive_scrambler_bb.cc @@ -30,7 +30,7 @@ gr_additive_scrambler_bb_sptr gr_make_additive_scrambler_bb(int mask, int seed, int len, int count) { - return gr_additive_scrambler_bb_sptr(new gr_additive_scrambler_bb(mask, seed, len, count)); + return gnuradio::get_initial_sptr(new gr_additive_scrambler_bb(mask, seed, len, count)); } gr_additive_scrambler_bb::gr_additive_scrambler_bb(int mask, int seed, int len, int count) diff --git a/gnuradio-core/src/lib/general/gr_agc2_cc.cc b/gnuradio-core/src/lib/general/gr_agc2_cc.cc index 175ca4ab2..687f6c857 100644 --- a/gnuradio-core/src/lib/general/gr_agc2_cc.cc +++ b/gnuradio-core/src/lib/general/gr_agc2_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ gr_agc2_cc_sptr gr_make_agc2_cc (float attack_rate, float decay_rate, float reference, float gain, float max_gain) { - return gr_agc2_cc_sptr (new gr_agc2_cc (attack_rate, decay_rate, reference, gain, max_gain)); + return gnuradio::get_initial_sptr(new gr_agc2_cc (attack_rate, decay_rate, reference, gain, max_gain)); } gr_agc2_cc::gr_agc2_cc (float attack_rate, float decay_rate, float reference, diff --git a/gnuradio-core/src/lib/general/gr_agc2_ff.cc b/gnuradio-core/src/lib/general/gr_agc2_ff.cc index a9f7fffab..667e9d05d 100644 --- a/gnuradio-core/src/lib/general/gr_agc2_ff.cc +++ b/gnuradio-core/src/lib/general/gr_agc2_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005,2006 Free Software Foundation, Inc. + * Copyright 2005,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ gr_agc2_ff_sptr gr_make_agc2_ff (float attack_rate, float decay_rate, float reference, float gain, float max_gain) { - return gr_agc2_ff_sptr (new gr_agc2_ff (attack_rate, decay_rate, reference, + return gnuradio::get_initial_sptr(new gr_agc2_ff (attack_rate, decay_rate, reference, gain, max_gain)); } diff --git a/gnuradio-core/src/lib/general/gr_agc_cc.cc b/gnuradio-core/src/lib/general/gr_agc_cc.cc index 3f48b55fe..92cec0088 100644 --- a/gnuradio-core/src/lib/general/gr_agc_cc.cc +++ b/gnuradio-core/src/lib/general/gr_agc_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ gr_agc_cc_sptr gr_make_agc_cc (float rate, float reference, float gain, float max_gain) { - return gr_agc_cc_sptr (new gr_agc_cc (rate, reference, gain, max_gain)); + return gnuradio::get_initial_sptr(new gr_agc_cc (rate, reference, gain, max_gain)); } gr_agc_cc::gr_agc_cc (float rate, float reference, diff --git a/gnuradio-core/src/lib/general/gr_agc_ff.cc b/gnuradio-core/src/lib/general/gr_agc_ff.cc index 9e74fed85..45c86d898 100644 --- a/gnuradio-core/src/lib/general/gr_agc_ff.cc +++ b/gnuradio-core/src/lib/general/gr_agc_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005,2006 Free Software Foundation, Inc. + * Copyright 2005,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_agc_ff_sptr gr_make_agc_ff (float rate, float reference, float gain, float max_gain) { - return gr_agc_ff_sptr (new gr_agc_ff (rate, reference, gain, max_gain)); + return gnuradio::get_initial_sptr(new gr_agc_ff (rate, reference, gain, max_gain)); } gr_agc_ff::gr_agc_ff (float rate, float reference, float gain, float max_gain) diff --git a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.cc b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.cc index 241a33f5d..e11793fdd 100644 --- a/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.cc +++ b/gnuradio-core/src/lib/general/gr_align_on_samplenumbers_ss.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -48,7 +48,7 @@ gr_align_on_samplenumbers_ss_sptr gr_make_align_on_samplenumbers_ss (int nchan, int align_interval) { - return gr_align_on_samplenumbers_ss_sptr (new gr_align_on_samplenumbers_ss (nchan,align_interval)); + return gnuradio::get_initial_sptr(new gr_align_on_samplenumbers_ss (nchan,align_interval)); } gr_align_on_samplenumbers_ss::gr_align_on_samplenumbers_ss (int nchan,int align_interval) diff --git a/gnuradio-core/src/lib/general/gr_bin_statistics_f.cc b/gnuradio-core/src/lib/general/gr_bin_statistics_f.cc index 61abd72b8..435a660cd 100644 --- a/gnuradio-core/src/lib/general/gr_bin_statistics_f.cc +++ b/gnuradio-core/src/lib/general/gr_bin_statistics_f.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -35,7 +35,7 @@ gr_make_bin_statistics_f(unsigned int vlen, size_t tune_delay, size_t dwell_delay) { - return gr_bin_statistics_f_sptr(new gr_bin_statistics_f(vlen, + return gnuradio::get_initial_sptr(new gr_bin_statistics_f(vlen, msgq, tune, tune_delay, diff --git a/gnuradio-core/src/lib/general/gr_binary_slicer_fb.cc b/gnuradio-core/src/lib/general/gr_binary_slicer_fb.cc index 69e85f0bc..ae8903abb 100644 --- a/gnuradio-core/src/lib/general/gr_binary_slicer_fb.cc +++ b/gnuradio-core/src/lib/general/gr_binary_slicer_fb.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_binary_slicer_fb_sptr gr_make_binary_slicer_fb () { - return gr_binary_slicer_fb_sptr (new gr_binary_slicer_fb ()); + return gnuradio::get_initial_sptr(new gr_binary_slicer_fb ()); } gr_binary_slicer_fb::gr_binary_slicer_fb () diff --git a/gnuradio-core/src/lib/general/gr_bytes_to_syms.cc b/gnuradio-core/src/lib/general/gr_bytes_to_syms.cc index 2babe492f..460444379 100644 --- a/gnuradio-core/src/lib/general/gr_bytes_to_syms.cc +++ b/gnuradio-core/src/lib/general/gr_bytes_to_syms.cc @@ -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 * @@ -33,7 +33,7 @@ static const int BITS_PER_BYTE = 8; gr_bytes_to_syms_sptr gr_make_bytes_to_syms () { - return gr_bytes_to_syms_sptr (new gr_bytes_to_syms ()); + return gnuradio::get_initial_sptr(new gr_bytes_to_syms ()); } gr_bytes_to_syms::gr_bytes_to_syms () diff --git a/gnuradio-core/src/lib/general/gr_char_to_float.cc b/gnuradio-core/src/lib/general/gr_char_to_float.cc index 2d3854873..e68f8d208 100644 --- a/gnuradio-core/src/lib/general/gr_char_to_float.cc +++ b/gnuradio-core/src/lib/general/gr_char_to_float.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_char_to_float_sptr gr_make_char_to_float () { - return gr_char_to_float_sptr (new gr_char_to_float ()); + return gnuradio::get_initial_sptr(new gr_char_to_float ()); } gr_char_to_float::gr_char_to_float () diff --git a/gnuradio-core/src/lib/general/gr_check_counting_s.cc b/gnuradio-core/src/lib/general/gr_check_counting_s.cc index 15c7b98e1..bce308814 100644 --- a/gnuradio-core/src/lib/general/gr_check_counting_s.cc +++ b/gnuradio-core/src/lib/general/gr_check_counting_s.cc @@ -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 * @@ -32,7 +32,7 @@ gr_check_counting_s_sptr gr_make_check_counting_s (bool do_32bit) { - return gr_check_counting_s_sptr (new gr_check_counting_s (do_32bit)); + return gnuradio::get_initial_sptr(new gr_check_counting_s (do_32bit)); } gr_check_counting_s::gr_check_counting_s (bool do_32bit) diff --git a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.cc b/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.cc index c5f7bfc47..95c6c7da5 100644 --- a/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.cc +++ b/gnuradio-core/src/lib/general/gr_check_lfsr_32k_s.cc @@ -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 * @@ -32,7 +32,7 @@ gr_check_lfsr_32k_s_sptr gr_make_check_lfsr_32k_s () { - return gr_check_lfsr_32k_s_sptr (new gr_check_lfsr_32k_s ()); + return gnuradio::get_initial_sptr(new gr_check_lfsr_32k_s ()); } gr_check_lfsr_32k_s::gr_check_lfsr_32k_s () diff --git a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.cc b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.cc index 60e3dd13d..23bbf821f 100644 --- a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.cc +++ b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005,2006 Free Software Foundation, Inc. + * Copyright 2005,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -39,7 +39,7 @@ gr_clock_recovery_mm_cc_sptr gr_make_clock_recovery_mm_cc(float omega, float gain_omega, float mu, float gain_mu, float omega_relative_limit) { - return gr_clock_recovery_mm_cc_sptr (new gr_clock_recovery_mm_cc (omega, + return gnuradio::get_initial_sptr(new gr_clock_recovery_mm_cc (omega, gain_omega, mu, gain_mu, diff --git a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.cc b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.cc index 2e9eea8e6..bb5a27071 100644 --- a/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.cc +++ b/gnuradio-core/src/lib/general/gr_clock_recovery_mm_ff.cc @@ -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 * @@ -37,7 +37,7 @@ gr_clock_recovery_mm_ff_sptr gr_make_clock_recovery_mm_ff(float omega, float gain_omega, float mu, float gain_mu, float omega_relative_limit) { - return gr_clock_recovery_mm_ff_sptr (new gr_clock_recovery_mm_ff (omega, + return gnuradio::get_initial_sptr(new gr_clock_recovery_mm_ff (omega, gain_omega, mu, gain_mu, diff --git a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.cc b/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.cc index fcecf0c8b..d198da0b0 100644 --- a/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.cc +++ b/gnuradio-core/src/lib/general/gr_complex_to_interleaved_short.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2005 Free Software Foundation, Inc. + * Copyright 2004,2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_complex_to_interleaved_short_sptr gr_make_complex_to_interleaved_short () { - return gr_complex_to_interleaved_short_sptr (new gr_complex_to_interleaved_short ()); + return gnuradio::get_initial_sptr(new gr_complex_to_interleaved_short ()); } gr_complex_to_interleaved_short::gr_complex_to_interleaved_short () diff --git a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc index abffa4da1..a59c127f3 100644 --- a/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc +++ b/gnuradio-core/src/lib/general/gr_complex_to_xxx.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008 Free Software Foundation, Inc. + * Copyright 2004,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -33,7 +33,7 @@ gr_complex_to_float_sptr gr_make_complex_to_float (unsigned int vlen) { - return gr_complex_to_float_sptr (new gr_complex_to_float (vlen)); + return gnuradio::get_initial_sptr(new gr_complex_to_float (vlen)); } gr_complex_to_float::gr_complex_to_float (unsigned int vlen) @@ -81,7 +81,7 @@ gr_complex_to_float::work (int noutput_items, gr_complex_to_real_sptr gr_make_complex_to_real (unsigned int vlen) { - return gr_complex_to_real_sptr (new gr_complex_to_real (vlen)); + return gnuradio::get_initial_sptr(new gr_complex_to_real (vlen)); } gr_complex_to_real::gr_complex_to_real (unsigned int vlen) @@ -112,7 +112,7 @@ gr_complex_to_real::work (int noutput_items, gr_complex_to_imag_sptr gr_make_complex_to_imag (unsigned int vlen) { - return gr_complex_to_imag_sptr (new gr_complex_to_imag (vlen)); + return gnuradio::get_initial_sptr(new gr_complex_to_imag (vlen)); } gr_complex_to_imag::gr_complex_to_imag (unsigned int vlen) @@ -143,7 +143,7 @@ gr_complex_to_imag::work (int noutput_items, gr_complex_to_mag_sptr gr_make_complex_to_mag (unsigned int vlen) { - return gr_complex_to_mag_sptr (new gr_complex_to_mag (vlen)); + return gnuradio::get_initial_sptr(new gr_complex_to_mag (vlen)); } gr_complex_to_mag::gr_complex_to_mag (unsigned int vlen) @@ -174,7 +174,7 @@ gr_complex_to_mag::work (int noutput_items, gr_complex_to_mag_squared_sptr gr_make_complex_to_mag_squared (unsigned int vlen) { - return gr_complex_to_mag_squared_sptr (new gr_complex_to_mag_squared (vlen)); + return gnuradio::get_initial_sptr(new gr_complex_to_mag_squared (vlen)); } gr_complex_to_mag_squared::gr_complex_to_mag_squared (unsigned int vlen) @@ -207,7 +207,7 @@ gr_complex_to_mag_squared::work (int noutput_items, gr_complex_to_arg_sptr gr_make_complex_to_arg (unsigned int vlen) { - return gr_complex_to_arg_sptr (new gr_complex_to_arg (vlen)); + return gnuradio::get_initial_sptr(new gr_complex_to_arg (vlen)); } gr_complex_to_arg::gr_complex_to_arg (unsigned int vlen) diff --git a/gnuradio-core/src/lib/general/gr_conjugate_cc.cc b/gnuradio-core/src/lib/general/gr_conjugate_cc.cc index f25ce1a57..59c3bae89 100644 --- a/gnuradio-core/src/lib/general/gr_conjugate_cc.cc +++ b/gnuradio-core/src/lib/general/gr_conjugate_cc.cc @@ -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 * @@ -32,7 +32,7 @@ gr_conjugate_cc_sptr gr_make_conjugate_cc () { - return gr_conjugate_cc_sptr (new gr_conjugate_cc ()); + return gnuradio::get_initial_sptr(new gr_conjugate_cc ()); } gr_conjugate_cc::gr_conjugate_cc () diff --git a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc b/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc index 43dae6c1a..15f673411 100644 --- a/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc +++ b/gnuradio-core/src/lib/general/gr_correlate_access_code_bb.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -37,7 +37,7 @@ gr_correlate_access_code_bb_sptr gr_make_correlate_access_code_bb (const std::string &access_code, int threshold) { - return gr_correlate_access_code_bb_sptr (new gr_correlate_access_code_bb (access_code, threshold)); + return gnuradio::get_initial_sptr(new gr_correlate_access_code_bb (access_code, threshold)); } diff --git a/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc b/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc index 4e0f7e067..f3bfd0951 100644 --- a/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc +++ b/gnuradio-core/src/lib/general/gr_costas_loop_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -38,7 +38,7 @@ gr_make_costas_loop_cc (float alpha, float beta, int order ) throw (std::invalid_argument) { - return gr_costas_loop_cc_sptr (new gr_costas_loop_cc (alpha, beta, + return gnuradio::get_initial_sptr(new gr_costas_loop_cc (alpha, beta, max_freq, min_freq, order)); } diff --git a/gnuradio-core/src/lib/general/gr_cpfsk_bc.cc b/gnuradio-core/src/lib/general/gr_cpfsk_bc.cc index 95d7c1753..f0b04ef97 100644 --- a/gnuradio-core/src/lib/general/gr_cpfsk_bc.cc +++ b/gnuradio-core/src/lib/general/gr_cpfsk_bc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * 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 @@ -31,7 +31,7 @@ gr_cpfsk_bc_sptr gr_make_cpfsk_bc(float k, float ampl, int samples_per_sym) { - return gr_cpfsk_bc_sptr(new gr_cpfsk_bc(k, ampl, samples_per_sym)); + return gnuradio::get_initial_sptr(new gr_cpfsk_bc(k, ampl, samples_per_sym)); } gr_cpfsk_bc::gr_cpfsk_bc(float k, float ampl, int samples_per_sym) diff --git a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.cc b/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.cc index 59034ddc1..6c1e98d47 100644 --- a/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.cc +++ b/gnuradio-core/src/lib/general/gr_ctcss_squelch_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -38,7 +38,7 @@ static int max_tone_index = 37; gr_ctcss_squelch_ff_sptr gr_make_ctcss_squelch_ff(int rate, float freq, float level, int len, int ramp, bool gate) { - return gr_ctcss_squelch_ff_sptr(new gr_ctcss_squelch_ff(rate, freq, level, len, ramp, gate)); + return gnuradio::get_initial_sptr(new gr_ctcss_squelch_ff(rate, freq, level, len, ramp, gate)); } int gr_ctcss_squelch_ff::find_tone(float freq) diff --git a/gnuradio-core/src/lib/general/gr_dd_mpsk_sync_cc.cc b/gnuradio-core/src/lib/general/gr_dd_mpsk_sync_cc.cc deleted file mode 100644 index d4141efc7..000000000 --- a/gnuradio-core/src/lib/general/gr_dd_mpsk_sync_cc.cc +++ /dev/null @@ -1,196 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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 <gr_dd_mpsk_sync_cc.h> -#include <gr_io_signature.h> -#include <gr_sincos.h> -#include <gri_mmse_fir_interpolator_cc.h> -#include <math.h> -#include <stdexcept> -#include <cstdio> - -#include <gr_complex.h> - -#define M_TWOPI (2*M_PI) - -gr_dd_mpsk_sync_cc_sptr -gr_make_dd_mpsk_sync_cc (float alpha, float beta, float max_freq, float min_freq, float ref_phase, - float omega, float gain_omega, float mu, float gain_mu) -{ - return gr_dd_mpsk_sync_cc_sptr (new gr_dd_mpsk_sync_cc (alpha, beta, max_freq, min_freq,ref_phase, - omega,gain_omega,mu,gain_mu)); -} - -gr_dd_mpsk_sync_cc::gr_dd_mpsk_sync_cc (float alpha, float beta, float max_freq, float min_freq, - float ref_phase, - float omega, float gain_omega, float mu, float gain_mu) - : gr_block ("dd_mpsk_sync_cc", - gr_make_io_signature (1, 1, sizeof (gr_complex)), - gr_make_io_signature (1, 1, sizeof (gr_complex))), - d_alpha(alpha), d_beta(beta), - d_max_freq(max_freq), d_min_freq(min_freq), - d_ref_phase(ref_phase),d_omega(omega), d_gain_omega(gain_omega), - d_mu(mu), d_gain_mu(gain_mu), - d_phase(0), d_freq((max_freq+min_freq)/2), d_last_sample(0), - d_interp(new gri_mmse_fir_interpolator_cc()), - d_dl_idx(0) -{ - if (omega <= 0.0) - throw std::out_of_range ("clock rate must be > 0"); - if (gain_mu < 0 || gain_omega < 0) - throw std::out_of_range ("Gains must be non-negative"); - - assert(d_interp->ntaps() <= DLLEN); - - // zero double length delay line. - for (unsigned int i = 0; i < 2 * DLLEN; i++) - d_dl[i] = gr_complex(0.0,0.0); -} - -gr_dd_mpsk_sync_cc::~gr_dd_mpsk_sync_cc() -{ - delete d_interp; -} - -float -gr_dd_mpsk_sync_cc::phase_detector(gr_complex sample,float ref_phase) -{ - return ((sample.real()>0 ? 1.0 : -1.0) * sample.imag() - - (sample.imag()>0 ? 1.0 : -1.0) * sample.real()); -} - -void -gr_dd_mpsk_sync_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) -{ - unsigned ninputs = ninput_items_required.size(); - for (unsigned i=0; i < ninputs; i++) - ninput_items_required[i] = - (int) ceil((noutput_items * d_omega) + d_interp->ntaps()); -} -gr_complex -gr_dd_mpsk_sync_cc::slicer_45deg (gr_complex sample) -{ - float real,imag; - if(sample.real() > 0) - real=1; - else - real=-1; - if(sample.imag() > 0) - imag = 1; - else - imag = -1; - return gr_complex(real,imag); -} - -gr_complex -gr_dd_mpsk_sync_cc::slicer_0deg (gr_complex sample) -{ - gr_complex out; - if( fabs(sample.real()) > fabs(sample.imag()) ) { - if(sample.real() > 0) - return gr_complex(1.0,0.0); - else - return gr_complex(-1.0,0.0); - } - else { - if(sample.imag() > 0) - return gr_complex(0.0, 1.0); - else - return gr_complex(0.0, -1.0); - } -} - -int -gr_dd_mpsk_sync_cc::general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - const gr_complex *in = (gr_complex *) input_items[0]; - gr_complex *out = (gr_complex *) output_items[0]; - - int ii, oo; - ii = 0; oo = 0; - - float error; - float t_imag, t_real; - gr_complex nco_out; - float mm_val; - - while (oo < noutput_items) { - // - // generate an output sample by interpolating between the carrier - // tracked samples in the delay line. d_mu, the fractional - // interpolation amount (in [0.0, 1.0]) is controlled by the - // symbol timing loop below. - // - out[oo] = d_interp->interpolate (&d_dl[d_dl_idx], d_mu); - - error = phase_detector(out[oo], d_ref_phase); - - d_freq = d_freq + d_beta * error; - d_phase = d_phase + d_alpha * error; - while(d_phase>M_TWOPI) - d_phase -= M_TWOPI; - while(d_phase<-M_TWOPI) - d_phase += M_TWOPI; - - if (d_freq > d_max_freq) - d_freq = d_max_freq; - else if (d_freq < d_min_freq) - d_freq = d_min_freq; - - mm_val = real(d_last_sample * slicer_0deg(out[oo]) - out[oo] * slicer_0deg(d_last_sample)); - d_last_sample = out[oo]; - - d_omega = d_omega + d_gain_omega * mm_val; - d_mu = d_mu + d_omega + d_gain_mu * mm_val; - - while(d_mu >= 1.0) { - // - // Generate more carrier tracked samples for the delay line - // - d_mu -= 1.0; - gr_sincosf(d_phase, &t_imag, &t_real); - nco_out = gr_complex(t_real, -t_imag); - gr_complex new_sample = in[ii] * nco_out; - - d_dl[d_dl_idx] = new_sample; // overwrite oldest sample - d_dl[(d_dl_idx + DLLEN)] = new_sample; // and second copy - d_dl_idx = (d_dl_idx+1) % DLLEN; // point to the new oldest sample - d_phase = d_phase + d_freq; - ii++; - } - oo++; - printf("%f\t%f\t%f\t%f\t%f\n",d_mu,d_omega,mm_val,d_freq,d_phase); - //printf("%f\t%f\t%f\t%f\t%f\t%f\t%f\n",mple).real(),slicer_0deg(d_last_sample).imag(),mm_val,d_omega,d_mu); - } - - assert(ii <= ninput_items[0]); - - consume_each (ii); - return noutput_items; -} diff --git a/gnuradio-core/src/lib/general/gr_dd_mpsk_sync_cc.h b/gnuradio-core/src/lib/general/gr_dd_mpsk_sync_cc.h deleted file mode 100644 index 4ffcd3771..000000000 --- a/gnuradio-core/src/lib/general/gr_dd_mpsk_sync_cc.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2006 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_DD_MPSK_SYNC_CC_H -#define INCLUDED_GR_DD_MPSK_SYNC_CC_H - -#include <gr_sync_block.h> - -class gri_mmse_fir_interpolator_cc; - -class gr_dd_mpsk_sync_cc; -typedef boost::shared_ptr<gr_dd_mpsk_sync_cc> gr_dd_mpsk_sync_cc_sptr; - -gr_dd_mpsk_sync_cc_sptr -gr_make_dd_mpsk_sync_cc (float alpha, float beta, - float max_freq, float min_freq, float ref_phase, - float omega, float gain_omega, float mu, float gain_mu); - -/*! - * \brief Decision directed M-PSK synchronous demod - * \ingroup sync_blk - * This block performs joint carrier tracking and symbol timing recovery. - * - * input: complex baseband; output: properly timed complex samples ready for slicing. - * - * N.B, at this point, it handles only QPSK. - */ - -class gr_dd_mpsk_sync_cc : public gr_block -{ - friend gr_dd_mpsk_sync_cc_sptr gr_make_dd_mpsk_sync_cc (float alpha, float beta, - float max_freq, float min_freq, float ref_phase, - float omega, float gain_omega, float mu, float gain_mu); -public: - ~gr_dd_mpsk_sync_cc (); - void forecast(int noutput_items, gr_vector_int &ninput_items_required); - float mu() const { return d_mu;} - float omega() const { return d_omega;} - float gain_mu() const { return d_gain_mu;} - float gain_omega() const { return d_gain_omega;} - - void set_gain_mu (float gain_mu) { d_gain_mu = gain_mu; } - void set_gain_omega (float gain_omega) { d_gain_omega = gain_omega; } - void set_mu (float mu) { d_mu = mu; } - void set_omega (float omega) { d_omega = omega; } - -protected: - gr_dd_mpsk_sync_cc (float alpha, float beta, float max_freq, float min_freq, float ref_phase, - float omega, float gain_omega, float mu, float gain_mu); - - int general_work (int noutput_items, - gr_vector_int &ninput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - -private: - static const unsigned int DLLEN = 8; // delay line length. - - float d_alpha,d_beta,d_max_freq,d_min_freq,d_ref_phase; - float d_omega, d_gain_omega, d_mu, d_gain_mu; - float d_phase, d_freq; - gr_complex slicer_45deg (gr_complex sample); - gr_complex slicer_0deg (gr_complex sample); - gr_complex d_last_sample; - gri_mmse_fir_interpolator_cc *d_interp; - - gr_complex d_dl[2 * DLLEN]; // Holds post carrier tracking samples. - // double length delay line to avoid wraps. - unsigned int d_dl_idx; // indexes oldest sample in delay line. - - float phase_detector(gr_complex sample,float ref_phase); -}; - -#endif diff --git a/gnuradio-core/src/lib/general/gr_dd_mpsk_sync_cc.i b/gnuradio-core/src/lib/general/gr_dd_mpsk_sync_cc.i deleted file mode 100644 index 17739248e..000000000 --- a/gnuradio-core/src/lib/general/gr_dd_mpsk_sync_cc.i +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005 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,dd_mpsk_sync_cc) - - gr_dd_mpsk_sync_cc_sptr gr_make_dd_mpsk_sync_cc (float alpha, float beta, - float max_freq, float min_freq, float ref_phase, - float omega, float gain_omega, float mu, float gain_mu); - -class gr_dd_mpsk_sync_cc : public gr_block -{ - private: - gr_dd_mpsk_sync_cc (float alpha, float beta, float max_freq, float min_freq, float ref_phase, - float omega, float gain_omega, float mu, float gain_mu); -}; diff --git a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc b/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc index add036f20..d5425bfc8 100644 --- a/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc +++ b/gnuradio-core/src/lib/general/gr_decode_ccsds_27_fb.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * 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 @@ -28,7 +28,7 @@ gr_decode_ccsds_27_fb_sptr gr_make_decode_ccsds_27_fb() { - return gr_decode_ccsds_27_fb_sptr(new gr_decode_ccsds_27_fb()); + return gnuradio::get_initial_sptr(new gr_decode_ccsds_27_fb()); } gr_decode_ccsds_27_fb::gr_decode_ccsds_27_fb() diff --git a/gnuradio-core/src/lib/general/gr_deinterleave.cc b/gnuradio-core/src/lib/general/gr_deinterleave.cc index 6530b9675..843275366 100644 --- a/gnuradio-core/src/lib/general/gr_deinterleave.cc +++ b/gnuradio-core/src/lib/general/gr_deinterleave.cc @@ -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 * @@ -32,7 +32,7 @@ gr_deinterleave_sptr gr_make_deinterleave (size_t itemsize) { - return gr_deinterleave_sptr (new gr_deinterleave (itemsize)); + return gnuradio::get_initial_sptr(new gr_deinterleave (itemsize)); } gr_deinterleave::gr_deinterleave (size_t itemsize) diff --git a/gnuradio-core/src/lib/general/gr_delay.cc b/gnuradio-core/src/lib/general/gr_delay.cc index d52faca39..b06346f59 100644 --- a/gnuradio-core/src/lib/general/gr_delay.cc +++ b/gnuradio-core/src/lib/general/gr_delay.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 * @@ -31,7 +31,7 @@ gr_delay_sptr gr_make_delay (size_t itemsize, int delay) { - return gr_delay_sptr (new gr_delay (itemsize, delay)); + return gnuradio::get_initial_sptr(new gr_delay (itemsize, delay)); } gr_delay::gr_delay (size_t itemsize, int delay) diff --git a/gnuradio-core/src/lib/general/gr_descrambler_bb.cc b/gnuradio-core/src/lib/general/gr_descrambler_bb.cc index e173a8a22..b712e69ed 100644 --- a/gnuradio-core/src/lib/general/gr_descrambler_bb.cc +++ b/gnuradio-core/src/lib/general/gr_descrambler_bb.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_descrambler_bb_sptr gr_make_descrambler_bb(int mask, int seed, int len) { - return gr_descrambler_bb_sptr(new gr_descrambler_bb(mask, seed, len)); + return gnuradio::get_initial_sptr(new gr_descrambler_bb(mask, seed, len)); } gr_descrambler_bb::gr_descrambler_bb(int mask, int seed, int len) diff --git a/gnuradio-core/src/lib/general/gr_diff_decoder_bb.cc b/gnuradio-core/src/lib/general/gr_diff_decoder_bb.cc index 1802b3b77..1b0bcfb96 100644 --- a/gnuradio-core/src/lib/general/gr_diff_decoder_bb.cc +++ b/gnuradio-core/src/lib/general/gr_diff_decoder_bb.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_diff_decoder_bb_sptr gr_make_diff_decoder_bb (unsigned int modulus) { - return gr_diff_decoder_bb_sptr (new gr_diff_decoder_bb(modulus)); + return gnuradio::get_initial_sptr(new gr_diff_decoder_bb(modulus)); } gr_diff_decoder_bb::gr_diff_decoder_bb (unsigned int modulus) diff --git a/gnuradio-core/src/lib/general/gr_diff_encoder_bb.cc b/gnuradio-core/src/lib/general/gr_diff_encoder_bb.cc index 3eb8e62cc..7e67a718e 100644 --- a/gnuradio-core/src/lib/general/gr_diff_encoder_bb.cc +++ b/gnuradio-core/src/lib/general/gr_diff_encoder_bb.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_diff_encoder_bb_sptr gr_make_diff_encoder_bb (unsigned int modulus) { - return gr_diff_encoder_bb_sptr (new gr_diff_encoder_bb(modulus)); + return gnuradio::get_initial_sptr(new gr_diff_encoder_bb(modulus)); } gr_diff_encoder_bb::gr_diff_encoder_bb (unsigned int modulus) diff --git a/gnuradio-core/src/lib/general/gr_diff_phasor_cc.cc b/gnuradio-core/src/lib/general/gr_diff_phasor_cc.cc index 003297ff8..fb6a3a910 100644 --- a/gnuradio-core/src/lib/general/gr_diff_phasor_cc.cc +++ b/gnuradio-core/src/lib/general/gr_diff_phasor_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_diff_phasor_cc_sptr gr_make_diff_phasor_cc () { - return gr_diff_phasor_cc_sptr (new gr_diff_phasor_cc()); + return gnuradio::get_initial_sptr(new gr_diff_phasor_cc()); } gr_diff_phasor_cc::gr_diff_phasor_cc () diff --git a/gnuradio-core/src/lib/general/gr_dpll_bb.cc b/gnuradio-core/src/lib/general/gr_dpll_bb.cc index f24b2a88e..fcaad2174 100644 --- a/gnuradio-core/src/lib/general/gr_dpll_bb.cc +++ b/gnuradio-core/src/lib/general/gr_dpll_bb.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2009 Free Software Foundation, Inc. + * Copyright 2007,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_dpll_bb_sptr gr_make_dpll_bb (float period, float gain) { - return gr_dpll_bb_sptr (new gr_dpll_bb (period, gain)); + return gnuradio::get_initial_sptr(new gr_dpll_bb (period, gain)); } gr_dpll_bb::gr_dpll_bb (float period, float gain) diff --git a/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.cc b/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.cc index 76b8091f7..092e91d8b 100644 --- a/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.cc +++ b/gnuradio-core/src/lib/general/gr_encode_ccsds_27_bb.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008 Free Software Foundation, Inc. + * Copyright 2004,2008,2010 Free Software Foundation, Inc. * * 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 @@ -32,7 +32,7 @@ extern "C" { gr_encode_ccsds_27_bb_sptr gr_make_encode_ccsds_27_bb() { - return gr_encode_ccsds_27_bb_sptr(new gr_encode_ccsds_27_bb()); + return gnuradio::get_initial_sptr(new gr_encode_ccsds_27_bb()); } gr_encode_ccsds_27_bb::gr_encode_ccsds_27_bb() diff --git a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.cc b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.cc index 02385c59e..24945cfd8 100644 --- a/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.cc +++ b/gnuradio-core/src/lib/general/gr_fake_channel_coder_pp.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -35,7 +35,7 @@ static const int PAD_VAL = 0xAA; gr_fake_channel_encoder_pp_sptr gr_make_fake_channel_encoder_pp(int input_vlen, int output_vlen) { - return gr_fake_channel_encoder_pp_sptr(new gr_fake_channel_encoder_pp(input_vlen, + return gnuradio::get_initial_sptr(new gr_fake_channel_encoder_pp(input_vlen, output_vlen)); } @@ -77,7 +77,7 @@ gr_fake_channel_encoder_pp::work (int noutput_items, gr_fake_channel_decoder_pp_sptr gr_make_fake_channel_decoder_pp(int input_vlen, int output_vlen) { - return gr_fake_channel_decoder_pp_sptr(new gr_fake_channel_decoder_pp(input_vlen, + return gnuradio::get_initial_sptr(new gr_fake_channel_decoder_pp(input_vlen, output_vlen)); } diff --git a/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.cc b/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.cc index 53fb2a819..9046fcaa7 100644 --- a/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.cc +++ b/gnuradio-core/src/lib/general/gr_feedforward_agc_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_feedforward_agc_cc_sptr gr_make_feedforward_agc_cc(int nsamples, float reference) { - return gr_feedforward_agc_cc_sptr(new gr_feedforward_agc_cc (nsamples, reference)); + return gnuradio::get_initial_sptr(new gr_feedforward_agc_cc (nsamples, reference)); } gr_feedforward_agc_cc::gr_feedforward_agc_cc (int nsamples, float reference) diff --git a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc b/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc index f69d2e84e..3293e3ab8 100644 --- a/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc +++ b/gnuradio-core/src/lib/general/gr_fft_vcc_fftw.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2007,2008 Free Software Foundation, Inc. + * Copyright 2004,2007,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -33,7 +33,7 @@ gr_fft_vcc_sptr gr_make_fft_vcc_fftw (int fft_size, bool forward, const std::vector<float> &window, bool shift) { - return gr_fft_vcc_sptr (new gr_fft_vcc_fftw (fft_size, forward, window, shift)); + return gnuradio::get_initial_sptr(new gr_fft_vcc_fftw (fft_size, forward, window, shift)); } gr_fft_vcc_fftw::gr_fft_vcc_fftw (int fft_size, bool forward, diff --git a/gnuradio-core/src/lib/general/gr_fft_vfc.cc b/gnuradio-core/src/lib/general/gr_fft_vfc.cc index df68af7e1..608161efe 100644 --- a/gnuradio-core/src/lib/general/gr_fft_vfc.cc +++ b/gnuradio-core/src/lib/general/gr_fft_vfc.cc @@ -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 * @@ -42,7 +42,7 @@ gr_fft_vfc_sptr gr_make_fft_vfc (int fft_size, bool forward, const std::vector<float> window) { - return gr_fft_vfc_sptr (new gr_fft_vfc (fft_size, forward, window)); + return gnuradio::get_initial_sptr(new gr_fft_vfc (fft_size, forward, window)); } gr_fft_vfc::gr_fft_vfc (int fft_size, bool forward, const std::vector<float> window) 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 7f2c468b7..ff997e7a9 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 @@ -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 * @@ -48,7 +48,7 @@ float sinc(float x) gr_fll_band_edge_cc_sptr gr_make_fll_band_edge_cc (float samps_per_sym, float rolloff, int filter_size, float gain_alpha, float gain_beta) { - return gr_fll_band_edge_cc_sptr (new gr_fll_band_edge_cc (samps_per_sym, rolloff, + return gnuradio::get_initial_sptr(new gr_fll_band_edge_cc (samps_per_sym, rolloff, filter_size, gain_alpha, gain_beta)); } diff --git a/gnuradio-core/src/lib/general/gr_float_to_char.cc b/gnuradio-core/src/lib/general/gr_float_to_char.cc index ed6c41826..88b9d276e 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_char.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_char.cc @@ -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 * @@ -31,7 +31,7 @@ gr_float_to_char_sptr gr_make_float_to_char () { - return gr_float_to_char_sptr (new gr_float_to_char ()); + return gnuradio::get_initial_sptr(new gr_float_to_char ()); } gr_float_to_char::gr_float_to_char () 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 af878231a..89ef18869 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_complex.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_complex.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004, 2009 Free Software Foundation, Inc. + * Copyright 2004, 2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_float_to_complex_sptr gr_make_float_to_complex (size_t vlen) { - return gr_float_to_complex_sptr (new gr_float_to_complex (vlen)); + return gnuradio::get_initial_sptr(new gr_float_to_complex (vlen)); } gr_float_to_complex::gr_float_to_complex (size_t vlen) diff --git a/gnuradio-core/src/lib/general/gr_float_to_short.cc b/gnuradio-core/src/lib/general/gr_float_to_short.cc index ecb0fa0fc..084f76f9c 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_short.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_short.cc @@ -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 * @@ -31,7 +31,7 @@ gr_float_to_short_sptr gr_make_float_to_short () { - return gr_float_to_short_sptr (new gr_float_to_short ()); + return gnuradio::get_initial_sptr(new gr_float_to_short ()); } gr_float_to_short::gr_float_to_short () diff --git a/gnuradio-core/src/lib/general/gr_float_to_uchar.cc b/gnuradio-core/src/lib/general/gr_float_to_uchar.cc index 3776ac897..78369f8be 100644 --- a/gnuradio-core/src/lib/general/gr_float_to_uchar.cc +++ b/gnuradio-core/src/lib/general/gr_float_to_uchar.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_float_to_uchar_sptr gr_make_float_to_uchar () { - return gr_float_to_uchar_sptr (new gr_float_to_uchar ()); + return gnuradio::get_initial_sptr(new gr_float_to_uchar ()); } gr_float_to_uchar::gr_float_to_uchar () diff --git a/gnuradio-core/src/lib/general/gr_fmdet_cf.cc b/gnuradio-core/src/lib/general/gr_fmdet_cf.cc index e2c7e7a7f..3d828124e 100644 --- a/gnuradio-core/src/lib/general/gr_fmdet_cf.cc +++ b/gnuradio-core/src/lib/general/gr_fmdet_cf.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -35,7 +35,7 @@ gr_fmdet_cf_sptr gr_make_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl) { - return gr_fmdet_cf_sptr (new gr_fmdet_cf (samplerate, freq_low, freq_high, scl)); + return gnuradio::get_initial_sptr(new gr_fmdet_cf (samplerate, freq_low, freq_high, scl)); } gr_fmdet_cf::gr_fmdet_cf (float samplerate, float freq_low, float freq_high, float scl) diff --git a/gnuradio-core/src/lib/general/gr_framer_sink_1.cc b/gnuradio-core/src/lib/general/gr_framer_sink_1.cc index 9da271bac..c90b26c35 100644 --- a/gnuradio-core/src/lib/general/gr_framer_sink_1.cc +++ b/gnuradio-core/src/lib/general/gr_framer_sink_1.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -69,7 +69,7 @@ gr_framer_sink_1::enter_have_header(int payload_len, int whitener_offset) gr_framer_sink_1_sptr gr_make_framer_sink_1(gr_msg_queue_sptr target_queue) { - return gr_framer_sink_1_sptr(new gr_framer_sink_1(target_queue)); + return gnuradio::get_initial_sptr(new gr_framer_sink_1(target_queue)); } diff --git a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc index 541f841f4..0f6f0d719 100644 --- a/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc +++ b/gnuradio-core/src/lib/general/gr_frequency_modulator_fc.cc @@ -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 * @@ -32,7 +32,7 @@ gr_frequency_modulator_fc_sptr gr_make_frequency_modulator_fc (double sensitivity) { - return gr_frequency_modulator_fc_sptr (new gr_frequency_modulator_fc (sensitivity)); + return gnuradio::get_initial_sptr(new gr_frequency_modulator_fc (sensitivity)); } gr_frequency_modulator_fc::gr_frequency_modulator_fc (double sensitivity) diff --git a/gnuradio-core/src/lib/general/gr_glfsr_source_b.cc b/gnuradio-core/src/lib/general/gr_glfsr_source_b.cc index 8fe616044..134f7a21a 100644 --- a/gnuradio-core/src/lib/general/gr_glfsr_source_b.cc +++ b/gnuradio-core/src/lib/general/gr_glfsr_source_b.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 * @@ -33,7 +33,7 @@ gr_glfsr_source_b_sptr gr_make_glfsr_source_b(int degree, bool repeat, int mask, int seed) { - return gr_glfsr_source_b_sptr(new gr_glfsr_source_b(degree, repeat, mask, seed)); + return gnuradio::get_initial_sptr(new gr_glfsr_source_b(degree, repeat, mask, seed)); } gr_glfsr_source_b::gr_glfsr_source_b(int degree, bool repeat, int mask, int seed) diff --git a/gnuradio-core/src/lib/general/gr_glfsr_source_f.cc b/gnuradio-core/src/lib/general/gr_glfsr_source_f.cc index 8ef3a06cf..7ffcfbd2a 100644 --- a/gnuradio-core/src/lib/general/gr_glfsr_source_f.cc +++ b/gnuradio-core/src/lib/general/gr_glfsr_source_f.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 * @@ -33,7 +33,7 @@ gr_glfsr_source_f_sptr gr_make_glfsr_source_f(int degree, bool repeat, int mask, int seed) { - return gr_glfsr_source_f_sptr(new gr_glfsr_source_f(degree, repeat, mask, seed)); + return gnuradio::get_initial_sptr(new gr_glfsr_source_f(degree, repeat, mask, seed)); } gr_glfsr_source_f::gr_glfsr_source_f(int degree, bool repeat, int mask, int seed) diff --git a/gnuradio-core/src/lib/general/gr_interleave.cc b/gnuradio-core/src/lib/general/gr_interleave.cc index 3c3ce8cc9..d210cd5ed 100644 --- a/gnuradio-core/src/lib/general/gr_interleave.cc +++ b/gnuradio-core/src/lib/general/gr_interleave.cc @@ -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 * @@ -32,7 +32,7 @@ gr_interleave_sptr gr_make_interleave (size_t itemsize) { - return gr_interleave_sptr (new gr_interleave (itemsize)); + return gnuradio::get_initial_sptr(new gr_interleave (itemsize)); } gr_interleave::gr_interleave (size_t itemsize) diff --git a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.cc b/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.cc index 74b853207..09aa91f47 100644 --- a/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.cc +++ b/gnuradio-core/src/lib/general/gr_interleaved_short_to_complex.cc @@ -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 * @@ -31,7 +31,7 @@ gr_interleaved_short_to_complex_sptr gr_make_interleaved_short_to_complex () { - return gr_interleaved_short_to_complex_sptr (new gr_interleaved_short_to_complex ()); + return gnuradio::get_initial_sptr(new gr_interleaved_short_to_complex ()); } gr_interleaved_short_to_complex::gr_interleaved_short_to_complex () diff --git a/gnuradio-core/src/lib/general/gr_iqcomp_cc.cc b/gnuradio-core/src/lib/general/gr_iqcomp_cc.cc index e0a2c08ae..16a68337f 100644 --- a/gnuradio-core/src/lib/general/gr_iqcomp_cc.cc +++ b/gnuradio-core/src/lib/general/gr_iqcomp_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_iqcomp_cc_sptr gr_make_iqcomp_cc (float mu) { - return gr_iqcomp_cc_sptr (new gr_iqcomp_cc (mu)); + return gnuradio::get_initial_sptr(new gr_iqcomp_cc (mu)); } gr_iqcomp_cc::gr_iqcomp_cc (float mu) diff --git a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc b/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc index e38240a3f..c07e177fe 100644 --- a/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc +++ b/gnuradio-core/src/lib/general/gr_keep_one_in_n.cc @@ -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 * @@ -31,7 +31,7 @@ gr_keep_one_in_n_sptr gr_make_keep_one_in_n (size_t item_size, int n) { - return gr_keep_one_in_n_sptr (new gr_keep_one_in_n (item_size, n)); + return gnuradio::get_initial_sptr(new gr_keep_one_in_n (item_size, n)); } gr_keep_one_in_n::gr_keep_one_in_n (size_t item_size, int n) diff --git a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.cc b/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.cc index b65e2b78a..e227f8b3e 100644 --- a/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.cc +++ b/gnuradio-core/src/lib/general/gr_lfsr_32k_source_s.cc @@ -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 * @@ -32,7 +32,7 @@ gr_lfsr_32k_source_s_sptr gr_make_lfsr_32k_source_s () { - return gr_lfsr_32k_source_s_sptr (new gr_lfsr_32k_source_s ()); + return gnuradio::get_initial_sptr(new gr_lfsr_32k_source_s ()); } diff --git a/gnuradio-core/src/lib/general/gr_lms_dfe_cc.cc b/gnuradio-core/src/lib/general/gr_lms_dfe_cc.cc index f1eff05cc..8659386d5 100644 --- a/gnuradio-core/src/lib/general/gr_lms_dfe_cc.cc +++ b/gnuradio-core/src/lib/general/gr_lms_dfe_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -67,7 +67,7 @@ gr_lms_dfe_cc_sptr gr_make_lms_dfe_cc (float lambda_ff, float lambda_fb, unsigned int num_fftaps, unsigned int num_fbtaps) { - return gr_lms_dfe_cc_sptr (new gr_lms_dfe_cc (lambda_ff, lambda_fb, + return gnuradio::get_initial_sptr(new gr_lms_dfe_cc (lambda_ff, lambda_fb, num_fftaps, num_fbtaps)); } diff --git a/gnuradio-core/src/lib/general/gr_lms_dfe_ff.cc b/gnuradio-core/src/lib/general/gr_lms_dfe_ff.cc index 2992dbf88..8a5e22c2f 100644 --- a/gnuradio-core/src/lib/general/gr_lms_dfe_ff.cc +++ b/gnuradio-core/src/lib/general/gr_lms_dfe_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -42,7 +42,7 @@ gr_lms_dfe_ff_sptr gr_make_lms_dfe_ff (float lambda_ff, float lambda_fb, unsigned int num_fftaps, unsigned int num_fbtaps) { - return gr_lms_dfe_ff_sptr (new gr_lms_dfe_ff (lambda_ff,lambda_fb,num_fftaps,num_fbtaps)); + return gnuradio::get_initial_sptr(new gr_lms_dfe_ff (lambda_ff,lambda_fb,num_fftaps,num_fbtaps)); } gr_lms_dfe_ff::gr_lms_dfe_ff (float lambda_ff, float lambda_fb , diff --git a/gnuradio-core/src/lib/general/gr_map_bb.cc b/gnuradio-core/src/lib/general/gr_map_bb.cc index b10dfea36..7762c7e35 100644 --- a/gnuradio-core/src/lib/general/gr_map_bb.cc +++ b/gnuradio-core/src/lib/general/gr_map_bb.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2007 Free Software Foundation, Inc. + * Copyright 2006,2007,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_map_bb_sptr gr_make_map_bb (const std::vector<int> &map) { - return gr_map_bb_sptr (new gr_map_bb (map)); + return gnuradio::get_initial_sptr(new gr_map_bb (map)); } gr_map_bb::gr_map_bb (const std::vector<int> &map) diff --git a/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc b/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc index 1efa82703..bc51c6769 100644 --- a/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc +++ b/gnuradio-core/src/lib/general/gr_mpsk_receiver_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005,2006,2007 Free Software Foundation, Inc. + * Copyright 2005,2006,2007,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -46,7 +46,7 @@ gr_make_mpsk_receiver_cc(unsigned int M, float theta, float mu, float gain_mu, float omega, float gain_omega, float omega_rel) { - return gr_mpsk_receiver_cc_sptr (new gr_mpsk_receiver_cc (M, theta, + return gnuradio::get_initial_sptr(new gr_mpsk_receiver_cc (M, theta, alpha, beta, fmin, fmax, mu, gain_mu, diff --git a/gnuradio-core/src/lib/general/gr_nlog10_ff.cc b/gnuradio-core/src/lib/general/gr_nlog10_ff.cc index 8175359b5..15d28d484 100644 --- a/gnuradio-core/src/lib/general/gr_nlog10_ff.cc +++ b/gnuradio-core/src/lib/general/gr_nlog10_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_nlog10_ff_sptr gr_make_nlog10_ff (float n, unsigned vlen, float k) { - return gr_nlog10_ff_sptr(new gr_nlog10_ff(n, vlen, k)); + return gnuradio::get_initial_sptr(new gr_nlog10_ff(n, vlen, k)); } gr_nlog10_ff::gr_nlog10_ff(float n, unsigned vlen, float k) diff --git a/gnuradio-core/src/lib/general/gr_nop.cc b/gnuradio-core/src/lib/general/gr_nop.cc index b8d5cb3ac..e69c8b340 100644 --- a/gnuradio-core/src/lib/general/gr_nop.cc +++ b/gnuradio-core/src/lib/general/gr_nop.cc @@ -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 * @@ -36,7 +36,7 @@ gr_nop::gr_nop (size_t sizeof_stream_item) gr_block_sptr gr_make_nop (size_t sizeof_stream_item) { - return gr_block_sptr (new gr_nop (sizeof_stream_item)); + return gnuradio::get_initial_sptr (new gr_nop (sizeof_stream_item)); } int diff --git a/gnuradio-core/src/lib/general/gr_null_sink.cc b/gnuradio-core/src/lib/general/gr_null_sink.cc index ed9973a3a..0b7f2d9e8 100644 --- a/gnuradio-core/src/lib/general/gr_null_sink.cc +++ b/gnuradio-core/src/lib/general/gr_null_sink.cc @@ -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 * @@ -37,7 +37,7 @@ gr_null_sink::gr_null_sink (size_t sizeof_stream_item) gr_block_sptr gr_make_null_sink (size_t sizeof_stream_item) { - return gr_block_sptr (new gr_null_sink (sizeof_stream_item)); + return gnuradio::get_initial_sptr (new gr_null_sink (sizeof_stream_item)); } int diff --git a/gnuradio-core/src/lib/general/gr_null_source.cc b/gnuradio-core/src/lib/general/gr_null_source.cc index d11976e1b..b65c39035 100644 --- a/gnuradio-core/src/lib/general/gr_null_source.cc +++ b/gnuradio-core/src/lib/general/gr_null_source.cc @@ -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 * @@ -38,7 +38,7 @@ gr_null_source::gr_null_source (size_t sizeof_stream_item) gr_block_sptr gr_make_null_source (size_t sizeof_stream_item) { - return gr_block_sptr (new gr_null_source (sizeof_stream_item)); + return gnuradio::get_initial_sptr (new gr_null_source (sizeof_stream_item)); } int diff --git a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc index a01cf358a..bcb469651 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc +++ b/gnuradio-core/src/lib/general/gr_ofdm_bpsk_demapper.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_ofdm_bpsk_demapper_sptr gr_make_ofdm_bpsk_demapper (unsigned int occupied_carriers) { - return gr_ofdm_bpsk_demapper_sptr (new gr_ofdm_bpsk_demapper (occupied_carriers)); + return gnuradio::get_initial_sptr(new gr_ofdm_bpsk_demapper (occupied_carriers)); } gr_ofdm_bpsk_demapper::gr_ofdm_bpsk_demapper (unsigned occupied_carriers) diff --git a/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc b/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc index 5327c5707..fb40a3035 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc +++ b/gnuradio-core/src/lib/general/gr_ofdm_cyclic_prefixer.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_ofdm_cyclic_prefixer_sptr gr_make_ofdm_cyclic_prefixer (size_t input_size, size_t output_size) { - return gr_ofdm_cyclic_prefixer_sptr (new gr_ofdm_cyclic_prefixer (input_size, output_size)); + return gnuradio::get_initial_sptr(new gr_ofdm_cyclic_prefixer (input_size, output_size)); } gr_ofdm_cyclic_prefixer::gr_ofdm_cyclic_prefixer (size_t input_size, size_t output_size) diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.cc b/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.cc index fd27e6d48..201375597 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.cc +++ b/gnuradio-core/src/lib/general/gr_ofdm_frame_acquisition.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2007,2008 Free Software Foundation, Inc. + * Copyright 2006,2007,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -40,7 +40,7 @@ gr_make_ofdm_frame_acquisition (unsigned int occupied_carriers, unsigned int fft const std::vector<gr_complex> &known_symbol, unsigned int max_fft_shift_len) { - return gr_ofdm_frame_acquisition_sptr (new gr_ofdm_frame_acquisition (occupied_carriers, fft_length, cplen, + return gnuradio::get_initial_sptr(new gr_ofdm_frame_acquisition (occupied_carriers, fft_length, cplen, known_symbol, max_fft_shift_len)); } diff --git a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc index 26a5cf0fe..3457370eb 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc +++ b/gnuradio-core/src/lib/general/gr_ofdm_frame_sink.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008 Free Software Foundation, Inc. + * Copyright 2007,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -184,7 +184,7 @@ gr_make_ofdm_frame_sink(const std::vector<gr_complex> &sym_position, gr_msg_queue_sptr target_queue, unsigned int occupied_carriers, float phase_gain, float freq_gain) { - return gr_ofdm_frame_sink_sptr(new gr_ofdm_frame_sink(sym_position, sym_value_out, + return gnuradio::get_initial_sptr(new gr_ofdm_frame_sink(sym_position, sym_value_out, target_queue, occupied_carriers, phase_gain, freq_gain)); } diff --git a/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.cc b/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.cc index 3706c3672..ed10c94a8 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.cc +++ b/gnuradio-core/src/lib/general/gr_ofdm_insert_preamble.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 * @@ -33,7 +33,7 @@ gr_ofdm_insert_preamble_sptr gr_make_ofdm_insert_preamble(int fft_length, const std::vector<std::vector<gr_complex> > &preamble) { - return gr_ofdm_insert_preamble_sptr(new gr_ofdm_insert_preamble(fft_length, + return gnuradio::get_initial_sptr(new gr_ofdm_insert_preamble(fft_length, preamble)); } diff --git a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc index 02f09f5f2..370b029cd 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc +++ b/gnuradio-core/src/lib/general/gr_ofdm_mapper_bcv.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2007,2008 Free Software Foundation, Inc. + * Copyright 2006,2007,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -34,7 +34,7 @@ gr_ofdm_mapper_bcv_sptr gr_make_ofdm_mapper_bcv (const std::vector<gr_complex> &constellation, unsigned int msgq_limit, unsigned int occupied_carriers, unsigned int fft_length) { - return gr_ofdm_mapper_bcv_sptr (new gr_ofdm_mapper_bcv (constellation, msgq_limit, + return gnuradio::get_initial_sptr(new gr_ofdm_mapper_bcv (constellation, msgq_limit, occupied_carriers, fft_length)); } diff --git a/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc b/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc index 74bd65a50..f9a53c87f 100644 --- a/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc +++ b/gnuradio-core/src/lib/general/gr_ofdm_sampler.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008 Free Software Foundation, Inc. + * Copyright 2007,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -34,7 +34,7 @@ gr_make_ofdm_sampler (unsigned int fft_length, unsigned int symbol_length, unsigned int timeout) { - return gr_ofdm_sampler_sptr (new gr_ofdm_sampler (fft_length, symbol_length, timeout)); + return gnuradio::get_initial_sptr(new gr_ofdm_sampler (fft_length, symbol_length, timeout)); } gr_ofdm_sampler::gr_ofdm_sampler (unsigned int fft_length, @@ -45,6 +45,7 @@ gr_ofdm_sampler::gr_ofdm_sampler (unsigned int fft_length, gr_make_io_signature2 (2, 2, sizeof (gr_complex)*fft_length, sizeof(char)*fft_length)), d_state(STATE_NO_SIG), d_timeout_max(timeout), d_fft_length(fft_length), d_symbol_length(symbol_length) { + set_relative_rate(1.0/(double) fft_length); // buffer allocator hint } void diff --git a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.cc b/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.cc index c4498ed93..a79e34be4 100644 --- a/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.cc +++ b/gnuradio-core/src/lib/general/gr_pa_2x2_phase_combiner.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_pa_2x2_phase_combiner_sptr gr_make_pa_2x2_phase_combiner() { - return gr_pa_2x2_phase_combiner_sptr(new gr_pa_2x2_phase_combiner()); + return gnuradio::get_initial_sptr(new gr_pa_2x2_phase_combiner()); } gr_pa_2x2_phase_combiner::gr_pa_2x2_phase_combiner () diff --git a/gnuradio-core/src/lib/general/gr_packet_sink.cc b/gnuradio-core/src/lib/general/gr_packet_sink.cc index 0979f76d3..d66d96839 100644 --- a/gnuradio-core/src/lib/general/gr_packet_sink.cc +++ b/gnuradio-core/src/lib/general/gr_packet_sink.cc @@ -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 * @@ -77,7 +77,7 @@ gr_packet_sink_sptr gr_make_packet_sink (const std::vector<unsigned char>& sync_vector, gr_msg_queue_sptr target_queue, int threshold) { - return gr_packet_sink_sptr (new gr_packet_sink (sync_vector, target_queue, threshold)); + return gnuradio::get_initial_sptr(new gr_packet_sink (sync_vector, target_queue, threshold)); } diff --git a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.cc b/gnuradio-core/src/lib/general/gr_peak_detector2_fb.cc index 4f927bffe..2b1c5da61 100644 --- a/gnuradio-core/src/lib/general/gr_peak_detector2_fb.cc +++ b/gnuradio-core/src/lib/general/gr_peak_detector2_fb.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 * @@ -32,7 +32,7 @@ gr_peak_detector2_fb_sptr gr_make_peak_detector2_fb (float threshold_factor_rise, int look_ahead, float alpha) { - return gr_peak_detector2_fb_sptr (new gr_peak_detector2_fb (threshold_factor_rise, + return gnuradio::get_initial_sptr(new gr_peak_detector2_fb (threshold_factor_rise, look_ahead, alpha)); } diff --git a/gnuradio-core/src/lib/general/gr_phase_modulator_fc.cc b/gnuradio-core/src/lib/general/gr_phase_modulator_fc.cc index 9ee8d3f4d..c1a2e7da3 100644 --- a/gnuradio-core/src/lib/general/gr_phase_modulator_fc.cc +++ b/gnuradio-core/src/lib/general/gr_phase_modulator_fc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005,2006 Free Software Foundation, Inc. + * Copyright 2005,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ gr_phase_modulator_fc_sptr gr_make_phase_modulator_fc (double sensitivity) { - return gr_phase_modulator_fc_sptr (new gr_phase_modulator_fc (sensitivity)); + return gnuradio::get_initial_sptr(new gr_phase_modulator_fc (sensitivity)); } gr_phase_modulator_fc::gr_phase_modulator_fc (double sensitivity) diff --git a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.cc b/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.cc index 5f0e9a692..19ab316a1 100644 --- a/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.cc +++ b/gnuradio-core/src/lib/general/gr_pll_carriertracking_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -35,7 +35,7 @@ gr_pll_carriertracking_cc_sptr gr_make_pll_carriertracking_cc (float alpha, float beta, float max_freq, float min_freq) { - return gr_pll_carriertracking_cc_sptr (new gr_pll_carriertracking_cc (alpha, beta, max_freq, min_freq)); + return gnuradio::get_initial_sptr(new gr_pll_carriertracking_cc (alpha, beta, max_freq, min_freq)); } gr_pll_carriertracking_cc::gr_pll_carriertracking_cc (float alpha, float beta, float max_freq, float min_freq) diff --git a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.cc b/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.cc index c9fd9a71e..1f17f2afc 100644 --- a/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.cc +++ b/gnuradio-core/src/lib/general/gr_pll_freqdet_cf.cc @@ -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 * @@ -36,7 +36,7 @@ gr_pll_freqdet_cf_sptr gr_make_pll_freqdet_cf (float alpha, float beta, float max_freq, float min_freq) { - return gr_pll_freqdet_cf_sptr (new gr_pll_freqdet_cf (alpha, beta, max_freq, min_freq)); + return gnuradio::get_initial_sptr(new gr_pll_freqdet_cf (alpha, beta, max_freq, min_freq)); } gr_pll_freqdet_cf::gr_pll_freqdet_cf (float alpha, float beta, float max_freq, float min_freq) diff --git a/gnuradio-core/src/lib/general/gr_pll_refout_cc.cc b/gnuradio-core/src/lib/general/gr_pll_refout_cc.cc index 5df822d37..8a7fbf88b 100644 --- a/gnuradio-core/src/lib/general/gr_pll_refout_cc.cc +++ b/gnuradio-core/src/lib/general/gr_pll_refout_cc.cc @@ -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 * @@ -37,7 +37,7 @@ gr_pll_refout_cc_sptr gr_make_pll_refout_cc (float alpha, float beta, float max_freq, float min_freq) { - return gr_pll_refout_cc_sptr (new gr_pll_refout_cc (alpha, beta, max_freq, min_freq)); + return gnuradio::get_initial_sptr(new gr_pll_refout_cc (alpha, beta, max_freq, min_freq)); } gr_pll_refout_cc::gr_pll_refout_cc (float alpha, float beta, float max_freq, float min_freq) diff --git a/gnuradio-core/src/lib/general/gr_pn_correlator_cc.cc b/gnuradio-core/src/lib/general/gr_pn_correlator_cc.cc index 2614c3a2d..37e7b803c 100644 --- a/gnuradio-core/src/lib/general/gr_pn_correlator_cc.cc +++ b/gnuradio-core/src/lib/general/gr_pn_correlator_cc.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 * @@ -30,7 +30,7 @@ gr_pn_correlator_cc_sptr gr_make_pn_correlator_cc(int degree, int mask, int seed) { - return gr_pn_correlator_cc_sptr (new gr_pn_correlator_cc(degree, mask, seed)); + return gnuradio::get_initial_sptr(new gr_pn_correlator_cc(degree, mask, seed)); } gr_pn_correlator_cc::gr_pn_correlator_cc(int degree, int mask, int seed) diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.cc b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.cc index 8af11ad22..c00eb5cdf 100644 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.cc +++ b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_c.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_probe_avg_mag_sqrd_c_sptr gr_make_probe_avg_mag_sqrd_c(double threshold_db, double alpha) { - return gr_probe_avg_mag_sqrd_c_sptr(new gr_probe_avg_mag_sqrd_c(threshold_db, alpha)); + return gnuradio::get_initial_sptr(new gr_probe_avg_mag_sqrd_c(threshold_db, alpha)); } gr_probe_avg_mag_sqrd_c::gr_probe_avg_mag_sqrd_c (double threshold_db, double alpha) diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.cc b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.cc index 8b1c7cc50..5350028a7 100644 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.cc +++ b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_cf.cc @@ -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 * @@ -30,7 +30,7 @@ gr_probe_avg_mag_sqrd_cf_sptr gr_make_probe_avg_mag_sqrd_cf(double threshold_db, double alpha) { - return gr_probe_avg_mag_sqrd_cf_sptr(new gr_probe_avg_mag_sqrd_cf(threshold_db, alpha)); + return gnuradio::get_initial_sptr(new gr_probe_avg_mag_sqrd_cf(threshold_db, alpha)); } gr_probe_avg_mag_sqrd_cf::gr_probe_avg_mag_sqrd_cf (double threshold_db, double alpha) diff --git a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.cc b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.cc index c39207d2c..d3b0e2d37 100644 --- a/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.cc +++ b/gnuradio-core/src/lib/general/gr_probe_avg_mag_sqrd_f.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_probe_avg_mag_sqrd_f_sptr gr_make_probe_avg_mag_sqrd_f(double threshold_db, double alpha) { - return gr_probe_avg_mag_sqrd_f_sptr(new gr_probe_avg_mag_sqrd_f(threshold_db, alpha)); + return gnuradio::get_initial_sptr(new gr_probe_avg_mag_sqrd_f(threshold_db, alpha)); } gr_probe_avg_mag_sqrd_f::gr_probe_avg_mag_sqrd_f (double threshold_db, double alpha) diff --git a/gnuradio-core/src/lib/general/gr_probe_density_b.cc b/gnuradio-core/src/lib/general/gr_probe_density_b.cc index dae4eec74..70b03e881 100644 --- a/gnuradio-core/src/lib/general/gr_probe_density_b.cc +++ b/gnuradio-core/src/lib/general/gr_probe_density_b.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * 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 @@ -30,7 +30,7 @@ gr_probe_density_b_sptr gr_make_probe_density_b(double alpha) { - return gr_probe_density_b_sptr(new gr_probe_density_b(alpha)); + return gnuradio::get_initial_sptr(new gr_probe_density_b(alpha)); } gr_probe_density_b::gr_probe_density_b(double alpha) diff --git a/gnuradio-core/src/lib/general/gr_probe_mpsk_snr_c.cc b/gnuradio-core/src/lib/general/gr_probe_mpsk_snr_c.cc index a0bb99ce1..fed9ad66e 100644 --- a/gnuradio-core/src/lib/general/gr_probe_mpsk_snr_c.cc +++ b/gnuradio-core/src/lib/general/gr_probe_mpsk_snr_c.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_probe_mpsk_snr_c_sptr gr_make_probe_mpsk_snr_c(double alpha) { - return gr_probe_mpsk_snr_c_sptr(new gr_probe_mpsk_snr_c(alpha)); + return gnuradio::get_initial_sptr(new gr_probe_mpsk_snr_c(alpha)); } gr_probe_mpsk_snr_c::gr_probe_mpsk_snr_c(double alpha) diff --git a/gnuradio-core/src/lib/general/gr_probe_signal_f.cc b/gnuradio-core/src/lib/general/gr_probe_signal_f.cc index b67836682..ee1a18e89 100644 --- a/gnuradio-core/src/lib/general/gr_probe_signal_f.cc +++ b/gnuradio-core/src/lib/general/gr_probe_signal_f.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -29,7 +29,7 @@ gr_probe_signal_f_sptr gr_make_probe_signal_f() { - return gr_probe_signal_f_sptr(new gr_probe_signal_f()); + return gnuradio::get_initial_sptr(new gr_probe_signal_f()); } gr_probe_signal_f::gr_probe_signal_f () diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.cc b/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.cc index 1604972fd..d2fee1a57 100644 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.cc +++ b/gnuradio-core/src/lib/general/gr_pwr_squelch_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -29,7 +29,7 @@ gr_pwr_squelch_cc_sptr gr_make_pwr_squelch_cc(double threshold, double alpha, int ramp, bool gate) { - return gr_pwr_squelch_cc_sptr(new gr_pwr_squelch_cc(threshold, alpha, ramp, gate)); + return gnuradio::get_initial_sptr(new gr_pwr_squelch_cc(threshold, alpha, ramp, gate)); } gr_pwr_squelch_cc::gr_pwr_squelch_cc(double threshold, double alpha, int ramp, bool gate) : diff --git a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.cc b/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.cc index 976b7a105..a689c407c 100644 --- a/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.cc +++ b/gnuradio-core/src/lib/general/gr_pwr_squelch_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -29,7 +29,7 @@ gr_pwr_squelch_ff_sptr gr_make_pwr_squelch_ff(double threshold, double alpha, int ramp, bool gate) { - return gr_pwr_squelch_ff_sptr(new gr_pwr_squelch_ff(threshold, alpha, ramp, gate)); + return gnuradio::get_initial_sptr(new gr_pwr_squelch_ff(threshold, alpha, ramp, gate)); } gr_pwr_squelch_ff::gr_pwr_squelch_ff(double threshold, double alpha, int ramp, bool gate) : diff --git a/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.cc b/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.cc index bae5a3857..8e59fbd71 100644 --- a/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.cc +++ b/gnuradio-core/src/lib/general/gr_quadrature_demod_cf.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2005 Free Software Foundation, Inc. + * Copyright 2004,2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -40,7 +40,7 @@ gr_quadrature_demod_cf::gr_quadrature_demod_cf (float gain) gr_quadrature_demod_cf_sptr gr_make_quadrature_demod_cf (float gain) { - return gr_quadrature_demod_cf_sptr (new gr_quadrature_demod_cf (gain)); + return gnuradio::get_initial_sptr(new gr_quadrature_demod_cf (gain)); } int diff --git a/gnuradio-core/src/lib/general/gr_rail_ff.cc b/gnuradio-core/src/lib/general/gr_rail_ff.cc index 9fd3af8df..260897199 100644 --- a/gnuradio-core/src/lib/general/gr_rail_ff.cc +++ b/gnuradio-core/src/lib/general/gr_rail_ff.cc @@ -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 * @@ -30,7 +30,7 @@ gr_rail_ff_sptr gr_make_rail_ff(float lo, float hi) { - return gr_rail_ff_sptr(new gr_rail_ff(lo, hi)); + return gnuradio::get_initial_sptr(new gr_rail_ff(lo, hi)); } gr_rail_ff::gr_rail_ff(float lo, float hi) diff --git a/gnuradio-core/src/lib/general/gr_regenerate_bb.cc b/gnuradio-core/src/lib/general/gr_regenerate_bb.cc index 183675520..3bb8be105 100644 --- a/gnuradio-core/src/lib/general/gr_regenerate_bb.cc +++ b/gnuradio-core/src/lib/general/gr_regenerate_bb.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 * @@ -30,7 +30,7 @@ gr_regenerate_bb_sptr gr_make_regenerate_bb (int period, unsigned int max_regen) { - return gr_regenerate_bb_sptr (new gr_regenerate_bb (period, max_regen)); + return gnuradio::get_initial_sptr(new gr_regenerate_bb (period, max_regen)); } gr_regenerate_bb::gr_regenerate_bb (int period, unsigned int max_regen) diff --git a/gnuradio-core/src/lib/general/gr_repeat.cc b/gnuradio-core/src/lib/general/gr_repeat.cc index 70bb44e5a..43ad50f52 100644 --- a/gnuradio-core/src/lib/general/gr_repeat.cc +++ b/gnuradio-core/src/lib/general/gr_repeat.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_repeat_sptr gr_make_repeat(size_t itemsize, int interp) { - return gr_repeat_sptr(new gr_repeat(itemsize, interp)); + return gnuradio::get_initial_sptr(new gr_repeat(itemsize, interp)); } gr_repeat::gr_repeat(size_t itemsize, int interp) diff --git a/gnuradio-core/src/lib/general/gr_rms_cf.cc b/gnuradio-core/src/lib/general/gr_rms_cf.cc index eab937e97..a7b5d99f1 100644 --- a/gnuradio-core/src/lib/general/gr_rms_cf.cc +++ b/gnuradio-core/src/lib/general/gr_rms_cf.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_rms_cf_sptr gr_make_rms_cf(double alpha) { - return gr_rms_cf_sptr(new gr_rms_cf(alpha)); + return gnuradio::get_initial_sptr(new gr_rms_cf(alpha)); } gr_rms_cf::gr_rms_cf (double alpha) diff --git a/gnuradio-core/src/lib/general/gr_rms_ff.cc b/gnuradio-core/src/lib/general/gr_rms_ff.cc index 604cb3c9b..1ff4379f6 100644 --- a/gnuradio-core/src/lib/general/gr_rms_ff.cc +++ b/gnuradio-core/src/lib/general/gr_rms_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_rms_ff_sptr gr_make_rms_ff(double alpha) { - return gr_rms_ff_sptr(new gr_rms_ff(alpha)); + return gnuradio::get_initial_sptr(new gr_rms_ff(alpha)); } gr_rms_ff::gr_rms_ff (double alpha) diff --git a/gnuradio-core/src/lib/general/gr_scrambler_bb.cc b/gnuradio-core/src/lib/general/gr_scrambler_bb.cc index 42f70901b..59bd1ca41 100644 --- a/gnuradio-core/src/lib/general/gr_scrambler_bb.cc +++ b/gnuradio-core/src/lib/general/gr_scrambler_bb.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_scrambler_bb_sptr gr_make_scrambler_bb(int mask, int seed, int len) { - return gr_scrambler_bb_sptr(new gr_scrambler_bb(mask, seed, len)); + return gnuradio::get_initial_sptr(new gr_scrambler_bb(mask, seed, len)); } gr_scrambler_bb::gr_scrambler_bb(int mask, int seed, int len) diff --git a/gnuradio-core/src/lib/general/gr_short_to_float.cc b/gnuradio-core/src/lib/general/gr_short_to_float.cc index 09dad2ef2..7b80953ac 100644 --- a/gnuradio-core/src/lib/general/gr_short_to_float.cc +++ b/gnuradio-core/src/lib/general/gr_short_to_float.cc @@ -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 * @@ -31,7 +31,7 @@ gr_short_to_float_sptr gr_make_short_to_float () { - return gr_short_to_float_sptr (new gr_short_to_float ()); + return gnuradio::get_initial_sptr(new gr_short_to_float ()); } gr_short_to_float::gr_short_to_float () diff --git a/gnuradio-core/src/lib/general/gr_simple_correlator.cc b/gnuradio-core/src/lib/general/gr_simple_correlator.cc index ebfbfa72e..01c007122 100644 --- a/gnuradio-core/src/lib/general/gr_simple_correlator.cc +++ b/gnuradio-core/src/lib/general/gr_simple_correlator.cc @@ -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 * @@ -39,7 +39,7 @@ static const int THRESHOLD = 3; gr_simple_correlator_sptr gr_make_simple_correlator (int payload_bytesize) { - return gr_simple_correlator_sptr (new gr_simple_correlator (payload_bytesize)); + return gnuradio::get_initial_sptr(new gr_simple_correlator (payload_bytesize)); } gr_simple_correlator::gr_simple_correlator (int payload_bytesize) diff --git a/gnuradio-core/src/lib/general/gr_simple_framer.cc b/gnuradio-core/src/lib/general/gr_simple_framer.cc index d2de09546..2a574a74e 100644 --- a/gnuradio-core/src/lib/general/gr_simple_framer.cc +++ b/gnuradio-core/src/lib/general/gr_simple_framer.cc @@ -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 * @@ -35,7 +35,7 @@ gr_simple_framer_sptr gr_make_simple_framer (int payload_bytesize) { - return gr_simple_framer_sptr (new gr_simple_framer (payload_bytesize)); + return gnuradio::get_initial_sptr(new gr_simple_framer (payload_bytesize)); } gr_simple_framer::gr_simple_framer (int payload_bytesize) diff --git a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.cc b/gnuradio-core/src/lib/general/gr_simple_squelch_cc.cc index 3900671a6..cdea8055b 100644 --- a/gnuradio-core/src/lib/general/gr_simple_squelch_cc.cc +++ b/gnuradio-core/src/lib/general/gr_simple_squelch_cc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_simple_squelch_cc_sptr gr_make_simple_squelch_cc(double threshold_db, double alpha) { - return gr_simple_squelch_cc_sptr(new gr_simple_squelch_cc(threshold_db, alpha)); + return gnuradio::get_initial_sptr(new gr_simple_squelch_cc(threshold_db, alpha)); } gr_simple_squelch_cc::gr_simple_squelch_cc (double threshold_db, double alpha) diff --git a/gnuradio-core/src/lib/general/gr_skiphead.cc b/gnuradio-core/src/lib/general/gr_skiphead.cc index 45e3d5cb2..ea7e9405f 100644 --- a/gnuradio-core/src/lib/general/gr_skiphead.cc +++ b/gnuradio-core/src/lib/general/gr_skiphead.cc @@ -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 * @@ -38,7 +38,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) { - return gr_skiphead_sptr (new gr_skiphead (itemsize, nitems_to_skip)); + return gnuradio::get_initial_sptr(new gr_skiphead (itemsize, nitems_to_skip)); } int diff --git a/gnuradio-core/src/lib/general/gr_squash_ff.cc b/gnuradio-core/src/lib/general/gr_squash_ff.cc index 05ad4a7eb..479204fdb 100644 --- a/gnuradio-core/src/lib/general/gr_squash_ff.cc +++ b/gnuradio-core/src/lib/general/gr_squash_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -35,7 +35,7 @@ gr_squash_ff_sptr gr_make_squash_ff(const std::vector<float> &igrid, const std::vector<float> &ogrid) { - return gr_squash_ff_sptr(new gr_squash_ff(igrid, ogrid)); + return gnuradio::get_initial_sptr(new gr_squash_ff(igrid, ogrid)); } gr_squash_ff::gr_squash_ff(const std::vector<float> &igrid, diff --git a/gnuradio-core/src/lib/general/gr_stream_mux.cc b/gnuradio-core/src/lib/general/gr_stream_mux.cc index 06556b583..7ef2bb3c7 100644 --- a/gnuradio-core/src/lib/general/gr_stream_mux.cc +++ b/gnuradio-core/src/lib/general/gr_stream_mux.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -34,7 +34,7 @@ gr_stream_mux_sptr gr_make_stream_mux (size_t itemsize, const std::vector<int> &lengths) { - return gr_stream_mux_sptr (new gr_stream_mux (itemsize, lengths)); + return gnuradio::get_initial_sptr(new gr_stream_mux (itemsize, lengths)); } gr_stream_mux::gr_stream_mux (size_t itemsize, const std::vector<int> &lengths) diff --git a/gnuradio-core/src/lib/general/gr_stream_to_streams.cc b/gnuradio-core/src/lib/general/gr_stream_to_streams.cc index b38a8d4d8..3d34dbc43 100644 --- a/gnuradio-core/src/lib/general/gr_stream_to_streams.cc +++ b/gnuradio-core/src/lib/general/gr_stream_to_streams.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_stream_to_streams_sptr gr_make_stream_to_streams (size_t item_size, size_t nstreams) { - return gr_stream_to_streams_sptr (new gr_stream_to_streams (item_size, nstreams)); + return gnuradio::get_initial_sptr(new gr_stream_to_streams (item_size, nstreams)); } gr_stream_to_streams::gr_stream_to_streams (size_t item_size, size_t nstreams) diff --git a/gnuradio-core/src/lib/general/gr_stream_to_vector.cc b/gnuradio-core/src/lib/general/gr_stream_to_vector.cc index fd233adca..f218601d7 100644 --- a/gnuradio-core/src/lib/general/gr_stream_to_vector.cc +++ b/gnuradio-core/src/lib/general/gr_stream_to_vector.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2005 Free Software Foundation, Inc. + * Copyright 2004,2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_stream_to_vector_sptr gr_make_stream_to_vector (size_t item_size, size_t nitems_per_block) { - return gr_stream_to_vector_sptr (new gr_stream_to_vector (item_size, nitems_per_block)); + return gnuradio::get_initial_sptr(new gr_stream_to_vector (item_size, nitems_per_block)); } gr_stream_to_vector::gr_stream_to_vector (size_t item_size, size_t nitems_per_block) diff --git a/gnuradio-core/src/lib/general/gr_streams_to_stream.cc b/gnuradio-core/src/lib/general/gr_streams_to_stream.cc index 6f6b49a82..ce4101089 100644 --- a/gnuradio-core/src/lib/general/gr_streams_to_stream.cc +++ b/gnuradio-core/src/lib/general/gr_streams_to_stream.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_streams_to_stream_sptr gr_make_streams_to_stream (size_t item_size, size_t nstreams) { - return gr_streams_to_stream_sptr (new gr_streams_to_stream (item_size, nstreams)); + return gnuradio::get_initial_sptr(new gr_streams_to_stream (item_size, nstreams)); } gr_streams_to_stream::gr_streams_to_stream (size_t item_size, size_t nstreams) diff --git a/gnuradio-core/src/lib/general/gr_streams_to_vector.cc b/gnuradio-core/src/lib/general/gr_streams_to_vector.cc index f3ee2c49a..e04fa4dcb 100644 --- a/gnuradio-core/src/lib/general/gr_streams_to_vector.cc +++ b/gnuradio-core/src/lib/general/gr_streams_to_vector.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2005 Free Software Foundation, Inc. + * Copyright 2004,2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_streams_to_vector_sptr gr_make_streams_to_vector (size_t item_size, size_t nstreams) { - return gr_streams_to_vector_sptr (new gr_streams_to_vector (item_size, nstreams)); + return gnuradio::get_initial_sptr(new gr_streams_to_vector (item_size, nstreams)); } gr_streams_to_vector::gr_streams_to_vector (size_t item_size, size_t nstreams) diff --git a/gnuradio-core/src/lib/general/gr_stretch_ff.cc b/gnuradio-core/src/lib/general/gr_stretch_ff.cc index f1822dcb8..c6395798a 100644 --- a/gnuradio-core/src/lib/general/gr_stretch_ff.cc +++ b/gnuradio-core/src/lib/general/gr_stretch_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ gr_stretch_ff_sptr gr_make_stretch_ff(float lo, size_t vlen) { - return gr_stretch_ff_sptr(new gr_stretch_ff(lo, vlen)); + return gnuradio::get_initial_sptr(new gr_stretch_ff(lo, vlen)); } gr_stretch_ff::gr_stretch_ff(float lo, size_t vlen) diff --git a/gnuradio-core/src/lib/general/gr_test.cc b/gnuradio-core/src/lib/general/gr_test.cc index a04554ec4..077b39707 100644 --- a/gnuradio-core/src/lib/general/gr_test.cc +++ b/gnuradio-core/src/lib/general/gr_test.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2008 Free Software Foundation, Inc. + * Copyright 2006,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -36,7 +36,7 @@ gr_test_sptr gr_make_test (const std::string &name, unsigned int history,unsigned int output_multiple,double relative_rate, bool fixed_rate,gr_consume_type_t cons_type, gr_produce_type_t prod_type) { - return gr_test_sptr (new gr_test (name, min_inputs,max_inputs,sizeof_input_item, + return gnuradio::get_initial_sptr(new gr_test (name, min_inputs,max_inputs,sizeof_input_item, min_outputs,max_outputs,sizeof_output_item, history,output_multiple,relative_rate,fixed_rate,cons_type, prod_type)); } diff --git a/gnuradio-core/src/lib/general/gr_threshold_ff.cc b/gnuradio-core/src/lib/general/gr_threshold_ff.cc index 9deb3e461..622fe1b45 100644 --- a/gnuradio-core/src/lib/general/gr_threshold_ff.cc +++ b/gnuradio-core/src/lib/general/gr_threshold_ff.cc @@ -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 * @@ -32,7 +32,7 @@ gr_threshold_ff_sptr gr_make_threshold_ff (float lo, float hi, float initial_state) { - return gr_threshold_ff_sptr (new gr_threshold_ff (lo, hi, initial_state)); + return gnuradio::get_initial_sptr(new gr_threshold_ff (lo, hi, initial_state)); } gr_threshold_ff::gr_threshold_ff (float lo, float hi, float initial_state) diff --git a/gnuradio-core/src/lib/general/gr_throttle.cc b/gnuradio-core/src/lib/general/gr_throttle.cc index 88219c1c8..3189e01c0 100644 --- a/gnuradio-core/src/lib/general/gr_throttle.cc +++ b/gnuradio-core/src/lib/general/gr_throttle.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -57,7 +57,7 @@ gr_nanosleep(struct timespec *ts) gr_throttle_sptr gr_make_throttle(size_t itemsize, double samples_per_sec) { - return gr_throttle_sptr(new gr_throttle(itemsize, samples_per_sec)); + return gnuradio::get_initial_sptr(new gr_throttle(itemsize, samples_per_sec)); } gr_throttle::gr_throttle(size_t itemsize, double samples_per_sec) diff --git a/gnuradio-core/src/lib/general/gr_uchar_to_float.cc b/gnuradio-core/src/lib/general/gr_uchar_to_float.cc index 305052942..83616b428 100644 --- a/gnuradio-core/src/lib/general/gr_uchar_to_float.cc +++ b/gnuradio-core/src/lib/general/gr_uchar_to_float.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_uchar_to_float_sptr gr_make_uchar_to_float () { - return gr_uchar_to_float_sptr (new gr_uchar_to_float ()); + return gnuradio::get_initial_sptr(new gr_uchar_to_float ()); } gr_uchar_to_float::gr_uchar_to_float () diff --git a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.cc b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.cc index 7c5fdb1d6..e33c3da9a 100644 --- a/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.cc +++ b/gnuradio-core/src/lib/general/gr_unpack_k_bits_bb.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_unpack_k_bits_bb_sptr gr_make_unpack_k_bits_bb (unsigned k) { - return gr_unpack_k_bits_bb_sptr (new gr_unpack_k_bits_bb (k)); + return gnuradio::get_initial_sptr(new gr_unpack_k_bits_bb (k)); } diff --git a/gnuradio-core/src/lib/general/gr_vco_f.cc b/gnuradio-core/src/lib/general/gr_vco_f.cc index 342a880e4..43a686327 100644 --- a/gnuradio-core/src/lib/general/gr_vco_f.cc +++ b/gnuradio-core/src/lib/general/gr_vco_f.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_vco_f_sptr gr_make_vco_f(double sampling_rate, double sensitivity, double amplitude) { - return gr_vco_f_sptr(new gr_vco_f(sampling_rate, sensitivity, amplitude)); + return gnuradio::get_initial_sptr(new gr_vco_f(sampling_rate, sensitivity, amplitude)); } diff --git a/gnuradio-core/src/lib/general/gr_vector_to_stream.cc b/gnuradio-core/src/lib/general/gr_vector_to_stream.cc index 149bc0d5b..0a0788de6 100644 --- a/gnuradio-core/src/lib/general/gr_vector_to_stream.cc +++ b/gnuradio-core/src/lib/general/gr_vector_to_stream.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_vector_to_stream_sptr gr_make_vector_to_stream (size_t item_size, size_t nitems_per_block) { - return gr_vector_to_stream_sptr (new gr_vector_to_stream (item_size, nitems_per_block)); + return gnuradio::get_initial_sptr(new gr_vector_to_stream (item_size, nitems_per_block)); } gr_vector_to_stream::gr_vector_to_stream (size_t item_size, size_t nitems_per_block) diff --git a/gnuradio-core/src/lib/general/gr_vector_to_streams.cc b/gnuradio-core/src/lib/general/gr_vector_to_streams.cc index 19f15b170..cc3264152 100644 --- a/gnuradio-core/src/lib/general/gr_vector_to_streams.cc +++ b/gnuradio-core/src/lib/general/gr_vector_to_streams.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2005 Free Software Foundation, Inc. + * Copyright 2004,2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ gr_vector_to_streams_sptr gr_make_vector_to_streams (size_t item_size, size_t nstreams) { - return gr_vector_to_streams_sptr (new gr_vector_to_streams (item_size, nstreams)); + return gnuradio::get_initial_sptr(new gr_vector_to_streams (item_size, nstreams)); } gr_vector_to_streams::gr_vector_to_streams (size_t item_size, size_t nstreams) diff --git a/gnuradio-core/src/lib/general/gr_wavelet_ff.cc b/gnuradio-core/src/lib/general/gr_wavelet_ff.cc index 6cbfa2381..f77c96e99 100644 --- a/gnuradio-core/src/lib/general/gr_wavelet_ff.cc +++ b/gnuradio-core/src/lib/general/gr_wavelet_ff.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -38,7 +38,7 @@ gr_make_wavelet_ff(int size, int order, bool forward) { - return gr_wavelet_ff_sptr(new gr_wavelet_ff(size, + return gnuradio::get_initial_sptr(new gr_wavelet_ff(size, order, forward)); } diff --git a/gnuradio-core/src/lib/general/gr_wvps_ff.cc b/gnuradio-core/src/lib/general/gr_wvps_ff.cc index f814ba8fc..8a8dc56ac 100644 --- a/gnuradio-core/src/lib/general/gr_wvps_ff.cc +++ b/gnuradio-core/src/lib/general/gr_wvps_ff.cc @@ -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 * @@ -39,7 +39,7 @@ ceil_log2(int k) gr_wvps_ff_sptr gr_make_wvps_ff(int ilen) { - return gr_wvps_ff_sptr(new gr_wvps_ff(ilen)); + return gnuradio::get_initial_sptr(new gr_wvps_ff(ilen)); } gr_wvps_ff::gr_wvps_ff(int ilen) diff --git a/gnuradio-core/src/lib/general/gri_agc2_cc.i b/gnuradio-core/src/lib/general/gri_agc2_cc.i index e7d6da97f..0f97f1d8e 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 3825ce225..d04b638a6 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 2e44c5ea7..58a25325a 100644 --- a/gnuradio-core/src/lib/gengen/gr_add_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_add_XX.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004, 2009 Free Software Foundation, Inc. + * Copyright 2004, 2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen) { - return @SPTR_NAME@ (new @NAME@ (vlen)); + return gnuradio::get_initial_sptr (new @NAME@ (vlen)); } @NAME@::@NAME@ (size_t vlen) diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_add_const_XX.cc.t index 3df3ea9c6..0d3034be7 100644 --- a/gnuradio-core/src/lib/gengen/gr_add_const_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_add_const_XX.cc.t @@ -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 * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k) { - return @SPTR_NAME@ (new @NAME@ (k)); + return gnuradio::get_initial_sptr (new @NAME@ (k)); } @NAME@::@NAME@ (@O_TYPE@ k) diff --git a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.cc.t b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.cc.t index 0e6588dc0..2a0a3ba3f 100755 --- a/gnuradio-core/src/lib/gengen/gr_add_const_vXX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_add_const_vXX.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> k) { - return @SPTR_NAME@ (new @NAME@ (k)); + return gnuradio::get_initial_sptr (new @NAME@ (k)); } @NAME@::@NAME@ (const std::vector<@I_TYPE@> k) diff --git a/gnuradio-core/src/lib/gengen/gr_and_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_and_XX.cc.t index cef21d333..150ef7f0d 100644 --- a/gnuradio-core/src/lib/gengen/gr_and_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_and_XX.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008 Free Software Foundation, Inc. + * Copyright 2004,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ () { - return @SPTR_NAME@ (new @NAME@ ()); + return gnuradio::get_initial_sptr (new @NAME@ ()); } @NAME@::@NAME@ () diff --git a/gnuradio-core/src/lib/gengen/gr_and_const_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_and_const_XX.cc.t index ec725b23d..bd48788e6 100644 --- a/gnuradio-core/src/lib/gengen/gr_and_const_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_and_const_XX.cc.t @@ -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 * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (@I_TYPE@ k) { - return @SPTR_NAME@ (new @NAME@ (k)); + return gnuradio::get_initial_sptr (new @NAME@ (k)); }; @NAME@::@NAME@ (@I_TYPE@ k) diff --git a/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.cc.t index ab61fb08d..635d991ef 100644 --- a/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_chunks_to_symbols_XX.cc.t @@ -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 * @@ -35,7 +35,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D) { - return @SPTR_NAME@ (new @NAME@ (symbol_table,D)); + return gnuradio::get_initial_sptr (new @NAME@ (symbol_table,D)); } @NAME@::@NAME@ (const std::vector<@O_TYPE@> &symbol_table, const int D) 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 2db490f13..1200145fa 100644 --- a/gnuradio-core/src/lib/gengen/gr_divide_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_divide_XX.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004, 2009 Free Software Foundation, Inc. + * Copyright 2004, 2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen) { - return @SPTR_NAME@ (new @NAME@ (vlen)); + return gnuradio::get_initial_sptr (new @NAME@ (vlen)); } @NAME@::@NAME@ (size_t vlen) diff --git a/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t index 0a62554bd..f6e38848c 100644 --- a/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_integrate_XX.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (int decim) { - return @SPTR_NAME@ (new @NAME@ (decim)); + return gnuradio::get_initial_sptr (new @NAME@ (decim)); } @NAME@::@NAME@ (int decim) diff --git a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t index 33a0acf9c..8d2370d3b 100644 --- a/gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_moving_average_XX.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (int length, @O_TYPE@ scale, int max_iter) { - return @SPTR_NAME@ (new @NAME@ (length, scale, max_iter)); + return gnuradio::get_initial_sptr (new @NAME@ (length, scale, max_iter)); } @NAME@::@NAME@ (int length, @O_TYPE@ scale, int max_iter) 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 000c5e0bd..13ec0c8b3 100644 --- a/gnuradio-core/src/lib/gengen/gr_multiply_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_multiply_XX.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004, 2009 Free Software Foundation, Inc. + * Copyright 2004, 2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen) { - return @SPTR_NAME@ (new @NAME@ (vlen)); + return gnuradio::get_initial_sptr (new @NAME@ (vlen)); } @NAME@::@NAME@ (size_t vlen) diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.cc.t index 715782dd1..09e658e90 100644 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_multiply_const_XX.cc.t @@ -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 * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (@O_TYPE@ k) { - return @SPTR_NAME@ (new @NAME@ (k)); + return gnuradio::get_initial_sptr (new @NAME@ (k)); } @NAME@::@NAME@ (@O_TYPE@ k) diff --git a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.cc.t b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.cc.t index 5b92ea8a1..8286453f1 100755 --- a/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_multiply_const_vXX.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (const std::vector<@I_TYPE@> k) { - return @SPTR_NAME@ (new @NAME@ (k)); + return gnuradio::get_initial_sptr (new @NAME@ (k)); } @NAME@::@NAME@ (const std::vector<@I_TYPE@> k) diff --git a/gnuradio-core/src/lib/gengen/gr_mute_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_mute_XX.cc.t index ee49d97b4..62a8e63da 100644 --- a/gnuradio-core/src/lib/gengen/gr_mute_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_mute_XX.cc.t @@ -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 * @@ -34,7 +34,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (bool mute) { - return @SPTR_NAME@ (new @NAME@ (mute)); + return gnuradio::get_initial_sptr (new @NAME@ (mute)); } @NAME@::@NAME@ (bool mute) diff --git a/gnuradio-core/src/lib/gengen/gr_noise_source_X.cc.t b/gnuradio-core/src/lib/gengen/gr_noise_source_X.cc.t index 83be9aa18..35f5fabd9 100644 --- a/gnuradio-core/src/lib/gengen/gr_noise_source_X.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_noise_source_X.cc.t @@ -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 * @@ -33,7 +33,7 @@ @NAME@_sptr gr_make_@BASE_NAME@ (gr_noise_type_t type, float ampl, long seed) { - return @NAME@_sptr (new @NAME@ (type, ampl, seed)); + return gnuradio::get_initial_sptr(new @NAME@ (type, ampl, seed)); } diff --git a/gnuradio-core/src/lib/gengen/gr_not_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_not_XX.cc.t index 272987411..432938e67 100644 --- a/gnuradio-core/src/lib/gengen/gr_not_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_not_XX.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008 Free Software Foundation, Inc. + * Copyright 2004,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ () { - return @SPTR_NAME@ (new @NAME@ ()); + return gnuradio::get_initial_sptr (new @NAME@ ()); } @NAME@::@NAME@ () diff --git a/gnuradio-core/src/lib/gengen/gr_or_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_or_XX.cc.t index e118cdbbb..07c759d73 100644 --- a/gnuradio-core/src/lib/gengen/gr_or_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_or_XX.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008 Free Software Foundation, Inc. + * Copyright 2004,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ () { - return @SPTR_NAME@ (new @NAME@ ()); + return gnuradio::get_initial_sptr (new @NAME@ ()); } @NAME@::@NAME@ () diff --git a/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.cc.t index ce6316920..1a4a2564b 100644 --- a/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_peak_detector_XX.cc.t @@ -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 * @@ -35,7 +35,7 @@ gr_make_@BASE_NAME@ (float threshold_factor_rise, float threshold_factor_fall, int look_ahead, float alpha) { - return @SPTR_NAME@ (new @NAME@ (threshold_factor_rise, + return gnuradio::get_initial_sptr (new @NAME@ (threshold_factor_rise, threshold_factor_fall, look_ahead, alpha)); } diff --git a/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.cc.t index 52538286e..b78c52857 100644 --- a/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_sample_and_hold_XX.cc.t @@ -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 * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ () { - return @SPTR_NAME@ (new @NAME@ ()); + return gnuradio::get_initial_sptr (new @NAME@ ()); } @NAME@::@NAME@ () diff --git a/gnuradio-core/src/lib/gengen/gr_sig_source_X.cc.t b/gnuradio-core/src/lib/gengen/gr_sig_source_X.cc.t index 0694df315..9354eb93c 100644 --- a/gnuradio-core/src/lib/gengen/gr_sig_source_X.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_sig_source_X.cc.t @@ -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 * @@ -47,7 +47,7 @@ gr_make_@BASE_NAME@ (double sampling_freq, gr_waveform_t waveform, double frequency, double ampl, @TYPE@ offset) { - return @NAME@_sptr (new @NAME@ (sampling_freq, waveform, frequency, ampl, offset)); + return gnuradio::get_initial_sptr(new @NAME@ (sampling_freq, waveform, frequency, ampl, offset)); } int 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 c8bdabf9f..f0ed75217 100644 --- a/gnuradio-core/src/lib/gengen/gr_sub_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_sub_XX.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004, 2009 Free Software Foundation, Inc. + * Copyright 2004, 2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ (size_t vlen) { - return @SPTR_NAME@ (new @NAME@ (vlen)); + return gnuradio::get_initial_sptr (new @NAME@ (vlen)); } @NAME@::@NAME@ (size_t vlen) diff --git a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t index b2a6c4ac4..f3466d46f 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_sink_X.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008 Free Software Foundation, Inc. + * Copyright 2004,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -54,7 +54,7 @@ int @NAME@_sptr gr_make_@BASE_NAME@ (int vlen) { - return @NAME@_sptr (new @NAME@ (vlen)); + return gnuradio::get_initial_sptr(new @NAME@ (vlen)); } std::vector<@TYPE@> diff --git a/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t b/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t index 889a6f22c..1fe5df5b5 100644 --- a/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_vector_source_X.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008 Free Software Foundation, Inc. + * Copyright 2004,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -84,6 +84,6 @@ int @NAME@_sptr gr_make_@BASE_NAME@ (const std::vector<@TYPE@> &data, bool repeat, int vlen) { - return @NAME@_sptr (new @NAME@ (data, repeat, vlen)); + return gnuradio::get_initial_sptr(new @NAME@ (data, repeat, vlen)); } diff --git a/gnuradio-core/src/lib/gengen/gr_xor_XX.cc.t b/gnuradio-core/src/lib/gengen/gr_xor_XX.cc.t index f64dd1c97..29230f7a6 100644 --- a/gnuradio-core/src/lib/gengen/gr_xor_XX.cc.t +++ b/gnuradio-core/src/lib/gengen/gr_xor_XX.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008 Free Software Foundation, Inc. + * Copyright 2004,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ @SPTR_NAME@ gr_make_@BASE_NAME@ () { - return @SPTR_NAME@ (new @NAME@ ()); + return gnuradio::get_initial_sptr (new @NAME@ ()); } @NAME@::@NAME@ () diff --git a/gnuradio-core/src/lib/io/Makefile.am b/gnuradio-core/src/lib/io/Makefile.am index 9eacd137d..c52554645 100644 --- a/gnuradio-core/src/lib/io/Makefile.am +++ b/gnuradio-core/src/lib/io/Makefile.am @@ -39,7 +39,6 @@ libio_la_SOURCES = \ gr_oscope_guts.cc \ gr_oscope_sink_f.cc \ gr_oscope_sink_x.cc \ - gri_logger.cc \ i2c.cc \ i2c_bitbang.cc \ i2c_bbio.cc \ @@ -72,7 +71,6 @@ grinclude_HEADERS = \ gr_oscope_sink_f.h \ gr_oscope_sink_x.h \ gr_trigger_mode.h \ - gri_logger.h \ i2c.h \ i2c_bitbang.h \ i2c_bbio.h \ diff --git a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc index 2da66b7ae..09fb6c826 100644 --- a/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc +++ b/gnuradio-core/src/lib/io/gr_file_descriptor_sink.cc @@ -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 * @@ -46,7 +46,7 @@ gr_file_descriptor_sink::gr_file_descriptor_sink (size_t itemsize, int fd) gr_file_descriptor_sink_sptr gr_make_file_descriptor_sink (size_t itemsize, int fd) { - return gr_file_descriptor_sink_sptr (new gr_file_descriptor_sink (itemsize, fd)); + return gnuradio::get_initial_sptr(new gr_file_descriptor_sink (itemsize, fd)); } gr_file_descriptor_sink::~gr_file_descriptor_sink () diff --git a/gnuradio-core/src/lib/io/gr_file_sink.cc b/gnuradio-core/src/lib/io/gr_file_sink.cc index d40235fab..aab0158e7 100644 --- a/gnuradio-core/src/lib/io/gr_file_sink.cc +++ b/gnuradio-core/src/lib/io/gr_file_sink.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006,2007 Free Software Foundation, Inc. + * Copyright 2004,2006,2007,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ gr_file_sink_sptr gr_make_file_sink (size_t itemsize, const char *filename) { - return gr_file_sink_sptr (new gr_file_sink (itemsize, filename)); + return gnuradio::get_initial_sptr(new gr_file_sink (itemsize, filename)); } gr_file_sink::gr_file_sink(size_t itemsize, const char *filename) @@ -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 5ddeeb4d5..c43304b0d 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 0c028d7fd..7b96cdb7f 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 05a3353bb..ed4342482 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_file_source.cc b/gnuradio-core/src/lib/io/gr_file_source.cc index 5591826d0..d045e26b3 100644 --- a/gnuradio-core/src/lib/io/gr_file_source.cc +++ b/gnuradio-core/src/lib/io/gr_file_source.cc @@ -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 * @@ -74,7 +74,7 @@ gr_file_source::gr_file_source (size_t itemsize, const char *filename, bool repe gr_file_source_sptr gr_make_file_source (size_t itemsize, const char *filename, bool repeat) { - return gr_file_source_sptr (new gr_file_source (itemsize, filename, repeat)); + return gnuradio::get_initial_sptr(new gr_file_source (itemsize, filename, repeat)); } gr_file_source::~gr_file_source () diff --git a/gnuradio-core/src/lib/io/gr_histo_sink_f.cc b/gnuradio-core/src/lib/io/gr_histo_sink_f.cc index 2885fe428..a37189c24 100644 --- a/gnuradio-core/src/lib/io/gr_histo_sink_f.cc +++ b/gnuradio-core/src/lib/io/gr_histo_sink_f.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 * @@ -46,7 +46,7 @@ static float get_clean_num(float num){ gr_histo_sink_f_sptr gr_make_histo_sink_f (gr_msg_queue_sptr msgq) { - return gr_histo_sink_f_sptr (new gr_histo_sink_f (msgq)); + return gnuradio::get_initial_sptr(new gr_histo_sink_f (msgq)); } gr_histo_sink_f::gr_histo_sink_f (gr_msg_queue_sptr msgq) diff --git a/gnuradio-core/src/lib/io/gr_message_sink.cc b/gnuradio-core/src/lib/io/gr_message_sink.cc index b9e0cc382..8881e97f4 100644 --- a/gnuradio-core/src/lib/io/gr_message_sink.cc +++ b/gnuradio-core/src/lib/io/gr_message_sink.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -40,7 +40,7 @@ gr_message_sink_sptr gr_make_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block) { - return gr_message_sink_sptr(new gr_message_sink(itemsize, msgq, dont_block)); + return gnuradio::get_initial_sptr(new gr_message_sink(itemsize, msgq, dont_block)); } gr_message_sink::gr_message_sink (size_t itemsize, gr_msg_queue_sptr msgq, bool dont_block) diff --git a/gnuradio-core/src/lib/io/gr_message_source.cc b/gnuradio-core/src/lib/io/gr_message_source.cc index 3efc5b321..0fa24f2f9 100644 --- a/gnuradio-core/src/lib/io/gr_message_source.cc +++ b/gnuradio-core/src/lib/io/gr_message_source.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -40,14 +40,14 @@ gr_message_source_sptr gr_make_message_source(size_t itemsize, int msgq_limit) { - return gr_message_source_sptr(new gr_message_source(itemsize, msgq_limit)); + return gnuradio::get_initial_sptr(new gr_message_source(itemsize, msgq_limit)); } // public constructor that takes existing message queue gr_message_source_sptr gr_make_message_source(size_t itemsize, gr_msg_queue_sptr msgq) { - return gr_message_source_sptr(new gr_message_source(itemsize, msgq)); + return gnuradio::get_initial_sptr(new gr_message_source(itemsize, msgq)); } gr_message_source::gr_message_source (size_t itemsize, int msgq_limit) diff --git a/gnuradio-core/src/lib/io/gr_oscope_guts.cc b/gnuradio-core/src/lib/io/gr_oscope_guts.cc index 80f78240d..ce7feca13 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_oscope_sink_f.cc b/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc index cb401699e..eca0f6dc6 100644 --- a/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc +++ b/gnuradio-core/src/lib/io/gr_oscope_sink_f.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2003,2004,2005 Free Software Foundation, Inc. + * Copyright 2003,2004,2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ gr_oscope_sink_f_sptr gr_make_oscope_sink_f (double sampling_rate, gr_msg_queue_sptr msgq) { - return gr_oscope_sink_f_sptr (new gr_oscope_sink_f (sampling_rate, msgq)); + return gnuradio::get_initial_sptr(new gr_oscope_sink_f (sampling_rate, msgq)); } diff --git a/gnuradio-core/src/lib/io/gr_trigger_mode.h b/gnuradio-core/src/lib/io/gr_trigger_mode.h index 63f6b1c98..8e1222856 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/io/gr_udp_sink.cc b/gnuradio-core/src/lib/io/gr_udp_sink.cc index d37adfb8a..36b4cbe36 100644 --- a/gnuradio-core/src/lib/io/gr_udp_sink.cc +++ b/gnuradio-core/src/lib/io/gr_udp_sink.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. + * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -26,13 +26,24 @@ #include <gr_udp_sink.h> #include <gr_io_signature.h> #include <stdexcept> -#if defined(HAVE_SOCKET) -#include <netdb.h> +#include <errno.h> #include <stdio.h> +#include <string.h> +#if defined(HAVE_NETDB_H) +#include <netdb.h> +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> //usually included by <netdb.h>? +#endif typedef void* optval_t; -#else +#elif defined(HAVE_WINDOWS_H) +// if not posix, assume winsock +#define USING_WINSOCK +#include <winsock2.h> +#include <ws2tcpip.h> #define SHUT_RDWR 2 -#define inet_aton(N,A) ( (A)->s_addr = inet_addr(N), ( (A)->s_addr != INADDR_NONE ) ) typedef char* optval_t; #endif @@ -40,91 +51,67 @@ typedef char* optval_t; #define SNK_VERBOSE 0 -gr_udp_sink::gr_udp_sink (size_t itemsize, - const char *src, unsigned short port_src, - const char *dst, unsigned short port_dst, - int payload_size) - : gr_sync_block ("udp_sink", - gr_make_io_signature (1, 1, itemsize), - gr_make_io_signature (0, 0, 0)), - d_itemsize (itemsize), d_updated(false), d_payload_size(payload_size) +static int is_error( int perr ) { - int ret = 0; - - // Set up the address stucture for the source address and port numbers - // Get the source IP address from the host name - struct hostent *hsrc = gethostbyname(src); - if(hsrc) { // if the source was provided as a host namex - d_ip_src = *(struct in_addr*)hsrc->h_addr_list[0]; + // Compare error to posix error code; return nonzero if match. +#if defined(USING_WINSOCK) +#define ENOPROTOOPT 109 +#define ECONNREFUSED 111 + // All codes to be checked for must be defined below + int werr = WSAGetLastError(); + switch( werr ) { + case WSAETIMEDOUT: + return( perr == EAGAIN ); + case WSAENOPROTOOPT: + return( perr == ENOPROTOOPT ); + case WSAECONNREFUSED: + return( perr == ECONNREFUSED ); + default: + fprintf(stderr,"gr_udp_source/is_error: unknown error %d\n", perr ); + throw std::runtime_error("internal error"); } - else { // assume it was specified as an IP address - if((ret=inet_aton(src, &d_ip_src)) == 0) { // format IP address - perror("Not a valid source IP address or host name"); - throw std::runtime_error("can't initialize source socket"); - } - } - - // Get the destination IP address from the host name - struct hostent *hdst = gethostbyname(dst); - if(hdst) { // if the source was provided as a host namex - d_ip_dst = *(struct in_addr*)hdst->h_addr_list[0]; - } - else { // assume it was specified as an IP address - if((ret=inet_aton(dst, &d_ip_dst)) == 0) { // format IP address - perror("Not a valid destination IP address or host name"); - throw std::runtime_error("can't initialize destination socket"); - } - } - - d_port_src = htons(port_src); // format port number - d_port_dst = htons(port_dst); // format port number - - d_sockaddr_src.sin_family = AF_INET; - d_sockaddr_src.sin_addr = d_ip_src; - d_sockaddr_src.sin_port = d_port_src; - - d_sockaddr_dst.sin_family = AF_INET; - d_sockaddr_dst.sin_addr = d_ip_dst; - d_sockaddr_dst.sin_port = d_port_dst; - - open(); -} - -// public constructor that returns a shared_ptr - -gr_udp_sink_sptr -gr_make_udp_sink (size_t itemsize, - const char *src, unsigned short port_src, - const char *dst, unsigned short port_dst, - int payload_size) -{ - return gr_udp_sink_sptr (new gr_udp_sink (itemsize, - src, port_src, - dst, port_dst, - payload_size)); + return 0; +#else + return( perr == errno ); +#endif } -gr_udp_sink::~gr_udp_sink () +static void report_error( const char *msg1, const char *msg2 ) { - close(); + // Deal with errors, both posix and winsock +#if defined(USING_WINSOCK) + int werr = WSAGetLastError(); + fprintf(stderr, "%s: winsock error %d\n", msg1, werr ); +#else + perror(msg1); +#endif + if( msg2 != NULL ) + throw std::runtime_error(msg2); + return; } -bool -gr_udp_sink::open() +gr_udp_sink::gr_udp_sink (size_t itemsize, + const char *host, unsigned short port, + int payload_size, bool eof) + : gr_sync_block ("udp_sink", + gr_make_io_signature (1, 1, itemsize), + gr_make_io_signature (0, 0, 0)), + d_itemsize (itemsize), d_payload_size(payload_size), d_eof(eof), + d_socket(-1), d_connected(false) { - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function - - // create socket - if((d_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { - perror("socket open"); - throw std::runtime_error("can't open socket"); +#if defined(USING_WINSOCK) // for Windows (with MinGW) + // initialize winsock DLL + WSADATA wsaData; + int iResult = WSAStartup( MAKEWORD(2,2), &wsaData ); + if( iResult != NO_ERROR ) { + report_error( "gr_udp_source WSAStartup", "can't open socket" ); } +#endif - // Turn on reuse address - int opt_val = true; - if(setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR, (optval_t)&opt_val, sizeof(int)) == -1) { - perror("SO_REUSEADDR"); - throw std::runtime_error("can't set socket option SO_REUSEADDR"); + // create socket + d_socket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); + if(d_socket == -1) { + report_error("socket open","can't open socket"); } // Don't wait when shutting down @@ -132,36 +119,46 @@ gr_udp_sink::open() lngr.l_onoff = 1; lngr.l_linger = 0; if(setsockopt(d_socket, SOL_SOCKET, SO_LINGER, (optval_t)&lngr, sizeof(linger)) == -1) { - perror("SO_LINGER"); - throw std::runtime_error("can't set socket option SO_LINGER"); + if( !is_error(ENOPROTOOPT) ) { // no SO_LINGER for SOCK_DGRAM on Windows + report_error("SO_LINGER","can't set socket option SO_LINGER"); + } } - // bind socket to an address and port number to listen on - if(bind (d_socket, (sockaddr*)&d_sockaddr_src, sizeof(struct sockaddr)) == -1) { - perror("socket bind"); - throw std::runtime_error("can't bind socket"); - } + // Get the destination address + connect(host, port); +} - // Not sure if we should throw here or allow retries - if(connect(d_socket, (sockaddr*)&d_sockaddr_dst, sizeof(struct sockaddr)) == -1) { - perror("socket connect"); - throw std::runtime_error("can't connect to socket"); - } +// public constructor that returns a shared_ptr - d_updated = true; - return d_socket != 0; +gr_udp_sink_sptr +gr_make_udp_sink (size_t itemsize, + const char *host, unsigned short port, + int payload_size, bool eof) +{ + return gnuradio::get_initial_sptr(new gr_udp_sink (itemsize, + host, port, + payload_size, eof)); } -void -gr_udp_sink::close() +gr_udp_sink::~gr_udp_sink () { - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function + if (d_connected) + disconnect(); - if (d_socket){ + if (d_socket != -1){ shutdown(d_socket, SHUT_RDWR); - d_socket = 0; +#if defined(USING_WINSOCK) + closesocket(d_socket); +#else + ::close(d_socket); +#endif + d_socket = -1; } - d_updated = true; + +#if defined(USING_WINSOCK) // for Windows (with MinGW) + // free winsock resources + WSACleanup(); +#endif } int @@ -174,21 +171,31 @@ gr_udp_sink::work (int noutput_items, ssize_t total_size = noutput_items*d_itemsize; #if SNK_VERBOSE - printf("Entered upd_sink\n"); + printf("Entered udp_sink\n"); #endif + gruel::scoped_lock guard(d_mutex); // protect d_socket + while(bytes_sent < total_size) { bytes_to_send = std::min((ssize_t)d_payload_size, (total_size-bytes_sent)); - r = send(d_socket, (in+bytes_sent), bytes_to_send, 0); - if(r == -1) { // error on send command - perror("udp_sink"); // there should be no error case where this function - return -1; // should not exit immediately + if(d_connected) { + r = send(d_socket, (in+bytes_sent), bytes_to_send, 0); + if(r == -1) { // error on send command + if( is_error(ECONNREFUSED) ) + r = bytes_to_send; // discard data until receiver is started + else { + report_error("udp_sink",NULL); // there should be no error case where + return -1; // this function should not exit immediately + } + } } + else + r = bytes_to_send; // discarded for lack of connection bytes_sent += r; #if SNK_VERBOSE - printf("\tbyte sent: %d bytes\n", bytes); + printf("\tbyte sent: %d bytes\n", r); #endif } @@ -198,3 +205,98 @@ gr_udp_sink::work (int noutput_items, return noutput_items; } + +void gr_udp_sink::connect( const char *host, unsigned short port ) +{ + if(d_connected) + disconnect(); + + if(host != NULL ) { + // Get the destination address + struct addrinfo *ip_dst; + struct addrinfo hints; + memset( (void*)&hints, 0, sizeof(hints) ); + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_protocol = IPPROTO_UDP; + char port_str[12]; + sprintf( port_str, "%d", port ); + + // FIXME leaks if report_error throws below + int ret = getaddrinfo( host, port_str, &hints, &ip_dst ); + if( ret != 0 ) + report_error("gr_udp_source/getaddrinfo", + "can't initialize destination socket" ); + + // don't need d_mutex lock when !d_connected + if(::connect(d_socket, ip_dst->ai_addr, ip_dst->ai_addrlen) == -1) { + report_error("socket connect","can't connect to socket"); + } + d_connected = true; + + freeaddrinfo(ip_dst); + } + + return; +} + +void gr_udp_sink::disconnect() +{ + if(!d_connected) + return; + + #if SNK_VERBOSE + printf("gr_udp_sink disconnecting\n"); + #endif + + gruel::scoped_lock guard(d_mutex); // protect d_socket from work() + + // Send a few zero-length packets to signal receiver we are done + if(d_eof) { + int i; + for( i = 0; i < 3; i++ ) + (void) send( d_socket, NULL, 0, 0 ); // ignore errors + } + + // Sending EOF can produce ERRCONNREFUSED errors that won't show up + // until the next send or recv, which might confuse us if it happens + // on a new connection. The following does a nonblocking recv to + // clear any such errors. + timeval timeout; + timeout.tv_sec = 0; // zero time for immediate return + timeout.tv_usec = 0; + fd_set readfds; + FD_ZERO(&readfds); + FD_SET(d_socket, &readfds); + int r = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout); + if(r < 0) { + #if SNK_VERBOSE + report_error("udp_sink/select",NULL); + #endif + } + else if(r > 0) { // call recv() to get error return + r = recv(d_socket, (char*)&readfds, sizeof(readfds), 0); + if(r < 0) { + #if SNK_VERBOSE + report_error("udp_sink/recv",NULL); + #endif + } + } + + // Since I can't find any way to disconnect a datagram socket in Cygwin, + // we just leave it connected but disable sending. +#if 0 + // zeroed address structure should reset connection + struct sockaddr addr; + memset( (void*)&addr, 0, sizeof(addr) ); + // addr.sa_family = AF_UNSPEC; // doesn't work on Cygwin + // addr.sa_family = AF_INET; // doesn't work on Cygwin + + if(::connect(d_socket, &addr, sizeof(addr)) == -1) + report_error("socket connect","can't connect to socket"); +#endif + + d_connected = false; + + return; +} diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.h b/gnuradio-core/src/lib/io/gr_udp_sink.h index f22b92dd0..421d514a4 100644 --- a/gnuradio-core/src/lib/io/gr_udp_sink.h +++ b/gnuradio-core/src/lib/io/gr_udp_sink.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. + * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,18 +24,6 @@ #define INCLUDED_GR_UDP_SINK_H #include <gr_sync_block.h> -#include <boost/thread.hpp> -#if defined(HAVE_SOCKET) -#include <sys/socket.h> -#include <arpa/inet.h> -#elif defined(HAVE_WINDOWS_H) -#include <winsock2.h> -#include <windows.h> -#endif -#if defined(HAVE_NETINET_IN_H) -#include <netinet/in.h> -#endif - #include <gruel/thread.h> class gr_udp_sink; @@ -43,85 +31,75 @@ typedef boost::shared_ptr<gr_udp_sink> gr_udp_sink_sptr; gr_udp_sink_sptr gr_make_udp_sink (size_t itemsize, - const char *src, unsigned short port_src, - const char *dst, unsigned short port_dst, - int payload_size=1472); + const char *host, unsigned short port, + int payload_size=1472, bool eof=true); /*! * \brief Write stream to an UDP socket. * \ingroup sink_blk * * \param itemsize The size (in bytes) of the item datatype - * \param src The source address as either the host name or the 'numbers-and-dots' - * IP address - * \param port_src Destination port to bind to (0 allows socket to choose an appropriate port) - * \param dst The destination address as either the host name or the 'numbers-and-dots' - * IP address - * \param port_dst Destination port to connect to - * \param payload_size UDP payload size by default set to - * 1472 = (1500 MTU - (8 byte UDP header) - (20 byte IP header)) + * \param host The name or IP address of the receiving host; use + * NULL or None for no connection + * \param port Destination port to connect to on receiving host + * \param payload_size UDP payload size by default set to 1472 = + * (1500 MTU - (8 byte UDP header) - (20 byte IP header)) + * \param eof Send zero-length packet on disconnect */ class gr_udp_sink : public gr_sync_block { friend gr_udp_sink_sptr gr_make_udp_sink (size_t itemsize, - const char *src, unsigned short port_src, - const char *dst, unsigned short port_dst, - int payload_size); + const char *host, + unsigned short port, + int payload_size, bool eof); private: size_t d_itemsize; - bool d_updated; - gruel::mutex d_mutex; - int d_payload_size; // maximum transmission unit (packet length) - int d_socket; // handle to socket - int d_socket_rcv; // handle to socket retuned in the accept call - struct in_addr d_ip_src; // store the source ip info - struct in_addr d_ip_dst; // store the destination ip info - unsigned short d_port_src; // the port number to open for connections to this service - unsigned short d_port_dst; // port number of the remove system - struct sockaddr_in d_sockaddr_src; // store the source sockaddr data (formatted IP address and port number) - struct sockaddr_in d_sockaddr_dst; // store the destination sockaddr data (formatted IP address and port number) + int d_payload_size; // maximum transmission unit (packet length) + bool d_eof; // send zero-length packet on disconnect + int d_socket; // handle to socket + bool d_connected; // are we connected? + gruel::mutex d_mutex; // protects d_socket and d_connected protected: /*! * \brief UDP Sink Constructor * * \param itemsize The size (in bytes) of the item datatype - * \param src The source address as either the host name or the 'numbers-and-dots' - * IP address - * \param port_src Destination port to bind to (0 allows socket to choose an appropriate port) - * \param dst The destination address as either the host name or the 'numbers-and-dots' - * IP address - * \param port_dst Destination port to connect to + * \param host The name or IP address of the receiving host; use + * NULL or None for no connection + * \param port Destination port to connect to on receiving host * \param payload_size UDP payload size by default set to * 1472 = (1500 MTU - (8 byte UDP header) - (20 byte IP header)) + * \param eof Send zero-length packet on disconnect */ gr_udp_sink (size_t itemsize, - const char *src, unsigned short port_src, - const char *dst, unsigned short port_dst, - int payload_size); + const char *host, unsigned short port, + int payload_size, bool eof); public: ~gr_udp_sink (); - /*! - * \brief open a socket specified by the port and ip address info - * - * Opens a socket, binds to the address, and makes connectionless association - * over UDP. If any of these fail, the fuction retuns the error and exits. - */ - bool open(); + /*! \brief return the PAYLOAD_SIZE of the socket */ + int payload_size() { return d_payload_size; } - /*! - * \brief Close current socket. + /*! \brief Change the connection to a new destination + * + * \param host The name or IP address of the receiving host; use + * NULL or None to break the connection without closing + * \param port Destination port to connect to on receiving host * - * Shuts down read/write on the socket + * Calls disconnect() to terminate any current connection first. */ - void close(); + void connect( const char *host, unsigned short port ); - /*! \brief return the PAYLOAD_SIZE of the socket */ - int payload_size() { return d_payload_size; } + /*! \brief Send zero-length packet (if eof is requested) then stop sending + * + * Zero-byte packets can be interpreted as EOF by gr_udp_source. Note that + * disconnect occurs automatically when the sink is destroyed, but not when + * its top_block stops.*/ + void disconnect(); // should we export anything else? diff --git a/gnuradio-core/src/lib/io/gr_udp_sink.i b/gnuradio-core/src/lib/io/gr_udp_sink.i index 0f37b477b..a71006ae0 100644 --- a/gnuradio-core/src/lib/io/gr_udp_sink.i +++ b/gnuradio-core/src/lib/io/gr_udp_sink.i @@ -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 * @@ -25,22 +25,22 @@ GR_SWIG_BLOCK_MAGIC(gr,udp_sink) gr_udp_sink_sptr gr_make_udp_sink (size_t itemsize, - const char *src, unsigned short port_src, - const char *dst, unsigned short port_dst, - int payload_size=1472); + const char *host, unsigned short port, + int payload_size=1472, bool eof=true) throw (std::runtime_error); class gr_udp_sink : public gr_sync_block { protected: gr_udp_sink (size_t itemsize, - const char *src, unsigned short port_src, - const char *dst, unsigned short port_dst, - int payload_size); - - bool open(); - void close(); - int payload_size() { return d_payload_size; } + const char *host, unsigned short port, + int payload_size, bool eof) + throw (std::runtime_error); public: ~gr_udp_sink (); + + int payload_size() { return d_payload_size; } + void connect( const char *host, unsigned short port ); + void disconnect(); + }; diff --git a/gnuradio-core/src/lib/io/gr_udp_source.cc b/gnuradio-core/src/lib/io/gr_udp_source.cc index d76d0ee32..ca31233de 100644 --- a/gnuradio-core/src/lib/io/gr_udp_source.cc +++ b/gnuradio-core/src/lib/io/gr_udp_source.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. + * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -29,80 +29,126 @@ #include <errno.h> #include <stdio.h> #include <string.h> -#if defined(HAVE_SOCKET) + +#if defined(HAVE_NETDB_H) #include <netdb.h> +#ifdef HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#ifdef HAVE_SYS_SOCKET_H +#include <sys/socket.h> +#endif typedef void* optval_t; -#else + +// ntohs() on FreeBSD may require both netinet/in.h and arpa/inet.h, in order +#if defined(HAVE_NETINET_IN_H) +#include <netinet/in.h> +#endif +#if defined(HAVE_ARPA_INET_H) +#include <arpa/inet.h> +#endif + +#elif defined(HAVE_WINDOWS_H) +// if not posix, assume winsock +#define USING_WINSOCK +#include <winsock2.h> +#include <ws2tcpip.h> #define SHUT_RDWR 2 -#define inet_aton(N,A) ( (A)->s_addr = inet_addr(N), ( (A)->s_addr != INADDR_NONE ) ) typedef char* optval_t; #endif +#define USE_SELECT 1 // non-blocking receive on all platforms +#define USE_RCV_TIMEO 0 // non-blocking receive on all but Cygwin #define SRC_VERBOSE 0 -gr_udp_source::gr_udp_source(size_t itemsize, const char *src, - unsigned short port_src, int payload_size) +static int is_error( int perr ) +{ + // Compare error to posix error code; return nonzero if match. +#if defined(USING_WINSOCK) +#define ENOPROTOOPT 109 + // All codes to be checked for must be defined below + int werr = WSAGetLastError(); + switch( werr ) { + case WSAETIMEDOUT: + return( perr == EAGAIN ); + case WSAENOPROTOOPT: + return( perr == ENOPROTOOPT ); + default: + fprintf(stderr,"gr_udp_source/is_error: unknown error %d\n", perr ); + throw std::runtime_error("internal error"); + } + return 0; +#else + return( perr == errno ); +#endif +} + +static void report_error( const char *msg1, const char *msg2 ) +{ + // Deal with errors, both posix and winsock +#if defined(USING_WINSOCK) + int werr = WSAGetLastError(); + fprintf(stderr, "%s: winsock error %d\n", msg1, werr ); +#else + perror(msg1); +#endif + if( msg2 != NULL ) + throw std::runtime_error(msg2); + return; +} + +gr_udp_source::gr_udp_source(size_t itemsize, const char *host, + unsigned short port, int payload_size, + bool eof, bool wait) : gr_sync_block ("udp_source", gr_make_io_signature(0, 0, 0), gr_make_io_signature(1, 1, itemsize)), - d_itemsize(itemsize), d_updated(false), d_payload_size(payload_size), d_residual(0), d_temp_offset(0) + d_itemsize(itemsize), d_payload_size(payload_size), + d_eof(eof), d_wait(wait), d_socket(-1), d_residual(0), d_temp_offset(0) { int ret = 0; + +#if defined(USING_WINSOCK) // for Windows (with MinGW) + // initialize winsock DLL + WSADATA wsaData; + int iResult = WSAStartup( MAKEWORD(2,2), &wsaData ); + if( iResult != NO_ERROR ) { + report_error( "gr_udp_source WSAStartup", "can't open socket" ); + } +#endif // Set up the address stucture for the source address and port numbers // Get the source IP address from the host name - struct hostent *hsrc = gethostbyname(src); - if(hsrc) { // if the source was provided as a host namex - d_ip_src = *(struct in_addr*)hsrc->h_addr_list[0]; - } - else { // assume it was specified as an IP address - if((ret=inet_aton(src, &d_ip_src)) == 0) { // format IP address - perror("Not a valid source IP address or host name"); - throw std::runtime_error("can't initialize source socket"); - } - } + struct addrinfo *ip_src; // store the source IP address to use + struct addrinfo hints; + memset( (void*)&hints, 0, sizeof(hints) ); + hints.ai_family = AF_INET; + hints.ai_socktype = SOCK_DGRAM; + hints.ai_protocol = IPPROTO_UDP; + hints.ai_flags = AI_PASSIVE; + char port_str[12]; + sprintf( port_str, "%d", port ); - d_port_src = htons(port_src); // format port number - - d_sockaddr_src.sin_family = AF_INET; - d_sockaddr_src.sin_addr = d_ip_src; - d_sockaddr_src.sin_port = d_port_src; + // FIXME leaks if report_error throws below + ret = getaddrinfo( host, port_str, &hints, &ip_src ); + if( ret != 0 ) + report_error("gr_udp_source/getaddrinfo", + "can't initialize source socket" ); + // FIXME leaks if report_error throws below d_temp_buff = new char[d_payload_size]; // allow it to hold up to payload_size bytes - - open(); -} -gr_udp_source_sptr -gr_make_udp_source (size_t itemsize, const char *ipaddr, - unsigned short port, int payload_size) -{ - return gr_udp_source_sptr (new gr_udp_source (itemsize, ipaddr, - port, payload_size)); -} - -gr_udp_source::~gr_udp_source () -{ - delete [] d_temp_buff; - close(); -} - -bool -gr_udp_source::open() -{ - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function // create socket - d_socket = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); + d_socket = socket(ip_src->ai_family, ip_src->ai_socktype, + ip_src->ai_protocol); if(d_socket == -1) { - perror("socket open"); - throw std::runtime_error("can't open socket"); + report_error("socket open","can't open socket"); } // Turn on reuse address int opt_val = 1; if(setsockopt(d_socket, SOL_SOCKET, SO_REUSEADDR, (optval_t)&opt_val, sizeof(int)) == -1) { - perror("SO_REUSEADDR"); - throw std::runtime_error("can't set socket option SO_REUSEADDR"); + report_error("SO_REUSEADDR","can't set socket option SO_REUSEADDR"); } // Don't wait when shutting down @@ -110,40 +156,61 @@ gr_udp_source::open() lngr.l_onoff = 1; lngr.l_linger = 0; if(setsockopt(d_socket, SOL_SOCKET, SO_LINGER, (optval_t)&lngr, sizeof(linger)) == -1) { - perror("SO_LINGER"); - throw std::runtime_error("can't set socket option SO_LINGER"); + if( !is_error(ENOPROTOOPT) ) { // no SO_LINGER for SOCK_DGRAM on Windows + report_error("SO_LINGER","can't set socket option SO_LINGER"); + } } +#if USE_RCV_TIMEO // Set a timeout on the receive function to not block indefinitely // This value can (and probably should) be changed + // Ignored on Cygwin +#if defined(USING_WINSOCK) + DWORD timeout = 1000; // milliseconds +#else timeval timeout; timeout.tv_sec = 1; timeout.tv_usec = 0; +#endif if(setsockopt(d_socket, SOL_SOCKET, SO_RCVTIMEO, (optval_t)&timeout, sizeof(timeout)) == -1) { - perror("SO_RCVTIMEO"); - throw std::runtime_error("can't set socket option SO_RCVTIMEO"); + report_error("SO_RCVTIMEO","can't set socket option SO_RCVTIMEO"); } +#endif // USE_RCV_TIMEO // bind socket to an address and port number to listen on - if(bind (d_socket, (sockaddr*)&d_sockaddr_src, sizeof(struct sockaddr)) == -1) { - perror("socket bind"); - throw std::runtime_error("can't bind socket"); + if(bind (d_socket, ip_src->ai_addr, ip_src->ai_addrlen) == -1) { + report_error("socket bind","can't bind socket"); } - - d_updated = true; - return d_socket != 0; + freeaddrinfo(ip_src); + +} + +gr_udp_source_sptr +gr_make_udp_source (size_t itemsize, const char *ipaddr, + unsigned short port, int payload_size, bool eof, bool wait) +{ + return gnuradio::get_initial_sptr(new gr_udp_source (itemsize, ipaddr, + port, payload_size, eof, wait)); } -void -gr_udp_source::close() +gr_udp_source::~gr_udp_source () { - gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function + delete [] d_temp_buff; - if (d_socket){ + if (d_socket != -1){ shutdown(d_socket, SHUT_RDWR); - d_socket = 0; +#if defined(USING_WINSOCK) + closesocket(d_socket); +#else + ::close(d_socket); +#endif + d_socket = -1; } - d_updated = true; + +#if defined(USING_WINSOCK) // for Windows (with MinGW) + // free winsock resources + WSACleanup(); +#endif } int @@ -175,29 +242,85 @@ gr_udp_source::work (int noutput_items, // Update indexing of amount of bytes left in the buffer d_residual -= nbytes; - d_temp_offset = d_temp_offset+d_residual; + d_temp_offset += nbytes; + + // Return now with what we've got. + assert(nbytes % d_itemsize == 0); + return nbytes/d_itemsize; } while(1) { // get the data into our output buffer and record the number of bytes + +#if USE_SELECT + // RCV_TIMEO doesn't work on all systems (e.g., Cygwin) + // use select() instead of, or in addition to RCV_TIMEO + fd_set readfds; + timeval timeout; + timeout.tv_sec = 1; // Init timeout each iteration. Select can modify it. + timeout.tv_usec = 0; + FD_ZERO(&readfds); + FD_SET(d_socket, &readfds); + r = select(FD_SETSIZE, &readfds, NULL, NULL, &timeout); + if(r < 0) { + report_error("udp_source/select",NULL); + return -1; + } + else if(r == 0 ) { // timed out + if( d_wait ) { + // Allow boost thread interrupt, then try again + boost::this_thread::interruption_point(); + continue; + } + else + return -1; + } +#endif // USE_SELECT + // This is a non-blocking call with a timeout set in the constructor r = recv(d_socket, d_temp_buff, d_payload_size, 0); // get the entire payload or the what's available + // If r > 0, round it down to a multiple of d_itemsize + // (If sender is broken, don't propagate problem) + if (r > 0) + r = (r/d_itemsize) * d_itemsize; + // Check if there was a problem; forget it if the operation just timed out if(r == -1) { - if(errno == EAGAIN) { // handle non-blocking call timeout + if( is_error(EAGAIN) ) { // handle non-blocking call timeout #if SRC_VERBOSE printf("UDP receive timed out\n"); #endif - // Break here to allow the rest of the flow graph time to run and so ctrl-C breaks - break; + if( d_wait ) { + // Allow boost thread interrupt, then try again + boost::this_thread::interruption_point(); + continue; + } + else + return -1; } else { - perror("udp_source"); + report_error("udp_source/recv",NULL); return -1; } } + else if(r==0) { + if(d_eof) { + // zero-length packet interpreted as EOF + + #if SNK_VERBOSE + printf("\tzero-length packet received; returning EOF\n"); + #endif + + return -1; + } + else{ + // do we need to allow boost thread interrupt? + boost::this_thread::interruption_point(); + continue; + } + } else { // Calculate the number of bytes we can take from the buffer in this call nbytes = std::min(r, total_bytes-bytes_received); @@ -235,3 +358,15 @@ gr_udp_source::work (int noutput_items, return bytes_received/d_itemsize; } +// Return port number of d_socket +int gr_udp_source::get_port(void) +{ + sockaddr_in name; + socklen_t len = sizeof(name); + int ret = getsockname( d_socket, (sockaddr*)&name, &len ); + if( ret ) { + report_error("gr_udp_source/getsockname",NULL); + return -1; + } + return ntohs(name.sin_port); +} diff --git a/gnuradio-core/src/lib/io/gr_udp_source.h b/gnuradio-core/src/lib/io/gr_udp_source.h index 61d719e4d..5d30fad30 100644 --- a/gnuradio-core/src/lib/io/gr_udp_source.h +++ b/gnuradio-core/src/lib/io/gr_udp_source.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. + * Copyright 2007,2008,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,54 +24,48 @@ #define INCLUDED_GR_UDP_SOURCE_H #include <gr_sync_block.h> -#if defined(HAVE_SOCKET) -#include <sys/socket.h> -#include <arpa/inet.h> -#elif defined(HAVE_WINDOWS_H) -#include <winsock2.h> -#include <windows.h> -#endif -#if defined(HAVE_NETINET_IN_H) -#include <netinet/in.h> -#endif - #include <gruel/thread.h> class gr_udp_source; typedef boost::shared_ptr<gr_udp_source> gr_udp_source_sptr; -gr_udp_source_sptr gr_make_udp_source(size_t itemsize, const char *src, - unsigned short port_src, int payload_size=1472); +gr_udp_source_sptr gr_make_udp_source(size_t itemsize, const char *host, + unsigned short port, + int payload_size=1472, + bool eof=true, bool wait=true); /*! * \brief Read stream from an UDP socket. * \ingroup source_blk * * \param itemsize The size (in bytes) of the item datatype - * \param src The source address as either the host name or the 'numbers-and-dots' - * IP address - * \param port_src The port number on which the socket listens for data - * \param payload_size UDP payload size by default set to - * 1472 = (1500 MTU - (8 byte UDP header) - (20 byte IP header)) + * \param host The name or IP address of the receiving host; can be + * NULL, None, or "0.0.0.0" to allow reading from any + * interface on the host + * \param port The port number on which to receive data; use 0 to + * have the system assign an unused port number + * \param payload_size UDP payload size by default set to 1472 = + * (1500 MTU - (8 byte UDP header) - (20 byte IP header)) + * \param eof Interpret zero-length packet as EOF (default: true) + * \param wait Wait for data if not immediately available + * (default: true) * */ class gr_udp_source : public gr_sync_block { - friend gr_udp_source_sptr gr_make_udp_source(size_t itemsize, const char *src, - unsigned short port_src, int payload_size); + friend gr_udp_source_sptr gr_make_udp_source(size_t itemsize, + const char *host, + unsigned short port, + int payload_size, + bool eof, bool wait); private: size_t d_itemsize; - bool d_updated; - gruel::mutex d_mutex; - - int d_payload_size; // maximum transmission unit (packet length) - int d_socket; // handle to socket - int d_socket_rcv; // handle to socket retuned in the accept call - struct in_addr d_ip_src; // store the source IP address to use - unsigned short d_port_src; // the port number to open for connections to this service - struct sockaddr_in d_sockaddr_src; // store the source sockaddr data (formatted IP address and port number) + int d_payload_size; // maximum transmission unit (packet length) + bool d_eof; // zero-length packet is EOF + bool d_wait; // wait if data if not immediately available + int d_socket; // handle to socket char *d_temp_buff; // hold buffer between calls ssize_t d_residual; // hold information about number of bytes stored in the temp buffer size_t d_temp_offset; // point to temp buffer location offset @@ -81,35 +75,29 @@ class gr_udp_source : public gr_sync_block * \brief UDP Source Constructor * * \param itemsize The size (in bytes) of the item datatype - * \param src The source address as either the host name or the 'numbers-and-dots' - * IP address - * \param port_src The port number on which the socket listens for data - * \param payload_size UDP payload size by default set to - * 1472 = (1500 MTU - (8 byte UDP header) - (20 byte IP header)) + * \param host The name or IP address of the receiving host; can be + * NULL, None, or "0.0.0.0" to allow reading from any + * interface on the host + * \param port The port number on which to receive data; use 0 to + * have the system assign an unused port number + * \param payload_size UDP payload size by default set to 1472 = + * (1500 MTU - (8 byte UDP header) - (20 byte IP header)) + * \param eof Interpret zero-length packet as EOF (default: true) + * \param wait Wait for data if not immediately available + * (default: true) */ - gr_udp_source(size_t itemsize, const char *src, unsigned short port_src, int payload_size); + gr_udp_source(size_t itemsize, const char *host, unsigned short port, + int payload_size, bool eof, bool wait); public: ~gr_udp_source(); - /*! - * \brief open a socket specified by the port and ip address info - * - * Opens a socket, binds to the address, and waits for a connection - * over UDP. If any of these fail, the fuction retuns the error and exits. - */ - bool open(); - - /*! - * \brief Close current socket. - * - * Shuts down read/write on the socket - */ - void close(); - /*! \brief return the PAYLOAD_SIZE of the socket */ int payload_size() { return d_payload_size; } + /*! \brief return the port number of the socket */ + int get_port(); + // should we export anything else? int work(int noutput_items, diff --git a/gnuradio-core/src/lib/io/gr_udp_source.i b/gnuradio-core/src/lib/io/gr_udp_source.i index fb39dad68..2001f33e9 100644 --- a/gnuradio-core/src/lib/io/gr_udp_source.i +++ b/gnuradio-core/src/lib/io/gr_udp_source.i @@ -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 * @@ -23,20 +23,19 @@ GR_SWIG_BLOCK_MAGIC(gr,udp_source) gr_udp_source_sptr -gr_make_udp_source (size_t itemsize, const char *src, - unsigned short port_src, int payload_size=1472); +gr_make_udp_source (size_t itemsize, const char *host, + unsigned short port, int payload_size=1472, + bool eof=true, bool wait=true) throw (std::runtime_error); class gr_udp_source : public gr_sync_block { protected: - gr_udp_source (size_t itemsize, const char *src, - unsigned short port_src, int payload_size); + gr_udp_source (size_t itemsize, const char *host, + unsigned short port, int payload_size, bool eof, bool wait) throw (std::runtime_error); public: ~gr_udp_source (); - bool open(); - void close(); int payload_size() { return d_payload_size; } - + int get_port(); }; diff --git a/gnuradio-core/src/lib/io/gr_wavfile_sink.cc b/gnuradio-core/src/lib/io/gr_wavfile_sink.cc index 72e4ef51e..b60a6e3ab 100644 --- a/gnuradio-core/src/lib/io/gr_wavfile_sink.cc +++ b/gnuradio-core/src/lib/io/gr_wavfile_sink.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006,2007,2008,2009 Free Software Foundation, Inc. + * Copyright 2004,2006,2007,2008,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -58,7 +58,7 @@ gr_make_wavfile_sink(const char *filename, unsigned int sample_rate, int bits_per_sample) { - return gr_wavfile_sink_sptr (new gr_wavfile_sink (filename, + return gnuradio::get_initial_sptr(new gr_wavfile_sink (filename, n_channels, sample_rate, bits_per_sample)); diff --git a/gnuradio-core/src/lib/io/gr_wavfile_source.cc b/gnuradio-core/src/lib/io/gr_wavfile_source.cc index 900f84efd..d00dd3028 100644 --- a/gnuradio-core/src/lib/io/gr_wavfile_source.cc +++ b/gnuradio-core/src/lib/io/gr_wavfile_source.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008 Free Software Foundation, Inc. + * Copyright 2004,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -52,7 +52,7 @@ gr_wavfile_source_sptr gr_make_wavfile_source (const char *filename, bool repeat) { - return gr_wavfile_source_sptr (new gr_wavfile_source (filename, repeat)); + return gnuradio::get_initial_sptr(new gr_wavfile_source (filename, repeat)); } diff --git a/gnuradio-core/src/lib/io/gri_logger.cc b/gnuradio-core/src/lib/io/gri_logger.cc deleted file mode 100644 index 473a7c5ed..000000000 --- a/gnuradio-core/src/lib/io/gri_logger.cc +++ /dev/null @@ -1,178 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#if 0 // This needs reimplementation with boost threads and synchronization - -#include <gri_logger.h> -#include <stdio.h> -#include <stdarg.h> -#include <stdexcept> -#include <boost/weak_ptr.hpp> -#include <string.h> - - -/* - * This class creates the thread that reads from the ringbuffer and - * and writes to the file. This is opaque to the user. - */ -class gri_log_poster : public omni_thread -{ - FILE *d_fp; - gr_buffer_sptr d_writer; - gr_buffer_reader_sptr d_reader; - omni_semaphore d_ringbuffer_ready; - volatile bool d_time_to_die; - volatile bool d_writer_overrun; - - virtual void* run_undetached(void * arg); - -public: - gri_log_poster(const char *filename); - ~gri_log_poster(); - - void kill() { d_time_to_die = true; post(); } - gr_buffer_sptr writer() const { return d_writer; } - void post() { d_ringbuffer_ready.post(); } - void note_writer_overrun() { d_writer_overrun = true; } -}; - -gri_log_poster::gri_log_poster(const char *filename) - : omni_thread(), - d_ringbuffer_ready(1, 1), // binary semaphore - d_time_to_die(false), - d_writer_overrun(false) -{ - if ((d_fp = fopen(filename, "w")) == 0){ - perror (filename); - throw std::runtime_error("can't open file"); - } - - // Create a 1MB buffer. - d_writer = gr_make_buffer(1 * 1024 * 1024, sizeof(unsigned char)); - d_reader = gr_buffer_add_reader(d_writer, 0); - - start_undetached(); // start the thread -} - -gri_log_poster::~gri_log_poster() -{ - if (d_fp != 0){ - fclose(d_fp); - d_fp = 0; - } -} - -/* - * This is the body of the logging thread. - */ -void * -gri_log_poster::run_undetached(void *arg) -{ - int nbytes; - - //fprintf(stderr, "Enter: run_undetached!\n"); - - while (!d_time_to_die){ - while ((nbytes = d_reader->items_available()) > 0){ - fwrite(d_reader->read_pointer(), 1, nbytes, d_fp); - d_reader->update_read_pointer(nbytes); - } - fflush(d_fp); - d_ringbuffer_ready.wait(); - - if (d_writer_overrun){ - fputs(">>>>> gri_logger: writer overrun. Info lost <<<<<\n", d_fp); - d_writer_overrun = false; - } - } - - // fprintf(stderr, "Exit: run_undetached!\n"); - return 0; -} - -// ------------------------------------------------------------------------ - -static boost::weak_ptr<gri_logger> s_singleton; // weak pointer IQ test ;-) -static omni_mutex s_singleton_mutex; - -gri_logger_sptr -gri_logger::singleton() -{ - omni_mutex_lock l(s_singleton_mutex); - gri_logger_sptr r; - - if (r = s_singleton.lock()) - return r; - - r = gri_logger_sptr(new gri_logger("gri_logger.log")); - s_singleton = r; - return r; -} - - -gri_logger::gri_logger(const char *filename) -{ - d_poster = new gri_log_poster(filename); -} - -gri_logger::~gri_logger() -{ - d_poster->kill(); - d_poster->join(NULL); -} - -void -gri_logger::write(const void *buf, size_t count) -{ - omni_mutex_lock l(d_write_mutex); - gr_buffer_sptr writer = d_poster->writer(); - - // either write it all, or drop it on the ground - if (count <= (size_t) writer->space_available()){ - memcpy(writer->write_pointer(), buf, count); - writer->update_write_pointer(count); - d_poster->post(); - } - else { - d_poster->note_writer_overrun(); - } -} - -void -gri_logger::printf(const char *format, ...) -{ - va_list ap; - char buf[4096]; - int n; - - va_start(ap, format); - n = vsnprintf(buf, sizeof(buf), format, ap); - va_end(ap); - if (n > -1 && n < (ssize_t) sizeof(buf)) - write(buf, n); -} - -#endif diff --git a/gnuradio-core/src/lib/io/gri_logger.h b/gnuradio-core/src/lib/io/gri_logger.h deleted file mode 100644 index 0a1414540..000000000 --- a/gnuradio-core/src/lib/io/gri_logger.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ -#ifndef INCLUDED_GRI_LOGGER_H -#define INCLUDED_GRI_LOGGER_H - -#if 0 // This needs reimplementation with boost threads and synchronization - -#include <stddef.h> -#include <gnuradio/omnithread.h> -#include <gr_buffer.h> - -class gri_log_poster; -class gri_logger; -typedef boost::shared_ptr<gri_logger> gri_logger_sptr; - - -/*! - * \brief non-blocking logging to a file. - * - * In reality, this may block, but only for a bounded time. - * Trust me, it's safe to use from portaudio and JACK callbacks. - */ -class gri_logger -{ - gri_log_poster *d_poster; - omni_mutex d_write_mutex; - -public: - static gri_logger_sptr singleton(); - - gri_logger(const char *filename); - ~gri_logger(); - - void write(const void *buf, size_t count); - void printf(const char *format, ...); -}; - -#endif - -#endif /* INCLUDED_GRI_LOGGER_H */ diff --git a/gnuradio-core/src/lib/runtime/Makefile.am b/gnuradio-core/src/lib/runtime/Makefile.am index b0e804277..abd789a1d 100644 --- a/gnuradio-core/src/lib/runtime/Makefile.am +++ b/gnuradio-core/src/lib/runtime/Makefile.am @@ -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_sptr_magic.cc b/gnuradio-core/src/lib/runtime/gr_sptr_magic.cc index 96ffae85f..b0351248c 100644 --- a/gnuradio-core/src/lib/runtime/gr_sptr_magic.cc +++ b/gnuradio-core/src/lib/runtime/gr_sptr_magic.cc @@ -39,7 +39,7 @@ namespace gnuradio { detail::sptr_magic::create_and_stash_initial_sptr(gr_hier_block2 *p) { gr_basic_block_sptr sptr(p); - gruel::scoped_lock guard(); + gruel::scoped_lock guard(s_mutex); s_map.insert(sptr_map::value_type(static_cast<gr_basic_block *>(p), sptr)); } @@ -60,7 +60,7 @@ namespace gnuradio { * p is a subclass of gr_hier_block2, thus we've already created the shared pointer * and stashed it away. Fish it out and return it. */ - gruel::scoped_lock guard(); + gruel::scoped_lock guard(s_mutex); sptr_map::iterator pos = s_map.find(static_cast<gr_basic_block *>(p)); if (pos == s_map.end()) throw std::invalid_argument("gr_sptr_magic: invalid pointer!"); 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 000000000..680e59ca4 --- /dev/null +++ b/gnuradio-core/src/lib/runtime/gr_unittests.h @@ -0,0 +1,70 @@ +/* -*- 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 <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <unistd.h> + + +#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 *grpath, 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 (grpath, 0750); + gr_mkdir (path, 0750); +} + +static void +get_unittest_path (const char *filename, char *fullpath, size_t pathsize) +{ + char path[200]; + char grpath[200]; + snprintf (grpath, sizeof(grpath), "%s/.gnuradio", getenv ("HOME")); + snprintf (path, sizeof(path), "%s/unittests", grpath); + snprintf (fullpath, pathsize, "%s/%s", path, filename); + + ensure_unittest_path(grpath, path); +} + diff --git a/gnuradio-core/src/python/gnuradio/Makefile.am b/gnuradio-core/src/python/gnuradio/Makefile.am index f0516f2fd..a3f3518de 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/gr/Makefile.am b/gnuradio-core/src/python/gnuradio/gr/Makefile.am index 3aff89ee7..341f58812 100644 --- a/gnuradio-core/src/python/gnuradio/gr/Makefile.am +++ b/gnuradio-core/src/python/gnuradio/gr/Makefile.am @@ -1,5 +1,5 @@ # -# Copyright 2004,2005,2006,2008 Free Software Foundation, Inc. +# Copyright 2004,2005,2006,2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -97,4 +97,5 @@ noinst_PYTHON = \ qa_unpack_k_bits.py \ qa_repeat.py \ qa_scrambler.py \ + qa_udp_sink_source.py \ qa_vector_sink_source.py 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 2fa97fad8..8fb70fb3f 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 215e0cace..90056e09f 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 bb3ddb11e..c55d191e0 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 2e16d879b..a9db3295a 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 29b9796cd..b8b718a09 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 ee9bae65b..8cfb60099 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 ac17aff29..ac5b53b57 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 b1ab8f546..79e9cd092 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 10f366879..76627247b 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 13d2840a0..27e1802e0 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 7f9f72a7b..e8ee480cc 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 a436c6ad6..b3575f4e6 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 8835cba5a..7cad0ae72 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 04c0e2a49..97e9e329a 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 385ffa519..5ac115e20 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 b0dc47061..caf3959f4 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 64bbe45ce..a91409537 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 412c4c48b..98d80fbb0 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 d4106ee47..b3124ad29 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 b92f143d5..a25c65e5c 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 4466e8aab..c9ba54164 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 53d1a89ba..829185c34 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 b506e3ed4..429e57c32 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 fc211657f..1665d9dd5 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 d5dc595c9..dcb3d867e 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 b7a60597b..aae233b56 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 cc336a4d1..924a0fb52 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 817ba9408..2235f28b1 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 833285077..0e522c16b 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 fbd601e34..501a89f84 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 3e0b6c5fc..1320d0ec5 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 ea326ce40..9901b71b7 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 cc25d180e..2f0bbe33d 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 91ddf7cd7..7d29a9507 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 0171c93db..5aa231623 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 cb6c4c33c..e7f2778d1 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 646f495c4..58c5062a5 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 4dca67b22..5a2e6a0d2 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 f8ed739a9..4a575f5d6 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 d45560d3c..d69f5ca5b 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 b1b3a971d..8833f755b 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 533f4f051..a6683c5c3 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 4a109663c..8e4a0eefa 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 ac9c1844e..5225a9a3b 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 9cafa61e3..c40a885a8 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 01d01bde0..fbdabb4cb 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 f8bf4b121..3bd6160df 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 64e751189..32ecc3776 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 1ecc7ead3..2b1429980 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 aecf49293..241d8ec2a 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 058890c4f..4bb58038f 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 8ad0a9bb2..1d2e6595c 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 865c7c906..47b4948ba 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 106e97314..de2d8fc95 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 8a76f8144..7d6ddf81b 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 new file mode 100755 index 000000000..097e394c9 --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/gr/qa_udp_sink_source.py @@ -0,0 +1,99 @@ +#!/usr/bin/env python +# +# Copyright 2008,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, gr_unittest +from threading import Timer + +class test_udp_sink_source(gr_unittest.TestCase): + + def setUp(self): + self.tb_snd = gr.top_block() + self.tb_rcv = gr.top_block() + + def tearDown(self): + self.tb_rcv = None + self.tb_snd = None + + def test_001(self): + port = 65500 + + n_data = 16 + src_data = [float(x) for x in range(n_data)] + expected_result = tuple(src_data) + src = gr.vector_source_f(src_data) + udp_snd = gr.udp_sink( gr.sizeof_float, 'localhost', port ) + self.tb_snd.connect( src, udp_snd ) + + udp_rcv = gr.udp_source( gr.sizeof_float, 'localhost', port ) + dst = gr.vector_sink_f() + self.tb_rcv.connect( udp_rcv, dst ) + + self.tb_rcv.start() + self.tb_snd.run() + udp_snd.disconnect() + self.timeout = False + q = Timer(3.0,self.stop_rcv) + q.start() + self.tb_rcv.wait() + q.cancel() + + result_data = dst.data() + self.assertEqual(expected_result, result_data) + self.assert_(not self.timeout) + + def test_002(self): + udp_rcv = gr.udp_source( gr.sizeof_float, '0.0.0.0', 0, eof=False ) + rcv_port = udp_rcv.get_port() + + udp_snd = gr.udp_sink( gr.sizeof_float, '127.0.0.1', 65500 ) + udp_snd.connect( 'localhost', rcv_port ) + + n_data = 16 + src_data = [float(x) for x in range(n_data)] + expected_result = tuple(src_data) + src = gr.vector_source_f(src_data) + dst = gr.vector_sink_f() + + self.tb_snd.connect( src, udp_snd ) + self.tb_rcv.connect( udp_rcv, dst ) + + self.tb_rcv.start() + self.tb_snd.run() + udp_snd.disconnect() + self.timeout = False + q = Timer(3.0,self.stop_rcv) + q.start() + self.tb_rcv.wait() + q.cancel() + + result_data = dst.data() + self.assertEqual(expected_result, result_data) + self.assert_(self.timeout) # source ignores EOF? + + def stop_rcv(self): + self.timeout = True + self.tb_rcv.stop() + #print "tb_rcv stopped by Timer" + +if __name__ == '__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 edb263ade..d1faf9d9e 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 149c66903..5d8d85c7c 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 3ba5dfbce..d9f38e3f1 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 a48343c6b..50d484a76 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 @@ -106,6 +107,57 @@ 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 $HOME/.gnuradio/unittests/python + ''' + + # Run this is given a file name + if(filename is not None): + homepath = os.getenv("HOME") + basepath = homepath + "/.gnuradio" + path = homepath + "/.gnuradio/unittests/python" + + xmlrunner = None + if os.path.exists(basepath): + # only proceed if $HOME/.gnuradio 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 000000000..ded77f5f3 --- /dev/null +++ b/gnuradio-core/src/python/gnuradio/gr_xmlrunner.py @@ -0,0 +1,385 @@ +""" +XML Test Runner for PyUnit +""" + +# Written by Sebastian Rittau <srittau@jroger.in-berlin.de> 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(' <testcase classname="%(class)s" name="%(method)s" time="%(time).4f">' % \ + { + "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('</testcase>\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(' </%s>\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('<testsuite errors="%(e)d" failures="%(f)d" ' % \ + { "e": len(self.errors), "f": len(self.failures) }) + stream.write('name="%(n)s" tests="%(t)d" time="%(time).3f">\n' % \ + { + "n": self._test_name, + "t": self.testsRun, + "time": time_taken, + }) + for info in self._tests: + info.print_report(stream) + stream.write(' <system-out><![CDATA[%s]]></system-out>\n' % out) + stream.write(' <system-err><![CDATA[%s]]></system-err>\n' % err) + stream.write('</testsuite>\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-<module>.<class>.xml in the + current working directory (if not overridden with the path property), + where <module> and <class> 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('<?xml version="1.0" encoding="utf-8"?>\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)<failure (.*?)>.*?</failure>', r'<failure \1>Foobar</failure>', got) + got = re.sub(r'(?s)<error (.*?)>.*?</error>', r'<error \1>Foobar</error>', 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, """<testsuite errors="0" failures="0" name="unittest.TestSuite" tests="0" time="0.000"> + <system-out><![CDATA[]]></system-out> + <system-err><![CDATA[]]></system-err> +</testsuite> +""") + + 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, """<testsuite errors="0" failures="0" name="unittest.TestSuite" tests="1" time="0.000"> + <testcase classname="__main__.TestTest" name="test_foo" time="0.000"></testcase> + <system-out><![CDATA[]]></system-out> + <system-err><![CDATA[]]></system-err> +</testsuite> +""") + + 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, """<testsuite errors="0" failures="1" name="unittest.TestSuite" tests="1" time="0.000"> + <testcase classname="__main__.TestTest" name="test_foo" time="0.000"> + <failure type="exceptions.AssertionError">Foobar</failure> + </testcase> + <system-out><![CDATA[]]></system-out> + <system-err><![CDATA[]]></system-err> +</testsuite> +""") + + 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, """<testsuite errors="1" failures="0" name="unittest.TestSuite" tests="1" time="0.000"> + <testcase classname="__main__.TestTest" name="test_foo" time="0.000"> + <error type="exceptions.IndexError">Foobar</error> + </testcase> + <system-out><![CDATA[]]></system-out> + <system-err><![CDATA[]]></system-err> +</testsuite> +""") + + 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, """<testsuite errors="0" failures="0" name="unittest.TestSuite" tests="1" time="0.000"> + <testcase classname="__main__.TestTest" name="test_foo" time="0.000"></testcase> + <system-out><![CDATA[Test +]]></system-out> + <system-err><![CDATA[]]></system-err> +</testsuite> +""") + + 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, """<testsuite errors="0" failures="0" name="unittest.TestSuite" tests="1" time="0.000"> + <testcase classname="__main__.TestTest" name="test_foo" time="0.000"></testcase> + <system-out><![CDATA[]]></system-out> + <system-err><![CDATA[Test +]]></system-err> +</testsuite> +""") + + 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/python/gnuradio/gruimpl/hexint.py b/gnuradio-core/src/python/gnuradio/gruimpl/hexint.py index 8d46e8192..f2808c448 100644 --- a/gnuradio-core/src/python/gnuradio/gruimpl/hexint.py +++ b/gnuradio-core/src/python/gnuradio/gruimpl/hexint.py @@ -30,3 +30,15 @@ def hexint(mask): if mask >= 2**31: return int(mask-2**32) return mask + +def hexshort(mask): + """ + Convert unsigned masks into signed shorts. + + This allows us to use hex constants like 0x8000 when talking to + our hardware and not get screwed by them getting treated as python + longs. + """ + if mask >= 2**15: + return int(mask-2**16) + return mask diff --git a/gnuradio-core/src/tests/test_all.cc b/gnuradio-core/src/tests/test_all.cc index 6dc1a26f8..17ee32f34 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 <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> +#include <gr_unittests.h> #include <qa_runtime.h> #include <qa_general.h> #include <qa_filter.h> @@ -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 f744d76e6..51642f81a 100644 --- a/gnuradio-core/src/tests/test_atsc.cc +++ b/gnuradio-core/src/tests/test_atsc.cc @@ -21,16 +21,24 @@ */ #include <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> + +#include <gr_unittests.h> #include <qa_atsc.h> 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 56e945238..90fe66c2f 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 <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> + +#include <gr_unittests.h> #include <qa_filter.h> 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_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 063e2ee45..16ee9c3ad 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 <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> + +#include <gr_unittests.h> #include <qa_general.h> 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 8549f2a9b..c7983a23e 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 <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> + +#include <gr_unittests.h> #include <qa_runtime.h> 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/python/digital/benchmark_qt_loopback.py b/gnuradio-examples/python/digital/benchmark_qt_loopback.py index 35cc2e376..0ae0e4e51 100755 --- a/gnuradio-examples/python/digital/benchmark_qt_loopback.py +++ b/gnuradio-examples/python/digital/benchmark_qt_loopback.py @@ -167,7 +167,10 @@ class dialog_box(QtGui.QMainWindow): # Pull these globals in from the main thread global n_rcvd, n_right, pktno - per = float(n_rcvd - n_right)/float(pktno) + if(pktno > 0): + per = float(n_rcvd - n_right)/float(pktno) + else: + per = 0 self.gui.pktsRcvdEdit.setText(QtCore.QString("%1").arg(n_rcvd)) self.gui.pktsCorrectEdit.setText(QtCore.QString("%1").arg(n_right)) self.gui.perEdit.setText(QtCore.QString("%1").arg(per)) @@ -186,6 +189,9 @@ class my_top_block(gr.top_block): self._sample_rate = options.sample_rate + if(options.samples_per_symbol is None): + options.samples_per_symbol = 2 + channelon = True; self.gui_on = options.gui @@ -202,7 +208,7 @@ class my_top_block(gr.top_block): self.rxpath = receive_path(demod_class, rx_callback, options) # FIXME: do better exposure to lower issues for control - self._timing_gain_alpha = self.rxpath.packet_receiver._demodulator._timing_alpha + self._timing_gain_alpha = self.rxpath.packet_receiver._demodulator._mm_gain_mu self._alpha = self.rxpath.packet_receiver._demodulator._costas_alpha if channelon: @@ -229,10 +235,10 @@ class my_top_block(gr.top_block): fftsize = 2048 self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - 0, 1, + 0, self._sample_rate, "Tx", True, True, False, True, True) self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, - 0, 1, + 0, self._sample_rate, "Rx", True, True, False, True, True) self.snk_tx.set_frequency_axis(-80, 0) @@ -240,14 +246,11 @@ class my_top_block(gr.top_block): # Connect to the QT sinks # FIXME: make better exposure to receiver from rxpath - self.freq_recov = self.rxpath.packet_receiver._demodulator.clock_recov - self.time_recov = self.rxpath.packet_receiver._demodulator.time_recov - self.freq_recov.set_alpha(0) - self.freq_recov.set_beta(0) - self.time_recov.set_alpha(2) - self.time_recov.set_beta(0.02) + self.receiver = self.rxpath.packet_receiver._demodulator.receiver + self.receiver.set_alpha(2) + self.receiver.set_beta(0.02) self.connect(self.channel, self.snk_tx) - self.connect(self.time_recov, self.snk_rx) + self.connect(self.receiver, self.snk_rx) pyTxQt = self.snk_tx.pyqwidget() pyTx = sip.wrapinstance(pyTxQt, QtGui.QWidget) @@ -312,7 +315,7 @@ class my_top_block(gr.top_block): def set_rx_timing_gain_alpha(self, gain): self._timing_gain_alpha = gain - self.time_recov.set_gain(self._timing_gain_alpha) + self.receiver.set_gain_mu(self._timing_gain_alpha) def rx_alpha(self): return self._alpha @@ -323,8 +326,8 @@ class my_top_block(gr.top_block): def set_rx_alpha(self, alpha): self._alpha = alpha self.beta = .25 * self._alpha * self._alpha - #self.freq_recov.set_alpha(self._alpha) - #self.freq_recov.set_beta(self.beta) + self.receiver.set_alpha(self._alpha) + self.receiver.set_beta(self.beta) diff --git a/gnuradio-examples/python/digital/benchmark_qt_loopback2.py b/gnuradio-examples/python/digital/benchmark_qt_loopback2.py index 56c6c7f52..02ae4b25f 100755 --- a/gnuradio-examples/python/digital/benchmark_qt_loopback2.py +++ b/gnuradio-examples/python/digital/benchmark_qt_loopback2.py @@ -254,7 +254,7 @@ class my_top_block(gr.top_block): # FIXME: do better exposure to lower issues for control self._gain_clock = self.rxpath.packet_receiver._demodulator._timing_alpha - self._gain_phase = self.rxpath.packet_receiver._demodulator._costas_alpha + self._gain_phase = self.rxpath.packet_receiver._demodulator._phase_alpha self._gain_freq = self.rxpath.packet_receiver._demodulator._freq_alpha if channelon: diff --git a/gnuradio-examples/python/digital/qt_digital_window.py b/gnuradio-examples/python/digital/qt_digital_window.py index 6e0f25212..b47ed0c2b 100644 --- a/gnuradio-examples/python/digital/qt_digital_window.py +++ b/gnuradio-examples/python/digital/qt_digital_window.py @@ -2,8 +2,8 @@ # Form implementation generated from reading ui file 'qt_digital_window.ui' # -# Created: Tue Oct 6 11:27:37 2009 -# by: PyQt4 UI code generator 4.4.4 +# Created: Tue May 11 20:58:35 2010 +# by: PyQt4 UI code generator 4.6.1 # # WARNING! All changes made in this file will be lost! @@ -12,63 +12,58 @@ from PyQt4 import QtCore, QtGui class Ui_DigitalWindow(object): def setupUi(self, DigitalWindow): DigitalWindow.setObjectName("DigitalWindow") - DigitalWindow.resize(1019, 754) + DigitalWindow.resize(1059, 754) self.centralwidget = QtGui.QWidget(DigitalWindow) self.centralwidget.setObjectName("centralwidget") - self.gridLayout = QtGui.QGridLayout(self.centralwidget) - self.gridLayout.setObjectName("gridLayout") - self.verticalLayout_3 = QtGui.QVBoxLayout() - self.verticalLayout_3.setObjectName("verticalLayout_3") - self.rxBox = QtGui.QGroupBox(self.centralwidget) + self.verticalLayout_4 = QtGui.QVBoxLayout(self.centralwidget) + self.verticalLayout_4.setObjectName("verticalLayout_4") + self.sinkLayout = QtGui.QHBoxLayout() + self.sinkLayout.setObjectName("sinkLayout") + self.verticalLayout_4.addLayout(self.sinkLayout) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.verticalLayout_2 = QtGui.QVBoxLayout() + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.sysBox = QtGui.QGroupBox(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.rxBox.sizePolicy().hasHeightForWidth()) - self.rxBox.setSizePolicy(sizePolicy) - self.rxBox.setMinimumSize(QtCore.QSize(180, 90)) - self.rxBox.setMaximumSize(QtCore.QSize(180, 16777215)) - self.rxBox.setObjectName("rxBox") - self.formLayoutWidget_3 = QtGui.QWidget(self.rxBox) - self.formLayoutWidget_3.setGeometry(QtCore.QRect(10, 20, 141, 61)) - self.formLayoutWidget_3.setObjectName("formLayoutWidget_3") - self.formLayout_3 = QtGui.QFormLayout(self.formLayoutWidget_3) - self.formLayout_3.setSizeConstraint(QtGui.QLayout.SetFixedSize) - self.formLayout_3.setObjectName("formLayout_3") - self.gainMuLabel = QtGui.QLabel(self.formLayoutWidget_3) - self.gainMuLabel.setObjectName("gainMuLabel") - self.formLayout_3.setWidget(0, QtGui.QFormLayout.LabelRole, self.gainMuLabel) - self.alphaLabel = QtGui.QLabel(self.formLayoutWidget_3) - self.alphaLabel.setObjectName("alphaLabel") - self.formLayout_3.setWidget(1, QtGui.QFormLayout.LabelRole, self.alphaLabel) - self.gainMuEdit = QtGui.QLineEdit(self.formLayoutWidget_3) - self.gainMuEdit.setMinimumSize(QtCore.QSize(60, 0)) - self.gainMuEdit.setMaximumSize(QtCore.QSize(80, 16777215)) - self.gainMuEdit.setObjectName("gainMuEdit") - self.formLayout_3.setWidget(0, QtGui.QFormLayout.FieldRole, self.gainMuEdit) - self.alphaEdit = QtGui.QLineEdit(self.formLayoutWidget_3) - self.alphaEdit.setMinimumSize(QtCore.QSize(60, 0)) - self.alphaEdit.setMaximumSize(QtCore.QSize(80, 16777215)) - self.alphaEdit.setObjectName("alphaEdit") - self.formLayout_3.setWidget(1, QtGui.QFormLayout.FieldRole, self.alphaEdit) - self.verticalLayout_3.addWidget(self.rxBox) - spacerItem = QtGui.QSpacerItem(20, 30, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - self.verticalLayout_3.addItem(spacerItem) - self.gridLayout.addLayout(self.verticalLayout_3, 2, 2, 1, 1) - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName("verticalLayout") - self.pauseButton = QtGui.QPushButton(self.centralwidget) - self.pauseButton.setMinimumSize(QtCore.QSize(80, 0)) - self.pauseButton.setMaximumSize(QtCore.QSize(80, 16777215)) - self.pauseButton.setObjectName("pauseButton") - self.verticalLayout.addWidget(self.pauseButton) - spacerItem1 = QtGui.QSpacerItem(20, 60, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - self.verticalLayout.addItem(spacerItem1) - self.closeButton = QtGui.QPushButton(self.centralwidget) - self.closeButton.setMinimumSize(QtCore.QSize(80, 0)) - self.closeButton.setMaximumSize(QtCore.QSize(80, 16777215)) - self.closeButton.setObjectName("closeButton") - self.verticalLayout.addWidget(self.closeButton) - self.gridLayout.addLayout(self.verticalLayout, 2, 5, 1, 1) + sizePolicy.setHeightForWidth(self.sysBox.sizePolicy().hasHeightForWidth()) + self.sysBox.setSizePolicy(sizePolicy) + self.sysBox.setMinimumSize(QtCore.QSize(240, 60)) + self.sysBox.setMaximumSize(QtCore.QSize(240, 16777215)) + self.sysBox.setObjectName("sysBox") + self.formLayoutWidget = QtGui.QWidget(self.sysBox) + self.formLayoutWidget.setGeometry(QtCore.QRect(10, 20, 211, 31)) + self.formLayoutWidget.setObjectName("formLayoutWidget") + self.formLayout = QtGui.QFormLayout(self.formLayoutWidget) + self.formLayout.setSizeConstraint(QtGui.QLayout.SetFixedSize) + self.formLayout.setVerticalSpacing(20) + self.formLayout.setObjectName("formLayout") + self.sampleRateEdit = QtGui.QLineEdit(self.formLayoutWidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.sampleRateEdit.sizePolicy().hasHeightForWidth()) + self.sampleRateEdit.setSizePolicy(sizePolicy) + self.sampleRateEdit.setMinimumSize(QtCore.QSize(60, 26)) + self.sampleRateEdit.setMaximumSize(QtCore.QSize(80, 26)) + self.sampleRateEdit.setObjectName("sampleRateEdit") + self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.sampleRateEdit) + self.sampleRateLabel = QtGui.QLabel(self.formLayoutWidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.sampleRateLabel.sizePolicy().hasHeightForWidth()) + self.sampleRateLabel.setSizePolicy(sizePolicy) + self.sampleRateLabel.setMinimumSize(QtCore.QSize(0, 20)) + self.sampleRateLabel.setMaximumSize(QtCore.QSize(16777215, 20)) + self.sampleRateLabel.setObjectName("sampleRateLabel") + self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.sampleRateLabel) + self.verticalLayout_2.addWidget(self.sysBox) + spacerItem = QtGui.QSpacerItem(20, 60, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) + self.verticalLayout_2.addItem(spacerItem) + self.horizontalLayout.addLayout(self.verticalLayout_2) self.channelModeBox = QtGui.QGroupBox(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) @@ -109,49 +104,39 @@ class Ui_DigitalWindow(object): self.timeEdit.setMaximumSize(QtCore.QSize(80, 16777215)) self.timeEdit.setObjectName("timeEdit") self.formLayout_2.setWidget(2, QtGui.QFormLayout.FieldRole, self.timeEdit) - self.gridLayout.addWidget(self.channelModeBox, 2, 1, 1, 1) - self.verticalLayout_2 = QtGui.QVBoxLayout() - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.sysBox = QtGui.QGroupBox(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.sysBox.sizePolicy().hasHeightForWidth()) - self.sysBox.setSizePolicy(sizePolicy) - self.sysBox.setMinimumSize(QtCore.QSize(240, 60)) - self.sysBox.setMaximumSize(QtCore.QSize(240, 16777215)) - self.sysBox.setObjectName("sysBox") - self.formLayoutWidget = QtGui.QWidget(self.sysBox) - self.formLayoutWidget.setGeometry(QtCore.QRect(10, 20, 211, 31)) - self.formLayoutWidget.setObjectName("formLayoutWidget") - self.formLayout = QtGui.QFormLayout(self.formLayoutWidget) - self.formLayout.setSizeConstraint(QtGui.QLayout.SetFixedSize) - self.formLayout.setVerticalSpacing(20) - self.formLayout.setObjectName("formLayout") - self.sampleRateEdit = QtGui.QLineEdit(self.formLayoutWidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.sampleRateEdit.sizePolicy().hasHeightForWidth()) - self.sampleRateEdit.setSizePolicy(sizePolicy) - self.sampleRateEdit.setMinimumSize(QtCore.QSize(60, 26)) - self.sampleRateEdit.setMaximumSize(QtCore.QSize(80, 26)) - self.sampleRateEdit.setObjectName("sampleRateEdit") - self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.sampleRateEdit) - self.sampleRateLabel = QtGui.QLabel(self.formLayoutWidget) + self.horizontalLayout.addWidget(self.channelModeBox) + self.rxBox = QtGui.QGroupBox(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.sampleRateLabel.sizePolicy().hasHeightForWidth()) - self.sampleRateLabel.setSizePolicy(sizePolicy) - self.sampleRateLabel.setMinimumSize(QtCore.QSize(0, 20)) - self.sampleRateLabel.setMaximumSize(QtCore.QSize(16777215, 20)) - self.sampleRateLabel.setObjectName("sampleRateLabel") - self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.sampleRateLabel) - self.verticalLayout_2.addWidget(self.sysBox) - spacerItem2 = QtGui.QSpacerItem(20, 60, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - self.verticalLayout_2.addItem(spacerItem2) - self.gridLayout.addLayout(self.verticalLayout_2, 2, 0, 1, 1) + sizePolicy.setHeightForWidth(self.rxBox.sizePolicy().hasHeightForWidth()) + self.rxBox.setSizePolicy(sizePolicy) + self.rxBox.setMinimumSize(QtCore.QSize(220, 130)) + self.rxBox.setMaximumSize(QtCore.QSize(180, 16777215)) + self.rxBox.setObjectName("rxBox") + self.formLayoutWidget_3 = QtGui.QWidget(self.rxBox) + self.formLayoutWidget_3.setGeometry(QtCore.QRect(10, 20, 201, 101)) + self.formLayoutWidget_3.setObjectName("formLayoutWidget_3") + self.formLayout_3 = QtGui.QFormLayout(self.formLayoutWidget_3) + self.formLayout_3.setSizeConstraint(QtGui.QLayout.SetFixedSize) + self.formLayout_3.setObjectName("formLayout_3") + self.gainMuLabel = QtGui.QLabel(self.formLayoutWidget_3) + self.gainMuLabel.setObjectName("gainMuLabel") + self.formLayout_3.setWidget(0, QtGui.QFormLayout.LabelRole, self.gainMuLabel) + self.alphaLabel = QtGui.QLabel(self.formLayoutWidget_3) + self.alphaLabel.setObjectName("alphaLabel") + self.formLayout_3.setWidget(1, QtGui.QFormLayout.LabelRole, self.alphaLabel) + self.gainMuEdit = QtGui.QLineEdit(self.formLayoutWidget_3) + self.gainMuEdit.setMinimumSize(QtCore.QSize(60, 0)) + self.gainMuEdit.setMaximumSize(QtCore.QSize(80, 16777215)) + self.gainMuEdit.setObjectName("gainMuEdit") + self.formLayout_3.setWidget(0, QtGui.QFormLayout.FieldRole, self.gainMuEdit) + self.alphaEdit = QtGui.QLineEdit(self.formLayoutWidget_3) + self.alphaEdit.setMinimumSize(QtCore.QSize(60, 0)) + self.alphaEdit.setMaximumSize(QtCore.QSize(80, 16777215)) + self.alphaEdit.setObjectName("alphaEdit") + self.formLayout_3.setWidget(1, QtGui.QFormLayout.FieldRole, self.alphaEdit) + self.horizontalLayout.addWidget(self.rxBox) self.rxBox_2 = QtGui.QGroupBox(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) @@ -162,7 +147,7 @@ class Ui_DigitalWindow(object): self.rxBox_2.setMaximumSize(QtCore.QSize(265, 125)) self.rxBox_2.setObjectName("rxBox_2") self.formLayoutWidget_4 = QtGui.QWidget(self.rxBox_2) - self.formLayoutWidget_4.setGeometry(QtCore.QRect(10, 20, 181, 92)) + self.formLayoutWidget_4.setGeometry(QtCore.QRect(10, 20, 201, 91)) self.formLayoutWidget_4.setObjectName("formLayoutWidget_4") self.formLayout_4 = QtGui.QFormLayout(self.formLayoutWidget_4) self.formLayout_4.setSizeConstraint(QtGui.QLayout.SetFixedSize) @@ -191,31 +176,28 @@ class Ui_DigitalWindow(object): self.perEdit.setMaximumSize(QtCore.QSize(80, 16777215)) self.perEdit.setObjectName("perEdit") self.formLayout_4.setWidget(2, QtGui.QFormLayout.FieldRole, self.perEdit) - self.gridLayout.addWidget(self.rxBox_2, 2, 3, 1, 1) - spacerItem3 = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.gridLayout.addItem(spacerItem3, 2, 4, 1, 1) - self.verticalLayout_5 = QtGui.QVBoxLayout() - self.verticalLayout_5.setObjectName("verticalLayout_5") - self.sinkFrame = QtGui.QFrame(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.sinkFrame.sizePolicy().hasHeightForWidth()) - self.sinkFrame.setSizePolicy(sizePolicy) - self.sinkFrame.setMinimumSize(QtCore.QSize(500, 550)) - self.sinkFrame.setFrameShape(QtGui.QFrame.StyledPanel) - self.sinkFrame.setFrameShadow(QtGui.QFrame.Raised) - self.sinkFrame.setObjectName("sinkFrame") - self.gridLayout_2 = QtGui.QGridLayout(self.sinkFrame) - self.gridLayout_2.setObjectName("gridLayout_2") - self.sinkLayout = QtGui.QHBoxLayout() - self.sinkLayout.setObjectName("sinkLayout") - self.gridLayout_2.addLayout(self.sinkLayout, 1, 0, 1, 1) - self.verticalLayout_5.addWidget(self.sinkFrame) - self.gridLayout.addLayout(self.verticalLayout_5, 0, 0, 1, 6) + self.horizontalLayout.addWidget(self.rxBox_2) + spacerItem1 = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem1) + self.verticalLayout = QtGui.QVBoxLayout() + self.verticalLayout.setObjectName("verticalLayout") + self.pauseButton = QtGui.QPushButton(self.centralwidget) + self.pauseButton.setMinimumSize(QtCore.QSize(80, 0)) + self.pauseButton.setMaximumSize(QtCore.QSize(80, 16777215)) + self.pauseButton.setObjectName("pauseButton") + self.verticalLayout.addWidget(self.pauseButton) + spacerItem2 = QtGui.QSpacerItem(20, 60, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) + self.verticalLayout.addItem(spacerItem2) + self.closeButton = QtGui.QPushButton(self.centralwidget) + self.closeButton.setMinimumSize(QtCore.QSize(80, 0)) + self.closeButton.setMaximumSize(QtCore.QSize(80, 16777215)) + self.closeButton.setObjectName("closeButton") + self.verticalLayout.addWidget(self.closeButton) + self.horizontalLayout.addLayout(self.verticalLayout) + self.verticalLayout_4.addLayout(self.horizontalLayout) DigitalWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(DigitalWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 1019, 25)) + self.menubar.setGeometry(QtCore.QRect(0, 0, 1059, 23)) self.menubar.setObjectName("menubar") self.menuFile = QtGui.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") @@ -237,21 +219,21 @@ class Ui_DigitalWindow(object): def retranslateUi(self, DigitalWindow): DigitalWindow.setWindowTitle(QtGui.QApplication.translate("DigitalWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) - self.rxBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.gainMuLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Gain mu", None, QtGui.QApplication.UnicodeUTF8)) - self.alphaLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Alpha", None, QtGui.QApplication.UnicodeUTF8)) - self.pauseButton.setText(QtGui.QApplication.translate("DigitalWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8)) - self.closeButton.setText(QtGui.QApplication.translate("DigitalWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) + self.sysBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "System Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.sampleRateLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Sample Rate (sps)", None, QtGui.QApplication.UnicodeUTF8)) self.channelModeBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Channel Model Parameters", None, QtGui.QApplication.UnicodeUTF8)) self.snrLabel.setText(QtGui.QApplication.translate("DigitalWindow", "SNR (dB)", None, QtGui.QApplication.UnicodeUTF8)) self.freqLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Frequency Offset (Hz)", None, QtGui.QApplication.UnicodeUTF8)) self.timeLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Timing Offset", None, QtGui.QApplication.UnicodeUTF8)) - self.sysBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "System Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.sampleRateLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Sample Rate (sps)", None, QtGui.QApplication.UnicodeUTF8)) + self.rxBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.gainMuLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Gain mu", None, QtGui.QApplication.UnicodeUTF8)) + self.alphaLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Alpha", None, QtGui.QApplication.UnicodeUTF8)) self.rxBox_2.setTitle(QtGui.QApplication.translate("DigitalWindow", "Received Packet Info", None, QtGui.QApplication.UnicodeUTF8)) self.pktsRcvdLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Packets Rcvd.", None, QtGui.QApplication.UnicodeUTF8)) self.pktsCorrectLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Packets Correct", None, QtGui.QApplication.UnicodeUTF8)) self.perLabel.setText(QtGui.QApplication.translate("DigitalWindow", "PER", None, QtGui.QApplication.UnicodeUTF8)) + self.pauseButton.setText(QtGui.QApplication.translate("DigitalWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8)) + self.closeButton.setText(QtGui.QApplication.translate("DigitalWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) self.menuFile.setTitle(QtGui.QApplication.translate("DigitalWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) self.actionExit.setText(QtGui.QApplication.translate("DigitalWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/gnuradio-examples/python/digital/qt_digital_window.ui b/gnuradio-examples/python/digital/qt_digital_window.ui index a0af196ed..4b3857d87 100644 --- a/gnuradio-examples/python/digital/qt_digital_window.ui +++ b/gnuradio-examples/python/digital/qt_digital_window.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>1019</width> + <width>1059</width> <height>754</height> </rect> </property> @@ -14,11 +14,124 @@ <string>MainWindow</string> </property> <widget class="QWidget" name="centralwidget"> - <layout class="QGridLayout" name="gridLayout"> - <item row="2" column="2"> - <layout class="QVBoxLayout" name="verticalLayout_3"> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <layout class="QHBoxLayout" name="sinkLayout"/> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> <item> - <widget class="QGroupBox" name="rxBox"> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QGroupBox" name="sysBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>240</width> + <height>60</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>240</width> + <height>16777215</height> + </size> + </property> + <property name="title"> + <string>System Parameters</string> + </property> + <widget class="QWidget" name="formLayoutWidget"> + <property name="geometry"> + <rect> + <x>10</x> + <y>20</y> + <width>211</width> + <height>31</height> + </rect> + </property> + <layout class="QFormLayout" name="formLayout"> + <property name="sizeConstraint"> + <enum>QLayout::SetFixedSize</enum> + </property> + <property name="verticalSpacing"> + <number>20</number> + </property> + <item row="0" column="1"> + <widget class="QLineEdit" name="sampleRateEdit"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>26</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>26</height> + </size> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="sampleRateLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>20</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string>Sample Rate (sps)</string> + </property> + </widget> + </item> + </layout> + </widget> + </widget> + </item> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>60</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> + <item> + <widget class="QGroupBox" name="channelModeBox"> <property name="sizePolicy"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> @@ -27,48 +140,67 @@ </property> <property name="minimumSize"> <size> - <width>180</width> - <height>90</height> + <width>245</width> + <height>130</height> </size> </property> <property name="maximumSize"> <size> - <width>180</width> + <width>245</width> <height>16777215</height> </size> </property> <property name="title"> - <string>Receiver Parameters</string> + <string>Channel Model Parameters</string> </property> - <widget class="QWidget" name="formLayoutWidget_3"> + <widget class="QWidget" name="formLayoutWidget_2"> <property name="geometry"> <rect> <x>10</x> <y>20</y> - <width>141</width> - <height>61</height> + <width>221</width> + <height>98</height> </rect> </property> - <layout class="QFormLayout" name="formLayout_3"> + <layout class="QFormLayout" name="formLayout_2"> <property name="sizeConstraint"> <enum>QLayout::SetFixedSize</enum> </property> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> + </property> <item row="0" column="0"> - <widget class="QLabel" name="gainMuLabel"> + <widget class="QLabel" name="snrLabel"> <property name="text"> - <string>Gain mu</string> + <string>SNR (dB)</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="snrEdit"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> </property> </widget> </item> <item row="1" column="0"> - <widget class="QLabel" name="alphaLabel"> + <widget class="QLabel" name="freqLabel"> <property name="text"> - <string>Alpha</string> + <string>Frequency Offset (Hz)</string> </property> </widget> </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="gainMuEdit"> + <item row="1" column="1"> + <widget class="QLineEdit" name="freqEdit"> <property name="minimumSize"> <size> <width>60</width> @@ -83,8 +215,15 @@ </property> </widget> </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="alphaEdit"> + <item row="2" column="0"> + <widget class="QLabel" name="timeLabel"> + <property name="text"> + <string>Timing Offset</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="timeEdit"> <property name="minimumSize"> <size> <width>60</width> @@ -101,200 +240,98 @@ </item> </layout> </widget> + <zorder>formLayoutWidget_2</zorder> + <zorder>sysBox</zorder> </widget> </item> <item> - <spacer name="verticalSpacer_4"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>30</height> - </size> - </property> - </spacer> - </item> - </layout> - </item> - <item row="2" column="5"> - <layout class="QVBoxLayout" name="verticalLayout"> - <item> - <widget class="QPushButton" name="pauseButton"> - <property name="minimumSize"> - <size> - <width>80</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>80</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Pause</string> - </property> - </widget> - </item> - <item> - <spacer name="verticalSpacer"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>60</height> - </size> + <widget class="QGroupBox" name="rxBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="closeButton"> <property name="minimumSize"> <size> - <width>80</width> - <height>0</height> + <width>220</width> + <height>130</height> </size> </property> <property name="maximumSize"> <size> - <width>80</width> + <width>180</width> <height>16777215</height> </size> </property> - <property name="text"> - <string>Close</string> + <property name="title"> + <string>Receiver Parameters</string> </property> + <widget class="QWidget" name="formLayoutWidget_3"> + <property name="geometry"> + <rect> + <x>10</x> + <y>20</y> + <width>201</width> + <height>101</height> + </rect> + </property> + <layout class="QFormLayout" name="formLayout_3"> + <property name="sizeConstraint"> + <enum>QLayout::SetFixedSize</enum> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="gainMuLabel"> + <property name="text"> + <string>Gain mu</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="alphaLabel"> + <property name="text"> + <string>Alpha</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="gainMuEdit"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="alphaEdit"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + </layout> + </widget> </widget> </item> - </layout> - </item> - <item row="2" column="1"> - <widget class="QGroupBox" name="channelModeBox"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>245</width> - <height>130</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>245</width> - <height>16777215</height> - </size> - </property> - <property name="title"> - <string>Channel Model Parameters</string> - </property> - <widget class="QWidget" name="formLayoutWidget_2"> - <property name="geometry"> - <rect> - <x>10</x> - <y>20</y> - <width>221</width> - <height>98</height> - </rect> - </property> - <layout class="QFormLayout" name="formLayout_2"> - <property name="sizeConstraint"> - <enum>QLayout::SetFixedSize</enum> - </property> - <property name="fieldGrowthPolicy"> - <enum>QFormLayout::AllNonFixedFieldsGrow</enum> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="snrLabel"> - <property name="text"> - <string>SNR (dB)</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="snrEdit"> - <property name="minimumSize"> - <size> - <width>60</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>80</width> - <height>16777215</height> - </size> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="freqLabel"> - <property name="text"> - <string>Frequency Offset (Hz)</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="freqEdit"> - <property name="minimumSize"> - <size> - <width>60</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>80</width> - <height>16777215</height> - </size> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="timeLabel"> - <property name="text"> - <string>Timing Offset</string> - </property> - </widget> - </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="timeEdit"> - <property name="minimumSize"> - <size> - <width>60</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>80</width> - <height>16777215</height> - </size> - </property> - </widget> - </item> - </layout> - </widget> - </widget> - </item> - <item row="2" column="0"> - <layout class="QVBoxLayout" name="verticalLayout_2"> <item> - <widget class="QGroupBox" name="sysBox"> + <widget class="QGroupBox" name="rxBox_2"> <property name="sizePolicy"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> @@ -303,79 +340,98 @@ </property> <property name="minimumSize"> <size> - <width>240</width> - <height>60</height> + <width>220</width> + <height>125</height> </size> </property> <property name="maximumSize"> <size> - <width>240</width> - <height>16777215</height> + <width>265</width> + <height>125</height> </size> </property> <property name="title"> - <string>System Parameters</string> + <string>Received Packet Info</string> </property> - <widget class="QWidget" name="formLayoutWidget"> + <widget class="QWidget" name="formLayoutWidget_4"> <property name="geometry"> <rect> <x>10</x> <y>20</y> - <width>211</width> - <height>31</height> + <width>201</width> + <height>91</height> </rect> </property> - <layout class="QFormLayout" name="formLayout"> + <layout class="QFormLayout" name="formLayout_4"> <property name="sizeConstraint"> <enum>QLayout::SetFixedSize</enum> </property> - <property name="verticalSpacing"> - <number>20</number> - </property> - <item row="0" column="1"> - <widget class="QLineEdit" name="sampleRateEdit"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item row="0" column="0"> + <widget class="QLabel" name="pktsRcvdLabel"> + <property name="text"> + <string>Packets Rcvd.</string> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="pktsCorrectLabel"> + <property name="text"> + <string>Packets Correct</string> </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="perLabel"> + <property name="text"> + <string>PER</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="pktsRcvdEdit"> <property name="minimumSize"> <size> <width>60</width> - <height>26</height> + <height>0</height> </size> </property> <property name="maximumSize"> <size> <width>80</width> - <height>26</height> + <height>16777215</height> </size> </property> </widget> </item> - <item row="0" column="0"> - <widget class="QLabel" name="sampleRateLabel"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> + <item row="1" column="1"> + <widget class="QLineEdit" name="pktsCorrectEdit"> <property name="minimumSize"> <size> - <width>0</width> - <height>20</height> + <width>60</width> + <height>0</height> </size> </property> <property name="maximumSize"> <size> - <width>16777215</width> - <height>20</height> + <width>80</width> + <height>16777215</height> </size> </property> - <property name="text"> - <string>Sample Rate (sps)</string> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="perEdit"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> </property> </widget> </item> @@ -384,85 +440,25 @@ </widget> </item> <item> - <spacer name="verticalSpacer_2"> + <spacer name="horizontalSpacer"> <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType"> - <enum>QSizePolicy::Fixed</enum> + <enum>Qt::Horizontal</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> - <height>60</height> + <height>20</height> </size> </property> </spacer> </item> - </layout> - </item> - <item row="2" column="3"> - <widget class="QGroupBox" name="rxBox_2"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>220</width> - <height>125</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>265</width> - <height>125</height> - </size> - </property> - <property name="title"> - <string>Received Packet Info</string> - </property> - <widget class="QWidget" name="formLayoutWidget_4"> - <property name="geometry"> - <rect> - <x>10</x> - <y>20</y> - <width>181</width> - <height>92</height> - </rect> - </property> - <layout class="QFormLayout" name="formLayout_4"> - <property name="sizeConstraint"> - <enum>QLayout::SetFixedSize</enum> - </property> - <item row="0" column="0"> - <widget class="QLabel" name="pktsRcvdLabel"> - <property name="text"> - <string>Packets Rcvd.</string> - </property> - </widget> - </item> - <item row="1" column="0"> - <widget class="QLabel" name="pktsCorrectLabel"> - <property name="text"> - <string>Packets Correct</string> - </property> - </widget> - </item> - <item row="2" column="0"> - <widget class="QLabel" name="perLabel"> - <property name="text"> - <string>PER</string> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="pktsRcvdEdit"> + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QPushButton" name="pauseButton"> <property name="minimumSize"> <size> - <width>60</width> + <width>80</width> <height>0</height> </size> </property> @@ -472,29 +468,32 @@ <height>16777215</height> </size> </property> + <property name="text"> + <string>Pause</string> + </property> </widget> </item> - <item row="1" column="1"> - <widget class="QLineEdit" name="pktsCorrectEdit"> - <property name="minimumSize"> - <size> - <width>60</width> - <height>0</height> - </size> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> </property> - <property name="maximumSize"> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> <size> - <width>80</width> - <height>16777215</height> + <width>20</width> + <height>60</height> </size> </property> - </widget> + </spacer> </item> - <item row="2" column="1"> - <widget class="QLineEdit" name="perEdit"> + <item> + <widget class="QPushButton" name="closeButton"> <property name="minimumSize"> <size> - <width>60</width> + <width>80</width> <height>0</height> </size> </property> @@ -504,70 +503,24 @@ <height>16777215</height> </size> </property> + <property name="text"> + <string>Close</string> + </property> </widget> </item> </layout> - </widget> - </widget> - </item> - <item row="2" column="4"> - <spacer name="horizontalSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="0" column="0" colspan="6"> - <layout class="QVBoxLayout" name="verticalLayout_5"> - <item> - <widget class="QFrame" name="sinkFrame"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Expanding" vsizetype="Expanding"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>500</width> - <height>550</height> - </size> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <layout class="QGridLayout" name="gridLayout_2"> - <item row="1" column="0"> - <layout class="QHBoxLayout" name="sinkLayout"/> - </item> - </layout> - </widget> </item> </layout> </item> </layout> - <zorder>channelModeBox</zorder> - <zorder></zorder> - <zorder>rxBox_2</zorder> - <zorder>horizontalSpacer</zorder> - <zorder></zorder> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>1019</width> - <height>25</height> + <width>1059</width> + <height>23</height> </rect> </property> <widget class="QMenu" name="menuFile"> diff --git a/gnuradio-examples/python/digital/qt_digital_window2.py b/gnuradio-examples/python/digital/qt_digital_window2.py index 98745dfe8..2d10e3a7f 100644 --- a/gnuradio-examples/python/digital/qt_digital_window2.py +++ b/gnuradio-examples/python/digital/qt_digital_window2.py @@ -2,8 +2,8 @@ # Form implementation generated from reading ui file 'qt_digital_window2.ui' # -# Created: Sat Jan 2 16:42:30 2010 -# by: PyQt4 UI code generator 4.4.3 +# Created: Tue May 11 20:55:10 2010 +# by: PyQt4 UI code generator 4.6.1 # # WARNING! All changes made in this file will be lost! @@ -12,30 +12,58 @@ from PyQt4 import QtCore, QtGui class Ui_DigitalWindow(object): def setupUi(self, DigitalWindow): DigitalWindow.setObjectName("DigitalWindow") - DigitalWindow.resize(1019, 754) + DigitalWindow.resize(1059, 751) self.centralwidget = QtGui.QWidget(DigitalWindow) self.centralwidget.setObjectName("centralwidget") - self.gridLayout = QtGui.QGridLayout(self.centralwidget) - self.gridLayout.setObjectName("gridLayout") - self.verticalLayout_5 = QtGui.QVBoxLayout() - self.verticalLayout_5.setObjectName("verticalLayout_5") - self.sinkFrame = QtGui.QFrame(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.sinkFrame.sizePolicy().hasHeightForWidth()) - self.sinkFrame.setSizePolicy(sizePolicy) - self.sinkFrame.setMinimumSize(QtCore.QSize(500, 550)) - self.sinkFrame.setFrameShape(QtGui.QFrame.StyledPanel) - self.sinkFrame.setFrameShadow(QtGui.QFrame.Raised) - self.sinkFrame.setObjectName("sinkFrame") - self.gridLayout_2 = QtGui.QGridLayout(self.sinkFrame) - self.gridLayout_2.setObjectName("gridLayout_2") + self.verticalLayout_3 = QtGui.QVBoxLayout(self.centralwidget) + self.verticalLayout_3.setObjectName("verticalLayout_3") self.sinkLayout = QtGui.QHBoxLayout() self.sinkLayout.setObjectName("sinkLayout") - self.gridLayout_2.addLayout(self.sinkLayout, 1, 0, 1, 1) - self.verticalLayout_5.addWidget(self.sinkFrame) - self.gridLayout.addLayout(self.verticalLayout_5, 0, 0, 1, 6) + self.verticalLayout_3.addLayout(self.sinkLayout) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") + self.verticalLayout_2 = QtGui.QVBoxLayout() + self.verticalLayout_2.setObjectName("verticalLayout_2") + self.sysBox = QtGui.QGroupBox(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.sysBox.sizePolicy().hasHeightForWidth()) + self.sysBox.setSizePolicy(sizePolicy) + self.sysBox.setMinimumSize(QtCore.QSize(240, 60)) + self.sysBox.setMaximumSize(QtCore.QSize(240, 16777215)) + self.sysBox.setObjectName("sysBox") + self.formLayoutWidget = QtGui.QWidget(self.sysBox) + self.formLayoutWidget.setGeometry(QtCore.QRect(10, 20, 211, 31)) + self.formLayoutWidget.setObjectName("formLayoutWidget") + self.formLayout = QtGui.QFormLayout(self.formLayoutWidget) + self.formLayout.setSizeConstraint(QtGui.QLayout.SetFixedSize) + self.formLayout.setVerticalSpacing(20) + self.formLayout.setObjectName("formLayout") + self.sampleRateEdit = QtGui.QLineEdit(self.formLayoutWidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.sampleRateEdit.sizePolicy().hasHeightForWidth()) + self.sampleRateEdit.setSizePolicy(sizePolicy) + self.sampleRateEdit.setMinimumSize(QtCore.QSize(60, 26)) + self.sampleRateEdit.setMaximumSize(QtCore.QSize(80, 26)) + self.sampleRateEdit.setObjectName("sampleRateEdit") + self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.sampleRateEdit) + self.sampleRateLabel = QtGui.QLabel(self.formLayoutWidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.sampleRateLabel.sizePolicy().hasHeightForWidth()) + self.sampleRateLabel.setSizePolicy(sizePolicy) + self.sampleRateLabel.setMinimumSize(QtCore.QSize(0, 20)) + self.sampleRateLabel.setMaximumSize(QtCore.QSize(16777215, 20)) + self.sampleRateLabel.setObjectName("sampleRateLabel") + self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.sampleRateLabel) + self.verticalLayout_2.addWidget(self.sysBox) + spacerItem = QtGui.QSpacerItem(20, 60, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) + self.verticalLayout_2.addItem(spacerItem) + self.horizontalLayout.addLayout(self.verticalLayout_2) self.channelModeBox = QtGui.QGroupBox(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) @@ -76,22 +104,46 @@ class Ui_DigitalWindow(object): self.timeEdit.setMaximumSize(QtCore.QSize(80, 16777215)) self.timeEdit.setObjectName("timeEdit") self.formLayout_2.setWidget(2, QtGui.QFormLayout.FieldRole, self.timeEdit) - self.gridLayout.addWidget(self.channelModeBox, 2, 1, 1, 1) - self.verticalLayout = QtGui.QVBoxLayout() - self.verticalLayout.setObjectName("verticalLayout") - self.pauseButton = QtGui.QPushButton(self.centralwidget) - self.pauseButton.setMinimumSize(QtCore.QSize(80, 0)) - self.pauseButton.setMaximumSize(QtCore.QSize(80, 16777215)) - self.pauseButton.setObjectName("pauseButton") - self.verticalLayout.addWidget(self.pauseButton) - spacerItem = QtGui.QSpacerItem(20, 60, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - self.verticalLayout.addItem(spacerItem) - self.closeButton = QtGui.QPushButton(self.centralwidget) - self.closeButton.setMinimumSize(QtCore.QSize(80, 0)) - self.closeButton.setMaximumSize(QtCore.QSize(80, 16777215)) - self.closeButton.setObjectName("closeButton") - self.verticalLayout.addWidget(self.closeButton) - self.gridLayout.addLayout(self.verticalLayout, 2, 5, 1, 1) + self.horizontalLayout.addWidget(self.channelModeBox) + self.rxBox = QtGui.QGroupBox(self.centralwidget) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.rxBox.sizePolicy().hasHeightForWidth()) + self.rxBox.setSizePolicy(sizePolicy) + self.rxBox.setMinimumSize(QtCore.QSize(220, 130)) + self.rxBox.setMaximumSize(QtCore.QSize(180, 16777215)) + self.rxBox.setObjectName("rxBox") + self.formLayoutWidget_3 = QtGui.QWidget(self.rxBox) + self.formLayoutWidget_3.setGeometry(QtCore.QRect(10, 20, 201, 101)) + self.formLayoutWidget_3.setObjectName("formLayoutWidget_3") + self.formLayout_3 = QtGui.QFormLayout(self.formLayoutWidget_3) + self.formLayout_3.setSizeConstraint(QtGui.QLayout.SetFixedSize) + self.formLayout_3.setObjectName("formLayout_3") + self.gainClockLabel = QtGui.QLabel(self.formLayoutWidget_3) + self.gainClockLabel.setObjectName("gainClockLabel") + self.formLayout_3.setWidget(0, QtGui.QFormLayout.LabelRole, self.gainClockLabel) + self.gainPhaseLabel = QtGui.QLabel(self.formLayoutWidget_3) + self.gainPhaseLabel.setObjectName("gainPhaseLabel") + self.formLayout_3.setWidget(2, QtGui.QFormLayout.LabelRole, self.gainPhaseLabel) + self.gainClockEdit = QtGui.QLineEdit(self.formLayoutWidget_3) + self.gainClockEdit.setMinimumSize(QtCore.QSize(60, 0)) + self.gainClockEdit.setMaximumSize(QtCore.QSize(80, 16777215)) + self.gainClockEdit.setObjectName("gainClockEdit") + self.formLayout_3.setWidget(0, QtGui.QFormLayout.FieldRole, self.gainClockEdit) + self.gainFreqEdit = QtGui.QLineEdit(self.formLayoutWidget_3) + self.gainFreqEdit.setMinimumSize(QtCore.QSize(60, 0)) + self.gainFreqEdit.setMaximumSize(QtCore.QSize(80, 16777215)) + self.gainFreqEdit.setObjectName("gainFreqEdit") + self.formLayout_3.setWidget(2, QtGui.QFormLayout.FieldRole, self.gainFreqEdit) + self.gainPhaseEdit = QtGui.QLineEdit(self.formLayoutWidget_3) + self.gainPhaseEdit.setMaximumSize(QtCore.QSize(80, 16777215)) + self.gainPhaseEdit.setObjectName("gainPhaseEdit") + self.formLayout_3.setWidget(1, QtGui.QFormLayout.FieldRole, self.gainPhaseEdit) + self.gainPhaseLabel_2 = QtGui.QLabel(self.formLayoutWidget_3) + self.gainPhaseLabel_2.setObjectName("gainPhaseLabel_2") + self.formLayout_3.setWidget(1, QtGui.QFormLayout.LabelRole, self.gainPhaseLabel_2) + self.horizontalLayout.addWidget(self.rxBox) self.rxBox_2 = QtGui.QGroupBox(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) @@ -102,7 +154,7 @@ class Ui_DigitalWindow(object): self.rxBox_2.setMaximumSize(QtCore.QSize(265, 125)) self.rxBox_2.setObjectName("rxBox_2") self.formLayoutWidget_4 = QtGui.QWidget(self.rxBox_2) - self.formLayoutWidget_4.setGeometry(QtCore.QRect(10, 20, 248, 188)) + self.formLayoutWidget_4.setGeometry(QtCore.QRect(10, 20, 201, 91)) self.formLayoutWidget_4.setObjectName("formLayoutWidget_4") self.formLayout_4 = QtGui.QFormLayout(self.formLayoutWidget_4) self.formLayout_4.setSizeConstraint(QtGui.QLayout.SetFixedSize) @@ -132,93 +184,28 @@ class Ui_DigitalWindow(object): self.perEdit.setMaximumSize(QtCore.QSize(80, 16777215)) self.perEdit.setObjectName("perEdit") self.formLayout_4.setWidget(2, QtGui.QFormLayout.FieldRole, self.perEdit) - self.gridLayout.addWidget(self.rxBox_2, 2, 3, 1, 1) + self.horizontalLayout.addWidget(self.rxBox_2) spacerItem1 = QtGui.QSpacerItem(20, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.gridLayout.addItem(spacerItem1, 2, 4, 1, 1) - self.verticalLayout_2 = QtGui.QVBoxLayout() - self.verticalLayout_2.setObjectName("verticalLayout_2") - self.sysBox = QtGui.QGroupBox(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.sysBox.sizePolicy().hasHeightForWidth()) - self.sysBox.setSizePolicy(sizePolicy) - self.sysBox.setMinimumSize(QtCore.QSize(240, 60)) - self.sysBox.setMaximumSize(QtCore.QSize(240, 16777215)) - self.sysBox.setObjectName("sysBox") - self.formLayoutWidget = QtGui.QWidget(self.sysBox) - self.formLayoutWidget.setGeometry(QtCore.QRect(10, 20, 211, 31)) - self.formLayoutWidget.setObjectName("formLayoutWidget") - self.formLayout = QtGui.QFormLayout(self.formLayoutWidget) - self.formLayout.setSizeConstraint(QtGui.QLayout.SetFixedSize) - self.formLayout.setVerticalSpacing(20) - self.formLayout.setObjectName("formLayout") - self.sampleRateEdit = QtGui.QLineEdit(self.formLayoutWidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.sampleRateEdit.sizePolicy().hasHeightForWidth()) - self.sampleRateEdit.setSizePolicy(sizePolicy) - self.sampleRateEdit.setMinimumSize(QtCore.QSize(60, 26)) - self.sampleRateEdit.setMaximumSize(QtCore.QSize(80, 26)) - self.sampleRateEdit.setObjectName("sampleRateEdit") - self.formLayout.setWidget(0, QtGui.QFormLayout.FieldRole, self.sampleRateEdit) - self.sampleRateLabel = QtGui.QLabel(self.formLayoutWidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.sampleRateLabel.sizePolicy().hasHeightForWidth()) - self.sampleRateLabel.setSizePolicy(sizePolicy) - self.sampleRateLabel.setMinimumSize(QtCore.QSize(0, 20)) - self.sampleRateLabel.setMaximumSize(QtCore.QSize(16777215, 20)) - self.sampleRateLabel.setObjectName("sampleRateLabel") - self.formLayout.setWidget(0, QtGui.QFormLayout.LabelRole, self.sampleRateLabel) - self.verticalLayout_2.addWidget(self.sysBox) + self.horizontalLayout.addItem(spacerItem1) + self.verticalLayout = QtGui.QVBoxLayout() + self.verticalLayout.setObjectName("verticalLayout") + self.pauseButton = QtGui.QPushButton(self.centralwidget) + self.pauseButton.setMinimumSize(QtCore.QSize(80, 0)) + self.pauseButton.setMaximumSize(QtCore.QSize(80, 16777215)) + self.pauseButton.setObjectName("pauseButton") + self.verticalLayout.addWidget(self.pauseButton) spacerItem2 = QtGui.QSpacerItem(20, 60, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - self.verticalLayout_2.addItem(spacerItem2) - self.gridLayout.addLayout(self.verticalLayout_2, 2, 0, 1, 1) - self.rxBox = QtGui.QGroupBox(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.rxBox.sizePolicy().hasHeightForWidth()) - self.rxBox.setSizePolicy(sizePolicy) - self.rxBox.setMinimumSize(QtCore.QSize(180, 120)) - self.rxBox.setMaximumSize(QtCore.QSize(180, 16777215)) - self.rxBox.setObjectName("rxBox") - self.formLayoutWidget_3 = QtGui.QWidget(self.rxBox) - self.formLayoutWidget_3.setGeometry(QtCore.QRect(10, 10, 164, 101)) - self.formLayoutWidget_3.setObjectName("formLayoutWidget_3") - self.formLayout_3 = QtGui.QFormLayout(self.formLayoutWidget_3) - self.formLayout_3.setSizeConstraint(QtGui.QLayout.SetFixedSize) - self.formLayout_3.setObjectName("formLayout_3") - self.gainClockLabel = QtGui.QLabel(self.formLayoutWidget_3) - self.gainClockLabel.setObjectName("gainClockLabel") - self.formLayout_3.setWidget(0, QtGui.QFormLayout.LabelRole, self.gainClockLabel) - self.gainPhaseLabel = QtGui.QLabel(self.formLayoutWidget_3) - self.gainPhaseLabel.setObjectName("gainPhaseLabel") - self.formLayout_3.setWidget(2, QtGui.QFormLayout.LabelRole, self.gainPhaseLabel) - self.gainClockEdit = QtGui.QLineEdit(self.formLayoutWidget_3) - self.gainClockEdit.setMinimumSize(QtCore.QSize(60, 0)) - self.gainClockEdit.setMaximumSize(QtCore.QSize(80, 16777215)) - self.gainClockEdit.setObjectName("gainClockEdit") - self.formLayout_3.setWidget(0, QtGui.QFormLayout.FieldRole, self.gainClockEdit) - self.gainFreqEdit = QtGui.QLineEdit(self.formLayoutWidget_3) - self.gainFreqEdit.setMinimumSize(QtCore.QSize(60, 0)) - self.gainFreqEdit.setMaximumSize(QtCore.QSize(80, 16777215)) - self.gainFreqEdit.setObjectName("gainFreqEdit") - self.formLayout_3.setWidget(2, QtGui.QFormLayout.FieldRole, self.gainFreqEdit) - self.gainPhaseEdit = QtGui.QLineEdit(self.formLayoutWidget_3) - self.gainPhaseEdit.setMaximumSize(QtCore.QSize(80, 16777215)) - self.gainPhaseEdit.setObjectName("gainPhaseEdit") - self.formLayout_3.setWidget(1, QtGui.QFormLayout.FieldRole, self.gainPhaseEdit) - self.gainPhaseLabel_2 = QtGui.QLabel(self.formLayoutWidget_3) - self.gainPhaseLabel_2.setObjectName("gainPhaseLabel_2") - self.formLayout_3.setWidget(1, QtGui.QFormLayout.LabelRole, self.gainPhaseLabel_2) - self.gridLayout.addWidget(self.rxBox, 2, 2, 1, 1) + self.verticalLayout.addItem(spacerItem2) + self.closeButton = QtGui.QPushButton(self.centralwidget) + self.closeButton.setMinimumSize(QtCore.QSize(80, 0)) + self.closeButton.setMaximumSize(QtCore.QSize(80, 16777215)) + self.closeButton.setObjectName("closeButton") + self.verticalLayout.addWidget(self.closeButton) + self.horizontalLayout.addLayout(self.verticalLayout) + self.verticalLayout_3.addLayout(self.horizontalLayout) DigitalWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(DigitalWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 1019, 24)) + self.menubar.setGeometry(QtCore.QRect(0, 0, 1059, 23)) self.menubar.setObjectName("menubar") self.menuFile = QtGui.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") @@ -240,22 +227,22 @@ class Ui_DigitalWindow(object): def retranslateUi(self, DigitalWindow): DigitalWindow.setWindowTitle(QtGui.QApplication.translate("DigitalWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) + self.sysBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "System Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.sampleRateLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Sample Rate (sps)", None, QtGui.QApplication.UnicodeUTF8)) self.channelModeBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Channel Model Parameters", None, QtGui.QApplication.UnicodeUTF8)) self.snrLabel.setText(QtGui.QApplication.translate("DigitalWindow", "SNR (dB)", None, QtGui.QApplication.UnicodeUTF8)) self.freqLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Frequency Offset (Hz)", None, QtGui.QApplication.UnicodeUTF8)) self.timeLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Timing Offset", None, QtGui.QApplication.UnicodeUTF8)) - self.pauseButton.setText(QtGui.QApplication.translate("DigitalWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8)) - self.closeButton.setText(QtGui.QApplication.translate("DigitalWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) - self.rxBox_2.setTitle(QtGui.QApplication.translate("DigitalWindow", "Received Packet Info", None, QtGui.QApplication.UnicodeUTF8)) - self.pktsRcvdLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Packets Rcvd.", None, QtGui.QApplication.UnicodeUTF8)) - self.pktsCorrectLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Packets Correct", None, QtGui.QApplication.UnicodeUTF8)) - self.perLabel.setText(QtGui.QApplication.translate("DigitalWindow", "PER", None, QtGui.QApplication.UnicodeUTF8)) - self.sysBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "System Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.sampleRateLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Sample Rate (sps)", None, QtGui.QApplication.UnicodeUTF8)) self.rxBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8)) self.gainClockLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Clock Loop Gain", None, QtGui.QApplication.UnicodeUTF8)) self.gainPhaseLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Freq. Loop Gain", None, QtGui.QApplication.UnicodeUTF8)) self.gainPhaseLabel_2.setText(QtGui.QApplication.translate("DigitalWindow", "Phase Loop Gain", None, QtGui.QApplication.UnicodeUTF8)) + self.rxBox_2.setTitle(QtGui.QApplication.translate("DigitalWindow", "Received Packet Info", None, QtGui.QApplication.UnicodeUTF8)) + self.pktsRcvdLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Packets Rcvd.", None, QtGui.QApplication.UnicodeUTF8)) + self.pktsCorrectLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Packets Correct", None, QtGui.QApplication.UnicodeUTF8)) + self.perLabel.setText(QtGui.QApplication.translate("DigitalWindow", "PER", None, QtGui.QApplication.UnicodeUTF8)) + self.pauseButton.setText(QtGui.QApplication.translate("DigitalWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8)) + self.closeButton.setText(QtGui.QApplication.translate("DigitalWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) self.menuFile.setTitle(QtGui.QApplication.translate("DigitalWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) self.actionExit.setText(QtGui.QApplication.translate("DigitalWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/gnuradio-examples/python/digital/qt_digital_window2.ui b/gnuradio-examples/python/digital/qt_digital_window2.ui index 4e87ff058..544704668 100644 --- a/gnuradio-examples/python/digital/qt_digital_window2.ui +++ b/gnuradio-examples/python/digital/qt_digital_window2.ui @@ -1,592 +1,563 @@ -<ui version="4.0" > +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> <class>DigitalWindow</class> - <widget class="QMainWindow" name="DigitalWindow" > - <property name="geometry" > + <widget class="QMainWindow" name="DigitalWindow"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>1019</width> - <height>754</height> + <width>1059</width> + <height>751</height> </rect> </property> - <property name="windowTitle" > + <property name="windowTitle"> <string>MainWindow</string> </property> - <widget class="QWidget" name="centralwidget" > - <layout class="QGridLayout" name="gridLayout" > - <item row="0" column="0" colspan="6" > - <layout class="QVBoxLayout" name="verticalLayout_5" > - <item> - <widget class="QFrame" name="sinkFrame" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Expanding" hsizetype="Expanding" > - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize" > - <size> - <width>500</width> - <height>550</height> - </size> - </property> - <property name="frameShape" > - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow" > - <enum>QFrame::Raised</enum> - </property> - <layout class="QGridLayout" name="gridLayout_2" > - <item row="1" column="0" > - <layout class="QHBoxLayout" name="sinkLayout" /> - </item> - </layout> - </widget> - </item> - </layout> + <widget class="QWidget" name="centralwidget"> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <layout class="QHBoxLayout" name="sinkLayout"/> </item> - <item row="2" column="1" > - <widget class="QGroupBox" name="channelModeBox" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize" > - <size> - <width>245</width> - <height>130</height> - </size> - </property> - <property name="maximumSize" > - <size> - <width>245</width> - <height>16777215</height> - </size> - </property> - <property name="title" > - <string>Channel Model Parameters</string> - </property> - <widget class="QWidget" name="formLayoutWidget_2" > - <property name="geometry" > - <rect> - <x>10</x> - <y>20</y> - <width>221</width> - <height>98</height> - </rect> - </property> - <layout class="QFormLayout" name="formLayout_2" > - <property name="sizeConstraint" > - <enum>QLayout::SetFixedSize</enum> - </property> - <property name="fieldGrowthPolicy" > - <enum>QFormLayout::AllNonFixedFieldsGrow</enum> - </property> - <item row="0" column="0" > - <widget class="QLabel" name="snrLabel" > - <property name="text" > - <string>SNR (dB)</string> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QGroupBox" name="sysBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - </widget> - </item> - <item row="0" column="1" > - <widget class="QLineEdit" name="snrEdit" > - <property name="minimumSize" > + <property name="minimumSize"> <size> - <width>60</width> - <height>0</height> + <width>240</width> + <height>60</height> </size> </property> - <property name="maximumSize" > + <property name="maximumSize"> <size> - <width>80</width> + <width>240</width> <height>16777215</height> </size> </property> - </widget> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="freqLabel" > - <property name="text" > - <string>Frequency Offset (Hz)</string> - </property> - </widget> - </item> - <item row="1" column="1" > - <widget class="QLineEdit" name="freqEdit" > - <property name="minimumSize" > - <size> - <width>60</width> - <height>0</height> - </size> - </property> - <property name="maximumSize" > - <size> - <width>80</width> - <height>16777215</height> - </size> + <property name="title"> + <string>System Parameters</string> </property> + <widget class="QWidget" name="formLayoutWidget"> + <property name="geometry"> + <rect> + <x>10</x> + <y>20</y> + <width>211</width> + <height>31</height> + </rect> + </property> + <layout class="QFormLayout" name="formLayout"> + <property name="sizeConstraint"> + <enum>QLayout::SetFixedSize</enum> + </property> + <property name="verticalSpacing"> + <number>20</number> + </property> + <item row="0" column="1"> + <widget class="QLineEdit" name="sampleRateEdit"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>60</width> + <height>26</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>26</height> + </size> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="sampleRateLabel"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>20</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string>Sample Rate (sps)</string> + </property> + </widget> + </item> + </layout> + </widget> </widget> </item> - <item row="2" column="0" > - <widget class="QLabel" name="timeLabel" > - <property name="text" > - <string>Timing Offset</string> + <item> + <spacer name="verticalSpacer_2"> + <property name="orientation"> + <enum>Qt::Vertical</enum> </property> - </widget> - </item> - <item row="2" column="1" > - <widget class="QLineEdit" name="timeEdit" > - <property name="minimumSize" > - <size> - <width>60</width> - <height>0</height> - </size> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> </property> - <property name="maximumSize" > + <property name="sizeHint" stdset="0"> <size> - <width>80</width> - <height>16777215</height> + <width>20</width> + <height>60</height> </size> </property> - </widget> + </spacer> </item> </layout> - </widget> - </widget> - </item> - <item row="2" column="5" > - <layout class="QVBoxLayout" name="verticalLayout" > + </item> <item> - <widget class="QPushButton" name="pauseButton" > - <property name="minimumSize" > + <widget class="QGroupBox" name="channelModeBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> <size> - <width>80</width> - <height>0</height> + <width>245</width> + <height>130</height> </size> </property> - <property name="maximumSize" > + <property name="maximumSize"> <size> - <width>80</width> + <width>245</width> <height>16777215</height> </size> </property> - <property name="text" > - <string>Pause</string> + <property name="title"> + <string>Channel Model Parameters</string> </property> + <widget class="QWidget" name="formLayoutWidget_2"> + <property name="geometry"> + <rect> + <x>10</x> + <y>20</y> + <width>221</width> + <height>98</height> + </rect> + </property> + <layout class="QFormLayout" name="formLayout_2"> + <property name="sizeConstraint"> + <enum>QLayout::SetFixedSize</enum> + </property> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="snrLabel"> + <property name="text"> + <string>SNR (dB)</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="snrEdit"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="freqLabel"> + <property name="text"> + <string>Frequency Offset (Hz)</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="freqEdit"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="timeLabel"> + <property name="text"> + <string>Timing Offset</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="timeEdit"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + </layout> + </widget> </widget> </item> <item> - <spacer name="verticalSpacer" > - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0" > - <size> - <width>20</width> - <height>60</height> - </size> + <widget class="QGroupBox" name="rxBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> </property> - </spacer> - </item> - <item> - <widget class="QPushButton" name="closeButton" > - <property name="minimumSize" > + <property name="minimumSize"> <size> - <width>80</width> - <height>0</height> + <width>220</width> + <height>130</height> </size> </property> - <property name="maximumSize" > + <property name="maximumSize"> <size> - <width>80</width> + <width>180</width> <height>16777215</height> </size> </property> - <property name="text" > - <string>Close</string> + <property name="title"> + <string>Receiver Parameters</string> </property> + <widget class="QWidget" name="formLayoutWidget_3"> + <property name="geometry"> + <rect> + <x>10</x> + <y>20</y> + <width>201</width> + <height>101</height> + </rect> + </property> + <layout class="QFormLayout" name="formLayout_3"> + <property name="sizeConstraint"> + <enum>QLayout::SetFixedSize</enum> + </property> + <item row="0" column="0"> + <widget class="QLabel" name="gainClockLabel"> + <property name="text"> + <string>Clock Loop Gain</string> + </property> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="gainPhaseLabel"> + <property name="text"> + <string>Freq. Loop Gain</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="gainClockEdit"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="gainFreqEdit"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="gainPhaseEdit"> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QLabel" name="gainPhaseLabel_2"> + <property name="text"> + <string>Phase Loop Gain</string> + </property> + </widget> + </item> + </layout> + </widget> </widget> </item> - </layout> - </item> - <item row="2" column="3" > - <widget class="QGroupBox" name="rxBox_2" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize" > - <size> - <width>220</width> - <height>125</height> - </size> - </property> - <property name="maximumSize" > - <size> - <width>265</width> - <height>125</height> - </size> - </property> - <property name="title" > - <string>Received Packet Info</string> - </property> - <widget class="QWidget" name="formLayoutWidget_4" > - <property name="geometry" > - <rect> - <x>10</x> - <y>20</y> - <width>248</width> - <height>188</height> - </rect> - </property> - <layout class="QFormLayout" name="formLayout_4" > - <property name="sizeConstraint" > - <enum>QLayout::SetFixedSize</enum> - </property> - <property name="fieldGrowthPolicy" > - <enum>QFormLayout::AllNonFixedFieldsGrow</enum> - </property> - <item row="0" column="0" > - <widget class="QLabel" name="pktsRcvdLabel" > - <property name="text" > - <string>Packets Rcvd.</string> - </property> - </widget> - </item> - <item row="0" column="1" > - <widget class="QLineEdit" name="pktsRcvdEdit" > - <property name="minimumSize" > - <size> - <width>60</width> - <height>0</height> - </size> - </property> - <property name="maximumSize" > - <size> - <width>80</width> - <height>16777215</height> - </size> - </property> - </widget> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="pktsCorrectLabel" > - <property name="text" > - <string>Packets Correct</string> - </property> - </widget> - </item> - <item row="1" column="1" > - <widget class="QLineEdit" name="pktsCorrectEdit" > - <property name="minimumSize" > - <size> - <width>60</width> - <height>0</height> - </size> - </property> - <property name="maximumSize" > - <size> - <width>80</width> - <height>16777215</height> - </size> - </property> - </widget> - </item> - <item row="2" column="0" > - <widget class="QLabel" name="perLabel" > - <property name="text" > - <string>PER</string> - </property> - </widget> - </item> - <item row="2" column="1" > - <widget class="QLineEdit" name="perEdit" > - <property name="minimumSize" > - <size> - <width>60</width> - <height>0</height> - </size> - </property> - <property name="maximumSize" > - <size> - <width>80</width> - <height>16777215</height> - </size> - </property> - </widget> - </item> - </layout> - <zorder>pktsRcvdLabel</zorder> - <zorder>pktsCorrectLabel</zorder> - <zorder>perLabel</zorder> - <zorder>pktsRcvdEdit</zorder> - <zorder>pktsCorrectEdit</zorder> - <zorder>perEdit</zorder> - </widget> - </widget> - </item> - <item row="2" column="4" > - <spacer name="horizontalSpacer" > - <property name="orientation" > - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0" > - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="2" column="0" > - <layout class="QVBoxLayout" name="verticalLayout_2" > <item> - <widget class="QGroupBox" name="sysBox" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <widget class="QGroupBox" name="rxBox_2"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumSize" > + <property name="minimumSize"> <size> - <width>240</width> - <height>60</height> + <width>220</width> + <height>125</height> </size> </property> - <property name="maximumSize" > + <property name="maximumSize"> <size> - <width>240</width> - <height>16777215</height> + <width>265</width> + <height>125</height> </size> </property> - <property name="title" > - <string>System Parameters</string> + <property name="title"> + <string>Received Packet Info</string> </property> - <widget class="QWidget" name="formLayoutWidget" > - <property name="geometry" > + <widget class="QWidget" name="formLayoutWidget_4"> + <property name="geometry"> <rect> <x>10</x> <y>20</y> - <width>211</width> - <height>31</height> + <width>201</width> + <height>91</height> </rect> </property> - <layout class="QFormLayout" name="formLayout" > - <property name="sizeConstraint" > + <layout class="QFormLayout" name="formLayout_4"> + <property name="sizeConstraint"> <enum>QLayout::SetFixedSize</enum> </property> - <property name="verticalSpacing" > - <number>20</number> + <property name="fieldGrowthPolicy"> + <enum>QFormLayout::AllNonFixedFieldsGrow</enum> </property> - <item row="0" column="1" > - <widget class="QLineEdit" name="sampleRateEdit" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item row="0" column="0"> + <widget class="QLabel" name="pktsRcvdLabel"> + <property name="text"> + <string>Packets Rcvd.</string> </property> - <property name="minimumSize" > + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="pktsRcvdEdit"> + <property name="minimumSize"> <size> <width>60</width> - <height>26</height> + <height>0</height> </size> </property> - <property name="maximumSize" > + <property name="maximumSize"> <size> <width>80</width> - <height>26</height> + <height>16777215</height> </size> </property> </widget> </item> - <item row="0" column="0" > - <widget class="QLabel" name="sampleRateLabel" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> + <item row="1" column="0"> + <widget class="QLabel" name="pktsCorrectLabel"> + <property name="text"> + <string>Packets Correct</string> </property> - <property name="minimumSize" > + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="pktsCorrectEdit"> + <property name="minimumSize"> <size> - <width>0</width> - <height>20</height> + <width>60</width> + <height>0</height> </size> </property> - <property name="maximumSize" > + <property name="maximumSize"> <size> - <width>16777215</width> - <height>20</height> + <width>80</width> + <height>16777215</height> </size> </property> - <property name="text" > - <string>Sample Rate (sps)</string> + </widget> + </item> + <item row="2" column="0"> + <widget class="QLabel" name="perLabel"> + <property name="text"> + <string>PER</string> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLineEdit" name="perEdit"> + <property name="minimumSize"> + <size> + <width>60</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> </property> </widget> </item> </layout> + <zorder>pktsRcvdLabel</zorder> + <zorder>pktsCorrectLabel</zorder> + <zorder>perLabel</zorder> + <zorder>pktsRcvdEdit</zorder> + <zorder>pktsCorrectEdit</zorder> + <zorder>perEdit</zorder> </widget> </widget> </item> <item> - <spacer name="verticalSpacer_2" > - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Fixed</enum> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> </property> - <property name="sizeHint" stdset="0" > + <property name="sizeHint" stdset="0"> <size> <width>20</width> - <height>60</height> + <height>20</height> </size> </property> </spacer> </item> - </layout> - </item> - <item row="2" column="2" > - <widget class="QGroupBox" name="rxBox" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize" > - <size> - <width>180</width> - <height>120</height> - </size> - </property> - <property name="maximumSize" > - <size> - <width>180</width> - <height>16777215</height> - </size> - </property> - <property name="title" > - <string>Receiver Parameters</string> - </property> - <widget class="QWidget" name="formLayoutWidget_3" > - <property name="geometry" > - <rect> - <x>10</x> - <y>10</y> - <width>164</width> - <height>101</height> - </rect> - </property> - <layout class="QFormLayout" name="formLayout_3" > - <property name="sizeConstraint" > - <enum>QLayout::SetFixedSize</enum> - </property> - <item row="0" column="0" > - <widget class="QLabel" name="gainClockLabel" > - <property name="text" > - <string>Clock Loop Gain</string> - </property> - </widget> - </item> - <item row="2" column="0" > - <widget class="QLabel" name="gainPhaseLabel" > - <property name="text" > - <string>Freq. Loop Gain</string> - </property> - </widget> - </item> - <item row="0" column="1" > - <widget class="QLineEdit" name="gainClockEdit" > - <property name="minimumSize" > + <item> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QPushButton" name="pauseButton"> + <property name="minimumSize"> <size> - <width>60</width> + <width>80</width> <height>0</height> </size> </property> - <property name="maximumSize" > + <property name="maximumSize"> <size> <width>80</width> <height>16777215</height> </size> </property> + <property name="text"> + <string>Pause</string> + </property> </widget> </item> - <item row="2" column="1" > - <widget class="QLineEdit" name="gainFreqEdit" > - <property name="minimumSize" > + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeType"> + <enum>QSizePolicy::Fixed</enum> + </property> + <property name="sizeHint" stdset="0"> <size> - <width>60</width> - <height>0</height> + <width>20</width> + <height>60</height> </size> </property> - <property name="maximumSize" > + </spacer> + </item> + <item> + <widget class="QPushButton" name="closeButton"> + <property name="minimumSize"> <size> <width>80</width> - <height>16777215</height> + <height>0</height> </size> </property> - </widget> - </item> - <item row="1" column="1" > - <widget class="QLineEdit" name="gainPhaseEdit" > - <property name="maximumSize" > + <property name="maximumSize"> <size> <width>80</width> <height>16777215</height> </size> </property> - </widget> - </item> - <item row="1" column="0" > - <widget class="QLabel" name="gainPhaseLabel_2" > - <property name="text" > - <string>Phase Loop Gain</string> + <property name="text"> + <string>Close</string> </property> </widget> </item> </layout> - </widget> - </widget> + </item> + </layout> </item> </layout> - <zorder>channelModeBox</zorder> - <zorder></zorder> - <zorder>rxBox_2</zorder> - <zorder>horizontalSpacer</zorder> - <zorder></zorder> - <zorder>rxBox</zorder> </widget> - <widget class="QMenuBar" name="menubar" > - <property name="geometry" > + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>1019</width> - <height>24</height> + <width>1059</width> + <height>23</height> </rect> </property> - <widget class="QMenu" name="menuFile" > - <property name="title" > + <widget class="QMenu" name="menuFile"> + <property name="title"> <string>&File</string> </property> - <addaction name="actionExit" /> + <addaction name="actionExit"/> </widget> - <addaction name="menuFile" /> + <addaction name="menuFile"/> </widget> - <widget class="QStatusBar" name="statusbar" /> - <action name="actionExit" > - <property name="text" > + <widget class="QStatusBar" name="statusbar"/> + <action name="actionExit"> + <property name="text"> <string>E&xit</string> </property> </action> @@ -604,11 +575,11 @@ <receiver>DigitalWindow</receiver> <slot>close()</slot> <hints> - <hint type="sourcelabel" > + <hint type="sourcelabel"> <x>322</x> <y>623</y> </hint> - <hint type="destinationlabel" > + <hint type="destinationlabel"> <x>66</x> <y>561</y> </hint> @@ -620,11 +591,11 @@ <receiver>DigitalWindow</receiver> <slot>close()</slot> <hints> - <hint type="sourcelabel" > + <hint type="sourcelabel"> <x>-1</x> <y>-1</y> </hint> - <hint type="destinationlabel" > + <hint type="destinationlabel"> <x>617</x> <y>327</y> </hint> diff --git a/gnuradio-examples/python/digital/qt_rx_window.py b/gnuradio-examples/python/digital/qt_rx_window.py index 60e1a6e37..e2488eb3d 100644 --- a/gnuradio-examples/python/digital/qt_rx_window.py +++ b/gnuradio-examples/python/digital/qt_rx_window.py @@ -2,8 +2,8 @@ # Form implementation generated from reading ui file 'qt_rx_window.ui' # -# Created: Fri Jul 3 01:03:19 2009 -# by: PyQt4 UI code generator 4.4.3 +# Created: Tue May 11 21:03:07 2010 +# by: PyQt4 UI code generator 4.6.1 # # WARNING! All changes made in this file will be lost! @@ -12,29 +12,14 @@ from PyQt4 import QtCore, QtGui class Ui_DigitalWindow(object): def setupUi(self, DigitalWindow): DigitalWindow.setObjectName("DigitalWindow") - DigitalWindow.resize(1000, 816) + DigitalWindow.resize(999, 519) self.centralwidget = QtGui.QWidget(DigitalWindow) self.centralwidget.setObjectName("centralwidget") - self.gridLayout = QtGui.QGridLayout(self.centralwidget) - self.gridLayout.setObjectName("gridLayout") - self.sinkFrame = QtGui.QFrame(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(1) - sizePolicy.setHeightForWidth(self.sinkFrame.sizePolicy().hasHeightForWidth()) - self.sinkFrame.setSizePolicy(sizePolicy) - self.sinkFrame.setMinimumSize(QtCore.QSize(800, 500)) - self.sinkFrame.setFrameShape(QtGui.QFrame.StyledPanel) - self.sinkFrame.setFrameShadow(QtGui.QFrame.Raised) - self.sinkFrame.setObjectName("sinkFrame") - self.horizontalLayout_2 = QtGui.QHBoxLayout(self.sinkFrame) - self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) + self.verticalLayout.setObjectName("verticalLayout") self.sinkLayout = QtGui.QHBoxLayout() self.sinkLayout.setObjectName("sinkLayout") - self.horizontalLayout_2.addLayout(self.sinkLayout) - self.gridLayout.addWidget(self.sinkFrame, 0, 0, 1, 1) - spacerItem = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - self.gridLayout.addItem(spacerItem, 1, 0, 1, 1) + self.verticalLayout.addLayout(self.sinkLayout) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setSizeConstraint(QtGui.QLayout.SetFixedSize) self.horizontalLayout.setObjectName("horizontalLayout") @@ -113,15 +98,15 @@ class Ui_DigitalWindow(object): self.perEdit.setGeometry(QtCore.QRect(120, 90, 113, 23)) self.perEdit.setObjectName("perEdit") self.verticalLayout_3.addWidget(self.rxPacketBox) - spacerItem1 = QtGui.QSpacerItem(20, 60, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) - self.verticalLayout_3.addItem(spacerItem1) + spacerItem = QtGui.QSpacerItem(20, 60, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) + self.verticalLayout_3.addItem(spacerItem) self.horizontalLayout.addLayout(self.verticalLayout_3) - spacerItem2 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) - self.horizontalLayout.addItem(spacerItem2) + spacerItem1 = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem1) self.verticalLayout_5 = QtGui.QVBoxLayout() self.verticalLayout_5.setObjectName("verticalLayout_5") - spacerItem3 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) - self.verticalLayout_5.addItem(spacerItem3) + spacerItem2 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout_5.addItem(spacerItem2) self.closeButton = QtGui.QPushButton(self.centralwidget) sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) @@ -133,10 +118,10 @@ class Ui_DigitalWindow(object): self.closeButton.setObjectName("closeButton") self.verticalLayout_5.addWidget(self.closeButton) self.horizontalLayout.addLayout(self.verticalLayout_5) - self.gridLayout.addLayout(self.horizontalLayout, 2, 0, 1, 1) + self.verticalLayout.addLayout(self.horizontalLayout) DigitalWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(DigitalWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 1000, 24)) + self.menubar.setGeometry(QtCore.QRect(0, 0, 999, 23)) self.menubar.setObjectName("menubar") self.menuFile = QtGui.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") diff --git a/gnuradio-examples/python/digital/qt_rx_window.ui b/gnuradio-examples/python/digital/qt_rx_window.ui index 4631b7782..f5a074876 100644 --- a/gnuradio-examples/python/digital/qt_rx_window.ui +++ b/gnuradio-examples/python/digital/qt_rx_window.ui @@ -1,92 +1,53 @@ -<ui version="4.0" > +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> <class>DigitalWindow</class> - <widget class="QMainWindow" name="DigitalWindow" > - <property name="geometry" > + <widget class="QMainWindow" name="DigitalWindow"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>1000</width> - <height>816</height> + <width>999</width> + <height>519</height> </rect> </property> - <property name="windowTitle" > + <property name="windowTitle"> <string>MainWindow</string> </property> - <widget class="QWidget" name="centralwidget" > - <layout class="QGridLayout" name="gridLayout" > - <item row="0" column="0" > - <widget class="QFrame" name="sinkFrame" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Preferred" hsizetype="Preferred" > - <horstretch>0</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="minimumSize" > - <size> - <width>800</width> - <height>500</height> - </size> - </property> - <property name="frameShape" > - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow" > - <enum>QFrame::Raised</enum> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2" > - <item> - <layout class="QHBoxLayout" name="sinkLayout" /> - </item> - </layout> - </widget> - </item> - <item row="1" column="0" > - <spacer name="verticalSpacer" > - <property name="orientation" > - <enum>Qt::Vertical</enum> - </property> - <property name="sizeType" > - <enum>QSizePolicy::Fixed</enum> - </property> - <property name="sizeHint" stdset="0" > - <size> - <width>20</width> - <height>40</height> - </size> - </property> - </spacer> + <widget class="QWidget" name="centralwidget"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="sinkLayout"/> </item> - <item row="2" column="0" > - <layout class="QHBoxLayout" name="horizontalLayout" > - <property name="sizeConstraint" > + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="sizeConstraint"> <enum>QLayout::SetFixedSize</enum> </property> <item> - <widget class="QGroupBox" name="rxBox" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <widget class="QGroupBox" name="rxBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumSize" > + <property name="minimumSize"> <size> <width>250</width> <height>190</height> </size> </property> - <property name="maximumSize" > + <property name="maximumSize"> <size> <width>250</width> <height>190</height> </size> </property> - <property name="title" > + <property name="title"> <string>Receiver Parameters</string> </property> - <widget class="QLineEdit" name="gainMuEdit" > - <property name="geometry" > + <widget class="QLineEdit" name="gainMuEdit"> + <property name="geometry"> <rect> <x>120</x> <y>120</y> @@ -95,8 +56,8 @@ </rect> </property> </widget> - <widget class="QLabel" name="gainMuLabel" > - <property name="geometry" > + <widget class="QLabel" name="gainMuLabel"> + <property name="geometry"> <rect> <x>10</x> <y>120</y> @@ -104,12 +65,12 @@ <height>20</height> </rect> </property> - <property name="text" > + <property name="text"> <string>mu's gain</string> </property> </widget> - <widget class="QLineEdit" name="alphaEdit" > - <property name="geometry" > + <widget class="QLineEdit" name="alphaEdit"> + <property name="geometry"> <rect> <x>120</x> <y>150</y> @@ -118,8 +79,8 @@ </rect> </property> </widget> - <widget class="QLabel" name="alphaLabel" > - <property name="geometry" > + <widget class="QLabel" name="alphaLabel"> + <property name="geometry"> <rect> <x>10</x> <y>150</y> @@ -127,12 +88,12 @@ <height>20</height> </rect> </property> - <property name="text" > + <property name="text"> <string>Alpha</string> </property> </widget> - <widget class="QLabel" name="gainLabel" > - <property name="geometry" > + <widget class="QLabel" name="gainLabel"> + <property name="geometry"> <rect> <x>10</x> <y>60</y> @@ -140,12 +101,12 @@ <height>17</height> </rect> </property> - <property name="text" > + <property name="text"> <string>Gain (dB)</string> </property> </widget> - <widget class="QLineEdit" name="freqEdit" > - <property name="geometry" > + <widget class="QLineEdit" name="freqEdit"> + <property name="geometry"> <rect> <x>120</x> <y>30</y> @@ -154,8 +115,8 @@ </rect> </property> </widget> - <widget class="QLabel" name="freqLabel" > - <property name="geometry" > + <widget class="QLabel" name="freqLabel"> + <property name="geometry"> <rect> <x>10</x> <y>30</y> @@ -163,12 +124,12 @@ <height>17</height> </rect> </property> - <property name="text" > + <property name="text"> <string>Frequency (Hz)</string> </property> </widget> - <widget class="QLineEdit" name="gainEdit" > - <property name="geometry" > + <widget class="QLineEdit" name="gainEdit"> + <property name="geometry"> <rect> <x>120</x> <y>60</y> @@ -177,8 +138,8 @@ </rect> </property> </widget> - <widget class="QLabel" name="decimLabel" > - <property name="geometry" > + <widget class="QLabel" name="decimLabel"> + <property name="geometry"> <rect> <x>10</x> <y>90</y> @@ -186,12 +147,12 @@ <height>17</height> </rect> </property> - <property name="text" > + <property name="text"> <string>Decimation</string> </property> </widget> - <widget class="QLineEdit" name="decimEdit" > - <property name="geometry" > + <widget class="QLineEdit" name="decimEdit"> + <property name="geometry"> <rect> <x>120</x> <y>90</y> @@ -203,41 +164,41 @@ </widget> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout_3" > + <layout class="QVBoxLayout" name="verticalLayout_3"> <item> - <widget class="QGroupBox" name="rxPacketBox" > - <property name="enabled" > + <widget class="QGroupBox" name="rxPacketBox"> + <property name="enabled"> <bool>true</bool> </property> - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumSize" > + <property name="minimumSize"> <size> <width>250</width> <height>130</height> </size> </property> - <property name="maximumSize" > + <property name="maximumSize"> <size> <width>250</width> <height>130</height> </size> </property> - <property name="font" > + <property name="font"> <font> <weight>50</weight> <bold>false</bold> </font> </property> - <property name="title" > + <property name="title"> <string>Received Packet Info</string> </property> - <widget class="QLineEdit" name="pktsRcvdEdit" > - <property name="geometry" > + <widget class="QLineEdit" name="pktsRcvdEdit"> + <property name="geometry"> <rect> <x>120</x> <y>30</y> @@ -246,8 +207,8 @@ </rect> </property> </widget> - <widget class="QLabel" name="pktsRcvdLabel" > - <property name="geometry" > + <widget class="QLabel" name="pktsRcvdLabel"> + <property name="geometry"> <rect> <x>10</x> <y>30</y> @@ -255,12 +216,12 @@ <height>20</height> </rect> </property> - <property name="text" > + <property name="text"> <string>Packets Rcvd.</string> </property> </widget> - <widget class="QLineEdit" name="pktsCorrectEdit" > - <property name="geometry" > + <widget class="QLineEdit" name="pktsCorrectEdit"> + <property name="geometry"> <rect> <x>120</x> <y>60</y> @@ -269,8 +230,8 @@ </rect> </property> </widget> - <widget class="QLabel" name="pktsCorrectLabel" > - <property name="geometry" > + <widget class="QLabel" name="pktsCorrectLabel"> + <property name="geometry"> <rect> <x>10</x> <y>60</y> @@ -278,12 +239,12 @@ <height>20</height> </rect> </property> - <property name="text" > + <property name="text"> <string>Packets Correct</string> </property> </widget> - <widget class="QLabel" name="perLabel" > - <property name="geometry" > + <widget class="QLabel" name="perLabel"> + <property name="geometry"> <rect> <x>10</x> <y>90</y> @@ -291,12 +252,12 @@ <height>20</height> </rect> </property> - <property name="text" > + <property name="text"> <string>PER</string> </property> </widget> - <widget class="QLineEdit" name="perEdit" > - <property name="geometry" > + <widget class="QLineEdit" name="perEdit"> + <property name="geometry"> <rect> <x>120</x> <y>90</y> @@ -305,25 +266,17 @@ </rect> </property> </widget> - <zorder>pktsRcvdEdit</zorder> - <zorder>pktsRcvdLabel</zorder> - <zorder>pktsCorrectEdit</zorder> - <zorder>pktsCorrectLabel</zorder> - <zorder>perLabel</zorder> - <zorder>perEdit</zorder> - <zorder>rxBox</zorder> - <zorder>verticalLayoutWidget</zorder> </widget> </item> <item> - <spacer name="verticalSpacer_2" > - <property name="orientation" > + <spacer name="verticalSpacer_2"> + <property name="orientation"> <enum>Qt::Vertical</enum> </property> - <property name="sizeType" > + <property name="sizeType"> <enum>QSizePolicy::Fixed</enum> </property> - <property name="sizeHint" stdset="0" > + <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>60</height> @@ -334,11 +287,11 @@ </layout> </item> <item> - <spacer name="horizontalSpacer" > - <property name="orientation" > + <spacer name="horizontalSpacer"> + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <property name="sizeHint" stdset="0" > + <property name="sizeHint" stdset="0"> <size> <width>40</width> <height>20</height> @@ -347,13 +300,13 @@ </spacer> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout_5" > + <layout class="QVBoxLayout" name="verticalLayout_5"> <item> - <spacer name="verticalSpacer_3" > - <property name="orientation" > + <spacer name="verticalSpacer_3"> + <property name="orientation"> <enum>Qt::Vertical</enum> </property> - <property name="sizeHint" stdset="0" > + <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>40</height> @@ -362,26 +315,26 @@ </spacer> </item> <item> - <widget class="QPushButton" name="closeButton" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <widget class="QPushButton" name="closeButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumSize" > + <property name="minimumSize"> <size> <width>80</width> <height>30</height> </size> </property> - <property name="maximumSize" > + <property name="maximumSize"> <size> <width>80</width> <height>30</height> </size> </property> - <property name="text" > + <property name="text"> <string>Close</string> </property> </widget> @@ -391,34 +344,27 @@ </layout> </item> </layout> - <zorder>closeButton</zorder> - <zorder>sinkFrame</zorder> - <zorder>rxBox</zorder> - <zorder>rxPacketBox</zorder> - <zorder>verticalLayoutWidget</zorder> - <zorder>verticalSpacer</zorder> - <zorder>horizontalLayoutWidget_2</zorder> </widget> - <widget class="QMenuBar" name="menubar" > - <property name="geometry" > + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> - <width>1000</width> - <height>24</height> + <width>999</width> + <height>23</height> </rect> </property> - <widget class="QMenu" name="menuFile" > - <property name="title" > + <widget class="QMenu" name="menuFile"> + <property name="title"> <string>&File</string> </property> - <addaction name="actionExit" /> + <addaction name="actionExit"/> </widget> - <addaction name="menuFile" /> + <addaction name="menuFile"/> </widget> - <widget class="QStatusBar" name="statusbar" /> - <action name="actionExit" > - <property name="text" > + <widget class="QStatusBar" name="statusbar"/> + <action name="actionExit"> + <property name="text"> <string>E&xit</string> </property> </action> @@ -431,11 +377,11 @@ <receiver>DigitalWindow</receiver> <slot>close()</slot> <hints> - <hint type="sourcelabel" > + <hint type="sourcelabel"> <x>-1</x> <y>-1</y> </hint> - <hint type="destinationlabel" > + <hint type="destinationlabel"> <x>617</x> <y>327</y> </hint> @@ -447,11 +393,11 @@ <receiver>DigitalWindow</receiver> <slot>close()</slot> <hints> - <hint type="sourcelabel" > + <hint type="sourcelabel"> <x>960</x> <y>694</y> </hint> - <hint type="destinationlabel" > + <hint type="destinationlabel"> <x>66</x> <y>561</y> </hint> diff --git a/gnuradio-examples/python/digital/qt_rx_window2.py b/gnuradio-examples/python/digital/qt_rx_window2.py index 14c961ab2..2fd719ce1 100644 --- a/gnuradio-examples/python/digital/qt_rx_window2.py +++ b/gnuradio-examples/python/digital/qt_rx_window2.py @@ -2,8 +2,8 @@ # Form implementation generated from reading ui file 'qt_rx_window2.ui' # -# Created: Sat Jan 2 12:54:51 2010 -# by: PyQt4 UI code generator 4.4.3 +# Created: Tue May 11 21:01:39 2010 +# by: PyQt4 UI code generator 4.6.1 # # WARNING! All changes made in this file will be lost! @@ -12,11 +12,14 @@ from PyQt4 import QtCore, QtGui class Ui_DigitalWindow(object): def setupUi(self, DigitalWindow): DigitalWindow.setObjectName("DigitalWindow") - DigitalWindow.resize(1000, 816) + DigitalWindow.resize(1000, 523) self.centralwidget = QtGui.QWidget(DigitalWindow) self.centralwidget.setObjectName("centralwidget") - self.gridLayout = QtGui.QGridLayout(self.centralwidget) - self.gridLayout.setObjectName("gridLayout") + self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) + self.verticalLayout.setObjectName("verticalLayout") + self.sinkLayout = QtGui.QHBoxLayout() + self.sinkLayout.setObjectName("sinkLayout") + self.verticalLayout.addLayout(self.sinkLayout) self.horizontalLayout = QtGui.QHBoxLayout() self.horizontalLayout.setSizeConstraint(QtGui.QLayout.SetFixedSize) self.horizontalLayout.setObjectName("horizontalLayout") @@ -123,26 +126,10 @@ class Ui_DigitalWindow(object): self.closeButton.setObjectName("closeButton") self.verticalLayout_5.addWidget(self.closeButton) self.horizontalLayout.addLayout(self.verticalLayout_5) - self.gridLayout.addLayout(self.horizontalLayout, 1, 0, 1, 1) - self.sinkFrame = QtGui.QFrame(self.centralwidget) - sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Preferred, QtGui.QSizePolicy.Preferred) - sizePolicy.setHorizontalStretch(0) - sizePolicy.setVerticalStretch(1) - sizePolicy.setHeightForWidth(self.sinkFrame.sizePolicy().hasHeightForWidth()) - self.sinkFrame.setSizePolicy(sizePolicy) - self.sinkFrame.setMinimumSize(QtCore.QSize(800, 500)) - self.sinkFrame.setFrameShape(QtGui.QFrame.StyledPanel) - self.sinkFrame.setFrameShadow(QtGui.QFrame.Raised) - self.sinkFrame.setObjectName("sinkFrame") - self.horizontalLayout_2 = QtGui.QHBoxLayout(self.sinkFrame) - self.horizontalLayout_2.setObjectName("horizontalLayout_2") - self.sinkLayout = QtGui.QHBoxLayout() - self.sinkLayout.setObjectName("sinkLayout") - self.horizontalLayout_2.addLayout(self.sinkLayout) - self.gridLayout.addWidget(self.sinkFrame, 0, 0, 1, 1) + self.verticalLayout.addLayout(self.horizontalLayout) DigitalWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(DigitalWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 1000, 24)) + self.menubar.setGeometry(QtCore.QRect(0, 0, 1000, 23)) self.menubar.setObjectName("menubar") self.menuFile = QtGui.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") diff --git a/gnuradio-examples/python/digital/qt_rx_window2.ui b/gnuradio-examples/python/digital/qt_rx_window2.ui index 5a83471b8..745af8fb8 100644 --- a/gnuradio-examples/python/digital/qt_rx_window2.ui +++ b/gnuradio-examples/python/digital/qt_rx_window2.ui @@ -1,104 +1,108 @@ -<ui version="4.0" > +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> <class>DigitalWindow</class> - <widget class="QMainWindow" name="DigitalWindow" > - <property name="geometry" > + <widget class="QMainWindow" name="DigitalWindow"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>1000</width> - <height>816</height> + <height>523</height> </rect> </property> - <property name="windowTitle" > + <property name="windowTitle"> <string>MainWindow</string> </property> - <widget class="QWidget" name="centralwidget" > - <layout class="QGridLayout" name="gridLayout" > - <item row="1" column="0" > - <layout class="QHBoxLayout" name="horizontalLayout" > - <property name="sizeConstraint" > + <widget class="QWidget" name="centralwidget"> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <layout class="QHBoxLayout" name="sinkLayout"/> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="sizeConstraint"> <enum>QLayout::SetFixedSize</enum> </property> <item> - <widget class="QGroupBox" name="rxBox" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <widget class="QGroupBox" name="rxBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumSize" > + <property name="minimumSize"> <size> <width>250</width> <height>190</height> </size> </property> - <property name="maximumSize" > + <property name="maximumSize"> <size> <width>250</width> <height>250</height> </size> </property> - <property name="title" > + <property name="title"> <string>Receiver Parameters</string> </property> - <layout class="QFormLayout" name="formLayout" > - <item row="0" column="0" > - <widget class="QLabel" name="freqLabel" > - <property name="text" > + <layout class="QFormLayout" name="formLayout"> + <item row="0" column="0"> + <widget class="QLabel" name="freqLabel"> + <property name="text"> <string>Frequency (Hz)</string> </property> </widget> </item> - <item row="0" column="1" > - <widget class="QLineEdit" name="freqEdit" /> + <item row="0" column="1"> + <widget class="QLineEdit" name="freqEdit"/> </item> - <item row="1" column="0" > - <widget class="QLabel" name="gainLabel" > - <property name="text" > + <item row="1" column="0"> + <widget class="QLabel" name="gainLabel"> + <property name="text"> <string>Gain (dB)</string> </property> </widget> </item> - <item row="1" column="1" > - <widget class="QLineEdit" name="gainEdit" /> + <item row="1" column="1"> + <widget class="QLineEdit" name="gainEdit"/> </item> - <item row="2" column="0" > - <widget class="QLabel" name="decimLabel" > - <property name="text" > + <item row="2" column="0"> + <widget class="QLabel" name="decimLabel"> + <property name="text"> <string>Decimation</string> </property> </widget> </item> - <item row="2" column="1" > - <widget class="QLineEdit" name="decimEdit" /> + <item row="2" column="1"> + <widget class="QLineEdit" name="decimEdit"/> </item> - <item row="3" column="0" > - <widget class="QLabel" name="gainClockLabel" > - <property name="text" > + <item row="3" column="0"> + <widget class="QLabel" name="gainClockLabel"> + <property name="text"> <string>Clock Loop Gain</string> </property> </widget> </item> - <item row="3" column="1" > - <widget class="QLineEdit" name="gainClockEdit" /> + <item row="3" column="1"> + <widget class="QLineEdit" name="gainClockEdit"/> </item> - <item row="4" column="0" > - <widget class="QLabel" name="gainPhaseLabel" > - <property name="text" > + <item row="4" column="0"> + <widget class="QLabel" name="gainPhaseLabel"> + <property name="text"> <string>Phase Loop Gain</string> </property> </widget> </item> - <item row="4" column="1" > - <widget class="QLineEdit" name="gainPhaseEdit" /> + <item row="4" column="1"> + <widget class="QLineEdit" name="gainPhaseEdit"/> </item> - <item row="5" column="1" > - <widget class="QLineEdit" name="gainFreqEdit" /> + <item row="5" column="1"> + <widget class="QLineEdit" name="gainFreqEdit"/> </item> - <item row="5" column="0" > - <widget class="QLabel" name="gainFreqLabel" > - <property name="text" > + <item row="5" column="0"> + <widget class="QLabel" name="gainFreqLabel"> + <property name="text"> <string>Freq. Loop Gain</string> </property> </widget> @@ -107,41 +111,41 @@ </widget> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout_3" > + <layout class="QVBoxLayout" name="verticalLayout_3"> <item> - <widget class="QGroupBox" name="rxPacketBox" > - <property name="enabled" > + <widget class="QGroupBox" name="rxPacketBox"> + <property name="enabled"> <bool>true</bool> </property> - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumSize" > + <property name="minimumSize"> <size> <width>250</width> <height>130</height> </size> </property> - <property name="maximumSize" > + <property name="maximumSize"> <size> <width>250</width> <height>130</height> </size> </property> - <property name="font" > + <property name="font"> <font> <weight>50</weight> <bold>false</bold> </font> </property> - <property name="title" > + <property name="title"> <string>Received Packet Info</string> </property> - <widget class="QLineEdit" name="pktsRcvdEdit" > - <property name="geometry" > + <widget class="QLineEdit" name="pktsRcvdEdit"> + <property name="geometry"> <rect> <x>120</x> <y>30</y> @@ -150,8 +154,8 @@ </rect> </property> </widget> - <widget class="QLabel" name="pktsRcvdLabel" > - <property name="geometry" > + <widget class="QLabel" name="pktsRcvdLabel"> + <property name="geometry"> <rect> <x>10</x> <y>30</y> @@ -159,12 +163,12 @@ <height>20</height> </rect> </property> - <property name="text" > + <property name="text"> <string>Packets Rcvd.</string> </property> </widget> - <widget class="QLineEdit" name="pktsCorrectEdit" > - <property name="geometry" > + <widget class="QLineEdit" name="pktsCorrectEdit"> + <property name="geometry"> <rect> <x>120</x> <y>60</y> @@ -173,8 +177,8 @@ </rect> </property> </widget> - <widget class="QLabel" name="pktsCorrectLabel" > - <property name="geometry" > + <widget class="QLabel" name="pktsCorrectLabel"> + <property name="geometry"> <rect> <x>10</x> <y>60</y> @@ -182,12 +186,12 @@ <height>20</height> </rect> </property> - <property name="text" > + <property name="text"> <string>Packets Correct</string> </property> </widget> - <widget class="QLabel" name="perLabel" > - <property name="geometry" > + <widget class="QLabel" name="perLabel"> + <property name="geometry"> <rect> <x>10</x> <y>90</y> @@ -195,12 +199,12 @@ <height>20</height> </rect> </property> - <property name="text" > + <property name="text"> <string>PER</string> </property> </widget> - <widget class="QLineEdit" name="perEdit" > - <property name="geometry" > + <widget class="QLineEdit" name="perEdit"> + <property name="geometry"> <rect> <x>120</x> <y>90</y> @@ -212,14 +216,14 @@ </widget> </item> <item> - <spacer name="verticalSpacer_2" > - <property name="orientation" > + <spacer name="verticalSpacer_2"> + <property name="orientation"> <enum>Qt::Vertical</enum> </property> - <property name="sizeType" > + <property name="sizeType"> <enum>QSizePolicy::Fixed</enum> </property> - <property name="sizeHint" stdset="0" > + <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>60</height> @@ -230,11 +234,11 @@ </layout> </item> <item> - <spacer name="horizontalSpacer" > - <property name="orientation" > + <spacer name="horizontalSpacer"> + <property name="orientation"> <enum>Qt::Horizontal</enum> </property> - <property name="sizeHint" stdset="0" > + <property name="sizeHint" stdset="0"> <size> <width>40</width> <height>20</height> @@ -243,13 +247,13 @@ </spacer> </item> <item> - <layout class="QVBoxLayout" name="verticalLayout_5" > + <layout class="QVBoxLayout" name="verticalLayout_5"> <item> - <spacer name="verticalSpacer_3" > - <property name="orientation" > + <spacer name="verticalSpacer_3"> + <property name="orientation"> <enum>Qt::Vertical</enum> </property> - <property name="sizeHint" stdset="0" > + <property name="sizeHint" stdset="0"> <size> <width>20</width> <height>40</height> @@ -258,26 +262,26 @@ </spacer> </item> <item> - <widget class="QPushButton" name="closeButton" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Fixed" hsizetype="Fixed" > + <widget class="QPushButton" name="closeButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> <horstretch>0</horstretch> <verstretch>0</verstretch> </sizepolicy> </property> - <property name="minimumSize" > + <property name="minimumSize"> <size> <width>80</width> <height>30</height> </size> </property> - <property name="maximumSize" > + <property name="maximumSize"> <size> <width>80</width> <height>30</height> </size> </property> - <property name="text" > + <property name="text"> <string>Close</string> </property> </widget> @@ -286,57 +290,28 @@ </item> </layout> </item> - <item row="0" column="0" > - <widget class="QFrame" name="sinkFrame" > - <property name="sizePolicy" > - <sizepolicy vsizetype="Preferred" hsizetype="Preferred" > - <horstretch>0</horstretch> - <verstretch>1</verstretch> - </sizepolicy> - </property> - <property name="minimumSize" > - <size> - <width>800</width> - <height>500</height> - </size> - </property> - <property name="frameShape" > - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow" > - <enum>QFrame::Raised</enum> - </property> - <layout class="QHBoxLayout" name="horizontalLayout_2" > - <item> - <layout class="QHBoxLayout" name="sinkLayout" /> - </item> - </layout> - </widget> - </item> </layout> - <zorder>sinkFrame</zorder> - <zorder>verticalSpacer</zorder> </widget> - <widget class="QMenuBar" name="menubar" > - <property name="geometry" > + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> <rect> <x>0</x> <y>0</y> <width>1000</width> - <height>24</height> + <height>23</height> </rect> </property> - <widget class="QMenu" name="menuFile" > - <property name="title" > + <widget class="QMenu" name="menuFile"> + <property name="title"> <string>&File</string> </property> - <addaction name="actionExit" /> + <addaction name="actionExit"/> </widget> - <addaction name="menuFile" /> + <addaction name="menuFile"/> </widget> - <widget class="QStatusBar" name="statusbar" /> - <action name="actionExit" > - <property name="text" > + <widget class="QStatusBar" name="statusbar"/> + <action name="actionExit"> + <property name="text"> <string>E&xit</string> </property> </action> @@ -349,11 +324,11 @@ <receiver>DigitalWindow</receiver> <slot>close()</slot> <hints> - <hint type="sourcelabel" > + <hint type="sourcelabel"> <x>-1</x> <y>-1</y> </hint> - <hint type="destinationlabel" > + <hint type="destinationlabel"> <x>617</x> <y>327</y> </hint> @@ -365,11 +340,11 @@ <receiver>DigitalWindow</receiver> <slot>close()</slot> <hints> - <hint type="sourcelabel" > + <hint type="sourcelabel"> <x>960</x> <y>694</y> </hint> - <hint type="destinationlabel" > + <hint type="destinationlabel"> <x>66</x> <y>561</y> </hint> diff --git a/gnuradio-examples/python/network/audio_sink.py b/gnuradio-examples/python/network/audio_sink.py index e59d50834..eb18a75aa 100755 --- a/gnuradio-examples/python/network/audio_sink.py +++ b/gnuradio-examples/python/network/audio_sink.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 # @@ -25,30 +25,36 @@ from gnuradio.eng_option import eng_option from optparse import OptionParser class audio_sink(gr.top_block): - def __init__(self, src, port, pkt_size, sample_rate): + def __init__(self, host, port, pkt_size, sample_rate, eof, wait): gr.top_block.__init__(self, "audio_sink") - src = gr.udp_source(gr.sizeof_float, src, port, pkt_size) + src = gr.udp_source(gr.sizeof_float, host, port, pkt_size, + eof=eof, wait=wait) dst = audio.sink(sample_rate) self.connect(src, dst) if __name__ == '__main__': parser = OptionParser(option_class=eng_option) - parser.add_option("", "--src-name", type="string", default="localhost", + parser.add_option("", "--host", type="string", default="0.0.0.0", help="local host name (domain name or IP address)") - parser.add_option("", "--src-port", type="int", default=65500, + parser.add_option("", "--port", type="int", default=65500, help="port value to listen to for connection") parser.add_option("", "--packet-size", type="int", default=1472, help="packet size.") parser.add_option("-r", "--sample-rate", type="int", default=32000, help="audio signal sample rate [default=%default]") + parser.add_option("", "--no-eof", action="store_true", default=False, + help="don't send EOF on disconnect") + parser.add_option("", "--no-wait", action="store_true", default=False, + help="don't wait for source") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 # Create an instance of a hierarchical block - top_block = audio_sink(options.src_name, options.src_port, - options.packet_size, options.sample_rate) + top_block = audio_sink(options.host, options.port, + options.packet_size, options.sample_rate, + not options.no_eof, not options.no_wait) try: # Run forever diff --git a/gnuradio-examples/python/network/audio_source.py b/gnuradio-examples/python/network/audio_source.py index d7f4f6d93..5818ccbd8 100755 --- a/gnuradio-examples/python/network/audio_source.py +++ b/gnuradio-examples/python/network/audio_source.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 # @@ -25,32 +25,33 @@ from gnuradio.eng_option import eng_option from optparse import OptionParser class audio_source(gr.top_block): - def __init__(self, src, dst, port, pkt_size, sample_rate): + def __init__(self, host, port, pkt_size, sample_rate, eof): gr.top_block.__init__(self, "audio_source") self.audio = audio.source(sample_rate) - self.sink = gr.udp_sink(gr.sizeof_float, src, 0, dst, port, pkt_size) + self.sink = gr.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof) self.connect(self.audio, self.sink) if __name__ == '__main__': parser = OptionParser(option_class=eng_option) - parser.add_option("", "--src-name", type="string", default="localhost", - help="local host name (domain name or IP address)") - parser.add_option("", "--dst-name", type="string", default="localhost", + parser.add_option("", "--host", type="string", default="localhost", help="Remote host name (domain name or IP address") - parser.add_option("", "--dst-port", type="int", default=65500, - help="port value to connect to") + parser.add_option("", "--port", type="int", default=65500, + help="port number to connect to") parser.add_option("", "--packet-size", type="int", default=1472, help="packet size.") parser.add_option("-r", "--sample-rate", type="int", default=32000 , help="audio signal sample rate [default=%default]") + parser.add_option("", "--no-eof", action="store_true", default=False, + help="don't send EOF on disconnect") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 # Create an instance of a hierarchical block - top_block = audio_source(options.src_name, options.dst_name, options.dst_port, - options.packet_size, options.sample_rate) + top_block = audio_source(options.host, options.port, + options.packet_size, options.sample_rate, + not options.no_eof) try: # Run forever diff --git a/gnuradio-examples/python/network/dial_tone_sink.py b/gnuradio-examples/python/network/dial_tone_sink.py index 47d24b9bc..1b9009552 100755 --- a/gnuradio-examples/python/network/dial_tone_sink.py +++ b/gnuradio-examples/python/network/dial_tone_sink.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 # @@ -25,30 +25,36 @@ from gnuradio.eng_option import eng_option from optparse import OptionParser class dial_tone_sink(gr.top_block): - def __init__(self, src, port, pkt_size, sample_rate): + def __init__(self, host, port, pkt_size, sample_rate, eof, wait): gr.top_block.__init__(self, "dial_tone_sink") - udp = gr.udp_source(gr.sizeof_float, src, port, pkt_size) + udp = gr.udp_source(gr.sizeof_float, host, port, pkt_size, + eof=eof, wait=wait) sink = audio.sink(sample_rate) self.connect(udp, sink) if __name__ == '__main__': parser = OptionParser(option_class=eng_option) - parser.add_option("", "--src-name", type="string", default="localhost", + parser.add_option("", "--host", type="string", default="0.0.0.0", help="local host name (domain name or IP address)") - parser.add_option("", "--src-port", type="int", default=65500, + parser.add_option("", "--port", type="int", default=65500, help="port value to listen to for connection") parser.add_option("", "--packet-size", type="int", default=1472, help="packet size.") parser.add_option("-r", "--sample-rate", type="int", default=8000, help="audio signal sample rate [default=%default]") + parser.add_option("", "--no-eof", action="store_true", default=False, + help="don't send EOF on disconnect") + parser.add_option("", "--no-wait", action="store_true", default=False, + help="don't wait for source") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 # Create an instance of a hierarchical block - top_block = dial_tone_sink(options.src_name, options.src_port, - options.packet_size, options.sample_rate) + top_block = dial_tone_sink(options.host, options.port, + options.packet_size, options.sample_rate, + not options.no_eof, not options.no_wait) try: # Run forever diff --git a/gnuradio-examples/python/network/dial_tone_source.py b/gnuradio-examples/python/network/dial_tone_source.py index 835f9aafc..766ecf16d 100755 --- a/gnuradio-examples/python/network/dial_tone_source.py +++ b/gnuradio-examples/python/network/dial_tone_source.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 # @@ -25,7 +25,7 @@ from gnuradio.eng_option import eng_option from optparse import OptionParser class dial_tone_source(gr.top_block): - def __init__(self, src, dst, port, pkt_size, sample_rate): + def __init__(self, host, port, pkt_size, sample_rate, eof): gr.top_block.__init__(self, "dial_tone_source") amplitude = 0.3 @@ -35,31 +35,32 @@ class dial_tone_source(gr.top_block): # Throttle needed here to account for the other side's audio card sampling rate thr = gr.throttle(gr.sizeof_float, sample_rate) - sink = gr.udp_sink(gr.sizeof_float, src, 0, dst, port, pkt_size) + sink = gr.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof) self.connect(src0, (add, 0)) self.connect(src1, (add, 1)) self.connect(add, thr, sink) if __name__ == '__main__': parser = OptionParser(option_class=eng_option) - parser.add_option("", "--src-name", type="string", default="localhost", - help="local host name (domain name or IP address)") - parser.add_option("", "--dst-name", type="string", default="localhost", + parser.add_option("", "--host", type="string", default="localhost", help="Remote host name (domain name or IP address") - parser.add_option("", "--dst-port", type="int", default=65500, - help="port value to connect to") + parser.add_option("", "--port", type="int", default=65500, + help="port number to connect to") parser.add_option("", "--packet-size", type="int", default=1472, help="packet size.") parser.add_option("-r", "--sample-rate", type="int", default=8000, help="audio signal sample rate [default=%default]") + parser.add_option("", "--no-eof", action="store_true", default=False, + help="don't send EOF on disconnect") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 # Create an instance of a hierarchical block - top_block = dial_tone_source(options.src_name, options.dst_name, options.dst_port, - options.packet_size, options.sample_rate) + top_block = dial_tone_source(options.host, options.port, + options.packet_size, options.sample_rate, + not options.no_eof) try: # Run forever @@ -67,4 +68,3 @@ if __name__ == '__main__': except KeyboardInterrupt: # Ctrl-C exits pass - diff --git a/gnuradio-examples/python/network/vector_sink.py b/gnuradio-examples/python/network/vector_sink.py index 981cc598b..5d73858a3 100755 --- a/gnuradio-examples/python/network/vector_sink.py +++ b/gnuradio-examples/python/network/vector_sink.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 # @@ -25,28 +25,35 @@ from gnuradio.eng_option import eng_option from optparse import OptionParser class vector_sink(gr.top_block): - def __init__(self, src, port, pkt_size): + def __init__(self, host, port, pkt_size, eof, wait): gr.top_block.__init__(self, "vector_sink") - udp = gr.udp_source(gr.sizeof_float, src, port, pkt_size) + udp = gr.udp_source(gr.sizeof_float, host, port, pkt_size, + eof=eof, wait=wait) sink = gr.file_sink(gr.sizeof_float, "received.dat") self.connect(udp, sink) if __name__ == "__main__": parser = OptionParser(option_class=eng_option) - parser.add_option("", "--src-name", type="string", default="localhost", + parser.add_option("", "--host", type="string", default="0.0.0.0", help="local host name (domain name or IP address)") - parser.add_option("", "--src-port", type="int", default=65500, + parser.add_option("", "--port", type="int", default=65500, help="port value to listen to for connection") parser.add_option("", "--packet-size", type="int", default=1471, help="packet size.") + parser.add_option("", "--no-eof", action="store_true", default=False, + help="don't send EOF on disconnect") + parser.add_option("", "--no-wait", action="store_true", default=False, + help="don't wait for source") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 # Create an instance of a hierarchical block - top_block = vector_sink(options.src_name, options.src_port, options.packet_size) + top_block = vector_sink(options.host, options.port, + options.packet_size, + not options.no_eof, not options.no_wait) try: # Run forever diff --git a/gnuradio-examples/python/network/vector_source.py b/gnuradio-examples/python/network/vector_source.py index e7ec2a461..0e7d67844 100755 --- a/gnuradio-examples/python/network/vector_source.py +++ b/gnuradio-examples/python/network/vector_source.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 # @@ -25,31 +25,31 @@ from gnuradio.eng_option import eng_option from optparse import OptionParser class vector_source(gr.top_block): - def __init__(self, src, dst, port, pkt_size): + def __init__(self, host, port, pkt_size, eof): gr.top_block.__init__(self, "vector_source") data = [i*0.01 for i in range(1000)] vec = gr.vector_source_f(data, True) - udp = gr.udp_sink(gr.sizeof_float, src, 0, dst, port, pkt_size) + udp = gr.udp_sink(gr.sizeof_float, host, port, pkt_size, eof=eof) self.connect(vec, udp) if __name__ == '__main__': parser = OptionParser(option_class=eng_option) - parser.add_option("", "--src-name", type="string", default="localhost", - help="local host name (domain name or IP address)") - parser.add_option("", "--dst-name", type="string", default="localhost", + parser.add_option("", "--host", type="string", default="localhost", help="Remote host name (domain name or IP address") - parser.add_option("", "--dst-port", type="int", default=65500, - help="port value to connect to") + parser.add_option("", "--port", type="int", default=65500, + help="port number to connect to") parser.add_option("", "--packet-size", type="int", default=1471, help="packet size.") + parser.add_option("", "--no-eof", action="store_true", default=False, + help="don't send EOF on disconnect") (options, args) = parser.parse_args() if len(args) != 0: parser.print_help() raise SystemExit, 1 # Create an instance of a hierarchical block - top_block = vector_source(options.src_name, options.dst_name, - options.dst_port, options.packet_size) + top_block = vector_source(options.host, options.port, options.packet_size, + not options.no_eof) try: # Run forever diff --git a/gr-atsc/gnuradio-atsc.pc.in b/gr-atsc/gnuradio-atsc.pc.in index 4c5ae0682..4413bfc82 100644 --- a/gr-atsc/gnuradio-atsc.pc.in +++ b/gr-atsc/gnuradio-atsc.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: gnuradio-atsc Description: The GNU Radio blocks for ATSC decoding Requires: gnuradio-core -Version: @VERSION@ +Version: @LIBVER@ Libs: -L${libdir} -lgnuradio-atsc Cflags: -I${includedir} diff --git a/gr-atsc/src/lib/Makefile.am b/gr-atsc/src/lib/Makefile.am index 8aeb80c0a..bf9c6626a 100644 --- a/gr-atsc/src/lib/Makefile.am +++ b/gr-atsc/src/lib/Makefile.am @@ -92,8 +92,7 @@ BUILT_SOURCES = \ libgnuradio_atsc_la_LIBADD = \ $(GNURADIO_CORE_LA) -libgnuradio_atsc_la_LDFLAGS = \ - $(NO_UNDEFINED) +libgnuradio_atsc_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) noinst_LTLIBRARIES = libgnuradio-atsc-qa.la diff --git a/gr-atsc/src/lib/atsc_bit_timing_loop.cc b/gr-atsc/src/lib/atsc_bit_timing_loop.cc index a661e708b..d87a2c3fd 100644 --- a/gr-atsc/src/lib/atsc_bit_timing_loop.cc +++ b/gr-atsc/src/lib/atsc_bit_timing_loop.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -37,7 +37,7 @@ double ratio_of_rx_clock_to_symbol_freq = input_rate / ATSC_SYMBOL_RATE; atsc_bit_timing_loop_sptr atsc_make_bit_timing_loop() { - return atsc_bit_timing_loop_sptr(new atsc_bit_timing_loop()); + return gnuradio::get_initial_sptr(new atsc_bit_timing_loop()); } diff --git a/gr-atsc/src/lib/atsc_deinterleaver.cc b/gr-atsc/src/lib/atsc_deinterleaver.cc index af58777dd..aee9cd58b 100644 --- a/gr-atsc/src/lib/atsc_deinterleaver.cc +++ b/gr-atsc/src/lib/atsc_deinterleaver.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ atsc_deinterleaver_sptr atsc_make_deinterleaver() { - return atsc_deinterleaver_sptr(new atsc_deinterleaver()); + return gnuradio::get_initial_sptr(new atsc_deinterleaver()); } atsc_deinterleaver::atsc_deinterleaver() diff --git a/gr-atsc/src/lib/atsc_depad.cc b/gr-atsc/src/lib/atsc_depad.cc index f1e830568..5cf0c3de2 100644 --- a/gr-atsc/src/lib/atsc_depad.cc +++ b/gr-atsc/src/lib/atsc_depad.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006,2008 Free Software Foundation, Inc. + * Copyright 2006,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ atsc_depad_sptr atsc_make_depad() { - return atsc_depad_sptr(new atsc_depad()); + return gnuradio::get_initial_sptr(new atsc_depad()); } atsc_depad::atsc_depad() diff --git a/gr-atsc/src/lib/atsc_derandomizer.cc b/gr-atsc/src/lib/atsc_derandomizer.cc index 361b781ad..7dc4cf4c1 100644 --- a/gr-atsc/src/lib/atsc_derandomizer.cc +++ b/gr-atsc/src/lib/atsc_derandomizer.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ atsc_derandomizer_sptr atsc_make_derandomizer() { - return atsc_derandomizer_sptr(new atsc_derandomizer()); + return gnuradio::get_initial_sptr(new atsc_derandomizer()); } atsc_derandomizer::atsc_derandomizer() diff --git a/gr-atsc/src/lib/atsc_ds_to_softds.cc b/gr-atsc/src/lib/atsc_ds_to_softds.cc index 8d3fc3385..c589bbb9f 100644 --- a/gr-atsc/src/lib/atsc_ds_to_softds.cc +++ b/gr-atsc/src/lib/atsc_ds_to_softds.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ atsc_ds_to_softds_sptr atsc_make_ds_to_softds() { - return atsc_ds_to_softds_sptr(new atsc_ds_to_softds()); + return gnuradio::get_initial_sptr(new atsc_ds_to_softds()); } atsc_ds_to_softds::atsc_ds_to_softds() diff --git a/gr-atsc/src/lib/atsc_equalizer.cc b/gr-atsc/src/lib/atsc_equalizer.cc index 3053c00b8..3e68de992 100644 --- a/gr-atsc/src/lib/atsc_equalizer.cc +++ b/gr-atsc/src/lib/atsc_equalizer.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -34,7 +34,7 @@ atsc_equalizer_sptr atsc_make_equalizer() { - return atsc_equalizer_sptr(new atsc_equalizer()); + return gnuradio::get_initial_sptr(new atsc_equalizer()); } // had atsc_equalizer(atsci_equalizer *equalizer) diff --git a/gr-atsc/src/lib/atsc_field_sync_demux.cc b/gr-atsc/src/lib/atsc_field_sync_demux.cc index b6195c6df..3b321eae6 100644 --- a/gr-atsc/src/lib/atsc_field_sync_demux.cc +++ b/gr-atsc/src/lib/atsc_field_sync_demux.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -44,7 +44,7 @@ static const int DEC = ATSC_DATA_SEGMENT_LENGTH; // nominal decimation fa atsc_field_sync_demux_sptr atsc_make_field_sync_demux() { - return atsc_field_sync_demux_sptr(new atsc_field_sync_demux()); + return gnuradio::get_initial_sptr(new atsc_field_sync_demux()); } atsc_field_sync_demux::atsc_field_sync_demux() diff --git a/gr-atsc/src/lib/atsc_field_sync_mux.cc b/gr-atsc/src/lib/atsc_field_sync_mux.cc index 526599aed..3d0e20a1c 100644 --- a/gr-atsc/src/lib/atsc_field_sync_mux.cc +++ b/gr-atsc/src/lib/atsc_field_sync_mux.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -33,7 +33,7 @@ atsc_field_sync_mux_sptr atsc_make_field_sync_mux() { - return atsc_field_sync_mux_sptr(new atsc_field_sync_mux()); + return gnuradio::get_initial_sptr(new atsc_field_sync_mux()); } atsc_field_sync_mux::atsc_field_sync_mux() diff --git a/gr-atsc/src/lib/atsc_fpll.cc b/gr-atsc/src/lib/atsc_fpll.cc index f5bf39d20..676a7453e 100644 --- a/gr-atsc/src/lib/atsc_fpll.cc +++ b/gr-atsc/src/lib/atsc_fpll.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -34,7 +34,7 @@ atsc_fpll_sptr atsc_make_fpll() { - return atsc_fpll_sptr(new atsc_fpll()); + return gnuradio::get_initial_sptr(new atsc_fpll()); } diff --git a/gr-atsc/src/lib/atsc_fs_checker.cc b/gr-atsc/src/lib/atsc_fs_checker.cc index 69406650e..6162c9ef6 100644 --- a/gr-atsc/src/lib/atsc_fs_checker.cc +++ b/gr-atsc/src/lib/atsc_fs_checker.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -35,7 +35,7 @@ atsc_fs_checker_sptr atsc_make_fs_checker() { - return atsc_fs_checker_sptr(new atsc_fs_checker()); + return gnuradio::get_initial_sptr(new atsc_fs_checker()); } atsc_fs_checker::atsc_fs_checker() diff --git a/gr-atsc/src/lib/atsc_interleaver.cc b/gr-atsc/src/lib/atsc_interleaver.cc index d9fd98bb3..a87091436 100644 --- a/gr-atsc/src/lib/atsc_interleaver.cc +++ b/gr-atsc/src/lib/atsc_interleaver.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ atsc_interleaver_sptr atsc_make_interleaver() { - return atsc_interleaver_sptr(new atsc_interleaver()); + return gnuradio::get_initial_sptr(new atsc_interleaver()); } atsc_interleaver::atsc_interleaver() diff --git a/gr-atsc/src/lib/atsc_pad.cc b/gr-atsc/src/lib/atsc_pad.cc index cd1353e26..8a36307af 100644 --- a/gr-atsc/src/lib/atsc_pad.cc +++ b/gr-atsc/src/lib/atsc_pad.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -33,7 +33,7 @@ static const int INTR = ATSC_MPEG_PKT_LENGTH; atsc_pad_sptr atsc_make_pad() { - return atsc_pad_sptr(new atsc_pad()); + return gnuradio::get_initial_sptr(new atsc_pad()); } atsc_pad::atsc_pad() diff --git a/gr-atsc/src/lib/atsc_randomizer.cc b/gr-atsc/src/lib/atsc_randomizer.cc index e6756c6ed..cd797b8f5 100644 --- a/gr-atsc/src/lib/atsc_randomizer.cc +++ b/gr-atsc/src/lib/atsc_randomizer.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ atsc_randomizer_sptr atsc_make_randomizer() { - return atsc_randomizer_sptr(new atsc_randomizer()); + return gnuradio::get_initial_sptr(new atsc_randomizer()); } atsc_randomizer::atsc_randomizer() diff --git a/gr-atsc/src/lib/atsc_rs_decoder.cc b/gr-atsc/src/lib/atsc_rs_decoder.cc index 680d64e43..aa3f9369e 100644 --- a/gr-atsc/src/lib/atsc_rs_decoder.cc +++ b/gr-atsc/src/lib/atsc_rs_decoder.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ atsc_rs_decoder_sptr atsc_make_rs_decoder() { - return atsc_rs_decoder_sptr(new atsc_rs_decoder()); + return gnuradio::get_initial_sptr(new atsc_rs_decoder()); } atsc_rs_decoder::atsc_rs_decoder() diff --git a/gr-atsc/src/lib/atsc_rs_encoder.cc b/gr-atsc/src/lib/atsc_rs_encoder.cc index faf9bfff3..f98ff664c 100644 --- a/gr-atsc/src/lib/atsc_rs_encoder.cc +++ b/gr-atsc/src/lib/atsc_rs_encoder.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ atsc_rs_encoder_sptr atsc_make_rs_encoder() { - return atsc_rs_encoder_sptr(new atsc_rs_encoder()); + return gnuradio::get_initial_sptr(new atsc_rs_encoder()); } atsc_rs_encoder::atsc_rs_encoder() diff --git a/gr-atsc/src/lib/atsc_trellis_encoder.cc b/gr-atsc/src/lib/atsc_trellis_encoder.cc index efd088310..4cf81a045 100644 --- a/gr-atsc/src/lib/atsc_trellis_encoder.cc +++ b/gr-atsc/src/lib/atsc_trellis_encoder.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ atsc_trellis_encoder_sptr atsc_make_trellis_encoder() { - return atsc_trellis_encoder_sptr(new atsc_trellis_encoder()); + return gnuradio::get_initial_sptr(new atsc_trellis_encoder()); } atsc_trellis_encoder::atsc_trellis_encoder() diff --git a/gr-atsc/src/lib/atsc_viterbi_decoder.cc b/gr-atsc/src/lib/atsc_viterbi_decoder.cc index 9db040121..81ad9178a 100644 --- a/gr-atsc/src/lib/atsc_viterbi_decoder.cc +++ b/gr-atsc/src/lib/atsc_viterbi_decoder.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -35,7 +35,7 @@ using std::endl; atsc_viterbi_decoder_sptr atsc_make_viterbi_decoder() { - return atsc_viterbi_decoder_sptr(new atsc_viterbi_decoder()); + return gnuradio::get_initial_sptr(new atsc_viterbi_decoder()); } atsc_viterbi_decoder::atsc_viterbi_decoder() diff --git a/gr-atsc/src/lib/test_atsci.cc b/gr-atsc/src/lib/test_atsci.cc index 5267e0d4f..184895a90 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 <gr_unittests.h> #include <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> #include <qa_atsci.h> 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/gnuradio-audio-alsa.pc.in b/gr-audio-alsa/gnuradio-audio-alsa.pc.in index 797bfc024..d5147e6af 100644 --- a/gr-audio-alsa/gnuradio-audio-alsa.pc.in +++ b/gr-audio-alsa/gnuradio-audio-alsa.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: gnuradio-audio-alsa Description: The GNU Radio block for the ALSA sound system Requires: gnuradio-core alsa -Version: @VERSION@ +Version: @LIBVER@ Libs: -L${libdir} -lgnuradio-audio-alsa Cflags: -I${includedir} diff --git a/gr-audio-alsa/src/Makefile.am b/gr-audio-alsa/src/Makefile.am index ee7498af4..ed92cc197 100644 --- a/gr-audio-alsa/src/Makefile.am +++ b/gr-audio-alsa/src/Makefile.am @@ -50,8 +50,7 @@ libgnuradio_audio_alsa_la_LIBADD = \ $(GNURADIO_CORE_LA) \ $(ALSA_LIBS) -libgnuradio_audio_alsa_la_LDFLAGS = \ - $(NO_UNDEFINED) +libgnuradio_audio_alsa_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) if PYTHON ################################### diff --git a/gr-audio-alsa/src/audio_alsa_sink.cc b/gr-audio-alsa/src/audio_alsa_sink.cc index fe3f043bf..d6b7f84cf 100644 --- a/gr-audio-alsa/src/audio_alsa_sink.cc +++ b/gr-audio-alsa/src/audio_alsa_sink.cc @@ -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 * @@ -70,7 +70,7 @@ audio_alsa_make_sink (int sampling_rate, const std::string dev, bool ok_to_block) { - return audio_alsa_sink_sptr (new audio_alsa_sink (sampling_rate, dev, + return gnuradio::get_initial_sptr(new audio_alsa_sink (sampling_rate, dev, ok_to_block)); } diff --git a/gr-audio-alsa/src/audio_alsa_source.cc b/gr-audio-alsa/src/audio_alsa_source.cc index 381e553f5..7b3d91b9d 100644 --- a/gr-audio-alsa/src/audio_alsa_source.cc +++ b/gr-audio-alsa/src/audio_alsa_source.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -68,7 +68,7 @@ audio_alsa_source_sptr audio_alsa_make_source (int sampling_rate, const std::string dev, bool ok_to_block) { - return audio_alsa_source_sptr (new audio_alsa_source (sampling_rate, dev, + return gnuradio::get_initial_sptr(new audio_alsa_source (sampling_rate, dev, ok_to_block)); } diff --git a/gr-audio-alsa/src/qa_alsa.py b/gr-audio-alsa/src/qa_alsa.py index f2a480a50..52dbfdc7a 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/gnuradio-audio-jack.pc.in b/gr-audio-jack/gnuradio-audio-jack.pc.in index eaceaea2f..8fb4a2e0d 100644 --- a/gr-audio-jack/gnuradio-audio-jack.pc.in +++ b/gr-audio-jack/gnuradio-audio-jack.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: gnuradio-audio-jack Description: GNU Radio blocks for the JACK sound system Requires: gnuradio-core jack -Version: @VERSION@ +Version: @LIBVER@ Libs: -L${libdir} -lgnuradio-audio-jack Cflags: -I${includedir} diff --git a/gr-audio-jack/src/Makefile.am b/gr-audio-jack/src/Makefile.am index b766ec201..8e0dfe1e3 100644 --- a/gr-audio-jack/src/Makefile.am +++ b/gr-audio-jack/src/Makefile.am @@ -42,8 +42,7 @@ libgnuradio_audio_jack_la_LIBADD = \ $(GNURADIO_CORE_LA) \ $(JACK_LIBS) -libgnuradio_audio_jack_la_LDFLAGS = \ - $(NO_UNDEFINED) +libgnuradio_audio_jack_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) noinst_PYTHON = \ qa_jack.py diff --git a/gr-audio-jack/src/audio_jack_sink.cc b/gr-audio-jack/src/audio_jack_sink.cc index 9dfc46751..6e39135c9 100644 --- a/gr-audio-jack/src/audio_jack_sink.cc +++ b/gr-audio-jack/src/audio_jack_sink.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005,2006 Free Software Foundation, Inc. + * Copyright 2005,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -87,7 +87,7 @@ jack_sink_process (jack_nframes_t nframes, void *arg) audio_jack_sink_sptr audio_jack_make_sink(int sampling_rate, const std::string dev, bool ok_to_block) { - return audio_jack_sink_sptr (new audio_jack_sink (sampling_rate, dev, + return gnuradio::get_initial_sptr(new audio_jack_sink (sampling_rate, dev, ok_to_block)); } diff --git a/gr-audio-jack/src/audio_jack_source.cc b/gr-audio-jack/src/audio_jack_source.cc index 392d246b4..ca3df51d7 100644 --- a/gr-audio-jack/src/audio_jack_source.cc +++ b/gr-audio-jack/src/audio_jack_source.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005,2006 Free Software Foundation, Inc. + * Copyright 2005,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -88,7 +88,7 @@ jack_source_process (jack_nframes_t nframes, void *arg) audio_jack_source_sptr audio_jack_make_source (int sampling_rate, const std::string dev, bool ok_to_block) { - return audio_jack_source_sptr (new audio_jack_source (sampling_rate, dev, ok_to_block)); + return gnuradio::get_initial_sptr(new audio_jack_source (sampling_rate, dev, ok_to_block)); } audio_jack_source::audio_jack_source (int sampling_rate, diff --git a/gr-audio-jack/src/qa_jack.py b/gr-audio-jack/src/qa_jack.py index d8a3aba88..ad6bee27b 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/gnuradio-audio-oss.pc.in b/gr-audio-oss/gnuradio-audio-oss.pc.in index f598ba304..4a215bdab 100644 --- a/gr-audio-oss/gnuradio-audio-oss.pc.in +++ b/gr-audio-oss/gnuradio-audio-oss.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: gnuradio-audio-oss Description: The GNU Radio block for the OSS sound system Requires: gnuradio-core -Version: @VERSION@ +Version: @LIBVER@ Libs: -L${libdir} -lgnuradio-audio-oss Cflags: -I${includedir} diff --git a/gr-audio-oss/src/Makefile.am b/gr-audio-oss/src/Makefile.am index 614280639..628c9fd93 100644 --- a/gr-audio-oss/src/Makefile.am +++ b/gr-audio-oss/src/Makefile.am @@ -42,8 +42,7 @@ libgnuradio_audio_oss_la_LIBADD = \ $(GNURADIO_CORE_LA) \ $(OSS_LIBS) -libgnuradio_audio_oss_la_LDFLAGS = \ - $(NO_UNDEFINED) +libgnuradio_audio_oss_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) if PYTHON ################################### diff --git a/gr-audio-oss/src/audio_oss_sink.cc b/gr-audio-oss/src/audio_oss_sink.cc index a14edc9d2..8230ab9b6 100644 --- a/gr-audio-oss/src/audio_oss_sink.cc +++ b/gr-audio-oss/src/audio_oss_sink.cc @@ -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 * @@ -47,7 +47,7 @@ default_device_name () audio_oss_sink_sptr audio_oss_make_sink (int sampling_rate, const std::string dev, bool ok_to_block) { - return audio_oss_sink_sptr (new audio_oss_sink (sampling_rate, dev, ok_to_block)); + return gnuradio::get_initial_sptr(new audio_oss_sink (sampling_rate, dev, ok_to_block)); } audio_oss_sink::audio_oss_sink (int sampling_rate, diff --git a/gr-audio-oss/src/audio_oss_source.cc b/gr-audio-oss/src/audio_oss_source.cc index 1df98a5eb..fbb898f8c 100644 --- a/gr-audio-oss/src/audio_oss_source.cc +++ b/gr-audio-oss/src/audio_oss_source.cc @@ -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 * @@ -47,7 +47,7 @@ default_device_name () audio_oss_source_sptr audio_oss_make_source (int sampling_rate, const std::string dev, bool ok_to_block) { - return audio_oss_source_sptr (new audio_oss_source (sampling_rate, dev, ok_to_block)); + return gnuradio::get_initial_sptr(new audio_oss_source (sampling_rate, dev, ok_to_block)); } diff --git a/gr-audio-oss/src/qa_oss.py b/gr-audio-oss/src/qa_oss.py index 5427b50ec..365dabc25 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-osx/src/Makefile.am b/gr-audio-osx/src/Makefile.am index 5bf28b8e7..ee9df7765 100644 --- a/gr-audio-osx/src/Makefile.am +++ b/gr-audio-osx/src/Makefile.am @@ -51,7 +51,8 @@ libgnuradio_audio_osx_la_LDFLAGS = \ -framework AudioUnit \ -framework CoreAudio \ -framework AudioToolbox \ - $(NO_UNDEFINED) + $(NO_UNDEFINED) \ + $(LTVERSIONFLAGS) if PYTHON ################################### diff --git a/gr-audio-osx/src/audio_osx_sink.cc b/gr-audio-osx/src/audio_osx_sink.cc index 20fd895b9..ec9b024e8 100644 --- a/gr-audio-osx/src/audio_osx_sink.cc +++ b/gr-audio-osx/src/audio_osx_sink.cc @@ -267,7 +267,7 @@ audio_osx_make_sink (int sampling_freq, int channel_config, int max_sample_count) { - return audio_osx_sink_sptr (new audio_osx_sink (sampling_freq, + return gnuradio::get_initial_sptr(new audio_osx_sink (sampling_freq, dev, do_block, channel_config, diff --git a/gr-audio-osx/src/audio_osx_source.cc b/gr-audio-osx/src/audio_osx_source.cc index 538cfd8f6..757e65a9e 100644 --- a/gr-audio-osx/src/audio_osx_source.cc +++ b/gr-audio-osx/src/audio_osx_source.cc @@ -614,7 +614,7 @@ audio_osx_make_source (int sampling_freq, int channel_config, int max_sample_count) { - return audio_osx_source_sptr (new audio_osx_source (sampling_freq, + return gnuradio::get_initial_sptr(new audio_osx_source (sampling_freq, device_name, do_block, channel_config, diff --git a/gr-audio-portaudio/gnuradio-audio-portaudio.pc.in b/gr-audio-portaudio/gnuradio-audio-portaudio.pc.in index 8f2c80869..086195965 100644 --- a/gr-audio-portaudio/gnuradio-audio-portaudio.pc.in +++ b/gr-audio-portaudio/gnuradio-audio-portaudio.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: gnuradio-audio-portaudio Description: The GNU Radio block for the PORTAUDIO sound system Requires: gnuradio-core -Version: @VERSION@ +Version: @LIBVER@ Libs: -L${libdir} -lgnuradio-audio-portaudio Cflags: -I${includedir} diff --git a/gr-audio-portaudio/src/Makefile.am b/gr-audio-portaudio/src/Makefile.am index 20213d16b..4fa098dcc 100644 --- a/gr-audio-portaudio/src/Makefile.am +++ b/gr-audio-portaudio/src/Makefile.am @@ -46,11 +46,9 @@ libgnuradio_audio_portaudio_la_SOURCES = \ libgnuradio_audio_portaudio_la_LIBADD = \ $(GNURADIO_CORE_LA) \ - $(OMNITHREAD_LA) \ $(PORTAUDIO_LIBS) -libgnuradio_audio_portaudio_la_LDFLAGS = \ - $(NO_UNDEFINED) +libgnuradio_audio_portaudio_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) if PYTHON diff --git a/gr-audio-portaudio/src/audio_portaudio_sink.cc b/gr-audio-portaudio/src/audio_portaudio_sink.cc index 2e48feb4a..9a3baf40e 100644 --- a/gr-audio-portaudio/src/audio_portaudio_sink.cc +++ b/gr-audio-portaudio/src/audio_portaudio_sink.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,6 @@ #include <unistd.h> #include <stdexcept> #include <gri_portaudio.h> -#include <gnuradio/omnithread.h> #include <string.h> //#define LOGGING 0 // define to 0 or 1 @@ -84,31 +83,33 @@ portaudio_sink_callback (const void *inputBuffer, int navail_samples = self->d_reader->items_available(); - if (nreqd_samples <= navail_samples){ // We've got enough data... - //if (LOGGING) - // self->d_log->printf("PAsink cb: f/b = %4ld\n", framesPerBuffer); - // copy from ringbuffer into output buffer - memcpy(outputBuffer, - self->d_reader->read_pointer(), - nreqd_samples * sizeof(sample_t)); - self->d_reader->update_read_pointer(nreqd_samples); - + if (nreqd_samples <= navail_samples) { // We've got enough data... + { + gruel::scoped_lock guard(self->d_ringbuffer_mutex); + + memcpy(outputBuffer, + self->d_reader->read_pointer(), + nreqd_samples * sizeof(sample_t)); + self->d_reader->update_read_pointer(nreqd_samples); + + self->d_ringbuffer_ready = true; + } + // Tell the sink thread there is new room in the ringbuffer. - self->d_ringbuffer_ready.post(); + self->d_ringbuffer_cond.notify_one(); return paContinue; } else { // underrun - //if (LOGGING) - // self->d_log->printf("PAsink cb: f/b = %4ld UNDERRUN\n", framesPerBuffer); - self->d_nunderuns++; ::write(2, "aU", 2); // FIXME change to non-blocking call // FIXME we should transfer what we've got and pad the rest memset(outputBuffer, 0, nreqd_samples * sizeof(sample_t)); - self->d_ringbuffer_ready.post(); // Tell the sink to get going! + self->d_ringbuffer_ready = true; + self->d_ringbuffer_cond.notify_one(); // Tell the sink to get going! + return paContinue; } } @@ -119,7 +120,7 @@ portaudio_sink_callback (const void *inputBuffer, audio_portaudio_sink_sptr audio_portaudio_make_sink (int sampling_rate, const std::string dev, bool ok_to_block) { - return audio_portaudio_sink_sptr (new audio_portaudio_sink (sampling_rate, + return gnuradio::get_initial_sptr(new audio_portaudio_sink (sampling_rate, dev, ok_to_block)); } @@ -135,7 +136,9 @@ audio_portaudio_sink::audio_portaudio_sink(int sampling_rate, d_verbose(gr_prefs::singleton()->get_bool("audio_portaudio", "verbose", false)), d_portaudio_buffer_size_frames(0), d_stream(0), - d_ringbuffer_ready(1, 1), // binary semaphore + d_ringbuffer_mutex(), + d_ringbuffer_cond(), + d_ringbuffer_ready(false), d_nunderuns(0) { memset(&d_output_parameters, 0, sizeof(d_output_parameters)); @@ -297,12 +300,17 @@ audio_portaudio_sink::work (int noutput_items, const unsigned nchan = d_output_parameters.channelCount; // # of channels == samples/frame int k; - for (k = 0; k < noutput_items; ){ + for (k = 0; k < noutput_items; ){ int nframes = d_writer->space_available() / nchan; // How much space in ringbuffer if (nframes == 0){ // no room... if (d_ok_to_block){ - d_ringbuffer_ready.wait(); // block here, then try again + { + gruel::scoped_lock guard(d_ringbuffer_mutex); + while (!d_ringbuffer_ready) + d_ringbuffer_cond.wait(guard); + } + continue; } else { @@ -316,16 +324,21 @@ audio_portaudio_sink::work (int noutput_items, } // We can write the smaller of the request and the room we've got - int nf = std::min(noutput_items - k, nframes); - - float *p = (float *) d_writer->write_pointer(); - for (int i = 0; i < nf; i++){ - for (unsigned int c = 0; c < nchan; c++){ - *p++ = in[c][k + i]; - } + { + gruel::scoped_lock guard(d_ringbuffer_mutex); + + int nf = std::min(noutput_items - k, nframes); + float *p = (float *) d_writer->write_pointer(); + + for (int i = 0; i < nf; i++) + for (unsigned int c = 0; c < nchan; c++) + *p++ = in[c][k + i]; + + d_writer->update_write_pointer(nf * nchan); + k += nf; + + d_ringbuffer_ready = false; } - d_writer->update_write_pointer(nf * nchan); - k += nf; } return k; // tell how many we actually did diff --git a/gr-audio-portaudio/src/audio_portaudio_sink.h b/gr-audio-portaudio/src/audio_portaudio_sink.h index 1a0729799..71cbfcf9f 100644 --- a/gr-audio-portaudio/src/audio_portaudio_sink.h +++ b/gr-audio-portaudio/src/audio_portaudio_sink.h @@ -24,7 +24,7 @@ #include <gr_sync_block.h> #include <gr_buffer.h> -#include <gnuradio/omnithread.h> +#include <gruel/thread.h> #include <string> #include <portaudio.h> #include <stdexcept> @@ -74,8 +74,10 @@ class audio_portaudio_sink : public gr_sync_block { gr_buffer_sptr d_writer; // buffer used between work and callback gr_buffer_reader_sptr d_reader; - omni_semaphore d_ringbuffer_ready; // binary semaphore + gruel::mutex d_ringbuffer_mutex; + gruel::condition_variable d_ringbuffer_cond; + bool d_ringbuffer_ready; // random stats int d_nunderuns; // count of underruns diff --git a/gr-audio-portaudio/src/audio_portaudio_source.cc b/gr-audio-portaudio/src/audio_portaudio_source.cc index 9e883ad8a..23801a8bf 100644 --- a/gr-audio-portaudio/src/audio_portaudio_source.cc +++ b/gr-audio-portaudio/src/audio_portaudio_source.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,6 @@ #include <unistd.h> #include <stdexcept> #include <gri_portaudio.h> -#include <gnuradio/omnithread.h> #include <string.h> //#define LOGGING 0 // define to 0 or 1 @@ -88,32 +87,28 @@ portaudio_source_callback (const void *inputBuffer, // self->d_log->printf("PAsrc cb: f/b = %4ld\n", framesPerBuffer); // copy from input buffer to ringbuffer - memcpy(self->d_writer->write_pointer(), - inputBuffer, - nframes_to_copy * nchan * sizeof(sample_t)); - self->d_writer->update_write_pointer(nframes_to_copy * nchan); + { + gruel::scoped_lock(d_ringbuffer_mutex); + + memcpy(self->d_writer->write_pointer(), + inputBuffer, + nframes_to_copy * nchan * sizeof(sample_t)); + self->d_writer->update_write_pointer(nframes_to_copy * nchan); - // Tell the source thread there is new data in the ringbuffer. - self->d_ringbuffer_ready.post(); + // Tell the source thread there is new data in the ringbuffer. + self->d_ringbuffer_ready = true; + } + + self->d_ringbuffer_cond.notify_one(); return paContinue; } else { // overrun - //if (LOGGING) - // self->d_log->printf("PAsrc cb: f/b = %4ld OVERRUN\n", framesPerBuffer); - self->d_noverruns++; ::write(2, "aO", 2); // FIXME change to non-blocking call -#if 0 - // copy any frames that will fit - memcpy(self->d_writer->write_pointer(), - inputBuffer, - nframes_room * nchan * sizeof(sample_t)); - self->d_writer->update_write_pointer(nframes_room * nchan); -#endif - - self->d_ringbuffer_ready.post(); // Tell the sink to get going! + self->d_ringbuffer_ready = false; + self->d_ringbuffer_cond.notify_one(); // Tell the sink to get going! return paContinue; } } @@ -124,7 +119,7 @@ portaudio_source_callback (const void *inputBuffer, audio_portaudio_source_sptr audio_portaudio_make_source (int sampling_rate, const std::string dev, bool ok_to_block) { - return audio_portaudio_source_sptr (new audio_portaudio_source (sampling_rate, + return gnuradio::get_initial_sptr(new audio_portaudio_source (sampling_rate, dev, ok_to_block)); } @@ -140,7 +135,9 @@ audio_portaudio_source::audio_portaudio_source(int sampling_rate, d_verbose(gr_prefs::singleton()->get_bool("audio_portaudio", "verbose", false)), d_portaudio_buffer_size_frames(0), d_stream(0), - d_ringbuffer_ready(1, 1), // binary semaphore + d_ringbuffer_mutex(), + d_ringbuffer_cond(), + d_ringbuffer_ready(false), d_noverruns(0) { memset(&d_input_parameters, 0, sizeof(d_input_parameters)); @@ -303,11 +300,13 @@ audio_portaudio_source::work (int noutput_items, if (k > 0) // If we've produced anything so far, return that return k; - if (d_ok_to_block){ - d_ringbuffer_ready.wait(); // block here, then try again + if (d_ok_to_block) { + gruel:: scoped_lock guard(d_ringbuffer_mutex); + while (d_ringbuffer_ready == false) + d_ringbuffer_cond.wait(guard); // block here, then try again continue; } - + assert(k == 0); // There's no data and we're not allowed to block. @@ -320,27 +319,38 @@ audio_portaudio_source::work (int noutput_items, // FIXME We'll fill with zeros for now. Yes, it will "click"... // Fill with some frames of zeros - int nf = std::min(noutput_items - k, (int) d_portaudio_buffer_size_frames); - for (int i = 0; i < nf; i++){ - for (unsigned int c = 0; c < nchan; c++){ - out[c][k + i] = 0; + { + gruel::scoped_lock guard(d_ringbuffer_mutex); + + int nf = std::min(noutput_items - k, (int) d_portaudio_buffer_size_frames); + for (int i = 0; i < nf; i++){ + for (unsigned int c = 0; c < nchan; c++){ + out[c][k + i] = 0; + } } + k += nf; + + d_ringbuffer_ready = false; + return k; } - k += nf; - return k; } // We can read the smaller of the request and what's in the buffer. - int nf = std::min(noutput_items - k, nframes); + { + gruel::scoped_lock guard(d_ringbuffer_mutex); - const float *p = (const float *) d_reader->read_pointer(); - for (int i = 0; i < nf; i++){ - for (unsigned int c = 0; c < nchan; c++){ - out[c][k + i] = *p++; + int nf = std::min(noutput_items - k, nframes); + + const float *p = (const float *) d_reader->read_pointer(); + for (int i = 0; i < nf; i++){ + for (unsigned int c = 0; c < nchan; c++){ + out[c][k + i] = *p++; + } } + d_reader->update_read_pointer(nf * nchan); + k += nf; + d_ringbuffer_ready = false; } - d_reader->update_read_pointer(nf * nchan); - k += nf; } return k; // tell how many we actually did diff --git a/gr-audio-portaudio/src/audio_portaudio_source.h b/gr-audio-portaudio/src/audio_portaudio_source.h index 3102db739..31e70a127 100644 --- a/gr-audio-portaudio/src/audio_portaudio_source.h +++ b/gr-audio-portaudio/src/audio_portaudio_source.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006.2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -24,11 +24,10 @@ #include <gr_sync_block.h> #include <gr_buffer.h> -#include <gnuradio/omnithread.h> +#include <gruel/thread.h> #include <string> #include <portaudio.h> #include <stdexcept> -//#include <gri_logger.h> class audio_portaudio_source; typedef boost::shared_ptr<audio_portaudio_source> audio_portaudio_source_sptr; @@ -74,11 +73,13 @@ class audio_portaudio_source : public gr_sync_block { gr_buffer_sptr d_writer; // buffer used between work and callback gr_buffer_reader_sptr d_reader; - omni_semaphore d_ringbuffer_ready; // binary semaphore + + gruel::mutex d_ringbuffer_mutex; + gruel::condition_variable d_ringbuffer_cond; + bool d_ringbuffer_ready; // random stats int d_noverruns; // count of overruns - //gri_logger_sptr d_log; // handle to non-blocking logging instance void output_error_msg (const char *msg, int err); void bail (const char *msg, int err) throw (std::runtime_error); @@ -87,7 +88,7 @@ class audio_portaudio_source : public gr_sync_block { protected: audio_portaudio_source (int sampling_rate, const std::string device_name, - bool ok_to_block); + bool ok_to_block); public: ~audio_portaudio_source (); diff --git a/gr-audio-portaudio/src/qa_portaudio.py b/gr-audio-portaudio/src/qa_portaudio.py index f6a54061e..20731f38d 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-audio-windows/src/Makefile.am b/gr-audio-windows/src/Makefile.am index dc91e140c..d3e3f5a85 100644 --- a/gr-audio-windows/src/Makefile.am +++ b/gr-audio-windows/src/Makefile.am @@ -44,7 +44,8 @@ libgnuradio_audio_windows_la_LIBADD = \ libgnuradio_audio_windows_la_LDFLAGS = \ $(LIBGNURADIO_CORE_EXTRA_LDFLAGS) \ - $(NO_UNDEFINED) + $(NO_UNDEFINED) \ + $(LTVERSIONFLAGS) if PYTHON ################################### diff --git a/gr-audio-windows/src/audio_windows_sink.cc b/gr-audio-windows/src/audio_windows_sink.cc index 1fa915072..a47871954 100644 --- a/gr-audio-windows/src/audio_windows_sink.cc +++ b/gr-audio-windows/src/audio_windows_sink.cc @@ -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 * @@ -81,8 +81,7 @@ audio_windows_sink::~audio_windows_sink () audio_windows_sink_sptr audio_windows_make_sink (int sampling_freq, const std::string dev) { - return audio_windows_sink_sptr (new - audio_windows_sink (sampling_freq, dev)); + return gnuradio::get_initial_sptr (new audio_windows_sink (sampling_freq, dev)); } diff --git a/gr-audio-windows/src/audio_windows_source.cc b/gr-audio-windows/src/audio_windows_source.cc index 5cdfb8c84..a88923afd 100644 --- a/gr-audio-windows/src/audio_windows_source.cc +++ b/gr-audio-windows/src/audio_windows_source.cc @@ -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 * @@ -128,9 +128,7 @@ audio_windows_source::~audio_windows_source () audio_windows_source_sptr audio_windows_make_source (int sampling_freq, const std::string dev) { - return audio_windows_source_sptr (new - audio_windows_source (sampling_freq, - dev)); + return gnuradio::get_initial_sptr (new audio_windows_source (sampling_freq, dev)); } diff --git a/gr-comedi/gnuradio-comedi.pc.in b/gr-comedi/gnuradio-comedi.pc.in index 8c320b563..205b40e37 100644 --- a/gr-comedi/gnuradio-comedi.pc.in +++ b/gr-comedi/gnuradio-comedi.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: gnuradio-comedi Description: GNU Radio blocks for the comedi library Requires: gnuradio-core -Version: @VERSION@ +Version: @LIBVER@ Libs: -L${libdir} -lgnuradio-comedi Cflags: -I${includedir} diff --git a/gr-comedi/src/Makefile.am b/gr-comedi/src/Makefile.am index 462c50ad5..a55bd175b 100644 --- a/gr-comedi/src/Makefile.am +++ b/gr-comedi/src/Makefile.am @@ -47,8 +47,7 @@ libgnuradio_comedi_la_LIBADD = \ $(GNURADIO_CORE_LA) \ $(COMEDI_LIBS) -libgnuradio_comedi_la_LDFLAGS = \ - $(NO_UNDEFINED) +libgnuradio_comedi_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) if PYTHON ################################### diff --git a/gr-comedi/src/comedi_sink_s.cc b/gr-comedi/src/comedi_sink_s.cc index 7f4c6d6aa..d4a668758 100644 --- a/gr-comedi/src/comedi_sink_s.cc +++ b/gr-comedi/src/comedi_sink_s.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -52,7 +52,7 @@ default_device_name () comedi_sink_s_sptr comedi_make_sink_s (int sampling_freq, const std::string dev) { - return comedi_sink_s_sptr (new comedi_sink_s (sampling_freq, dev)); + return gnuradio::get_initial_sptr(new comedi_sink_s (sampling_freq, dev)); } comedi_sink_s::comedi_sink_s (int sampling_freq, diff --git a/gr-comedi/src/comedi_source_s.cc b/gr-comedi/src/comedi_source_s.cc index 4e3980e76..a52d04e2a 100644 --- a/gr-comedi/src/comedi_source_s.cc +++ b/gr-comedi/src/comedi_source_s.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -49,7 +49,7 @@ default_device_name () comedi_source_s_sptr comedi_make_source_s (int sampling_freq, const std::string dev) { - return comedi_source_s_sptr (new comedi_source_s (sampling_freq, dev)); + return gnuradio::get_initial_sptr(new comedi_source_s (sampling_freq, dev)); } comedi_source_s::comedi_source_s (int sampling_freq, diff --git a/gr-cvsd-vocoder/gnuradio-cvsd-vocoder.pc.in b/gr-cvsd-vocoder/gnuradio-cvsd-vocoder.pc.in index 056230864..f5f0c2e64 100644 --- a/gr-cvsd-vocoder/gnuradio-cvsd-vocoder.pc.in +++ b/gr-cvsd-vocoder/gnuradio-cvsd-vocoder.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: gnuradio-cvsd-vocoder Description: GNU Radio blocks implementing a CVSD vocoder Requires: gnuradio-core -Version: @VERSION@ +Version: @LIBVER@ Libs: -L${libdir} -lgnuradio-cvsd-vocoder Cflags: -I${includedir} diff --git a/gr-cvsd-vocoder/src/lib/Makefile.am b/gr-cvsd-vocoder/src/lib/Makefile.am index 500d0e858..c5957f4ac 100644 --- a/gr-cvsd-vocoder/src/lib/Makefile.am +++ b/gr-cvsd-vocoder/src/lib/Makefile.am @@ -37,8 +37,7 @@ libgnuradio_cvsd_vocoder_la_SOURCES = \ libgnuradio_cvsd_vocoder_la_LIBADD = \ $(GNURADIO_CORE_LA) -libgnuradio_cvsd_vocoder_la_LDFLAGS = \ - $(NO_UNDEFINED) +libgnuradio_cvsd_vocoder_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) if PYTHON ################################### diff --git a/gr-cvsd-vocoder/src/lib/cvsd_decode_bs.cc b/gr-cvsd-vocoder/src/lib/cvsd_decode_bs.cc index 1dad15d43..26dcb29da 100644 --- a/gr-cvsd-vocoder/src/lib/cvsd_decode_bs.cc +++ b/gr-cvsd-vocoder/src/lib/cvsd_decode_bs.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 * @@ -42,7 +42,7 @@ cvsd_make_decode_bs (short min_step, short max_step, double step_decay, double accum_decay, int K, int J, short pos_accum_max, short neg_accum_max) { - return cvsd_decode_bs_sptr (new cvsd_decode_bs (min_step, max_step, + return gnuradio::get_initial_sptr(new cvsd_decode_bs (min_step, max_step, step_decay, accum_decay, K, J, pos_accum_max, neg_accum_max)); } diff --git a/gr-cvsd-vocoder/src/lib/cvsd_encode_sb.cc b/gr-cvsd-vocoder/src/lib/cvsd_encode_sb.cc index 561b91c68..df867f3ba 100644 --- a/gr-cvsd-vocoder/src/lib/cvsd_encode_sb.cc +++ b/gr-cvsd-vocoder/src/lib/cvsd_encode_sb.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 * @@ -42,7 +42,7 @@ cvsd_make_encode_sb (short min_step, short max_step, double step_decay, double accum_decay, int K, int J, short pos_accum_max, short neg_accum_max) { - return cvsd_encode_sb_sptr (new cvsd_encode_sb (min_step, max_step, + return gnuradio::get_initial_sptr(new cvsd_encode_sb (min_step, max_step, step_decay, accum_decay, K, J, pos_accum_max, neg_accum_max)); } diff --git a/gr-cvsd-vocoder/src/python/qa_cvsd_vocoder.py b/gr-cvsd-vocoder/src/python/qa_cvsd_vocoder.py index 1a39f636e..99a38d946 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 f44095b47..63dc156b1 100644 --- a/gr-gcell/src/Makefile.am +++ b/gr-gcell/src/Makefile.am @@ -52,7 +52,7 @@ libgnuradio_gcell_la_LIBADD = \ $(GNURADIO_CORE_LA) \ $(GCELL_LA) -libgnuradio_gcell_la_LDFLAGS = $(NO_UNDEFINED) +libgnuradio_gcell_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) if PYTHON # ---------------------------------------------------------------- diff --git a/gr-gcell/src/gcell_fft_vcc.cc b/gr-gcell/src/gcell_fft_vcc.cc index 8bbcfb2b9..ae40b6fad 100644 --- a/gr-gcell/src/gcell_fft_vcc.cc +++ b/gr-gcell/src/gcell_fft_vcc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2007,2008 Free Software Foundation, Inc. + * Copyright 2004,2007,2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -71,7 +71,7 @@ gcell_make_fft_vcc(int fft_size, bool forward, const std::vector<float> &window, gcell_fft_vcc_sptr gcell_make_fft_vcc(int fft_size, bool forward, const std::vector<float> &window, bool shift) { - return gcell_fft_vcc_sptr (new gcell_fft_vcc(fft_size, forward, window, shift)); + return gnuradio::get_initial_sptr(new gcell_fft_vcc(fft_size, forward, window, shift)); } #endif diff --git a/gr-gsm-fr-vocoder/gnuradio-gsm-fr-vocoder.pc.in b/gr-gsm-fr-vocoder/gnuradio-gsm-fr-vocoder.pc.in index 43d5c6bad..a799fcd82 100644 --- a/gr-gsm-fr-vocoder/gnuradio-gsm-fr-vocoder.pc.in +++ b/gr-gsm-fr-vocoder/gnuradio-gsm-fr-vocoder.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: gnuradio-comedi Description: GNU Radio blocks implementing a GSM full rate vocoder Requires: gnuradio-core -Version: @VERSION@ -Libs: -L${libdir} -lgnuradio-gsm-fr-vocoder +Version: @LIBVER@ +Libs: -L${libdir} -lgnuradio-gsm-fr-vocoder-$@LIBVER@ Cflags: -I${includedir} diff --git a/gr-gsm-fr-vocoder/src/lib/Makefile.am b/gr-gsm-fr-vocoder/src/lib/Makefile.am index 3b0270c2f..97d6fc306 100644 --- a/gr-gsm-fr-vocoder/src/lib/Makefile.am +++ b/gr-gsm-fr-vocoder/src/lib/Makefile.am @@ -40,8 +40,7 @@ libgnuradio_gsm_fr_vocoder_la_LIBADD = \ $(GNURADIO_CORE_LA) \ gsm/libgsm.la -libgnuradio_gsm_fr_vocoder_la_LDFLAGS = \ - $(NO_UNDEFINED) +libgnuradio_gsm_fr_vocoder_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) if PYTHON # SWIG interface and library diff --git a/gr-gsm-fr-vocoder/src/lib/gsm_fr_decode_ps.cc b/gr-gsm-fr-vocoder/src/lib/gsm_fr_decode_ps.cc index c4fc782fa..9b788dedf 100644 --- a/gr-gsm-fr-vocoder/src/lib/gsm_fr_decode_ps.cc +++ b/gr-gsm-fr-vocoder/src/lib/gsm_fr_decode_ps.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -34,7 +34,7 @@ extern "C"{ gsm_fr_decode_ps_sptr gsm_fr_make_decode_ps () { - return gsm_fr_decode_ps_sptr (new gsm_fr_decode_ps ()); + return gnuradio::get_initial_sptr(new gsm_fr_decode_ps ()); } gsm_fr_decode_ps::gsm_fr_decode_ps () diff --git a/gr-gsm-fr-vocoder/src/lib/gsm_fr_encode_sp.cc b/gr-gsm-fr-vocoder/src/lib/gsm_fr_encode_sp.cc index 3fd35db04..10bd1fef8 100644 --- a/gr-gsm-fr-vocoder/src/lib/gsm_fr_encode_sp.cc +++ b/gr-gsm-fr-vocoder/src/lib/gsm_fr_encode_sp.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2005 Free Software Foundation, Inc. + * Copyright 2005,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -33,7 +33,7 @@ extern "C"{ gsm_fr_encode_sp_sptr gsm_fr_make_encode_sp () { - return gsm_fr_encode_sp_sptr (new gsm_fr_encode_sp ()); + return gnuradio::get_initial_sptr(new gsm_fr_encode_sp ()); } gsm_fr_encode_sp::gsm_fr_encode_sp () 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 ac5084072..4164a1965 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/Makefile.common b/gr-howto-write-a-block/Makefile.common index e628d6b16..15a521698 100644 --- a/gr-howto-write-a-block/Makefile.common +++ b/gr-howto-write-a-block/Makefile.common @@ -27,6 +27,9 @@ modname = howto # when going in to non-SWIG libraries AM_CXXFLAGS = @autoconf_default_CXXFLAGS@ +# Sets ABI version in SONAME and appends -LIBVER to filename +LTVERSIONFLAGS = -version-info 0:0:0 -release $(LIBVER) + # these flags are used when compiling any CXX file AM_CPPFLAGS = \ $(STD_DEFINES_AND_INCLUDES) \ @@ -37,7 +40,7 @@ AM_CPPFLAGS = \ # these are used by both SWIG and CXX STD_DEFINES_AND_INCLUDES = \ $(DEFINES) \ - -I$(abs_top_srcdir)/include \ + -I$(abs_top_srcdir)/lib \ -I$(GNURADIO_CORE_INCLUDEDIR) \ -I$(GNURADIO_CORE_INCLUDEDIR)/swig diff --git a/gr-howto-write-a-block/config.guess b/gr-howto-write-a-block/config.guess index dc84c68ef..285237846 100755 --- a/gr-howto-write-a-block/config.guess +++ b/gr-howto-write-a-block/config.guess @@ -1,10 +1,10 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 # Free Software Foundation, Inc. -timestamp='2009-11-20' +timestamp='2010-08-21' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -56,8 +56,9 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free +Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -91,7 +92,7 @@ if test $# != 0; then exit 1 fi -trap 'exit 1' 1 2 15 +trap 'exit 1' HUP INT TERM # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires @@ -105,7 +106,7 @@ trap 'exit 1' 1 2 15 set_cc_for_build=' trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ; +trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" HUP INT PIPE TERM ; : ${TMPDIR=/tmp} ; { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } || { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } || @@ -551,7 +552,7 @@ EOF echo rs6000-ibm-aix3.2 fi exit ;; - *:AIX:*:[456]) + *:AIX:*:[4567]) IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then IBM_ARCH=rs6000 @@ -967,6 +968,9 @@ EOF sparc:Linux:*:* | sparc64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit ;; + tile*:Linux:*:*) + echo ${UNAME_MACHINE}-tilera-linux-gnu + exit ;; vax:Linux:*:*) echo ${UNAME_MACHINE}-dec-linux-gnu exit ;; diff --git a/gr-howto-write-a-block/config.sub b/gr-howto-write-a-block/config.sub index 2a55a5075..320e30388 100755 --- a/gr-howto-write-a-block/config.sub +++ b/gr-howto-write-a-block/config.sub @@ -1,10 +1,10 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 +# 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 # Free Software Foundation, Inc. -timestamp='2009-11-20' +timestamp='2010-09-11' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -75,8 +75,9 @@ Report bugs and patches to <config-patches@gnu.org>." version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, +2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free +Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE." @@ -123,8 +124,9 @@ esac # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in - nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ - uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \ + nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ + linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ + knetbsd*-gnu* | netbsd*-gnu* | \ kopensolaris*-gnu* | \ storm-chaos* | os2-emx* | rtmk-nova*) os=-$maybe_os @@ -281,6 +283,7 @@ case $basic_machine in | moxie \ | mt \ | msp430 \ + | nds32 | nds32le | nds32be \ | nios | nios2 \ | ns16k | ns32k \ | or32 \ @@ -294,7 +297,7 @@ case $basic_machine in | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \ | spu | strongarm \ - | tahoe | thumb | tic4x | tic80 | tron \ + | tahoe | thumb | tic4x | tic54x | tic55x | tic6x | tic80 | tron \ | ubicom32 \ | v850 | v850e \ | we32k \ @@ -302,6 +305,15 @@ case $basic_machine in | z8k | z80) basic_machine=$basic_machine-unknown ;; + c54x) + basic_machine=tic54x-unknown + ;; + c55x) + basic_machine=tic55x-unknown + ;; + c6x) + basic_machine=tic6x-unknown + ;; m6811 | m68hc11 | m6812 | m68hc12 | picochip) # Motorola 68HC11/12. basic_machine=$basic_machine-unknown @@ -333,7 +345,7 @@ case $basic_machine in | arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | avr-* | avr32-* \ | bfin-* | bs2000-* \ - | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ + | c[123]* | c30-* | [cjt]90-* | c4x-* \ | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ @@ -367,6 +379,7 @@ case $basic_machine in | mmix-* \ | mt-* \ | msp430-* \ + | nds32-* | nds32le-* | nds32be-* \ | nios-* | nios2-* \ | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ @@ -380,7 +393,8 @@ case $basic_machine in | sparclite-* \ | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ - | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* | tile-* \ + | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ + | tile-* | tilegx-* \ | tron-* \ | ubicom32-* \ | v850-* | v850e-* | vax-* \ @@ -480,6 +494,15 @@ case $basic_machine in basic_machine=powerpc-ibm os=-cnk ;; + c54x-*) + basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c55x-*) + basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; + c6x-*) + basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` + ;; c90) basic_machine=c90-cray os=-unicos @@ -839,6 +862,12 @@ case $basic_machine in np1) basic_machine=np1-gould ;; + neo-tandem) + basic_machine=neo-tandem + ;; + nse-tandem) + basic_machine=nse-tandem + ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -1073,17 +1102,10 @@ case $basic_machine in basic_machine=t90-cray os=-unicos ;; - tic54x | c54x*) - basic_machine=tic54x-unknown - os=-coff - ;; - tic55x | c55x*) - basic_machine=tic55x-unknown - os=-coff - ;; - tic6x | c6x*) - basic_machine=tic6x-unknown - os=-coff + # This must be matched before tile*. + tilegx*) + basic_machine=tilegx-unknown + os=-linux-gnu ;; tile*) basic_machine=tile-unknown @@ -1294,7 +1316,8 @@ case $os in | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* | -cegcc* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ - | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \ + | -mingw32* | -linux-gnu* | -linux-android* \ + | -linux-newlib* | -linux-uclibc* \ | -uxpv* | -beos* | -mpeix* | -udk* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ @@ -1435,6 +1458,8 @@ case $os in -dicos*) os=-dicos ;; + -nacl*) + ;; -none) ;; *) @@ -1475,6 +1500,15 @@ case $basic_machine in c4x-* | tic4x-*) os=-coff ;; + tic54x-*) + os=-coff + ;; + tic55x-*) + os=-coff + ;; + tic6x-*) + os=-coff + ;; # This must come before the *-dec entry. pdp10-*) os=-tops20 diff --git a/gr-howto-write-a-block/config/gr_git.m4 b/gr-howto-write-a-block/config/gr_git.m4 index 5fe424808..c4f1ea0c0 100644 --- a/gr-howto-write-a-block/config/gr_git.m4 +++ b/gr-howto-write-a-block/config/gr_git.m4 @@ -1,4 +1,4 @@ -dnl Copyright 2009 Free Software Foundation, Inc. +dnl Copyright 2009,2010 Free Software Foundation, Inc. dnl dnl This file is part of GNU Radio dnl @@ -24,12 +24,40 @@ AC_DEFUN([GR_GIT],[ dnl If it exists, get either 'git describe' or fallback to current commit if test x$GIT != x ; then - if (cd $srcdir && $GIT describe >/dev/null 2>&1); then - GIT_VERSION=`cd $srcdir && $GIT describe --abbrev=8 | cut -f 2- -d '-'` - else - if (cd $srcdir && $GIT describe --always --abbrev=8 >/dev/null 2>&1); then - GIT_VERSION=`cd $srcdir && $GIT describe --always --abbrev=8` + AC_MSG_CHECKING([existence of git version control directory]) + if test -d $srcdir/.git ; then + AC_MSG_RESULT([ok]) + AC_MSG_CHECKING([git description of current commit]) + if (cd $srcdir && $GIT describe >/dev/null 2>&1); then + GIT_DESCRIBE=`cd $srcdir && $GIT describe --abbrev=8 --long` + # Release candidate tags create an extra -rcX field + case $GIT_DESCRIBE in + *-*-*-*) + GIT_TAG=`echo $GIT_DESCRIBE | cut -f -2 -d '-'` + GIT_SEQNO=`echo $GIT_DESCRIBE | cut -f 3 -d '-'` + GIT_COMMIT=`echo $GIT_DESCRIBE | cut -f 4 -d '-' | cut -f 2- -d 'g'` + ;; + *-*-*) + GIT_TAG=`echo $GIT_DESCRIBE | cut -f 1 -d '-'` + GIT_SEQNO=`echo $GIT_DESCRIBE | cut -f 2 -d '-'` + GIT_COMMIT=`echo $GIT_DESCRIBE | cut -f 3 -d '-' | cut -f 2- -d 'g'` + ;; + esac + + AC_MSG_RESULT([$GIT_DESCRIBE]) + else + AC_MSG_RESULT([no tag in history, using current commit]) + GIT_TAG='' + GIT_SEQNO='' + GIT_COMMIT=`cd $srcdir && $GIT describe --always --abbrev=8` fi + else + AC_MSG_RESULT([not found]) fi + + AC_SUBST([GIT_DESCRIBE]) + AC_SUBST([GIT_TAG]) + AC_SUBST([GIT_SEQNO]) + AC_SUBST([GIT_COMMIT]) fi ]) diff --git a/gr-howto-write-a-block/config/gr_version.m4 b/gr-howto-write-a-block/config/gr_version.m4 index 3360b7d54..a7a202238 100644 --- a/gr-howto-write-a-block/config/gr_version.m4 +++ b/gr-howto-write-a-block/config/gr_version.m4 @@ -1,4 +1,4 @@ -dnl Copyright 2009 Free Software Foundation, Inc. +dnl Copyright 2009,2010 Free Software Foundation, Inc. dnl dnl This file is part of GNU Radio dnl @@ -25,50 +25,49 @@ AC_DEFUN([GR_VERSION],[ dnl dnl MAJOR_VERSION Major release generation (2.x, 3.x, etc.) dnl API_COMPAT API compatibility version (3.2.x, 3.3.x, etc.) - dnl MINOR_VERSION Minor release version + dnl MINOR_VERSION Minor release version (3.3.0, 3.3.1, etc.) dnl MAINT_VERSION Pure bugfix additions to make maintenance release dnl dnl The last two fields can have 'git' instead of a number to indicate dnl that this branch is between versions. . $srcdir/version.sh - RELEASE=$MAJOR_VERSION.$API_COMPAT dnl Get git version if available GR_GIT dnl Test if we should use git version if test "$MINOR_VERSION" == "git"; then - dnl 3.3git-xxx-gxxxxxxxx - RELEASE=$RELEASE$MINOR_VERSION - DOCVER=$RELEASE - if test "$GIT_VERSION" != "" ; then - RELEASE=$RELEASE-$GIT_VERSION - fi + dnl RELEASE: 3.3git-xxx-gxxxxxxxx + dnl DOCVER: 3.3git + dnl LIBVER: 3.3git + RELEASE=$GIT_DESCRIBE + DOCVER=$MAJOR_VERSION.$API_COMPAT$MINOR_VERSION + LIBVER=$MAJOR_VERSION.$API_COMPAT$MINOR_VERSION else if test "$MAINT_VERSION" == "git" ; then - dnl 3.3.1git-xxx-gxxxxxxxx - RELEASE=$RELEASE.$MINOR_VERSION$MAINT_VERSION - DOCVER=$RELEASE - if test "$GIT_VERSION" != "" ; then - RELEASE=$RELEASE-$GIT_VERSION - fi + dnl RELEASE: 3.3.1git-xxx-gxxxxxxxx + dnl DOCVER: 3.3.1git + dnl LIBVER: 3.3.1git + RELEASE=$GIT_DESCRIBE + DOCVER=$MAJOR_VERSION.$API_COMPAT.$MINOR_VERSION$MAINT_VERSION + LIBVER=$MAJOR_VERSION.$API_COMPAT.$MINOR_VERSION$MAINT_VERSION else - dnl This is a numbered reelase. - dnl Test if minor version is 0, which we don't encode, unless it is also - dnl a maintenance release - if test "$MINOR_VERSION" != "0" -o "$MAINT_VERSION" != "0"; then - dnl 3.3.1 - RELEASE=$RELEASE.$MINOR_VERSION - if test "$MAINT_VERSION" != "0"; then - dnl 3.3.0.1, 3.3.1.1 - RELEASE=$RELEASE.$MAINT_VERSION - fi - DOCVER=$RELEASE + dnl This is a numbered release. + dnl RELEASE: 3.3.1{.x} + dnl DOCVER: 3.3.1{.x} + dnl LIBVER: 3.3.1{.x} + RELEASE=$MAJOR_VERSION.$API_COMPAT.$MINOR_VERSION + if test "$MAINT_VERSION" != "0"; then + RELEASE=$RELEASE.$MAINT_VERSION fi + + DOCVER=$RELEASE + LIBVER=$RELEASE fi fi AC_MSG_NOTICE([GNU Radio Release $RELEASE]) AC_SUBST(RELEASE) AC_SUBST(DOCVER) + AC_SUBST(LIBVER) ]) diff --git a/gr-howto-write-a-block/lib/Makefile.am b/gr-howto-write-a-block/lib/Makefile.am index 2e76ee453..f0a18358f 100644 --- a/gr-howto-write-a-block/lib/Makefile.am +++ b/gr-howto-write-a-block/lib/Makefile.am @@ -42,8 +42,7 @@ libgnuradio_howto_la_SOURCES = \ libgnuradio_howto_la_LIBADD = \ $(GNURADIO_CORE_LA) -libgnuradio_howto_la_LDFLAGS = \ - $(NO_UNDEFINED) +libgnuradio_howto_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) # ---------------------------------------------------------------- # howto C++ QA library: libgnuradio-howto-qa.so (not installed) diff --git a/gr-howto-write-a-block/lib/howto_square2_ff.cc b/gr-howto-write-a-block/lib/howto_square2_ff.cc index e86db93dd..5e0fd7a43 100644 --- a/gr-howto-write-a-block/lib/howto_square2_ff.cc +++ b/gr-howto-write-a-block/lib/howto_square2_ff.cc @@ -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 * @@ -39,7 +39,7 @@ howto_square2_ff_sptr howto_make_square2_ff () { - return howto_square2_ff_sptr (new howto_square2_ff ()); + return gnuradio::get_initial_sptr(new howto_square2_ff ()); } /* diff --git a/gr-howto-write-a-block/lib/howto_square_ff.cc b/gr-howto-write-a-block/lib/howto_square_ff.cc index 5ab45d1f2..f1d5a7848 100644 --- a/gr-howto-write-a-block/lib/howto_square_ff.cc +++ b/gr-howto-write-a-block/lib/howto_square_ff.cc @@ -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 * @@ -39,7 +39,7 @@ howto_square_ff_sptr howto_make_square_ff () { - return howto_square_ff_sptr (new howto_square_ff ()); + return gnuradio::get_initial_sptr(new howto_square_ff ()); } /* diff --git a/gr-howto-write-a-block/lib/test_all.cc b/gr-howto-write-a-block/lib/test_all.cc index 192c537bc..ac1e83839 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 <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> +#include <gr_unittests.h> #include <qa_howto.h> 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-howto-write-a-block/python/run_tests.in b/gr-howto-write-a-block/python/run_tests.in index 5b50509e1..2c32539c7 100644 --- a/gr-howto-write-a-block/python/run_tests.in +++ b/gr-howto-write-a-block/python/run_tests.in @@ -28,6 +28,30 @@ echo $PYTHONPATH export PYTHONPATH +case "@host_os@" in + darwin*) + # FIXME: Code for Darwin guessed but not tested + # Special Code for executing on Darwin / Mac OS X only + if [ "$DYLD_LIBRARY_PATH" = "" ] + then + DYLD_LIBRARY_PATH=$libbld/.libs + else + DYLD_LIBRARY_PATH=$libbld/.libs:$DYLD_LIBRARY_PATH + fi + export DYLD_LIBRARY_PATH + ;; + cygwin*|win*|mingw*) + # Special Code for executing on Win32 variants only + if [ "$PATH" = "" ] + then + PATH=$libbld/.libs + else + PATH=$libbld/.libs:$PATH + fi + export PATH + ;; +esac + # # This is the simple part... # Run everything that matches qa_*.py and return the final result. diff --git a/gr-howto-write-a-block/version.sh b/gr-howto-write-a-block/version.sh index b2cad877d..01a47b5d9 100644 --- a/gr-howto-write-a-block/version.sh +++ b/gr-howto-write-a-block/version.sh @@ -1,4 +1,4 @@ MAJOR_VERSION=3 API_COMPAT=3 -MINOR_VERSION=git -MAINT_VERSION= +MINOR_VERSION=0 +MAINT_VERSION=0 diff --git a/gr-msdd6000/gnuradio-msdd6000.pc.in b/gr-msdd6000/gnuradio-msdd6000.pc.in index 8c320b563..565420718 100644 --- a/gr-msdd6000/gnuradio-msdd6000.pc.in +++ b/gr-msdd6000/gnuradio-msdd6000.pc.in @@ -4,8 +4,8 @@ libdir=@libdir@ includedir=@includedir@ Name: gnuradio-comedi -Description: GNU Radio blocks for the comedi library +Description: GNU Radio blocks for the Softronics MSDD 6000 Requires: gnuradio-core -Version: @VERSION@ -Libs: -L${libdir} -lgnuradio-comedi +Version: @LIBVER@ +Libs: -L${libdir} -lgnuradio-msdd6000 Cflags: -I${includedir} diff --git a/gr-msdd6000/src/Makefile.am b/gr-msdd6000/src/Makefile.am index 7744395f3..f6dbd2fb8 100644 --- a/gr-msdd6000/src/Makefile.am +++ b/gr-msdd6000/src/Makefile.am @@ -35,6 +35,9 @@ grinclude_HEADERS = \ lib_LTLIBRARIES = libgnuradio-msdd6000.la \ libgnuradio-msdd6000_rs.la +libgnuradio_msdd6000_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) +libgnuradio_msdd6000_rs_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) + libgnuradio_msdd6000_la_SOURCES = \ msdd_source_simple.cc \ msdd6000.cc @@ -47,14 +50,9 @@ libgnuradio_msdd6000_rs_la_SOURCES = \ libgnuradio_msdd6000_la_LIBADD = \ $(GNURADIO_CORE_LA) -libgnuradio_msdd6000_la_LDFLAGS = \ - $(NO_UNDEFINED) - libgnuradio_msdd6000_rs_la_LIBADD = \ $(GNURADIO_CORE_LA) -libgnuradio_msdd6000_rs_la_LDFLAGS = \ - $(NO_UNDEFINED) if PYTHON ################################# diff --git a/gr-msdd6000/src/msdd_rs_source_simple.cc b/gr-msdd6000/src/msdd_rs_source_simple.cc index 2ffc64240..c44808f51 100644 --- a/gr-msdd6000/src/msdd_rs_source_simple.cc +++ b/gr-msdd6000/src/msdd_rs_source_simple.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008 Free Software Foundation, Inc. + * Copyright 2008,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ msdd_rs_source_simple_sptr msdd_rs_make_source_simple ( const char *src, unsigned short port_src) { - return msdd_rs_source_simple_sptr (new msdd_rs_source_simple ( src, port_src)); + return gnuradio::get_initial_sptr(new msdd_rs_source_simple ( src, port_src)); } diff --git a/gr-msdd6000/src/msdd_source_simple.cc b/gr-msdd6000/src/msdd_source_simple.cc index 0ee2505d4..076a305f1 100644 --- a/gr-msdd6000/src/msdd_source_simple.cc +++ b/gr-msdd6000/src/msdd_source_simple.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008,2009 Free Software Foundation, Inc. + * Copyright 2008,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -31,7 +31,7 @@ msdd_source_simple_sptr msdd_make_source_simple (const char *src, unsigned short port_src) { - return msdd_source_simple_sptr (new msdd_source_simple ( src, port_src)); + return gnuradio::get_initial_sptr(new msdd_source_simple ( src, port_src)); } diff --git a/gr-noaa/lib/Makefile.am b/gr-noaa/lib/Makefile.am index f01bbfab8..fdc1476cd 100644 --- a/gr-noaa/lib/Makefile.am +++ b/gr-noaa/lib/Makefile.am @@ -39,7 +39,7 @@ noinst_HEADERS = \ libgnuradio_noaa_la_LIBADD = \ $(GNURADIO_CORE_LA) -libgnuradio_noaa_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 +libgnuradio_noaa_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) grinclude_HEADERS = \ noaa_hrpt_decoder.h \ diff --git a/gr-pager/gnuradio-pager.pc.in b/gr-pager/gnuradio-pager.pc.in index 35516b6ed..6fda2d2f2 100644 --- a/gr-pager/gnuradio-pager.pc.in +++ b/gr-pager/gnuradio-pager.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: gnuradio-comedi Description: GNU Radio blocks implementing a FLEX pager decoder Requires: gnuradio-core -Version: @VERSION@ +Version: @LIBVER@ Libs: -L${libdir} -lgnuradio-pager Cflags: -I${includedir} diff --git a/gr-pager/lib/Makefile.am b/gr-pager/lib/Makefile.am index 1d8a43b3c..29c82ebe8 100644 --- a/gr-pager/lib/Makefile.am +++ b/gr-pager/lib/Makefile.am @@ -49,5 +49,4 @@ libgnuradio_pager_la_SOURCES = \ libgnuradio_pager_la_LIBADD = \ $(GNURADIO_CORE_LA) -libgnuradio_pager_la_LDFLAGS = \ - $(NO_UNDEFINED) +libgnuradio_pager_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) diff --git a/gr-pager/lib/pager_flex_deinterleave.cc b/gr-pager/lib/pager_flex_deinterleave.cc index 25ea22e39..a51670b22 100644 --- a/gr-pager/lib/pager_flex_deinterleave.cc +++ b/gr-pager/lib/pager_flex_deinterleave.cc @@ -1,5 +1,5 @@ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -30,7 +30,7 @@ pager_flex_deinterleave_sptr pager_make_flex_deinterleave() { - return pager_flex_deinterleave_sptr(new pager_flex_deinterleave()); + return gnuradio::get_initial_sptr(new pager_flex_deinterleave()); } pager_flex_deinterleave::pager_flex_deinterleave() : diff --git a/gr-pager/lib/pager_flex_parse.cc b/gr-pager/lib/pager_flex_parse.cc index 0819294da..19d3d96c6 100644 --- a/gr-pager/lib/pager_flex_parse.cc +++ b/gr-pager/lib/pager_flex_parse.cc @@ -1,5 +1,5 @@ /* - * Copyright 2004,2006,2007 Free Software Foundation, Inc. + * Copyright 2004,2006,2007,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -32,7 +32,7 @@ pager_flex_parse_sptr pager_make_flex_parse(gr_msg_queue_sptr queue, float freq) { - return pager_flex_parse_sptr(new pager_flex_parse(queue, freq)); + return gnuradio::get_initial_sptr(new pager_flex_parse(queue, freq)); } pager_flex_parse::pager_flex_parse(gr_msg_queue_sptr queue, float freq) : diff --git a/gr-pager/lib/pager_flex_sync.cc b/gr-pager/lib/pager_flex_sync.cc index 6bcee8ede..61cf4ad38 100644 --- a/gr-pager/lib/pager_flex_sync.cc +++ b/gr-pager/lib/pager_flex_sync.cc @@ -1,5 +1,5 @@ /* - * Copyright 2004,2006 Free Software Foundation, Inc. + * Copyright 2004,2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -33,7 +33,7 @@ pager_flex_sync_sptr pager_make_flex_sync() { - return pager_flex_sync_sptr(new pager_flex_sync()); + return gnuradio::get_initial_sptr(new pager_flex_sync()); } // FLEX sync block takes input from sliced baseband stream [0-3] at specified diff --git a/gr-pager/lib/pager_slicer_fb.cc b/gr-pager/lib/pager_slicer_fb.cc index d419db78a..53ba7b9de 100644 --- a/gr-pager/lib/pager_slicer_fb.cc +++ b/gr-pager/lib/pager_slicer_fb.cc @@ -1,5 +1,5 @@ /* - * Copyright 2004,2006,2007 Free Software Foundation, Inc. + * Copyright 2004,2006,2007,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -28,7 +28,7 @@ pager_slicer_fb_sptr pager_make_slicer_fb(float alpha) { - return pager_slicer_fb_sptr(new pager_slicer_fb(alpha)); + return gnuradio::get_initial_sptr(new pager_slicer_fb(alpha)); } pager_slicer_fb::pager_slicer_fb(float alpha) : diff --git a/gr-pager/python/qa_pager.py b/gr-pager/python/qa_pager.py index 5bf72b561..12a45d4c3 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-qtgui/src/lib/.gitignore b/gr-qtgui/src/lib/.gitignore index 58c8081e5..11bb4342a 100644 --- a/gr-qtgui/src/lib/.gitignore +++ b/gr-qtgui/src/lib/.gitignore @@ -4,10 +4,10 @@ /.deps /qtgui.cc /qtgui.py -/WaterfallDisplayPlot_moc.cc -/Waterfall3DDisplayPlot_moc.cc -/TimeDomainDisplayPlot_moc.cc -/spectrumdisplayform_moc.cc -/spectrumdisplayform_ui.h -/FrequencyDisplayPlot_moc.cc -/ConstellationDisplayPlot_moc.cc +/WaterfallDisplayPlot.moc.cc +/Waterfall3DDisplayPlot.moc.cc +/TimeDomainDisplayPlot.moc.cc +/spectrumdisplayform.moc.cc +/spectrumdisplayform.ui.h +/FrequencyDisplayPlot.moc.cc +/ConstellationDisplayPlot.moc.cc diff --git a/gr-qtgui/src/lib/ConstellationDisplayPlot.cc b/gr-qtgui/src/lib/ConstellationDisplayPlot.cc index 80bf4503f..9ad5bdd3c 100644 --- a/gr-qtgui/src/lib/ConstellationDisplayPlot.cc +++ b/gr-qtgui/src/lib/ConstellationDisplayPlot.cc @@ -24,10 +24,11 @@ public: } protected: + using QwtPlotZoomer::trackerText; virtual QwtText trackerText( const QwtDoublePoint& p ) const { - QwtText t(QString("Sample %1, %2 V").arg(p.x(), 0, 'f', 0).arg(p.y(), 0, 'f', 4)); - + QwtText t(QString("(%1, %2)").arg(p.x(), 0, 'f', 4). + arg(p.y(), 0, 'f', 4)); return t; } }; @@ -39,8 +40,6 @@ ConstellationDisplayPlot::ConstellationDisplayPlot(QWidget* parent) resize(parent->width(), parent->height()); - _displayIntervalTime = (1.0/10.0); // 1/10 of a second between updates - _numPoints = 1024; _penSize = 5; _realDataPoints = new double[_numPoints]; @@ -58,12 +57,10 @@ ConstellationDisplayPlot::ConstellationDisplayPlot(QWidget* parent) canvas()->setPalette(palette); setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine); - //setAxisScale(QwtPlot::xBottom, -1.0, 1.0); set_xaxis(-2.0, 2.0); setAxisTitle(QwtPlot::xBottom, "In-phase"); setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine); - //setAxisScale(QwtPlot::yLeft, -1.0, 1.0); set_yaxis(-2.0, 2.0); setAxisTitle(QwtPlot::yLeft, "Quadrature"); @@ -148,19 +145,9 @@ ConstellationDisplayPlot::set_axis(double xmin, double xmax, set_yaxis(ymin, ymax); } -void ConstellationDisplayPlot::replot(){ - - const timespec startTime = get_highres_clock(); - +void ConstellationDisplayPlot::replot() +{ QwtPlot::replot(); - - double differenceTime = (diff_timespec(get_highres_clock(), startTime)); - - differenceTime *= 99.0; - // Require at least a 10% duty cycle - if(differenceTime > (1.0/10.0)){ - _displayIntervalTime = differenceTime; - } } void @@ -171,10 +158,12 @@ ConstellationDisplayPlot::resizeSlot( QSize *s ) void ConstellationDisplayPlot::PlotNewData(const double* realDataPoints, const double* imagDataPoints, - const int64_t numDataPoints) + const int64_t numDataPoints, + const double timeInterval) { - if(numDataPoints > 0){ - + if((numDataPoints > 0) && + (diff_timespec(get_highres_clock(), _lastReplot) > timeInterval)) { + if(numDataPoints != _numPoints){ _numPoints = numDataPoints; @@ -185,17 +174,12 @@ void ConstellationDisplayPlot::PlotNewData(const double* realDataPoints, _plot_curve->setRawData(_realDataPoints, _imagDataPoints, _numPoints); } + memcpy(_realDataPoints, realDataPoints, numDataPoints*sizeof(double)); memcpy(_imagDataPoints, imagDataPoints, numDataPoints*sizeof(double)); - } - - // Allow at least a 50% duty cycle - if(diff_timespec(get_highres_clock(), _lastReplot) > _displayIntervalTime){ - // Only replot the screen if it is visible - if(isVisible()){ - replot(); - } + replot(); + _lastReplot = get_highres_clock(); } } diff --git a/gr-qtgui/src/lib/ConstellationDisplayPlot.h b/gr-qtgui/src/lib/ConstellationDisplayPlot.h index 99ae566e0..a441a8bfe 100644 --- a/gr-qtgui/src/lib/ConstellationDisplayPlot.h +++ b/gr-qtgui/src/lib/ConstellationDisplayPlot.h @@ -24,7 +24,8 @@ public: void PlotNewData(const double* realDataPoints, const double* imagDataPoints, - const int64_t numDataPoints); + const int64_t numDataPoints, + const double timeInterval); virtual void replot(); @@ -55,8 +56,6 @@ private: int64_t _numPoints; int64_t _penSize; - - double _displayIntervalTime; }; #endif /* CONSTELLATION_DISPLAY_PLOT_HPP */ diff --git a/gr-qtgui/src/lib/FrequencyDisplayPlot.cc b/gr-qtgui/src/lib/FrequencyDisplayPlot.cc index 7deff8543..d150e2e4c 100644 --- a/gr-qtgui/src/lib/FrequencyDisplayPlot.cc +++ b/gr-qtgui/src/lib/FrequencyDisplayPlot.cc @@ -73,15 +73,23 @@ public: updateDisplay(); } -protected: - virtual QwtText trackerText( const QwtDoublePoint& p ) const + void SetUnitType(const std::string &type) { - QString strunits = (GetFrequencyPrecision() == 0) ? "Hz" : "kHz"; - QwtText t(QString("%1 %2, %3 dB").arg(p.x(), 0, 'f', - GetFrequencyPrecision()).arg(strunits).arg(p.y(), 0, 'f', 2)); + _unitType = type; + } +protected: + using QwtPlotZoomer::trackerText; + virtual QwtText trackerText( const QwtDoublePoint& p ) const + { + QwtText t(QString("%1 %2, %3 dB"). + arg(p.x(), 0, 'f', GetFrequencyPrecision()). + arg(_unitType.c_str()).arg(p.y(), 0, 'f', 2)); return t; } + +private: + std::string _unitType; }; FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent) @@ -94,8 +102,6 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent) resize(parent->width(), parent->height()); - _displayIntervalTime = (1.0/10.0); // 1/10 of a second between updates - _useCenterFrequencyFlag = false; _numPoints = 1024; @@ -115,9 +121,8 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent) palette.setColor(canvas()->backgroundRole(), QColor("white")); canvas()->setPalette(palette); - setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0)); - setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); setAxisTitle(QwtPlot::xBottom, "Frequency (Hz)"); + setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(0)); _minYAxis = -120; _maxYAxis = 10; @@ -150,7 +155,7 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent) _upper_intensity_marker = new QwtPlotMarker(); _upper_intensity_marker->setLineStyle(QwtPlotMarker::HLine); - _upper_intensity_marker->setLinePen(QPen(Qt::green)); + _upper_intensity_marker->setLinePen(QPen(Qt::green, 0, Qt::DotLine)); _upper_intensity_marker->attach(this); memset(_dataPoints, 0x0, _numPoints*sizeof(double)); @@ -161,9 +166,6 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent) _maxFFTPoints[number] = -280.0; } - _resetXAxisPoints(); - - // set up peak marker QwtSymbol symbol; @@ -213,6 +215,9 @@ FrequencyDisplayPlot::FrequencyDisplayPlot(QWidget* parent) const QColor c(Qt::darkRed); _zoomer->setRubberBandPen(c); _zoomer->setTrackerPen(c); + + // Do this after the zoomer has been built + _resetXAxisPoints(); } FrequencyDisplayPlot::~FrequencyDisplayPlot() @@ -258,21 +263,26 @@ FrequencyDisplayPlot::SetFrequencyRange(const double constStartFreq, stopFreq = (stopFreq + centerFreq); } - _startFrequency = startFreq; - _stopFrequency = stopFreq; - _resetXAxisPoints(); - - double display_units = ceil(log10(units)/2.0); - setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); - setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(display_units)); - setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str())); - ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(display_units); - - // Load up the new base zoom settings - _zoomer->setZoomBase(); - - // Zooms back to the base and clears any other zoom levels - _zoomer->zoom(0); + bool reset = false; + if((startFreq != _startFrequency) || (stopFreq != _stopFrequency)) + reset = true; + + if(stopFreq > startFreq) { + _startFrequency = startFreq; + _stopFrequency = stopFreq; + + if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)){ + double display_units = ceil(log10(units)/2.0); + setAxisScaleDraw(QwtPlot::xBottom, new FreqDisplayScaleDraw(display_units)); + setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str())); + + if(reset) + _resetXAxisPoints(); + + ((FreqDisplayZoomer*)_zoomer)->SetFrequencyPrecision(display_units); + ((FreqDisplayZoomer*)_zoomer)->SetUnitType(strunits); + } + } } @@ -291,8 +301,6 @@ FrequencyDisplayPlot::GetStopFrequency() const void FrequencyDisplayPlot::replot() { - const timespec startTime = get_highres_clock(); - _markerNoiseFloorAmplitude->setYValue(_noiseFloorAmplitude); // Make sure to take into account the start frequency @@ -305,14 +313,6 @@ FrequencyDisplayPlot::replot() _markerPeakAmplitude->setYValue(_peakAmplitude); QwtPlot::replot(); - - double differenceTime = (diff_timespec(get_highres_clock(), startTime)); - - differenceTime *= 99.0; - // Require at least a 10% duty cycle - if(differenceTime > (1.0/10.0)){ - _displayIntervalTime = differenceTime; - } } void @@ -324,13 +324,15 @@ FrequencyDisplayPlot::resizeSlot( QSize *s ) void FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDataPoints, const double noiseFloorAmplitude, const double peakFrequency, - const double peakAmplitude) + const double peakAmplitude, const double timeInterval) { - if(numDataPoints > 0){ - - if(numDataPoints != _numPoints){ + // Only update plot if there is data and if the time interval has elapsed + if((numDataPoints > 0) && + (diff_timespec(get_highres_clock(), _lastReplot) > timeInterval)) { + + if(numDataPoints != _numPoints) { _numPoints = numDataPoints; - + delete[] _dataPoints; delete[] _minFFTPoints; delete[] _maxFFTPoints; @@ -343,12 +345,12 @@ FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDat _fft_plot_curve->setRawData(_xAxisPoints, _dataPoints, _numPoints); _min_fft_plot_curve->setRawData(_xAxisPoints, _minFFTPoints, _numPoints); _max_fft_plot_curve->setRawData(_xAxisPoints, _maxFFTPoints, _numPoints); - + _resetXAxisPoints(); ClearMaxData(); ClearMinData(); } - + memcpy(_dataPoints, dataPoints, numDataPoints*sizeof(double)); for(int64_t point = 0; point < numDataPoints; point++){ if(dataPoints[point] < _minFFTPoints[point]){ @@ -363,14 +365,10 @@ FrequencyDisplayPlot::PlotNewData(const double* dataPoints, const int64_t numDat _peakFrequency = peakFrequency; _peakAmplitude = peakAmplitude; - } + SetUpperIntensityLevel(_peakAmplitude); - // Allow at least a 50% duty cycle - if(diff_timespec(get_highres_clock(), _lastReplot) > _displayIntervalTime){ - // Only replot the screen if it is visible - if(isVisible()){ - replot(); - } + replot(); + _lastReplot = get_highres_clock(); } } @@ -412,6 +410,17 @@ FrequencyDisplayPlot::_resetXAxisPoints() _xAxisPoints[loc] = freqValue; freqValue += fft_bin_size; } + + setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); + + // Set up zoomer base for maximum unzoom x-axis + // and reset to maximum unzoom level + QwtDoubleRect zbase = _zoomer->zoomBase(); + zbase.setLeft(_startFrequency); + zbase.setRight(_stopFrequency); + _zoomer->zoom(zbase); + _zoomer->setZoomBase(zbase); + _zoomer->zoom(0); } void diff --git a/gr-qtgui/src/lib/FrequencyDisplayPlot.h b/gr-qtgui/src/lib/FrequencyDisplayPlot.h index 785efe694..c78e1667e 100644 --- a/gr-qtgui/src/lib/FrequencyDisplayPlot.h +++ b/gr-qtgui/src/lib/FrequencyDisplayPlot.h @@ -30,7 +30,7 @@ public: void PlotNewData(const double* dataPoints, const int64_t numDataPoints, const double noiseFloorAmplitude, const double peakFrequency, - const double peakAmplitude); + const double peakAmplitude, const double timeInterval); void ClearMaxData(); void ClearMinData(); @@ -86,8 +86,6 @@ private: timespec _lastReplot; bool _useCenterFrequencyFlag; - - double _displayIntervalTime; }; #endif /* FREQUENCY_DISPLAY_PLOT_HPP */ diff --git a/gr-qtgui/src/lib/Makefile.am b/gr-qtgui/src/lib/Makefile.am index 814bee136..4ba637ad6 100644 --- a/gr-qtgui/src/lib/Makefile.am +++ b/gr-qtgui/src/lib/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 # @@ -27,13 +27,12 @@ AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ # Only include these files in the build if qtgui passes configure checks # This is mostly to help make distcheck pass QMAKE_SOURCES = \ - spectrumdisplayform_moc.cc \ - FrequencyDisplayPlot_moc.cc \ - TimeDomainDisplayPlot_moc.cc \ - WaterfallDisplayPlot_moc.cc \ - Waterfall3DDisplayPlot_moc.cc \ - ConstellationDisplayPlot_moc.cc \ - spectrumdisplayform_ui.h + spectrumdisplayform.moc.cc \ + FrequencyDisplayPlot.moc.cc \ + TimeDomainDisplayPlot.moc.cc \ + WaterfallDisplayPlot.moc.cc \ + ConstellationDisplayPlot.moc.cc \ + spectrumdisplayform.ui.h EXTRA_DIST = spectrumdisplayform.ui @@ -47,23 +46,22 @@ libgnuradio_qtgui_la_SOURCES = \ FrequencyDisplayPlot.cc \ TimeDomainDisplayPlot.cc \ WaterfallDisplayPlot.cc \ - Waterfall3DDisplayPlot.cc \ waterfallGlobalData.cc \ ConstellationDisplayPlot.cc \ spectrumdisplayform.cc \ SpectrumGUIClass.cc \ spectrumUpdateEvents.cc \ plot_waterfall.cc \ - $(QMAKE_SOURCES) \ qtgui_sink_c.cc \ qtgui_sink_f.cc +nodist_libgnuradio_qtgui_la_SOURCES=$(BUILT_SOURCES) + # These headers get installed in ${prefix}/include/gnuradio grinclude_HEADERS = \ FrequencyDisplayPlot.h \ TimeDomainDisplayPlot.h \ WaterfallDisplayPlot.h \ - Waterfall3DDisplayPlot.h \ waterfallGlobalData.h \ ConstellationDisplayPlot.h \ highResTimeFunctions.h \ @@ -75,14 +73,15 @@ grinclude_HEADERS = \ qtgui_sink_c.h \ qtgui_sink_f.h -%_moc.cc : %.h - $(QT_MOC_EXEC) -DQT_SHARED -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -p $(srcdir) $< -o $@ +QT_MOC_FLAGS=-DQT_SHARED -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB +%.moc.cc : %.h + $(QT_MOC_EXEC) $(QT_MOC_FLAGS) -p $(srcdir) $< -o $@ -%_ui.h : %.ui +%.ui.h : %.ui $(QT_UIC_EXEC) $< -o $@ # magic flags -libgnuradio_qtgui_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 +libgnuradio_qtgui_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) libgnuradio_qtgui_la_LIBADD = \ $(GNURADIO_CORE_LA) \ diff --git a/gr-qtgui/src/lib/SpectrumGUIClass.cc b/gr-qtgui/src/lib/SpectrumGUIClass.cc index 4cb71a31a..563ed34ba 100644 --- a/gr-qtgui/src/lib/SpectrumGUIClass.cc +++ b/gr-qtgui/src/lib/SpectrumGUIClass.cc @@ -61,8 +61,7 @@ SpectrumGUIClass::~SpectrumGUIClass() void SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, const bool frequency, const bool waterfall, - const bool waterfall3d, const bool time, - const bool constellation, + const bool time, const bool constellation, const bool use_openGL) { //_windowStateLock->Lock(); @@ -87,7 +86,6 @@ SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, // Toggle Windows on/off _spectrumDisplayForm->ToggleTabFrequency(frequency); _spectrumDisplayForm->ToggleTabWaterfall(waterfall); - _spectrumDisplayForm->ToggleTabWaterfall3D(waterfall3d); _spectrumDisplayForm->ToggleTabTime(time); _spectrumDisplayForm->ToggleTabConstellation(constellation); @@ -111,7 +109,7 @@ SpectrumGUIClass::OpenSpectrumWindow(QWidget* parent, timespec_reset(&_lastGUIUpdateTime); // Draw Blank Display - UpdateWindow(false, NULL, 0, NULL, 0, NULL, 0, 1.0, get_highres_clock(), true); + UpdateWindow(false, NULL, 0, NULL, 0, NULL, 0, get_highres_clock(), true); // Set up the initial frequency axis settings SetFrequencyRange(_centerFrequency, _startFrequency, _stopFrequency); @@ -220,7 +218,6 @@ SpectrumGUIClass::UpdateWindow(const bool updateDisplayFlag, const uint64_t realTimeDomainDataSize, const float* complexTimeDomainData, const uint64_t complexTimeDomainDataSize, - const double timePerFFT, const timespec timestamp, const bool lastOfMultipleFFTUpdateFlag) { @@ -277,7 +274,7 @@ SpectrumGUIClass::UpdateWindow(const bool updateDisplayFlag, const timespec currentTime = get_highres_clock(); const timespec lastUpdateGUITime = GetLastGUIUpdateTime(); - if((diff_timespec(currentTime, lastUpdateGUITime) > (4*timePerFFT)) && + if((diff_timespec(currentTime, lastUpdateGUITime) > (4*_updateTime)) && (GetPendingGUIUpdateEvents() > 0) && !timespec_empty(&lastUpdateGUITime)) { // Do not update the display if too much data is pending to be displayed _droppedEntriesCount++; @@ -290,7 +287,7 @@ SpectrumGUIClass::UpdateWindow(const bool updateDisplayFlag, _realTimeDomainPoints, _imagTimeDomainPoints, timeDomainBufferSize, - timePerFFT, timestamp, + timestamp, repeatDataFlag, lastOfMultipleFFTUpdateFlag, currentTime, @@ -460,4 +457,12 @@ SpectrumGUIClass::SetFrequencyAxis(double min, double max) _spectrumDisplayForm->SetFrequencyAxis(min, max); } +void +SpectrumGUIClass::SetUpdateTime(double t) +{ + _updateTime = t; + _spectrumDisplayForm->SetUpdateTime(_updateTime); +} + + #endif /* SPECTRUM_GUI_CLASS_CPP */ diff --git a/gr-qtgui/src/lib/SpectrumGUIClass.h b/gr-qtgui/src/lib/SpectrumGUIClass.h index d8dcb2769..63a340c34 100644 --- a/gr-qtgui/src/lib/SpectrumGUIClass.h +++ b/gr-qtgui/src/lib/SpectrumGUIClass.h @@ -31,8 +31,7 @@ public: void OpenSpectrumWindow(QWidget*, const bool frequency=true, const bool waterfall=true, - const bool waterfall3d=true, const bool time=true, - const bool constellation=true, + const bool time=true, const bool constellation=true, const bool use_openGL=true); void SetDisplayTitle(const std::string); @@ -47,7 +46,7 @@ public: void UpdateWindow(const bool, const std::complex<float>*, const uint64_t, const float*, const uint64_t, const float*, - const uint64_t, const double, + const uint64_t, const timespec, const bool); float GetPowerValue()const; @@ -79,6 +78,8 @@ public: void SetConstellationPenSize(int size); void SetFrequencyAxis(double min, double max); + void SetUpdateTime(double t); + protected: private: @@ -98,6 +99,7 @@ private: unsigned int _pendingGUIUpdateEventsCount; int _droppedEntriesCount; bool _fftBuffersCreatedFlag; + double _updateTime; SpectrumDisplayForm* _spectrumDisplayForm; diff --git a/gr-qtgui/src/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/src/lib/TimeDomainDisplayPlot.cc index cb18b4418..9c98cec5b 100644 --- a/gr-qtgui/src/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/src/lib/TimeDomainDisplayPlot.cc @@ -7,10 +7,37 @@ #include <qwt_legend.h> -class TimeDomainDisplayZoomer: public QwtPlotZoomer +class TimePrecisionClass { public: - TimeDomainDisplayZoomer(QwtPlotCanvas* canvas):QwtPlotZoomer(canvas) + TimePrecisionClass(const int timePrecision) + { + _timePrecision = timePrecision; + } + + virtual ~TimePrecisionClass() + { + } + + virtual unsigned int GetTimePrecision() const + { + return _timePrecision; + } + + virtual void SetTimePrecision(const unsigned int newPrecision) + { + _timePrecision = newPrecision; + } +protected: + unsigned int _timePrecision; +}; + + +class TimeDomainDisplayZoomer: public QwtPlotZoomer, public TimePrecisionClass +{ +public: + TimeDomainDisplayZoomer(QwtPlotCanvas* canvas, const unsigned int timePrecision) + : QwtPlotZoomer(canvas),TimePrecisionClass(timePrecision) { setTrackerMode(QwtPicker::AlwaysOn); } @@ -23,28 +50,38 @@ public: updateDisplay(); } + void SetUnitType(const std::string &type) + { + _unitType = type; + } + protected: + using QwtPlotZoomer::trackerText; virtual QwtText trackerText( const QwtDoublePoint& p ) const { - QwtText t(QString("Sample %1, %2 V").arg(p.x(), 0, 'f', 0).arg(p.y(), 0, 'f', 4)); + QwtText t(QString("%1 %2, %3 V").arg(p.x(), 0, 'f', GetTimePrecision()). + arg(_unitType.c_str()). + arg(p.y(), 0, 'f', 4)); return t; } + +private: + std::string _unitType; }; -TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent){ +TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent) +{ timespec_reset(&_lastReplot); resize(parent->width(), parent->height()); - _displayIntervalTime = (1.0/10.0); // 1/10 of a second between updates - _numPoints = 1024; _realDataPoints = new double[_numPoints]; _imagDataPoints = new double[_numPoints]; _xAxisPoints = new double[_numPoints]; - _zoomer = new TimeDomainDisplayZoomer(canvas()); + _zoomer = new TimeDomainDisplayZoomer(canvas(), 0); // Disable polygon clipping QwtPainter::setDeviceClipping(false); @@ -59,7 +96,7 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent){ setAxisScaleEngine(QwtPlot::xBottom, new QwtLinearScaleEngine); set_xaxis(0, _numPoints); - setAxisTitle(QwtPlot::xBottom, "Sample Number"); + setAxisTitle(QwtPlot::xBottom, "Time (sec)"); setAxisScaleEngine(QwtPlot::yLeft, new QwtLinearScaleEngine); set_yaxis(-2.0, 2.0); @@ -81,6 +118,7 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent){ memset(_imagDataPoints, 0x0, _numPoints*sizeof(double)); memset(_xAxisPoints, 0x0, _numPoints*sizeof(double)); + _sampleRate = 1; _resetXAxisPoints(); replot(); @@ -114,7 +152,8 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(QWidget* parent):QwtPlot(parent){ legendDisplay->setItemMode(QwtLegend::CheckableItem); insertLegend(legendDisplay); - connect(this, SIGNAL( legendChecked(QwtPlotItem *, bool ) ), this, SLOT( LegendEntryChecked(QwtPlotItem *, bool ) )); + connect(this, SIGNAL( legendChecked(QwtPlotItem *, bool ) ), + this, SLOT( LegendEntryChecked(QwtPlotItem *, bool ) )); } TimeDomainDisplayPlot::~TimeDomainDisplayPlot(){ @@ -143,17 +182,7 @@ TimeDomainDisplayPlot::set_xaxis(double min, double max) void TimeDomainDisplayPlot::replot() { - const timespec startTime = get_highres_clock(); - QwtPlot::replot(); - - double differenceTime = (diff_timespec(get_highres_clock(), startTime)); - - differenceTime *= 99.0; - // Require at least a 10% duty cycle - if(differenceTime > (1.0/10.0)){ - _displayIntervalTime = differenceTime; - } } void @@ -164,10 +193,12 @@ TimeDomainDisplayPlot::resizeSlot( QSize *s ) void TimeDomainDisplayPlot::PlotNewData(const double* realDataPoints, const double* imagDataPoints, - const int64_t numDataPoints) + const int64_t numDataPoints, + const double timeInterval) { - if(numDataPoints > 0){ - + if((numDataPoints > 0) && + (diff_timespec(get_highres_clock(), _lastReplot) > timeInterval)) { + if(numDataPoints != _numPoints){ _numPoints = numDataPoints; @@ -185,34 +216,61 @@ void TimeDomainDisplayPlot::PlotNewData(const double* realDataPoints, _resetXAxisPoints(); } + memcpy(_realDataPoints, realDataPoints, numDataPoints*sizeof(double)); memcpy(_imagDataPoints, imagDataPoints, numDataPoints*sizeof(double)); - } + replot(); - // Allow at least a 50% duty cycle - if(diff_timespec(get_highres_clock(), _lastReplot) > _displayIntervalTime){ - // Only replot the screen if it is visible - if(isVisible()){ - replot(); - } _lastReplot = get_highres_clock(); } } -void TimeDomainDisplayPlot::SetImaginaryDataVisible(const bool visibleFlag){ +void TimeDomainDisplayPlot::SetImaginaryDataVisible(const bool visibleFlag) +{ _imag_plot_curve->setVisible(visibleFlag); } -void TimeDomainDisplayPlot::_resetXAxisPoints(){ +void TimeDomainDisplayPlot::_resetXAxisPoints() +{ + double delt = 1.0/_sampleRate; for(long loc = 0; loc < _numPoints; loc++){ - _xAxisPoints[loc] = loc; + _xAxisPoints[loc] = loc*delt; } - setAxisScale(QwtPlot::xBottom, 0, _numPoints); + setAxisScale(QwtPlot::xBottom, 0, _numPoints*delt); + + // Set up zoomer base for maximum unzoom x-axis + // and reset to maximum unzoom level + QwtDoubleRect zbase = _zoomer->zoomBase(); + zbase.setLeft(0); + zbase.setRight(_numPoints*delt); + _zoomer->zoom(zbase); + _zoomer->setZoomBase(zbase); + _zoomer->zoom(0); } -void TimeDomainDisplayPlot::LegendEntryChecked(QwtPlotItem* plotItem, bool on){ +void TimeDomainDisplayPlot::LegendEntryChecked(QwtPlotItem* plotItem, bool on) +{ plotItem->setVisible(!on); } +void +TimeDomainDisplayPlot::SetSampleRate(double sr, double units, + const std::string &strunits) +{ + double newsr = sr/units; + if(newsr != _sampleRate) { + _sampleRate = sr/units; + _resetXAxisPoints(); + + // While we could change the displayed sigfigs based on the unit being + // displayed, I think it looks better by just setting it to 4 regardless. + //double display_units = ceil(log10(units)/2.0); + double display_units = 4; + setAxisTitle(QwtPlot::xBottom, QString("Time (%1)").arg(strunits.c_str())); + ((TimeDomainDisplayZoomer*)_zoomer)->SetTimePrecision(display_units); + ((TimeDomainDisplayZoomer*)_zoomer)->SetUnitType(strunits); + } +} + #endif /* TIME_DOMAIN_DISPLAY_PLOT_C */ diff --git a/gr-qtgui/src/lib/TimeDomainDisplayPlot.h b/gr-qtgui/src/lib/TimeDomainDisplayPlot.h index 8d98abac6..5525bbabe 100644 --- a/gr-qtgui/src/lib/TimeDomainDisplayPlot.h +++ b/gr-qtgui/src/lib/TimeDomainDisplayPlot.h @@ -21,7 +21,8 @@ public: TimeDomainDisplayPlot(QWidget*); virtual ~TimeDomainDisplayPlot(); - void PlotNewData(const double* realDataPoints, const double* imagDataPoints, const int64_t numDataPoints); + void PlotNewData(const double* realDataPoints, const double* imagDataPoints, + const int64_t numDataPoints, const double timeInterval); void SetImaginaryDataVisible(const bool); @@ -32,6 +33,8 @@ public: public slots: void resizeSlot( QSize *s ); + void SetSampleRate(double sr, double units, + const std::string &strunits); protected slots: void LegendEntryChecked(QwtPlotItem *plotItem, bool on); @@ -51,11 +54,11 @@ private: double* _imagDataPoints; double* _xAxisPoints; + double _sampleRate; + timespec _lastReplot; int64_t _numPoints; - - double _displayIntervalTime; }; #endif /* TIME_DOMAIN_DISPLAY_PLOT_HPP */ diff --git a/gr-qtgui/src/lib/Waterfall3DDisplayPlot.cc b/gr-qtgui/src/lib/Waterfall3DDisplayPlot.cc deleted file mode 100644 index f676cb4af..000000000 --- a/gr-qtgui/src/lib/Waterfall3DDisplayPlot.cc +++ /dev/null @@ -1,410 +0,0 @@ -#ifndef WATERFALL_3D_DISPLAY_PLOT_C -#define WATERFALL_3D_DISPLAY_PLOT_C - -#include <Waterfall3DDisplayPlot.h> - -#include <qwt3d_helper.h> -#include <qapplication.h> - -Waterfall3DColorMap::Waterfall3DColorMap(): Qwt3D::Color(), QwtLinearColorMap(){ - _interval.setInterval(0, 1.0); - -} - -Waterfall3DColorMap::~Waterfall3DColorMap(){ - -} - -Qwt3D::RGBA -Waterfall3DColorMap::operator()(double, double, double z) const -{ - return Qwt3D::RGBA(Qwt3D::Qt2GL(color(_interval, z))); -} - -void -Waterfall3DColorMap::SetInterval(const double minValue, const double maxValue) -{ - _interval.setInterval(minValue, maxValue); -} - -Qwt3D::ColorVector& -Waterfall3DColorMap::createVector(Qwt3D::ColorVector& vec) -{ - // Generate 100 interval values and then return those - Qwt3D::ColorVector colorVec; - for(unsigned int number = 0; number < 100; number++){ - double value = (_interval.width() * (static_cast<double>(number) / 100.0)) + _interval.minValue(); - colorVec.push_back(operator()(0,0,value)); - } - vec = colorVec; - return vec; -} - - -const int Waterfall3DDisplayPlot::INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR; -const int Waterfall3DDisplayPlot::INTENSITY_COLOR_MAP_TYPE_WHITE_HOT; -const int Waterfall3DDisplayPlot::INTENSITY_COLOR_MAP_TYPE_BLACK_HOT; -const int Waterfall3DDisplayPlot::INTENSITY_COLOR_MAP_TYPE_INCANDESCENT; -const int Waterfall3DDisplayPlot::INTENSITY_COLOR_MAP_TYPE_USER_DEFINED; - -Waterfall3DDisplayPlot::Waterfall3DDisplayPlot(QWidget* parent):Qwt3D::SurfacePlot(parent) -{ - _startFrequency = 0; - _stopFrequency = 4000; - - _createCoordinateSystemFlag = true; - - _initialized = false; - - _numPoints = 1024; - - _displayIntervalTime = (1.0/5.0); // 1/5 of a second between updates - - timespec_reset(&_lastReplot); - - _useCenterFrequencyFlag = false; - _centerFrequency = 0.0; - - _timePerFFT = 1.0; - timespec_reset(&_dataTimestamp); - - coordinates()->setAutoScale(false); - - _waterfallData = new Waterfall3DData(_startFrequency, _stopFrequency, _numPoints, 200); - _waterfallData->assign(this); - _waterfallData->create(); - - _intensityColorMapType = -1; - SetIntensityColorMapType(INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR, Qt::white, Qt::black, true, true); - - legend()->setScale(Qwt3D::LINEARSCALE); - legend()->setTitleString("Intensity"); - - enableMouse(true); -} - -Waterfall3DDisplayPlot::~Waterfall3DDisplayPlot() -{ - delete _waterfallData; -} - -void -Waterfall3DDisplayPlot::Init() -{ - if(!_initialized && initializedGL()){ - resize(parentWidget()->width(), parentWidget()->height()); - - // Attempting to prevent valgrind uninitialized variable errors in QwtPlot3d::Drawable class - glDisable(GL_POLYGON_OFFSET_FILL); - - setPlotStyle(Qwt3D::FILLED); - - setCoordinateStyle(Qwt3D::FRAME); - setFloorStyle(Qwt3D::FLOORDATA); - setOrtho(true); - - _initialized = true; - } -} - -void -Waterfall3DDisplayPlot::Reset() -{ - _waterfallData->ResizeData(_startFrequency, _stopFrequency, _numPoints); - _waterfallData->Reset(); - - if(initializedGL()){ - setScale(1, static_cast<int>(((_stopFrequency - _startFrequency) / 200) ), 10); - } - - _createCoordinateSystemFlag = true; - - timespec_reset(&_dataTimestamp); - _timePerFFT = 1.0; -} - -void -Waterfall3DDisplayPlot::SetFrequencyRange(const double constStartFreq, - const double constStopFreq, - const double constCenterFreq, - const bool useCenterFrequencyFlag, - const double units, - const std::string &strunits) -{ - double startFreq = constStartFreq / units; - double stopFreq = constStopFreq / units; - double centerFreq = constCenterFreq / units; - - if(stopFreq > startFreq) { - _startFrequency = startFreq; - _stopFrequency = stopFreq; - - _useCenterFrequencyFlag = useCenterFrequencyFlag; - _centerFrequency = centerFreq; - - Reset(); - - // Only replot if screen is visible - if(isVisible()){ - replot(); - } - } -} - -bool -Waterfall3DDisplayPlot::loadFromData(double** data, unsigned int columns, unsigned int rows - ,double minx, double maxx, double miny, double maxy) -{ - - Qwt3D::GridData* gridPtr = (Qwt3D::GridData*)actualData_p; - - gridPtr->setPeriodic(false,false); - gridPtr->setSize(columns,rows); - readIn(*gridPtr,data,columns,rows,minx,maxx,miny,maxy); - calcNormals(*gridPtr); - - updateData(); - updateNormals(); - - if( _createCoordinateSystemFlag ){ - createCoordinateSystem(); - - for (unsigned i=0; i!=coordinates()->axes.size(); ++i) - { - coordinates()->axes[i].setMajors(5); - coordinates()->axes[i].setMinors(3); - } - - coordinates()->axes[Qwt3D::Y1].setLabelString("Time"); - coordinates()->axes[Qwt3D::Y2].setLabelString("Time"); - coordinates()->axes[Qwt3D::Y3].setLabelString("Time"); - coordinates()->axes[Qwt3D::Y4].setLabelString("Time"); - coordinates()->axes[Qwt3D::Z1].setLabelString("Intensity (dB)"); - coordinates()->axes[Qwt3D::Z2].setLabelString("Intensity (dB)"); - coordinates()->axes[Qwt3D::Z3].setLabelString("Intensity (dB)"); - coordinates()->axes[Qwt3D::Z4].setLabelString("Intensity (dB)"); - - coordinates()->axes[Qwt3D::X1].setLabelString((!_useCenterFrequencyFlag ? "Frequency (Hz)" : "Frequency (kHz)")); - coordinates()->axes[Qwt3D::X2].setLabelString((!_useCenterFrequencyFlag ? "Frequency (Hz)" : "Frequency (kHz)")); - coordinates()->axes[Qwt3D::X3].setLabelString((!_useCenterFrequencyFlag ? "Frequency (Hz)" : "Frequency (kHz)")); - coordinates()->axes[Qwt3D::X4].setLabelString((!_useCenterFrequencyFlag ? "Frequency (Hz)" : "Frequency (kHz)")); - - // The QwtPlot3D Interface takes ownership of these items, so there is no need to delete them... - coordinates()->axes[Qwt3D::X1].setScale(new FrequencyScale(_useCenterFrequencyFlag, _centerFrequency)); - coordinates()->axes[Qwt3D::X2].setScale(new FrequencyScale(_useCenterFrequencyFlag, _centerFrequency)); - coordinates()->axes[Qwt3D::X3].setScale(new FrequencyScale(_useCenterFrequencyFlag, _centerFrequency)); - coordinates()->axes[Qwt3D::X4].setScale(new FrequencyScale(_useCenterFrequencyFlag, _centerFrequency)); - - coordinates()->axes[Qwt3D::Y1].setScale(new TimeScale(this)); - coordinates()->axes[Qwt3D::Y2].setScale(new TimeScale(this)); - coordinates()->axes[Qwt3D::Y3].setScale(new TimeScale(this)); - coordinates()->axes[Qwt3D::Y4].setScale(new TimeScale(this)); - - coordinates()->axes[Qwt3D::Z1].setScale(new IntensityScale(_waterfallData->GetFloorValue())); - coordinates()->axes[Qwt3D::Z2].setScale(new IntensityScale(_waterfallData->GetFloorValue())); - coordinates()->axes[Qwt3D::Z3].setScale(new IntensityScale(_waterfallData->GetFloorValue())); - coordinates()->axes[Qwt3D::Z4].setScale(new IntensityScale(_waterfallData->GetFloorValue())); - - _createCoordinateSystemFlag = false; - } - - return true; -} - -double -Waterfall3DDisplayPlot::GetStartFrequency() const -{ - return _startFrequency; -} - -double -Waterfall3DDisplayPlot::GetStopFrequency() const -{ - return _stopFrequency; -} - -void -Waterfall3DDisplayPlot::PlotNewData(const double* dataPoints, - const int64_t numDataPoints, - const double timePerFFT, - const timespec timestamp, - const int droppedFrames) -{ - if(numDataPoints > 0){ - if(numDataPoints != _numPoints){ - _numPoints = numDataPoints; - - Reset(); - - if(isVisible()){ - replot(); - } - - _createCoordinateSystemFlag = true; - - _lastReplot = get_highres_clock(); - } - - _dataTimestamp = timestamp; - _timePerFFT = timePerFFT; - - _waterfallData->addFFTData(dataPoints, numDataPoints, droppedFrames); - _waterfallData->IncrementNumLinesToUpdate(); - } - - // Allow at least a 50% duty cycle - if(diff_timespec(get_highres_clock(), _lastReplot) > _displayIntervalTime){ - // Only update when window is visible - if(isVisible()){ - replot(); - } - - _lastReplot = get_highres_clock(); - } -} - -void -Waterfall3DDisplayPlot::SetIntensityRange(const double minIntensity, - const double maxIntensity) -{ - _waterfallData->SetFloorValue(minIntensity); - _waterfallData->setMinZ(0); - _waterfallData->setMaxZ(maxIntensity-minIntensity); - - _createCoordinateSystemFlag = true; - - emit UpdatedLowerIntensityLevel(minIntensity); - emit UpdatedUpperIntensityLevel(maxIntensity); - - SetIntensityColorMapType(_intensityColorMapType, - _userDefinedLowIntensityColor, - _userDefinedLowIntensityColor, true); -} - -void -Waterfall3DDisplayPlot::replot() -{ - if(!_initialized){ - Init(); - } - if(initializedGL()){ - const timespec startTime = get_highres_clock(); - - _waterfallData->create(); - - legend()->setMajors(4); - legend()->setMinors(5); - double start, stop; - coordinates()->axes[Qwt3D::Z1].limits(start,stop); - legend()->setLimits( _waterfallData->GetFloorValue(), _waterfallData->GetFloorValue() + stop - start ); - - coordinates()->axes[Qwt3D::X1].limits(start,stop); - - showColorLegend(true); - - updateGL(); - - double differenceTime = (diff_timespec(get_highres_clock(), startTime)); - - // Require at least a 20% duty cycle - differenceTime *= 4.0; - if(differenceTime > (1.0/5.0)){ - _displayIntervalTime = differenceTime; - } - } -} - -void -Waterfall3DDisplayPlot::resizeSlot( QSize *s ) -{ - resize(s->width(), s->height()); -} - -int -Waterfall3DDisplayPlot::GetIntensityColorMapType() const -{ - return _intensityColorMapType; -} - -void -Waterfall3DDisplayPlot::SetIntensityColorMapType(const int newType, - const QColor lowColor, - const QColor highColor, - const bool forceFlag, - const bool noReplotFlag) -{ - if(((_intensityColorMapType != newType) || forceFlag) || - ((newType == INTENSITY_COLOR_MAP_TYPE_USER_DEFINED) && - (lowColor.isValid() && highColor.isValid()))){ - - Waterfall3DColorMap* colorMap = new Waterfall3DColorMap(); - colorMap->SetInterval(_waterfallData->minZ(), _waterfallData->maxZ()); - - switch(newType){ - case INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR:{ - _intensityColorMapType = newType; - colorMap->setColorInterval(Qt::darkCyan, Qt::white); - colorMap->addColorStop(0.25, Qt::cyan); - colorMap->addColorStop(0.5, Qt::yellow); - colorMap->addColorStop(0.75, Qt::red); - setBackgroundColor(Qwt3D::Qt2GL(Qt::gray)); - break; - } - case INTENSITY_COLOR_MAP_TYPE_WHITE_HOT:{ - _intensityColorMapType = newType; - colorMap->setColorInterval(Qt::black, Qt::white); - setBackgroundColor(Qwt3D::Qt2GL(Qt::blue)); - break; - } - case INTENSITY_COLOR_MAP_TYPE_BLACK_HOT:{ - _intensityColorMapType = newType; - colorMap->setColorInterval(Qt::white, Qt::black); - setBackgroundColor(Qwt3D::Qt2GL(Qt::blue)); - break; - } - case INTENSITY_COLOR_MAP_TYPE_INCANDESCENT:{ - _intensityColorMapType = newType; - colorMap->setColorInterval(Qt::black, Qt::white); - colorMap->addColorStop(0.5, Qt::darkRed); - setBackgroundColor(Qwt3D::Qt2GL(Qt::gray)); - break; - } - case INTENSITY_COLOR_MAP_TYPE_USER_DEFINED:{ - _userDefinedLowIntensityColor = lowColor; - _userDefinedHighIntensityColor = highColor; - _intensityColorMapType = newType; - colorMap->setColorInterval(_userDefinedLowIntensityColor, _userDefinedHighIntensityColor); - setBackgroundColor(Qwt3D::Qt2GL(Qt::white)); - break; - } - default: - colorMap->setColorInterval(Qt::black, Qt::white); - break; - } - - // Qwt3D takes over destruction of this object... - setDataColor(colorMap); - - if(!noReplotFlag){ - // Draw again - replot(); - - // Update the last replot timer - _lastReplot = get_highres_clock(); - } - } -} - -const QColor -Waterfall3DDisplayPlot::GetUserDefinedLowIntensityColor() const -{ - return _userDefinedLowIntensityColor; -} - -const QColor -Waterfall3DDisplayPlot::GetUserDefinedHighIntensityColor() const -{ - return _userDefinedHighIntensityColor; -} - -#endif /* WATERFALL_3D_DISPLAY_PLOT_C */ diff --git a/gr-qtgui/src/lib/Waterfall3DDisplayPlot.h b/gr-qtgui/src/lib/Waterfall3DDisplayPlot.h deleted file mode 100644 index 272bdf697..000000000 --- a/gr-qtgui/src/lib/Waterfall3DDisplayPlot.h +++ /dev/null @@ -1,206 +0,0 @@ -#ifndef WATERFALL_3D_DISPLAY_PLOT_HPP -#define WATERFALL_3D_DISPLAY_PLOT_HPP - -#include <cstdio> -#include <highResTimeFunctions.h> - -#include <waterfallGlobalData.h> -#include <qwt3d_surfaceplot.h> - -#include <qwt3d_color.h> -#include <qwt_color_map.h> - -class Waterfall3DColorMap: public Qwt3D::Color, public QwtLinearColorMap -{ -public: - Waterfall3DColorMap(); - virtual ~Waterfall3DColorMap(); - - virtual Qwt3D::RGBA operator()(double x, double y, double z)const; - virtual Qwt3D::ColorVector& createVector(Qwt3D::ColorVector& vec); - - virtual void SetInterval(const double minValue, const double maxValue); - -protected: - -private: - QwtDoubleInterval _interval; -}; - -class Waterfall3DDisplayPlot:public Qwt3D::SurfacePlot{ - Q_OBJECT - - protected: - class IntensityScale:public Qwt3D::LinearScale{ - - friend class Qwt3D::Axis; - friend class Qwt3D::qwt3d_ptr<Qwt3D::Scale>; - - private: - double _floor; - - public: - explicit IntensityScale(const double newFloor):_floor(newFloor){ } - virtual ~IntensityScale(){} - - virtual QString ticLabel(unsigned int idx) const{ - if (idx<majors_p.size()) - { - return QString("%1").arg( majors_p[idx] + GetFloorValue(), 0, 'f', 0 ); - } - return QString(""); - } - - virtual double GetFloorValue()const{ return _floor; } - virtual void SetFloorValue(const double newFloor){ _floor = newFloor; } - - //! Returns a new heap based object utilized from qwt3d_ptr - Scale* clone() const {return new IntensityScale(*this);} - }; - - class TimeScale:public Qwt3D::LinearScale{ - - friend class Qwt3D::Axis; - friend class Qwt3D::qwt3d_ptr<Qwt3D::Scale>; - friend class Waterfall3DDisplayPlot; - - private: - Waterfall3DDisplayPlot* _plot; - - public: - TimeScale(Waterfall3DDisplayPlot* plot ):_plot(plot){ - } - virtual ~TimeScale(){ - } - - virtual QString ticLabel(unsigned int idx) const{ - if (idx<majors_p.size()) - { - const timespec markerTime = timespec_add(_plot->_dataTimestamp, - -(_plot->_timePerFFT) * majors_p[idx]); - struct tm timeTm; - gmtime_r(&markerTime.tv_sec, &timeTm); - - char* timeBuffer = new char[128]; - snprintf(timeBuffer, 128, "%02d:%02d:%02d.%03ld", timeTm.tm_hour, - timeTm.tm_min, timeTm.tm_sec, (markerTime.tv_nsec / 1000000)); - QString returnBuffer(timeBuffer); - delete[] timeBuffer; - return returnBuffer; - } - return QString(""); - } - - //! Returns a new heap based object utilized from qwt3d_ptr - Scale* clone() const {return new TimeScale(*this);} - }; - - class FrequencyScale: public Qwt3D::LinearScale{ - - friend class Qwt3D::Axis; - friend class Qwt3D::qwt3d_ptr<Qwt3D::Scale>; - private: - double _centerFrequency; - bool _useCenterFrequencyFlag; - public: - FrequencyScale(bool useCenterFrequencyFlag, double centerFrequency) - : _centerFrequency(centerFrequency),_useCenterFrequencyFlag(useCenterFrequencyFlag) - {} - - virtual ~FrequencyScale(){} - - virtual QString ticLabel(unsigned int idx) const - { - if (idx<majors_p.size()) - { - if(!_useCenterFrequencyFlag){ - return QString("%1").arg( majors_p[idx], 0, 'f', 0 ); - - } - else{ - return QString("%1").arg( (majors_p[idx] + _centerFrequency)/1000.0, 0, 'f', 3 ); - } - } - return QString(""); - } - - //! Returns a new heap based object utilized from qwt3d_ptr - Scale* clone() const {return new FrequencyScale(*this);} - }; - -public: - Waterfall3DDisplayPlot(QWidget*); - virtual ~Waterfall3DDisplayPlot(); - - void Init(); - void Reset(); - - bool loadFromData(double** data, unsigned int columns, unsigned int rows - ,double minx, double maxx, double miny, double maxy); - - void SetFrequencyRange(const double, const double, - const double, const bool, - const double units, const std::string &strunits); - double GetStartFrequency()const; - double GetStopFrequency()const; - - void PlotNewData(const double* dataPoints, const int64_t numDataPoints, - const double timePerFFT, const timespec timestamp, - const int droppedFrames); - - void SetIntensityRange(const double minIntensity, const double maxIntensity); - - virtual void replot(void); - - int GetIntensityColorMapType()const; - void SetIntensityColorMapType( const int, const QColor, - const QColor, const bool forceFlag = false, - const bool noReplotFlag = false ); - const QColor GetUserDefinedLowIntensityColor()const; - const QColor GetUserDefinedHighIntensityColor()const; - - static const int INTENSITY_COLOR_MAP_TYPE_MULTI_COLOR = 0; - static const int INTENSITY_COLOR_MAP_TYPE_WHITE_HOT = 1; - static const int INTENSITY_COLOR_MAP_TYPE_BLACK_HOT = 2; - static const int INTENSITY_COLOR_MAP_TYPE_INCANDESCENT = 3; - static const int INTENSITY_COLOR_MAP_TYPE_USER_DEFINED = 4; - -public slots: - void resizeSlot( QSize *s ); - - -signals: - void UpdatedLowerIntensityLevel(const double); - void UpdatedUpperIntensityLevel(const double); - -protected: - - double _startFrequency; - double _stopFrequency; - - Waterfall3DData* _waterfallData; - - timespec _lastReplot; - - int64_t _numPoints; - - double _displayIntervalTime; - - int _intensityColorMapType; - QColor _userDefinedLowIntensityColor; - QColor _userDefinedHighIntensityColor; - - bool _useCenterFrequencyFlag; - double _centerFrequency; - - timespec _dataTimestamp; - double _timePerFFT; - bool _initialized; - - bool _createCoordinateSystemFlag; - -private: - -}; - -#endif /* WATERFALL_3D_DISPLAY_PLOT_HPP */ diff --git a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc index f6d0cc0ba..680c44756 100644 --- a/gr-qtgui/src/lib/WaterfallDisplayPlot.cc +++ b/gr-qtgui/src/lib/WaterfallDisplayPlot.cc @@ -66,8 +66,7 @@ public: QwtText label(double value) const { - return QString("%1").arg((value + GetCenterFrequency()) / ((GetFrequencyPrecision() == 0) ? 1.0 : 1000.0), - 0, 'f', GetFrequencyPrecision()); + return QString("%1").arg(value, 0, 'f', GetFrequencyPrecision()); } virtual void initiateUpdate() @@ -161,7 +160,8 @@ private: }; -class WaterfallZoomer: public QwtPlotZoomer, public TimeScaleData, public FreqOffsetAndPrecisionClass +class WaterfallZoomer: public QwtPlotZoomer, public TimeScaleData, + public FreqOffsetAndPrecisionClass { public: WaterfallZoomer(QwtPlotCanvas* canvas, const unsigned int freqPrecision) @@ -180,7 +180,13 @@ public: updateDisplay(); } + void SetUnitType(const std::string &type) + { + _unitType = type; + } + protected: + using QwtPlotZoomer::trackerText; virtual QwtText trackerText( const QwtDoublePoint& p ) const { QString yLabel(""); @@ -193,10 +199,14 @@ protected: timeTm.tm_mday, timeTm.tm_hour, timeTm.tm_min, timeTm.tm_sec, lineTime.tv_nsec/1000000)); - QwtText t(QString("%1 %2, %3").arg((p.x() + GetCenterFrequency()) / ((GetFrequencyPrecision() == 0) ? 1.0 : 1000.0), 0, 'f', GetFrequencyPrecision()).arg( (GetFrequencyPrecision() == 0) ? "Hz" : "kHz").arg(yLabel)); - + QwtText t(QString("%1 %2, %3"). + arg(p.x(), 0, 'f', GetFrequencyPrecision()). + arg(_unitType.c_str()).arg(yLabel)); return t; } + +private: + std::string _unitType; }; @@ -216,8 +226,6 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) resize(parent->width(), parent->height()); _numPoints = 1024; - _displayIntervalTime = (1.0/5.0); // 1/5 of a second between updates - _waterfallData = new WaterfallData(_startFrequency, _stopFrequency, _numPoints, 200); QPalette palette; @@ -282,6 +290,7 @@ WaterfallDisplayPlot::WaterfallDisplayPlot(QWidget* parent) WaterfallDisplayPlot::~WaterfallDisplayPlot() { delete _waterfallData; + delete d_spectrogram; } void @@ -290,6 +299,8 @@ WaterfallDisplayPlot::Reset() _waterfallData->ResizeData(_startFrequency, _stopFrequency, _numPoints); _waterfallData->Reset(); + setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); + // Load up the new base zoom settings QwtDoubleRect newSize = _zoomer->zoomBase(); newSize.setLeft(_startFrequency); @@ -310,27 +321,32 @@ WaterfallDisplayPlot::SetFrequencyRange(const double constStartFreq, double stopFreq = constStopFreq / units; double centerFreq = constCenterFreq / units; - if(stopFreq > startFreq) { - _startFrequency = 1000*startFreq; - _stopFrequency = 1000*stopFreq; + _useCenterFrequencyFlag = useCenterFrequencyFlag; - setAxisScale(QwtPlot::xBottom, _startFrequency, _stopFrequency); + if(_useCenterFrequencyFlag){ + startFreq = (startFreq + centerFreq); + stopFreq = (stopFreq + centerFreq); + } - if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)){ - WaterfallFreqDisplayScaleDraw* freqScale = ((WaterfallFreqDisplayScaleDraw*)axisScaleDraw(QwtPlot::xBottom)); - freqScale->SetCenterFrequency(centerFreq); - ((WaterfallZoomer*)_zoomer)->SetCenterFrequency(centerFreq); + bool reset = false; + if((startFreq != _startFrequency) || (stopFreq != _stopFrequency)) + reset = true; - freqScale->SetFrequencyPrecision( 2 ); - ((WaterfallZoomer*)_zoomer)->SetFrequencyPrecision( 2 ); + if(stopFreq > startFreq) { + _startFrequency = startFreq; + _stopFrequency = stopFreq; + + if((axisScaleDraw(QwtPlot::xBottom) != NULL) && (_zoomer != NULL)){ + double display_units = ceil(log10(units)/2.0); + setAxisScaleDraw(QwtPlot::xBottom, new WaterfallFreqDisplayScaleDraw(display_units)); setAxisTitle(QwtPlot::xBottom, QString("Frequency (%1)").arg(strunits.c_str())); - } - Reset(); + if(reset) { + Reset(); + } - // Only replot if screen is visible - if(isVisible()){ - replot(); + ((WaterfallZoomer*)_zoomer)->SetFrequencyPrecision(display_units); + ((WaterfallZoomer*)_zoomer)->SetUnitType(strunits); } } } @@ -350,50 +366,46 @@ WaterfallDisplayPlot::GetStopFrequency() const void WaterfallDisplayPlot::PlotNewData(const double* dataPoints, - const int64_t numDataPoints, - const double timePerFFT, - const timespec timestamp, - const int droppedFrames) + const int64_t numDataPoints, + const double timePerFFT, + const timespec timestamp, + const int droppedFrames) { if(numDataPoints > 0){ if(numDataPoints != _numPoints){ _numPoints = numDataPoints; - + Reset(); - + d_spectrogram->invalidateCache(); d_spectrogram->itemChanged(); - + if(isVisible()){ replot(); } - + _lastReplot = get_highres_clock(); } - _waterfallData->addFFTData(dataPoints, numDataPoints, droppedFrames); - _waterfallData->IncrementNumLinesToUpdate(); - - QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft); - timeScale->SetSecondsPerLine(timePerFFT); - timeScale->SetZeroTime(timestamp); - - ((WaterfallZoomer*)_zoomer)->SetSecondsPerLine(timePerFFT); - ((WaterfallZoomer*)_zoomer)->SetZeroTime(timestamp); - } - - // Allow at least a 50% duty cycle - if(diff_timespec(get_highres_clock(), _lastReplot) > _displayIntervalTime){ - - d_spectrogram->invalidateCache(); - d_spectrogram->itemChanged(); - - // Only update when window is visible - if(isVisible()){ + if(diff_timespec(get_highres_clock(), _lastReplot) > timePerFFT) { + //FIXME: We may want to average the data between these updates to smooth display + _waterfallData->addFFTData(dataPoints, numDataPoints, droppedFrames); + _waterfallData->IncrementNumLinesToUpdate(); + + QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft); + timeScale->SetSecondsPerLine(timePerFFT); + timeScale->SetZeroTime(timestamp); + + ((WaterfallZoomer*)_zoomer)->SetSecondsPerLine(timePerFFT); + ((WaterfallZoomer*)_zoomer)->SetZeroTime(timestamp); + + d_spectrogram->invalidateCache(); + d_spectrogram->itemChanged(); + replot(); - } - _lastReplot = get_highres_clock(); + _lastReplot = get_highres_clock(); + } } } @@ -412,8 +424,6 @@ WaterfallDisplayPlot::SetIntensityRange(const double minIntensity, void WaterfallDisplayPlot::replot() { - const timespec startTime = get_highres_clock(); - QwtTimeScaleDraw* timeScale = (QwtTimeScaleDraw*)axisScaleDraw(QwtPlot::yLeft); timeScale->initiateUpdate(); @@ -435,14 +445,6 @@ WaterfallDisplayPlot::replot() } QwtPlot::replot(); - - double differenceTime = (diff_timespec(get_highres_clock(), startTime)); - - // Require at least a 5% duty cycle - differenceTime *= 19.0; - if(differenceTime > (1.0/5.0)){ - _displayIntervalTime = differenceTime; - } } void diff --git a/gr-qtgui/src/lib/WaterfallDisplayPlot.h b/gr-qtgui/src/lib/WaterfallDisplayPlot.h index bb87fb09f..a5ccaec40 100644 --- a/gr-qtgui/src/lib/WaterfallDisplayPlot.h +++ b/gr-qtgui/src/lib/WaterfallDisplayPlot.h @@ -69,9 +69,9 @@ private: timespec _lastReplot; - int64_t _numPoints; + bool _useCenterFrequencyFlag; - double _displayIntervalTime; + int64_t _numPoints; int _intensityColorMapType; QColor _userDefinedLowIntensityColor; diff --git a/gr-qtgui/src/lib/highResTimeFunctions.h b/gr-qtgui/src/lib/highResTimeFunctions.h index b85b1acad..251bbad8b 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<long>(modf(timeValue, &seconds) * static_cast<double>(NSEC_PER_SEC)); + long nsec = static_cast<long>(modf(timeValue, &seconds) * + static_cast<double>(NSEC_PER_SEC)); time_t sec = static_cast<time_t>(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<double>(actual.tv_sec) + (static_cast<double>(actual.tv_nsec) / static_cast<double>(NSEC_PER_SEC))); +static inline double +convert_from_timespec(const timespec actual) +{ + return (static_cast<double>(actual.tv_sec) + + (static_cast<double>(actual.tv_nsec) / + static_cast<double>(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-qtgui/src/lib/qtgui_sink_c.cc b/gr-qtgui/src/lib/qtgui_sink_c.cc index 7340141a6..c12c451b0 100644 --- a/gr-qtgui/src/lib/qtgui_sink_c.cc +++ b/gr-qtgui/src/lib/qtgui_sink_c.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008,2009 Free Software Foundation, Inc. + * Copyright 2008,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -40,7 +40,7 @@ qtgui_make_sink_c (int fftsize, int wintype, bool use_openGL, QWidget *parent) { - return qtgui_sink_c_sptr (new qtgui_sink_c (fftsize, wintype, + return gnuradio::get_initial_sptr(new qtgui_sink_c (fftsize, wintype, fc, bw, name, plotfreq, plotwaterfall, plotwaterfall3d, plottime, @@ -64,10 +64,13 @@ qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype, d_wintype((gr_firdes::win_type)(wintype)), d_center_freq(fc), d_bandwidth(bw), d_name(name), d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall), - d_plotwaterfall3d(plotwaterfall3d), d_plottime(plottime), - d_plotconst(plotconst), + d_plottime(plottime), d_plotconst(plotconst), d_parent(parent) { + if(plotwaterfall3d == true) { + fprintf(stderr, "Warning: plotting Waterfall3D has been removed; enabling plotwaterfall3d has no effect.\n"); + } + d_main_gui = NULL; pthread_mutex_init(&d_pmutex, NULL); lock(); @@ -88,7 +91,7 @@ qtgui_sink_c::qtgui_sink_c (int fftsize, int wintype, qtgui_sink_c::~qtgui_sink_c() { - delete d_object; + delete d_main_gui; delete [] d_residbuf; delete d_fft; } @@ -141,10 +144,12 @@ qtgui_sink_c::initialize(const bool opengl) d_main_gui->OpenSpectrumWindow(d_parent, d_plotfreq, d_plotwaterfall, - d_plotwaterfall3d, d_plottime, - d_plotconst, + d_plottime, d_plotconst, opengl); + // initialize update time to 10 times a second + set_update_time(0.1); + d_object = new qtgui_obj(d_qApplication); qApp->postEvent(d_object, new qtgui_event(&d_pmutex)); } @@ -208,6 +213,13 @@ qtgui_sink_c::set_frequency_axis(double min, double max) } void +qtgui_sink_c::set_update_time(double t) +{ + d_update_time = t; + d_main_gui->SetUpdateTime(d_update_time); +} + +void qtgui_sink_c::fft(const gr_complex *data_in, int size) { if (d_window.size()) { @@ -300,7 +312,7 @@ qtgui_sink_c::general_work (int noutput_items, d_main_gui->UpdateWindow(true, d_fft->get_outbuf(), d_fftsize, NULL, 0, (float*)d_residbuf, d_fftsize, - 1.0/4.0, currentTime, true); + currentTime, true); } // Otherwise, copy what we received into the residbuf for next time else { diff --git a/gr-qtgui/src/lib/qtgui_sink_c.h b/gr-qtgui/src/lib/qtgui_sink_c.h index 91c6b03e6..9aee66503 100644 --- a/gr-qtgui/src/lib/qtgui_sink_c.h +++ b/gr-qtgui/src/lib/qtgui_sink_c.h @@ -23,12 +23,12 @@ #ifndef INCLUDED_QTGUI_SINK_C_H #define INCLUDED_QTGUI_SINK_C_H +#include <Python.h> #include <gr_block.h> #include <gr_firdes.h> #include <gri_fft.h> #include <qapplication.h> #include <qtgui.h> -#include <Python.h> #include "SpectrumGUIClass.h" class qtgui_sink_c; @@ -84,8 +84,10 @@ private: int d_index; gr_complex *d_residbuf; - bool d_plotfreq, d_plotwaterfall, d_plotwaterfall3d, d_plottime, d_plotconst; + bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst; + double d_update_time; + QWidget *d_parent; SpectrumGUIClass *d_main_gui; @@ -111,6 +113,8 @@ public: void set_constellation_pen_size(int size); void set_frequency_axis(double min, double max); + void set_update_time(double t); + QApplication *d_qApplication; qtgui_obj *d_object; diff --git a/gr-qtgui/src/lib/qtgui_sink_f.cc b/gr-qtgui/src/lib/qtgui_sink_f.cc index 6fbb2f381..ab4fd082d 100644 --- a/gr-qtgui/src/lib/qtgui_sink_f.cc +++ b/gr-qtgui/src/lib/qtgui_sink_f.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2008,2009 Free Software Foundation, Inc. + * Copyright 2008,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -40,7 +40,7 @@ qtgui_make_sink_f (int fftsize, int wintype, bool use_openGL, QWidget *parent) { - return qtgui_sink_f_sptr (new qtgui_sink_f (fftsize, wintype, + return gnuradio::get_initial_sptr(new qtgui_sink_f (fftsize, wintype, fc, bw, name, plotfreq, plotwaterfall, plotwaterfall3d, plottime, @@ -64,10 +64,13 @@ qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype, d_wintype((gr_firdes::win_type)(wintype)), d_center_freq(fc), d_bandwidth(bw), d_name(name), d_plotfreq(plotfreq), d_plotwaterfall(plotwaterfall), - d_plotwaterfall3d(plotwaterfall3d), d_plottime(plottime), - d_plotconst(plotconst), + d_plottime(plottime), d_plotconst(plotconst), d_parent(parent) { + if(plotwaterfall3d == true) { + fprintf(stderr, "Warning: plotting Waterfall3D has been removed; enabling plotwaterfall3d has no effect.\n"); + } + d_main_gui = NULL; pthread_mutex_init(&d_pmutex, NULL); lock(); @@ -88,7 +91,7 @@ qtgui_sink_f::qtgui_sink_f (int fftsize, int wintype, qtgui_sink_f::~qtgui_sink_f() { - delete d_object; + delete d_main_gui; delete [] d_residbuf; delete d_fft; } @@ -136,10 +139,12 @@ qtgui_sink_f::initialize(const bool opengl) d_main_gui->OpenSpectrumWindow(d_parent, d_plotfreq, d_plotwaterfall, - d_plotwaterfall3d, d_plottime, - d_plotconst, + d_plottime, d_plotconst, opengl); + // initialize update time to 10 times a second + set_update_time(0.1); + d_object = new qtgui_obj(d_qApplication); qApp->postEvent(d_object, new qtgui_event(&d_pmutex)); } @@ -202,6 +207,13 @@ qtgui_sink_f::set_frequency_axis(double min, double max) } void +qtgui_sink_f::set_update_time(double t) +{ + d_update_time = t; + d_main_gui->SetUpdateTime(d_update_time); +} + +void qtgui_sink_f::fft(const float *data_in, int size) { if (d_window.size()) { @@ -295,7 +307,7 @@ qtgui_sink_f::general_work (int noutput_items, d_main_gui->UpdateWindow(true, d_fft->get_outbuf(), d_fftsize, (float*)d_residbuf, d_fftsize, NULL, 0, - 1.0/4.0, currentTime, true); + currentTime, true); } // Otherwise, copy what we received into the residbuf for next time else { diff --git a/gr-qtgui/src/lib/qtgui_sink_f.h b/gr-qtgui/src/lib/qtgui_sink_f.h index 47c928d17..0cac35d90 100644 --- a/gr-qtgui/src/lib/qtgui_sink_f.h +++ b/gr-qtgui/src/lib/qtgui_sink_f.h @@ -23,12 +23,12 @@ #ifndef INCLUDED_QTGUI_SINK_F_H #define INCLUDED_QTGUI_SINK_F_H +#include <Python.h> #include <gr_block.h> #include <gr_firdes.h> #include <gri_fft.h> #include <qapplication.h> #include <qtgui.h> -#include <Python.h> #include "SpectrumGUIClass.h" class qtgui_sink_f; @@ -82,7 +82,9 @@ private: int d_index; float *d_residbuf; - bool d_plotfreq, d_plotwaterfall, d_plotwaterfall3d, d_plottime, d_plotconst; + bool d_plotfreq, d_plotwaterfall, d_plottime, d_plotconst; + + double d_update_time; QWidget *d_parent; SpectrumGUIClass *d_main_gui; @@ -109,6 +111,8 @@ public: void set_constellation_pen_size(int size); void set_frequency_axis(double min, double max); + void set_update_time(double t); + QApplication *d_qApplication; qtgui_obj *d_object; diff --git a/gr-qtgui/src/lib/spectrumUpdateEvents.cc b/gr-qtgui/src/lib/spectrumUpdateEvents.cc index 2da37d350..53a205fb7 100644 --- a/gr-qtgui/src/lib/spectrumUpdateEvents.cc +++ b/gr-qtgui/src/lib/spectrumUpdateEvents.cc @@ -8,7 +8,6 @@ SpectrumUpdateEvent::SpectrumUpdateEvent(const std::complex<float>* fftPoints, const double* realTimeDomainPoints, const double* imagTimeDomainPoints, const uint64_t numTimeDomainDataPoints, - const double timePerFFT, const timespec dataTimestamp, const bool repeatDataFlag, const bool lastOfMultipleUpdateFlag, @@ -16,15 +15,19 @@ SpectrumUpdateEvent::SpectrumUpdateEvent(const std::complex<float>* fftPoints, const int droppedFFTFrames) : QEvent(QEvent::Type(10005)) { - _numFFTDataPoints = numFFTDataPoints; - if(_numFFTDataPoints < 1){ + if(numFFTDataPoints < 1) { _numFFTDataPoints = 1; } + else { + _numFFTDataPoints = numFFTDataPoints; + } - _numTimeDomainDataPoints = numTimeDomainDataPoints; - if(_numTimeDomainDataPoints < 1){ + if(numTimeDomainDataPoints < 1) { _numTimeDomainDataPoints = 1; } + else { + _numTimeDomainDataPoints = numTimeDomainDataPoints; + } _fftPoints = new std::complex<float>[_numFFTDataPoints]; _fftPoints[0] = std::complex<float>(0,0); @@ -32,26 +35,26 @@ SpectrumUpdateEvent::SpectrumUpdateEvent(const std::complex<float>* fftPoints, _realDataTimeDomainPoints = new double[_numTimeDomainDataPoints]; memset(_realDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(double)); - if(numTimeDomainDataPoints > 0){ + if(numTimeDomainDataPoints > 0) { memcpy(_realDataTimeDomainPoints, realTimeDomainPoints, numTimeDomainDataPoints*sizeof(double)); } _imagDataTimeDomainPoints = new double[_numTimeDomainDataPoints]; memset(_imagDataTimeDomainPoints, 0x0, _numTimeDomainDataPoints*sizeof(double)); - if(numTimeDomainDataPoints > 0){ + if(numTimeDomainDataPoints > 0) { memcpy(_imagDataTimeDomainPoints, imagTimeDomainPoints, numTimeDomainDataPoints*sizeof(double)); } _dataTimestamp = dataTimestamp; - _timePerFFT = timePerFFT; _repeatDataFlag = repeatDataFlag; _lastOfMultipleUpdateFlag = lastOfMultipleUpdateFlag; _eventGeneratedTimestamp = generatedTimestamp; _droppedFFTFrames = droppedFFTFrames; } -SpectrumUpdateEvent::~SpectrumUpdateEvent(){ +SpectrumUpdateEvent::~SpectrumUpdateEvent() +{ delete[] _fftPoints; delete[] _realDataTimeDomainPoints; delete[] _imagDataTimeDomainPoints; @@ -87,12 +90,6 @@ SpectrumUpdateEvent::getNumTimeDomainDataPoints() const return _numTimeDomainDataPoints; } -double -SpectrumUpdateEvent::getTimePerFFT() const -{ - return _timePerFFT; -} - timespec SpectrumUpdateEvent::getDataTimestamp() const { diff --git a/gr-qtgui/src/lib/spectrumUpdateEvents.h b/gr-qtgui/src/lib/spectrumUpdateEvents.h index 75fa27324..ccc072c3e 100644 --- a/gr-qtgui/src/lib/spectrumUpdateEvents.h +++ b/gr-qtgui/src/lib/spectrumUpdateEvents.h @@ -10,19 +10,29 @@ class SpectrumUpdateEvent:public QEvent{ public: - SpectrumUpdateEvent(const std::complex<float>* fftPoints, const uint64_t numFFTDataPoints, const double* realTimeDomainPoints, const double* imagTimeDomainPoints, const uint64_t numTimeDomainDataPoints, const double timePerFFT, const timespec dataTimestamp, const bool repeatDataFlag, const bool lastOfMultipleUpdateFlag, const timespec generatedTimestamp, const int droppedFFTFrames); + SpectrumUpdateEvent(const std::complex<float>* fftPoints, + const uint64_t numFFTDataPoints, + const double* realTimeDomainPoints, + const double* imagTimeDomainPoints, + const uint64_t numTimeDomainDataPoints, + const timespec dataTimestamp, + const bool repeatDataFlag, + const bool lastOfMultipleUpdateFlag, + const timespec generatedTimestamp, + const int droppedFFTFrames); + ~SpectrumUpdateEvent(); - const std::complex<float>* getFFTPoints()const; - const double* getRealTimeDomainPoints()const; - const double* getImagTimeDomainPoints()const; - uint64_t getNumFFTDataPoints()const; - uint64_t getNumTimeDomainDataPoints()const; - double getTimePerFFT()const; - timespec getDataTimestamp()const; - bool getRepeatDataFlag()const; - bool getLastOfMultipleUpdateFlag()const; - timespec getEventGeneratedTimestamp()const; - int getDroppedFFTFrames()const; + + const std::complex<float>* getFFTPoints() const; + const double* getRealTimeDomainPoints() const; + const double* getImagTimeDomainPoints() const; + uint64_t getNumFFTDataPoints() const; + uint64_t getNumTimeDomainDataPoints() const; + timespec getDataTimestamp() const; + bool getRepeatDataFlag() const; + bool getLastOfMultipleUpdateFlag() const; + timespec getEventGeneratedTimestamp() const; + int getDroppedFFTFrames() const; protected: @@ -32,7 +42,6 @@ private: double* _imagDataTimeDomainPoints; uint64_t _numFFTDataPoints; uint64_t _numTimeDomainDataPoints; - double _timePerFFT; timespec _dataTimestamp; bool _repeatDataFlag; bool _lastOfMultipleUpdateFlag; diff --git a/gr-qtgui/src/lib/spectrumdisplayform.cc b/gr-qtgui/src/lib/spectrumdisplayform.cc Binary files differindex b27292193..e0509a294 100644 --- a/gr-qtgui/src/lib/spectrumdisplayform.cc +++ b/gr-qtgui/src/lib/spectrumdisplayform.cc diff --git a/gr-qtgui/src/lib/spectrumdisplayform.h b/gr-qtgui/src/lib/spectrumdisplayform.h index d89141f1e..fbd08349b 100644 --- a/gr-qtgui/src/lib/spectrumdisplayform.h +++ b/gr-qtgui/src/lib/spectrumdisplayform.h @@ -1,7 +1,7 @@ #ifndef SPECTRUM_DISPLAY_FORM_H #define SPECTRUM_DISPLAY_FORM_H -#include "spectrumdisplayform_ui.h" +#include "spectrumdisplayform.ui.h" class SpectrumGUIClass; #include <SpectrumGUIClass.h> @@ -9,10 +9,10 @@ class SpectrumGUIClass; #include <SpectrumGUIClass.h> #include <FrequencyDisplayPlot.h> #include <WaterfallDisplayPlot.h> -#include <Waterfall3DDisplayPlot.h> #include <TimeDomainDisplayPlot.h> #include <ConstellationDisplayPlot.h> #include <QValidator> +#include <QTimer> #include <vector> class SpectrumDisplayForm : public QWidget, public Ui::SpectrumDisplayForm @@ -43,7 +43,6 @@ public slots: void MaxHoldResetBtn_clicked(); void TabChanged(int index); - void PowerLineEdit_textChanged( const QString& valueString ); void SetFrequencyRange( const double newCenterFrequency, const double newStartFrequency, const double newStopFrequency ); @@ -54,15 +53,10 @@ public slots: void waterfallMinimumIntensityChangedCB(double); void WaterfallIntensityColorTypeChanged(int); void WaterfallAutoScaleBtnCB(); - void waterfall3DMaximumIntensityChangedCB(double); - void waterfall3DMinimumIntensityChangedCB(double); - void Waterfall3DIntensityColorTypeChanged(int); - void Waterfall3DAutoScaleBtnCB(); void FFTComboBoxSelectedCB(const QString&); void ToggleTabFrequency(const bool state); void ToggleTabWaterfall(const bool state); - void ToggleTabWaterfall3D(const bool state); void ToggleTabTime(const bool state); void ToggleTabConstellation(const bool state); @@ -71,9 +65,11 @@ public slots: double ymin, double ymax); void SetConstellationPenSize(int size); void SetFrequencyAxis(double min, double max); + void SetUpdateTime(double t); private slots: void newFrequencyData( const SpectrumUpdateEvent* ); + void UpdateGuiTimer(); protected: @@ -90,7 +86,6 @@ private: QIntValidator* _intValidator; FrequencyDisplayPlot* _frequencyDisplayPlot; WaterfallDisplayPlot* _waterfallDisplayPlot; - Waterfall3DDisplayPlot* _waterfall3DDisplayPlot; TimeDomainDisplayPlot* _timeDomainDisplayPlot; ConstellationDisplayPlot* _constellationDisplayPlot; SpectrumGUIClass* _system; @@ -111,6 +106,9 @@ private: int d_plot_waterfall3d; int d_plot_time; int d_plot_constellation; + + QTimer *displayTimer; + double d_update_time; }; #endif /* SPECTRUM_DISPLAY_FORM_H */ diff --git a/gr-qtgui/src/lib/spectrumdisplayform.ui b/gr-qtgui/src/lib/spectrumdisplayform.ui index cb7b4f996..5a23bc8a9 100644 --- a/gr-qtgui/src/lib/spectrumdisplayform.ui +++ b/gr-qtgui/src/lib/spectrumdisplayform.ui @@ -6,7 +6,7 @@ <rect> <x>0</x> <y>0</y> - <width>657</width> + <width>712</width> <height>543</height> </rect> </property> @@ -183,7 +183,7 @@ <property name="minimumSize"> <size> <width>400</width> - <height>332</height> + <height>350</height> </size> </property> <property name="sizeIncrement"> @@ -222,31 +222,6 @@ </property> </widget> </item> - <item row="1" column="3"> - <widget class="QLabel" name="PowerLabel"> - <property name="minimumSize"> - <size> - <width>50</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>50</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Power</string> - </property> - <property name="alignment"> - <set>Qt::AlignCenter</set> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - </widget> - </item> <item row="1" column="1"> <widget class="QPushButton" name="MaxHoldResetBtn"> <property name="sizePolicy"> @@ -266,7 +241,7 @@ </property> </widget> </item> - <item row="1" column="4"> + <item row="1" column="3"> <widget class="QLabel" name="AvgLabel"> <property name="sizePolicy"> <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> @@ -298,33 +273,8 @@ </property> </widget> </item> - <item row="2" column="4"> - <widget class="QSpinBox" name="AvgLineEdit"/> - </item> <item row="2" column="3"> - <widget class="QLineEdit" name="PowerLineEdit"> - <property name="sizePolicy"> - <sizepolicy hsizetype="Fixed" vsizetype="Fixed"> - <horstretch>0</horstretch> - <verstretch>0</verstretch> - </sizepolicy> - </property> - <property name="minimumSize"> - <size> - <width>50</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>50</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>1</string> - </property> - </widget> + <widget class="QSpinBox" name="AvgLineEdit"/> </item> <item row="1" column="2"> <spacer name="horizontalSpacer_2"> @@ -517,190 +467,6 @@ </item> </layout> </widget> - <widget class="QWidget" name="Waterfall3DPage"> - <attribute name="title"> - <string>3D Waterfall Display</string> - </attribute> - <layout class="QGridLayout" name="gridLayout_6"> - <item row="0" column="0"> - <widget class="QLabel" name="textLabel1_2"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>Intensity Display:</string> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QComboBox" name="Waterfall3DIntensityComboBox"> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <item> - <property name="text"> - <string>Color</string> - </property> - </item> - <item> - <property name="text"> - <string>White Hot</string> - </property> - </item> - <item> - <property name="text"> - <string>Black Hot</string> - </property> - </item> - <item> - <property name="text"> - <string>Incandescent</string> - </property> - </item> - <item> - <property name="text"> - <string>User Defined</string> - </property> - </item> - </widget> - </item> - <item row="0" column="2"> - <widget class="QwtWheel" name="Waterfall3DMaximumIntensityWheel"> - <property name="minimumSize"> - <size> - <width>200</width> - <height>0</height> - </size> - </property> - <property name="mouseTracking"> - <bool>true</bool> - </property> - <property name="focusPolicy"> - <enum>Qt::WheelFocus</enum> - </property> - <property name="valid"> - <bool>true</bool> - </property> - <property name="totalAngle"> - <double>200.000000000000000</double> - </property> - <property name="viewAngle"> - <double>20.000000000000000</double> - </property> - <property name="mass"> - <double>0.000000000000000</double> - </property> - </widget> - </item> - <item row="0" column="3"> - <widget class="QLabel" name="Waterfall3DMaximumIntensityLabel"> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>100 dB</string> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - </widget> - </item> - <item row="1" column="0" colspan="4"> - <widget class="QFrame" name="Waterfall3DPlotDisplayFrame"> - <property name="frameShape"> - <enum>QFrame::NoFrame</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Plain</enum> - </property> - </widget> - </item> - <item row="2" column="0" colspan="2"> - <widget class="QPushButton" name="Waterfall3DAutoScaleBtn"> - <property name="minimumSize"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="maximumSize"> - <size> - <width>80</width> - <height>16777215</height> - </size> - </property> - <property name="sizeIncrement"> - <size> - <width>0</width> - <height>0</height> - </size> - </property> - <property name="toolTip"> - <string>Scales the Intensity to the current data extremes.</string> - </property> - <property name="text"> - <string>Auto Scale</string> - </property> - </widget> - </item> - <item row="2" column="2"> - <widget class="QwtWheel" name="Waterfall3DMinimumIntensityWheel"> - <property name="minimumSize"> - <size> - <width>200</width> - <height>0</height> - </size> - </property> - <property name="valid"> - <bool>true</bool> - </property> - <property name="totalAngle"> - <double>200.000000000000000</double> - </property> - <property name="viewAngle"> - <double>20.000000000000000</double> - </property> - <property name="mass"> - <double>0.000000000000000</double> - </property> - </widget> - </item> - <item row="2" column="3"> - <widget class="QLabel" name="Waterfall3DMinimumIntensityLabel"> - <property name="maximumSize"> - <size> - <width>100</width> - <height>16777215</height> - </size> - </property> - <property name="text"> - <string>-100 dB</string> - </property> - <property name="wordWrap"> - <bool>false</bool> - </property> - </widget> - </item> - </layout> - </widget> <widget class="QWidget" name="TimeDomainPage"> <attribute name="title"> <string>Time Domain Display</string> @@ -771,7 +537,6 @@ <include location="global">SpectrumGUIClass.h</include> <include location="global">FrequencyDisplayPlot.h</include> <include location="global">WaterfallDisplayPlot.h</include> - <include location="global">Waterfall3DDisplayPlot.h</include> <include location="global">TimeDomainDisplayPlot.h</include> <include location="global">qvalidator.h</include> <include location="global">vector</include> @@ -844,22 +609,6 @@ </hints> </connection> <connection> - <sender>PowerLineEdit</sender> - <signal>textChanged(QString)</signal> - <receiver>SpectrumDisplayForm</receiver> - <slot>PowerLineEdit_textChanged(QString)</slot> - <hints> - <hint type="sourcelabel"> - <x>482</x> - <y>344</y> - </hint> - <hint type="destinationlabel"> - <x>20</x> - <y>20</y> - </hint> - </hints> - </connection> - <connection> <sender>WindowComboBox</sender> <signal>activated(int)</signal> <receiver>SpectrumDisplayForm</receiver> @@ -924,38 +673,6 @@ </hints> </connection> <connection> - <sender>Waterfall3DMaximumIntensityWheel</sender> - <signal>valueChanged(double)</signal> - <receiver>SpectrumDisplayForm</receiver> - <slot>waterfall3DMaximumIntensityChangedCB(double)</slot> - <hints> - <hint type="sourcelabel"> - <x>217</x> - <y>44</y> - </hint> - <hint type="destinationlabel"> - <x>20</x> - <y>20</y> - </hint> - </hints> - </connection> - <connection> - <sender>Waterfall3DMinimumIntensityWheel</sender> - <signal>valueChanged(double)</signal> - <receiver>SpectrumDisplayForm</receiver> - <slot>waterfall3DMinimumIntensityChangedCB(double)</slot> - <hints> - <hint type="sourcelabel"> - <x>217</x> - <y>349</y> - </hint> - <hint type="destinationlabel"> - <x>20</x> - <y>20</y> - </hint> - </hints> - </connection> - <connection> <sender>FFTSizeComboBox</sender> <signal>activated(QString)</signal> <receiver>SpectrumDisplayForm</receiver> diff --git a/gr-qtgui/src/lib/waterfallGlobalData.cc b/gr-qtgui/src/lib/waterfallGlobalData.cc index 0cbef4ec3..1ba153f0d 100644 --- a/gr-qtgui/src/lib/waterfallGlobalData.cc +++ b/gr-qtgui/src/lib/waterfallGlobalData.cc @@ -3,11 +3,13 @@ #include <waterfallGlobalData.h> -#include <Waterfall3DDisplayPlot.h> - -WaterfallData::WaterfallData(const double minimumFrequency, const double maximumFrequency, const uint64_t fftPoints, const unsigned int historyExtent): - QwtRasterData(QwtDoubleRect(minimumFrequency /* X START */, 0 /* Y START */, maximumFrequency - minimumFrequency /* WIDTH */, static_cast<double>(historyExtent)/* HEIGHT */)) - +WaterfallData::WaterfallData(const double minimumFrequency, + const double maximumFrequency, + const uint64_t fftPoints, + const unsigned int historyExtent) + : QwtRasterData(QwtDoubleRect(minimumFrequency /* X START */, 0 /* Y START */, + maximumFrequency - minimumFrequency /* WIDTH */, + static_cast<double>(historyExtent)/* HEIGHT */)) { _intensityRange = QwtDoubleInterval(-200.0, 0.0); @@ -19,17 +21,20 @@ WaterfallData::WaterfallData(const double minimumFrequency, const double maximum Reset(); } -WaterfallData::~WaterfallData(){ +WaterfallData::~WaterfallData() +{ delete[] _spectrumData; } -void WaterfallData::Reset(){ +void WaterfallData::Reset() +{ memset(_spectrumData, 0x0, _fftPoints*_historyLength*sizeof(double)); _numLinesToUpdate = -1; } -void WaterfallData::Copy(const WaterfallData* rhs){ +void WaterfallData::Copy(const WaterfallData* rhs) +{ if((_fftPoints != rhs->GetNumFFTPoints()) || (boundingRect() != rhs->boundingRect()) ){ _fftPoints = rhs->GetNumFFTPoints(); @@ -43,7 +48,10 @@ void WaterfallData::Copy(const WaterfallData* rhs){ setRange(rhs->range()); } -void WaterfallData::ResizeData(const double startFreq, const double stopFreq, const uint64_t fftPoints){ +void WaterfallData::ResizeData(const double startFreq, + const double stopFreq, + const uint64_t fftPoints) +{ if((fftPoints != GetNumFFTPoints()) || (boundingRect().width() != (stopFreq - startFreq)) || (boundingRect().left() != startFreq)){ @@ -57,21 +65,27 @@ void WaterfallData::ResizeData(const double startFreq, const double stopFreq, co Reset(); } -QwtRasterData *WaterfallData::copy() const{ - WaterfallData* returnData = new WaterfallData(boundingRect().left(), boundingRect().right(), _fftPoints, _historyLength); +QwtRasterData *WaterfallData::copy() const +{ + WaterfallData* returnData = new WaterfallData(boundingRect().left(), + boundingRect().right(), + _fftPoints, _historyLength); returnData->Copy(this); return returnData; } -QwtDoubleInterval WaterfallData::range() const{ +QwtDoubleInterval WaterfallData::range() const +{ return _intensityRange; } -void WaterfallData::setRange(const QwtDoubleInterval& newRange){ +void WaterfallData::setRange(const QwtDoubleInterval& newRange) +{ _intensityRange = newRange; } -double WaterfallData::value(double x, double y) const{ +double WaterfallData::value(double x, double y) const +{ double returnValue = 0.0; const unsigned int intY = static_cast<unsigned int>((1.0 - (y/boundingRect().height())) * @@ -87,11 +101,14 @@ double WaterfallData::value(double x, double y) const{ return returnValue; } -uint64_t WaterfallData::GetNumFFTPoints()const{ +uint64_t WaterfallData::GetNumFFTPoints() const +{ return _fftPoints; } -void WaterfallData::addFFTData(const double* fftData, const uint64_t fftDataSize, const int droppedFrames){ +void WaterfallData::addFFTData(const double* fftData, + const uint64_t fftDataSize, + const int droppedFrames){ if(fftDataSize == _fftPoints){ int64_t heightOffset = _historyLength - 1 - droppedFrames; uint64_t drawingDroppedFrames = droppedFrames; @@ -104,155 +121,44 @@ void WaterfallData::addFFTData(const double* fftData, const uint64_t fftDataSize // Copy the old data over if any available if(heightOffset > 0){ - memmove( _spectrumData, &_spectrumData[(drawingDroppedFrames+1) * _fftPoints], heightOffset * _fftPoints * sizeof(double)) ; + memmove( _spectrumData, &_spectrumData[(drawingDroppedFrames+1) * _fftPoints], + heightOffset * _fftPoints * sizeof(double)) ; } if(drawingDroppedFrames > 0){ // Fill in zeros data for dropped data - memset(&_spectrumData[heightOffset * _fftPoints], 0x00, static_cast<int64_t>(drawingDroppedFrames) * _fftPoints * sizeof(double)); + memset(&_spectrumData[heightOffset * _fftPoints], 0x00, + static_cast<int64_t>(drawingDroppedFrames) * _fftPoints * sizeof(double)); } // add the new buffer memcpy(&_spectrumData[(_historyLength - 1) * _fftPoints], fftData, _fftPoints*sizeof(double)); - } } -double* WaterfallData::GetSpectrumDataBuffer()const{ +double* WaterfallData::GetSpectrumDataBuffer() const +{ return _spectrumData; } -void WaterfallData::SetSpectrumDataBuffer(const double* newData){ +void WaterfallData::SetSpectrumDataBuffer(const double* newData) +{ memcpy(_spectrumData, newData, _fftPoints * _historyLength * sizeof(double)); } -int WaterfallData::GetNumLinesToUpdate()const{ +int WaterfallData::GetNumLinesToUpdate() const +{ return _numLinesToUpdate; } -void WaterfallData::SetNumLinesToUpdate(const int newNum){ +void WaterfallData::SetNumLinesToUpdate(const int newNum) +{ _numLinesToUpdate = newNum; } -void WaterfallData::IncrementNumLinesToUpdate(){ - _numLinesToUpdate++; -} - -Waterfall3DData::Waterfall3DData(const double minimumFrequency, const double maximumFrequency, const uint64_t fftPoints, const unsigned int historyExtent): - WaterfallData(minimumFrequency, maximumFrequency, fftPoints, historyExtent), Qwt3D::Function(){ - - _floorValue = 0.0; - setMinZ(0.0); - setMaxZ(200.0); - - // Create the dummy mesh data until _ResizeMesh is called - data = new double*[1]; - data[0] = new double[1]; - Qwt3D::Function::setMesh(1,1); - - _ResizeMesh(); -} - -Waterfall3DData::~Waterfall3DData(){ - for ( unsigned i = 0; i < umesh_p; i++){ - delete[] data[i]; - } - delete[] data; - -} - -void Waterfall3DData::ResizeData(const double startFreq, const double stopFreq, const uint64_t fftPoints){ - if((fftPoints != GetNumFFTPoints()) || - (boundingRect().width() != (stopFreq - startFreq)) || - (boundingRect().left() != startFreq)){ - WaterfallData::ResizeData(startFreq, stopFreq, fftPoints); - _ResizeMesh(); - } - - Reset(); -} - -bool Waterfall3DData::create() +void WaterfallData::IncrementNumLinesToUpdate() { - if ((umesh_p<=2) || (vmesh_p<=2) || !plotwidget_p) - return false; - - // Almost the same as the old create, except that here we store our own data buffer in the class rather than re-creating it each time... - - unsigned i,j; - - /* get the data */ - double dx = (maxu_p - minu_p) / (umesh_p - 1); - double dy = (maxv_p - minv_p) / (vmesh_p - 1); - - for (i = 0; i < umesh_p; ++i) - { - for (j = 0; j < vmesh_p; ++j) - { - data[i][j] = operator()(minu_p + i*dx, minv_p + j*dy); - - if (data[i][j] > range_p.maxVertex.z) - data[i][j] = range_p.maxVertex.z; - else if (data[i][j] < range_p.minVertex.z) - data[i][j] = range_p.minVertex.z; - } - } - - Q_ASSERT(plotwidget_p); - if (!plotwidget_p) - { - fprintf(stderr,"Function: no valid Plot3D Widget assigned"); - } - else - { - ((Waterfall3DDisplayPlot*)plotwidget_p)->loadFromData(data, umesh_p, vmesh_p, minu_p, maxu_p, minv_p, maxv_p); - } - - return true; -} - -double Waterfall3DData::operator()(double x, double y){ - return value(x,y) - _floorValue; -} - -double Waterfall3DData::GetFloorValue()const{ - return _floorValue; -} - -void Waterfall3DData::SetFloorValue(const double newValue){ - _floorValue = newValue; -} - -double Waterfall3DData::minZ()const{ - return range_p.minVertex.z; -} - -double Waterfall3DData::maxZ()const{ - return range_p.maxVertex.z; -} - -void Waterfall3DData::setMesh(unsigned int, unsigned int){ - // Do Nothing - printf("Should Not Reach this Function\n"); -} - -void Waterfall3DData::_ResizeMesh(){ - // Clear out the old mesh - for ( unsigned i = 0; i < umesh_p; i++){ - delete[] data[i]; - } - delete[] data; - - Qwt3D::Function::setMesh(static_cast<int>(boundingRect().width()/20.0), _historyLength); - setDomain( boundingRect().left(), static_cast<int>(boundingRect().right()), 0, _historyLength); - - /* allocate some space for the mesh */ - unsigned i; - data = new double* [umesh_p] ; - for ( i = 0; i < umesh_p; i++) - { - data[i] = new double [vmesh_p]; - } + _numLinesToUpdate++; } #endif /* WATERFALL_GLOBAL_DATA_CPP */ diff --git a/gr-qtgui/src/lib/waterfallGlobalData.h b/gr-qtgui/src/lib/waterfallGlobalData.h index 6e34ce5b1..51f65064c 100644 --- a/gr-qtgui/src/lib/waterfallGlobalData.h +++ b/gr-qtgui/src/lib/waterfallGlobalData.h @@ -2,9 +2,8 @@ #define WATERFALL_GLOBAL_DATA_HPP #include <qwt_raster_data.h> -#include <qwt3d_function.h> +#include <inttypes.h> -class Waterfall3DDisplayPlot; class WaterfallData: public QwtRasterData { @@ -45,34 +44,4 @@ private: }; -class Waterfall3DData: public WaterfallData, public Qwt3D::Function -{ -public: - Waterfall3DData(const double, const double, const uint64_t, const unsigned int); - virtual ~Waterfall3DData(); - - virtual void ResizeData(const double, const double, const uint64_t); - - virtual bool create(); - virtual void setMesh(unsigned int columns, unsigned int rows); //!< Sets number of rows and columns. - - virtual double operator()(double x, double y); - - virtual double GetFloorValue()const; - virtual void SetFloorValue(const double); - - virtual double minZ()const; - virtual double maxZ()const; - -protected: - void _ResizeMesh(); - - double** data; - double _floorValue; - -private: - -}; - - #endif /* WATERFALL_GLOBAL_DATA_HPP */ diff --git a/gr-qtgui/src/python/pyqt_example.py b/gr-qtgui/src/python/pyqt_example.py index 4fa8cdd92..7c0cfc698 100755 --- a/gr-qtgui/src/python/pyqt_example.py +++ b/gr-qtgui/src/python/pyqt_example.py @@ -131,9 +131,9 @@ class my_top_block(gr.top_block): # Wrap the pointer as a PyQt SIP object # This can now be manipulated as a PyQt4.QtGui.QWidget - pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) + self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) - self.main_box = dialog_box(pyWin, self.ctrl_win) + self.main_box = dialog_box(self.pyWin, self.ctrl_win) self.main_box.show() diff --git a/gr-qtgui/src/python/pyqt_example_f.py b/gr-qtgui/src/python/pyqt_example_f.py index 46fe07e0d..4e36ccca5 100755 --- a/gr-qtgui/src/python/pyqt_example_f.py +++ b/gr-qtgui/src/python/pyqt_example_f.py @@ -130,9 +130,9 @@ class my_top_block(gr.top_block): # Wrap the pointer as a PyQt SIP object # This can now be manipulated as a PyQt4.QtGui.QWidget - pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) + self.pyWin = sip.wrapinstance(pyQt, QtGui.QWidget) - self.main_box = dialog_box(pyWin, self.ctrl_win) + self.main_box = dialog_box(self.pyWin, self.ctrl_win) self.main_box.show() diff --git a/gr-qtgui/src/python/qt_digital.py b/gr-qtgui/src/python/qt_digital.py index ceb492c8d..679f144ef 100755 --- a/gr-qtgui/src/python/qt_digital.py +++ b/gr-qtgui/src/python/qt_digital.py @@ -139,7 +139,7 @@ class my_top_block(gr.top_block): self.qapp = QtGui.QApplication(sys.argv) - self._sample_rate = 200e3 + self._sample_rate = 2000e3 self.sps = 2 self.excess_bw = 0.35 @@ -182,11 +182,13 @@ class my_top_block(gr.top_block): self.to = 1.0 self.channel = gr.channel_model(noise, self.fo, self.to) - self.thr = gr.throttle(gr.sizeof_char, 10*fftsize) - self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, 1, + self.thr = gr.throttle(gr.sizeof_char, self._sample_rate) + self.snk_tx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, self._sample_rate*self.sps, "Tx", True, True, False, True, True) - self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, 0, 1, + self.snk_rx = qtgui.sink_c(fftsize, gr.firdes.WIN_BLACKMAN_hARRIS, + 0, self._sample_rate, "Rx", True, True, False, True, True) self.connect(self.src, self.thr, self.mod, self.channel, self.snk_tx) diff --git a/gr-qtgui/src/python/qt_digital_window.py b/gr-qtgui/src/python/qt_digital_window.py index 9e4c57a89..50dd53a92 100644 --- a/gr-qtgui/src/python/qt_digital_window.py +++ b/gr-qtgui/src/python/qt_digital_window.py @@ -2,8 +2,8 @@ # Form implementation generated from reading ui file 'qt_digital_window.ui' # -# Created: Thu Jun 18 07:57:58 2009 -# by: PyQt4 UI code generator 4.4.3 +# Created: Sat May 1 20:14:02 2010 +# by: PyQt4 UI code generator 4.6.1 # # WARNING! All changes made in this file will be lost! @@ -12,73 +12,118 @@ from PyQt4 import QtCore, QtGui class Ui_DigitalWindow(object): def setupUi(self, DigitalWindow): DigitalWindow.setObjectName("DigitalWindow") - DigitalWindow.resize(1236, 739) + DigitalWindow.resize(1236, 741) self.centralwidget = QtGui.QWidget(DigitalWindow) self.centralwidget.setObjectName("centralwidget") - self.closeButton = QtGui.QPushButton(self.centralwidget) - self.closeButton.setGeometry(QtCore.QRect(1120, 650, 101, 31)) - self.closeButton.setObjectName("closeButton") + self.verticalLayout = QtGui.QVBoxLayout(self.centralwidget) + self.verticalLayout.setObjectName("verticalLayout") self.sinkFrame = QtGui.QFrame(self.centralwidget) - self.sinkFrame.setGeometry(QtCore.QRect(10, 10, 1221, 501)) + self.sinkFrame.setMinimumSize(QtCore.QSize(0, 550)) self.sinkFrame.setFrameShape(QtGui.QFrame.StyledPanel) self.sinkFrame.setFrameShadow(QtGui.QFrame.Raised) self.sinkFrame.setObjectName("sinkFrame") - self.horizontalLayoutWidget = QtGui.QWidget(self.sinkFrame) - self.horizontalLayoutWidget.setGeometry(QtCore.QRect(10, 10, 1201, 481)) - self.horizontalLayoutWidget.setObjectName("horizontalLayoutWidget") - self.sinkLayout = QtGui.QHBoxLayout(self.horizontalLayoutWidget) + self.horizontalLayout_2 = QtGui.QHBoxLayout(self.sinkFrame) + self.horizontalLayout_2.setObjectName("horizontalLayout_2") + self.sinkLayout = QtGui.QHBoxLayout() self.sinkLayout.setObjectName("sinkLayout") - self.channelModeBox = QtGui.QGroupBox(self.centralwidget) - self.channelModeBox.setGeometry(QtCore.QRect(290, 520, 291, 161)) - self.channelModeBox.setObjectName("channelModeBox") - self.timeLabel = QtGui.QLabel(self.channelModeBox) - self.timeLabel.setGeometry(QtCore.QRect(10, 90, 101, 17)) - self.timeLabel.setObjectName("timeLabel") - self.timeEdit = QtGui.QLineEdit(self.channelModeBox) - self.timeEdit.setGeometry(QtCore.QRect(160, 90, 113, 23)) - self.timeEdit.setObjectName("timeEdit") - self.snrEdit = QtGui.QLineEdit(self.channelModeBox) - self.snrEdit.setGeometry(QtCore.QRect(160, 30, 113, 23)) - self.snrEdit.setObjectName("snrEdit") - self.snrLabel = QtGui.QLabel(self.channelModeBox) - self.snrLabel.setGeometry(QtCore.QRect(10, 30, 111, 20)) - self.snrLabel.setObjectName("snrLabel") - self.freqEdit = QtGui.QLineEdit(self.channelModeBox) - self.freqEdit.setGeometry(QtCore.QRect(160, 60, 113, 23)) - self.freqEdit.setObjectName("freqEdit") - self.freqLabel = QtGui.QLabel(self.channelModeBox) - self.freqLabel.setGeometry(QtCore.QRect(10, 60, 141, 17)) - self.freqLabel.setObjectName("freqLabel") - self.rxBox = QtGui.QGroupBox(self.centralwidget) - self.rxBox.setGeometry(QtCore.QRect(590, 520, 251, 161)) - self.rxBox.setObjectName("rxBox") - self.gainMuEdit = QtGui.QLineEdit(self.rxBox) - self.gainMuEdit.setGeometry(QtCore.QRect(120, 30, 113, 23)) - self.gainMuEdit.setObjectName("gainMuEdit") - self.gainMuLabel = QtGui.QLabel(self.rxBox) - self.gainMuLabel.setGeometry(QtCore.QRect(10, 30, 111, 20)) - self.gainMuLabel.setObjectName("gainMuLabel") - self.alphaEdit = QtGui.QLineEdit(self.rxBox) - self.alphaEdit.setGeometry(QtCore.QRect(120, 60, 113, 23)) - self.alphaEdit.setObjectName("alphaEdit") - self.alphaLabel = QtGui.QLabel(self.rxBox) - self.alphaLabel.setGeometry(QtCore.QRect(10, 60, 111, 20)) - self.alphaLabel.setObjectName("alphaLabel") + self.horizontalLayout_2.addLayout(self.sinkLayout) + self.verticalLayout.addWidget(self.sinkFrame) + self.horizontalLayout = QtGui.QHBoxLayout() + self.horizontalLayout.setObjectName("horizontalLayout") self.sysBox = QtGui.QGroupBox(self.centralwidget) - self.sysBox.setGeometry(QtCore.QRect(20, 520, 261, 161)) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Minimum) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.sysBox.sizePolicy().hasHeightForWidth()) + self.sysBox.setSizePolicy(sizePolicy) + self.sysBox.setMinimumSize(QtCore.QSize(0, 0)) + self.sysBox.setMaximumSize(QtCore.QSize(16777215, 120)) + self.sysBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) self.sysBox.setObjectName("sysBox") + self.gridLayout_2 = QtGui.QGridLayout(self.sysBox) + self.gridLayout_2.setObjectName("gridLayout_2") self.sampleRateEdit = QtGui.QLineEdit(self.sysBox) - self.sampleRateEdit.setGeometry(QtCore.QRect(140, 30, 113, 23)) + self.sampleRateEdit.setMaximumSize(QtCore.QSize(100, 16777215)) self.sampleRateEdit.setObjectName("sampleRateEdit") + self.gridLayout_2.addWidget(self.sampleRateEdit, 0, 3, 1, 1) self.sampleRateLabel = QtGui.QLabel(self.sysBox) - self.sampleRateLabel.setGeometry(QtCore.QRect(10, 30, 121, 20)) self.sampleRateLabel.setObjectName("sampleRateLabel") + self.gridLayout_2.addWidget(self.sampleRateLabel, 0, 2, 1, 1) + self.horizontalLayout.addWidget(self.sysBox) + self.rxBox = QtGui.QGroupBox(self.centralwidget) + self.rxBox.setMaximumSize(QtCore.QSize(16777215, 120)) + self.rxBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.rxBox.setObjectName("rxBox") + self.gridLayout_3 = QtGui.QGridLayout(self.rxBox) + self.gridLayout_3.setObjectName("gridLayout_3") + self.alphaLabel = QtGui.QLabel(self.rxBox) + self.alphaLabel.setObjectName("alphaLabel") + self.gridLayout_3.addWidget(self.alphaLabel, 1, 0, 1, 1) + self.alphaEdit = QtGui.QLineEdit(self.rxBox) + self.alphaEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.alphaEdit.setObjectName("alphaEdit") + self.gridLayout_3.addWidget(self.alphaEdit, 1, 1, 1, 1) + self.gainMuLabel = QtGui.QLabel(self.rxBox) + self.gainMuLabel.setObjectName("gainMuLabel") + self.gridLayout_3.addWidget(self.gainMuLabel, 0, 0, 1, 1) + self.gainMuEdit = QtGui.QLineEdit(self.rxBox) + self.gainMuEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.gainMuEdit.setObjectName("gainMuEdit") + self.gridLayout_3.addWidget(self.gainMuEdit, 0, 1, 1, 1) + self.horizontalLayout.addWidget(self.rxBox) + self.channelModeBox = QtGui.QGroupBox(self.centralwidget) + self.channelModeBox.setMaximumSize(QtCore.QSize(16777215, 120)) + self.channelModeBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) + self.channelModeBox.setObjectName("channelModeBox") + self.gridLayout = QtGui.QGridLayout(self.channelModeBox) + self.gridLayout.setSizeConstraint(QtGui.QLayout.SetMinimumSize) + self.gridLayout.setObjectName("gridLayout") + self.snrLabel = QtGui.QLabel(self.channelModeBox) + self.snrLabel.setObjectName("snrLabel") + self.gridLayout.addWidget(self.snrLabel, 0, 1, 1, 1) + self.snrEdit = QtGui.QLineEdit(self.channelModeBox) + self.snrEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.snrEdit.setObjectName("snrEdit") + self.gridLayout.addWidget(self.snrEdit, 0, 2, 1, 1) + self.freqLabel = QtGui.QLabel(self.channelModeBox) + self.freqLabel.setObjectName("freqLabel") + self.gridLayout.addWidget(self.freqLabel, 1, 1, 1, 1) + self.freqEdit = QtGui.QLineEdit(self.channelModeBox) + self.freqEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.freqEdit.setObjectName("freqEdit") + self.gridLayout.addWidget(self.freqEdit, 1, 2, 1, 1) + self.timeLabel = QtGui.QLabel(self.channelModeBox) + self.timeLabel.setObjectName("timeLabel") + self.gridLayout.addWidget(self.timeLabel, 2, 1, 1, 1) + self.timeEdit = QtGui.QLineEdit(self.channelModeBox) + self.timeEdit.setMaximumSize(QtCore.QSize(100, 16777215)) + self.timeEdit.setObjectName("timeEdit") + self.gridLayout.addWidget(self.timeEdit, 2, 2, 1, 1) + self.horizontalLayout.addWidget(self.channelModeBox) + spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum) + self.horizontalLayout.addItem(spacerItem) + self.verticalLayout_2 = QtGui.QVBoxLayout() + self.verticalLayout_2.setObjectName("verticalLayout_2") + spacerItem1 = QtGui.QSpacerItem(20, 40, QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Expanding) + self.verticalLayout_2.addItem(spacerItem1) self.pauseButton = QtGui.QPushButton(self.centralwidget) - self.pauseButton.setGeometry(QtCore.QRect(1120, 520, 101, 31)) + sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum, QtGui.QSizePolicy.Fixed) + sizePolicy.setHorizontalStretch(0) + sizePolicy.setVerticalStretch(0) + sizePolicy.setHeightForWidth(self.pauseButton.sizePolicy().hasHeightForWidth()) + self.pauseButton.setSizePolicy(sizePolicy) + self.pauseButton.setMaximumSize(QtCore.QSize(80, 16777215)) self.pauseButton.setObjectName("pauseButton") + self.verticalLayout_2.addWidget(self.pauseButton) + self.closeButton = QtGui.QPushButton(self.centralwidget) + self.closeButton.setMaximumSize(QtCore.QSize(80, 16777215)) + self.closeButton.setObjectName("closeButton") + self.verticalLayout_2.addWidget(self.closeButton) + self.horizontalLayout.addLayout(self.verticalLayout_2) + self.verticalLayout.addLayout(self.horizontalLayout) DigitalWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(DigitalWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 1236, 25)) + self.menubar.setGeometry(QtCore.QRect(0, 0, 1236, 23)) self.menubar.setObjectName("menubar") self.menuFile = QtGui.QMenu(self.menubar) self.menuFile.setObjectName("menuFile") @@ -95,23 +140,22 @@ class Ui_DigitalWindow(object): QtCore.QObject.connect(self.closeButton, QtCore.SIGNAL("clicked()"), DigitalWindow.close) QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL("triggered()"), DigitalWindow.close) QtCore.QMetaObject.connectSlotsByName(DigitalWindow) - DigitalWindow.setTabOrder(self.closeButton, self.snrEdit) DigitalWindow.setTabOrder(self.snrEdit, self.freqEdit) DigitalWindow.setTabOrder(self.freqEdit, self.timeEdit) def retranslateUi(self, DigitalWindow): DigitalWindow.setWindowTitle(QtGui.QApplication.translate("DigitalWindow", "MainWindow", None, QtGui.QApplication.UnicodeUTF8)) - self.closeButton.setText(QtGui.QApplication.translate("DigitalWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) + self.sysBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "System Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.sampleRateLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Sample Rate (sps)", None, QtGui.QApplication.UnicodeUTF8)) + self.rxBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8)) + self.alphaLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Alpha", None, QtGui.QApplication.UnicodeUTF8)) + self.gainMuLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Gain mu", None, QtGui.QApplication.UnicodeUTF8)) self.channelModeBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Channel Model Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.timeLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Timing Offset", None, QtGui.QApplication.UnicodeUTF8)) self.snrLabel.setText(QtGui.QApplication.translate("DigitalWindow", "SNR (dB)", None, QtGui.QApplication.UnicodeUTF8)) self.freqLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Frequency Offset (Hz)", None, QtGui.QApplication.UnicodeUTF8)) - self.rxBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "Receiver Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.gainMuLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Gain mu", None, QtGui.QApplication.UnicodeUTF8)) - self.alphaLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Alpha", None, QtGui.QApplication.UnicodeUTF8)) - self.sysBox.setTitle(QtGui.QApplication.translate("DigitalWindow", "System Parameters", None, QtGui.QApplication.UnicodeUTF8)) - self.sampleRateLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Sample Rate (sps)", None, QtGui.QApplication.UnicodeUTF8)) + self.timeLabel.setText(QtGui.QApplication.translate("DigitalWindow", "Timing Offset", None, QtGui.QApplication.UnicodeUTF8)) self.pauseButton.setText(QtGui.QApplication.translate("DigitalWindow", "Pause", None, QtGui.QApplication.UnicodeUTF8)) + self.closeButton.setText(QtGui.QApplication.translate("DigitalWindow", "Close", None, QtGui.QApplication.UnicodeUTF8)) self.menuFile.setTitle(QtGui.QApplication.translate("DigitalWindow", "&File", None, QtGui.QApplication.UnicodeUTF8)) self.actionExit.setText(QtGui.QApplication.translate("DigitalWindow", "E&xit", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/gr-qtgui/src/python/qt_digital_window.ui b/gr-qtgui/src/python/qt_digital_window.ui index 79ba01286..967252181 100644 --- a/gr-qtgui/src/python/qt_digital_window.ui +++ b/gr-qtgui/src/python/qt_digital_window.ui @@ -7,243 +7,273 @@ <x>0</x> <y>0</y> <width>1236</width> - <height>739</height> + <height>741</height> </rect> </property> <property name="windowTitle"> <string>MainWindow</string> </property> <widget class="QWidget" name="centralwidget"> - <widget class="QPushButton" name="closeButton"> - <property name="geometry"> - <rect> - <x>1120</x> - <y>650</y> - <width>101</width> - <height>31</height> - </rect> - </property> - <property name="text"> - <string>Close</string> - </property> - </widget> - <widget class="QFrame" name="sinkFrame"> - <property name="geometry"> - <rect> - <x>10</x> - <y>10</y> - <width>1221</width> - <height>501</height> - </rect> - </property> - <property name="frameShape"> - <enum>QFrame::StyledPanel</enum> - </property> - <property name="frameShadow"> - <enum>QFrame::Raised</enum> - </property> - <widget class="QWidget" name="horizontalLayoutWidget"> - <property name="geometry"> - <rect> - <x>10</x> - <y>10</y> - <width>1201</width> - <height>481</height> - </rect> - </property> - <layout class="QHBoxLayout" name="sinkLayout"/> - </widget> - </widget> - <widget class="QGroupBox" name="channelModeBox"> - <property name="geometry"> - <rect> - <x>290</x> - <y>520</y> - <width>291</width> - <height>161</height> - </rect> - </property> - <property name="title"> - <string>Channel Model Parameters</string> - </property> - <widget class="QLabel" name="timeLabel"> - <property name="geometry"> - <rect> - <x>10</x> - <y>90</y> - <width>101</width> - <height>17</height> - </rect> - </property> - <property name="text"> - <string>Timing Offset</string> - </property> - </widget> - <widget class="QLineEdit" name="timeEdit"> - <property name="geometry"> - <rect> - <x>160</x> - <y>90</y> - <width>113</width> - <height>23</height> - </rect> - </property> - </widget> - <widget class="QLineEdit" name="snrEdit"> - <property name="geometry"> - <rect> - <x>160</x> - <y>30</y> - <width>113</width> - <height>23</height> - </rect> - </property> - </widget> - <widget class="QLabel" name="snrLabel"> - <property name="geometry"> - <rect> - <x>10</x> - <y>30</y> - <width>111</width> - <height>20</height> - </rect> - </property> - <property name="text"> - <string>SNR (dB)</string> - </property> - </widget> - <widget class="QLineEdit" name="freqEdit"> - <property name="geometry"> - <rect> - <x>160</x> - <y>60</y> - <width>113</width> - <height>23</height> - </rect> - </property> - </widget> - <widget class="QLabel" name="freqLabel"> - <property name="geometry"> - <rect> - <x>10</x> - <y>60</y> - <width>141</width> - <height>17</height> - </rect> - </property> - <property name="text"> - <string>Frequency Offset (Hz)</string> - </property> - </widget> - </widget> - <widget class="QGroupBox" name="rxBox"> - <property name="geometry"> - <rect> - <x>590</x> - <y>520</y> - <width>251</width> - <height>161</height> - </rect> - </property> - <property name="title"> - <string>Receiver Parameters</string> - </property> - <widget class="QLineEdit" name="gainMuEdit"> - <property name="geometry"> - <rect> - <x>120</x> - <y>30</y> - <width>113</width> - <height>23</height> - </rect> - </property> - </widget> - <widget class="QLabel" name="gainMuLabel"> - <property name="geometry"> - <rect> - <x>10</x> - <y>30</y> - <width>111</width> - <height>20</height> - </rect> - </property> - <property name="text"> - <string>Gain mu</string> - </property> - </widget> - <widget class="QLineEdit" name="alphaEdit"> - <property name="geometry"> - <rect> - <x>120</x> - <y>60</y> - <width>113</width> - <height>23</height> - </rect> - </property> - </widget> - <widget class="QLabel" name="alphaLabel"> - <property name="geometry"> - <rect> - <x>10</x> - <y>60</y> - <width>111</width> - <height>20</height> - </rect> - </property> - <property name="text"> - <string>Alpha</string> - </property> - </widget> - </widget> - <widget class="QGroupBox" name="sysBox"> - <property name="geometry"> - <rect> - <x>20</x> - <y>520</y> - <width>261</width> - <height>161</height> - </rect> - </property> - <property name="title"> - <string>System Parameters</string> - </property> - <widget class="QLineEdit" name="sampleRateEdit"> - <property name="geometry"> - <rect> - <x>140</x> - <y>30</y> - <width>113</width> - <height>23</height> - </rect> - </property> - </widget> - <widget class="QLabel" name="sampleRateLabel"> - <property name="geometry"> - <rect> - <x>10</x> - <y>30</y> - <width>121</width> - <height>20</height> - </rect> - </property> - <property name="text"> - <string>Sample Rate (sps)</string> - </property> - </widget> - </widget> - <widget class="QPushButton" name="pauseButton"> - <property name="geometry"> - <rect> - <x>1120</x> - <y>520</y> - <width>101</width> - <height>31</height> - </rect> - </property> - <property name="text"> - <string>Pause</string> - </property> - </widget> + <layout class="QVBoxLayout" name="verticalLayout"> + <item> + <widget class="QFrame" name="sinkFrame"> + <property name="minimumSize"> + <size> + <width>0</width> + <height>550</height> + </size> + </property> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <layout class="QHBoxLayout" name="sinkLayout"/> + </item> + </layout> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QGroupBox" name="sysBox"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Minimum"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>120</height> + </size> + </property> + <property name="title"> + <string>System Parameters</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <layout class="QGridLayout" name="gridLayout_2"> + <item row="0" column="3"> + <widget class="QLineEdit" name="sampleRateEdit"> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLabel" name="sampleRateLabel"> + <property name="text"> + <string>Sample Rate (sps)</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="rxBox"> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>120</height> + </size> + </property> + <property name="title"> + <string>Receiver Parameters</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <layout class="QGridLayout" name="gridLayout_3"> + <item row="1" column="0"> + <widget class="QLabel" name="alphaLabel"> + <property name="text"> + <string>Alpha</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLineEdit" name="alphaEdit"> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item row="0" column="0"> + <widget class="QLabel" name="gainMuLabel"> + <property name="text"> + <string>Gain mu</string> + </property> + </widget> + </item> + <item row="0" column="1"> + <widget class="QLineEdit" name="gainMuEdit"> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="channelModeBox"> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>120</height> + </size> + </property> + <property name="title"> + <string>Channel Model Parameters</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <layout class="QGridLayout" name="gridLayout"> + <property name="sizeConstraint"> + <enum>QLayout::SetMinimumSize</enum> + </property> + <item row="0" column="1"> + <widget class="QLabel" name="snrLabel"> + <property name="text"> + <string>SNR (dB)</string> + </property> + </widget> + </item> + <item row="0" column="2"> + <widget class="QLineEdit" name="snrEdit"> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="QLabel" name="freqLabel"> + <property name="text"> + <string>Frequency Offset (Hz)</string> + </property> + </widget> + </item> + <item row="1" column="2"> + <widget class="QLineEdit" name="freqEdit"> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + <item row="2" column="1"> + <widget class="QLabel" name="timeLabel"> + <property name="text"> + <string>Timing Offset</string> + </property> + </widget> + </item> + <item row="2" column="2"> + <widget class="QLineEdit" name="timeEdit"> + <property name="maximumSize"> + <size> + <width>100</width> + <height>16777215</height> + </size> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <spacer name="horizontalSpacer"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + <item> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="pauseButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Pause</string> + </property> + </widget> + </item> + <item> + <widget class="QPushButton" name="closeButton"> + <property name="maximumSize"> + <size> + <width>80</width> + <height>16777215</height> + </size> + </property> + <property name="text"> + <string>Close</string> + </property> + </widget> + </item> + </layout> + </item> + </layout> + </item> + </layout> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> @@ -251,7 +281,7 @@ <x>0</x> <y>0</y> <width>1236</width> - <height>25</height> + <height>23</height> </rect> </property> <widget class="QMenu" name="menuFile"> @@ -270,7 +300,6 @@ </action> </widget> <tabstops> - <tabstop>closeButton</tabstop> <tabstop>snrEdit</tabstop> <tabstop>freqEdit</tabstop> <tabstop>timeEdit</tabstop> diff --git a/gr-qtgui/src/python/usrp2_display.py b/gr-qtgui/src/python/usrp2_display.py index 46ebfe94a..75d374c2b 100755 --- a/gr-qtgui/src/python/usrp2_display.py +++ b/gr-qtgui/src/python/usrp2_display.py @@ -171,9 +171,9 @@ class my_top_block(gr.top_block): help="select Ethernet interface, default is eth0") parser.add_option("-m", "--mac-addr", type="string", default="", help="select USRP by MAC address, default is auto-select") - parser.add_option("-W", "--bw", type="float", default=1e6, + parser.add_option("-W", "--bw", type="eng_float", default=1e6, help="set bandwidth of receiver [default=%default]") - parser.add_option("-f", "--freq", type="eng_float", default=None, + parser.add_option("-f", "--freq", type="eng_float", default=2412e6, help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=None, help="set gain in dB (default is midpoint)") diff --git a/gr-radio-astronomy/src/python/qa_ra.py b/gr-radio-astronomy/src/python/qa_ra.py index 1c44e23ad..2cb0f42be 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/gnuradio-trellis.pc.in b/gr-trellis/gnuradio-trellis.pc.in index 8c320b563..618667c42 100644 --- a/gr-trellis/gnuradio-trellis.pc.in +++ b/gr-trellis/gnuradio-trellis.pc.in @@ -3,9 +3,9 @@ exec_prefix=@exec_prefix@ libdir=@libdir@ includedir=@includedir@ -Name: gnuradio-comedi -Description: GNU Radio blocks for the comedi library +Name: gnuradio-trellis +Description: GNU Radio blocks for trellis coded modulation Requires: gnuradio-core -Version: @VERSION@ -Libs: -L${libdir} -lgnuradio-comedi +Version: @LIBVER@ +Libs: -L${libdir} -lgnuradio-trellis Cflags: -I${includedir} diff --git a/gr-trellis/src/lib/Makefile.am b/gr-trellis/src/lib/Makefile.am index 58115de25..3e1803554 100644 --- a/gr-trellis/src/lib/Makefile.am +++ b/gr-trellis/src/lib/Makefile.am @@ -82,10 +82,7 @@ libgnuradio_trellis_la_SOURCES = \ libgnuradio_trellis_la_LIBADD = \ $(GNURADIO_CORE_LA) -libgnuradio_trellis_la_LDFLAGS = \ - $(NO_UNDEFINED) - - +libgnuradio_trellis_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) if PYTHON diff --git a/gr-trellis/src/lib/trellis_encoder_XX.cc.t b/gr-trellis/src/lib/trellis_encoder_XX.cc.t index 1985fa46a..698a0b307 100644 --- a/gr-trellis/src/lib/trellis_encoder_XX.cc.t +++ b/gr-trellis/src/lib/trellis_encoder_XX.cc.t @@ -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 * @@ -33,7 +33,7 @@ @SPTR_NAME@ trellis_make_@BASE_NAME@ (const fsm &FSM, int ST) { - return @SPTR_NAME@ (new @NAME@ (FSM,ST)); + return gnuradio::get_initial_sptr (new @NAME@ (FSM,ST)); } @NAME@::@NAME@ (const fsm &FSM, int ST) diff --git a/gr-trellis/src/lib/trellis_metrics_X.cc.t b/gr-trellis/src/lib/trellis_metrics_X.cc.t index bced13c0c..4bdaabc22 100644 --- a/gr-trellis/src/lib/trellis_metrics_X.cc.t +++ b/gr-trellis/src/lib/trellis_metrics_X.cc.t @@ -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 * @@ -36,7 +36,7 @@ @SPTR_NAME@ trellis_make_@BASE_NAME@ (int O, int D, const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE) { - return @SPTR_NAME@ (new @NAME@ (O,D,TABLE,TYPE)); + return gnuradio::get_initial_sptr (new @NAME@ (O,D,TABLE,TYPE)); } diff --git a/gr-trellis/src/lib/trellis_permutation.cc b/gr-trellis/src/lib/trellis_permutation.cc index c80d820cd..a32390742 100644 --- a/gr-trellis/src/lib/trellis_permutation.cc +++ b/gr-trellis/src/lib/trellis_permutation.cc @@ -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 * @@ -32,7 +32,7 @@ trellis_permutation_sptr trellis_make_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t NBYTES_INOUT) { - return trellis_permutation_sptr (new trellis_permutation (K,TABLE,SYMS_PER_BLOCK,NBYTES_INOUT)); + return gnuradio::get_initial_sptr(new trellis_permutation (K,TABLE,SYMS_PER_BLOCK,NBYTES_INOUT)); } trellis_permutation::trellis_permutation (int K, const std::vector<int> &TABLE, int SYMS_PER_BLOCK, size_t NBYTES_INOUT) diff --git a/gr-trellis/src/lib/trellis_siso_combined_f.cc b/gr-trellis/src/lib/trellis_siso_combined_f.cc index c8181d109..708608b16 100644 --- a/gr-trellis/src/lib/trellis_siso_combined_f.cc +++ b/gr-trellis/src/lib/trellis_siso_combined_f.cc @@ -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 * @@ -45,7 +45,7 @@ trellis_make_siso_combined_f ( const std::vector<float> &TABLE, trellis_metric_type_t TYPE) { - return trellis_siso_combined_f_sptr (new trellis_siso_combined_f (FSM,K,S0,SK,POSTI,POSTO,SISO_TYPE,D,TABLE,TYPE)); + return gnuradio::get_initial_sptr(new trellis_siso_combined_f (FSM,K,S0,SK,POSTI,POSTO,SISO_TYPE,D,TABLE,TYPE)); } trellis_siso_combined_f::trellis_siso_combined_f ( diff --git a/gr-trellis/src/lib/trellis_siso_f.cc b/gr-trellis/src/lib/trellis_siso_f.cc index ed9ebed61..c8fa8231d 100644 --- a/gr-trellis/src/lib/trellis_siso_f.cc +++ b/gr-trellis/src/lib/trellis_siso_f.cc @@ -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 * @@ -42,7 +42,7 @@ trellis_make_siso_f ( bool POSTO, trellis_siso_type_t SISO_TYPE) { - return trellis_siso_f_sptr (new trellis_siso_f (FSM,K,S0,SK,POSTI,POSTO,SISO_TYPE)); + return gnuradio::get_initial_sptr(new trellis_siso_f (FSM,K,S0,SK,POSTI,POSTO,SISO_TYPE)); } trellis_siso_f::trellis_siso_f ( diff --git a/gr-trellis/src/lib/trellis_viterbi_X.cc.t b/gr-trellis/src/lib/trellis_viterbi_X.cc.t index d2ecfacff..178215362 100644 --- a/gr-trellis/src/lib/trellis_viterbi_X.cc.t +++ b/gr-trellis/src/lib/trellis_viterbi_X.cc.t @@ -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 * @@ -40,7 +40,7 @@ trellis_make_@BASE_NAME@ ( int S0, int SK) { - return @SPTR_NAME@ (new @NAME@ (FSM,K,S0,SK)); + return gnuradio::get_initial_sptr (new @NAME@ (FSM,K,S0,SK)); } @NAME@::@NAME@ ( diff --git a/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t b/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t index e343a4965..d365de75f 100644 --- a/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t +++ b/gr-trellis/src/lib/trellis_viterbi_combined_XX.cc.t @@ -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 * @@ -43,7 +43,7 @@ trellis_make_@BASE_NAME@ ( const std::vector<@I_TYPE@> &TABLE, trellis_metric_type_t TYPE) { - return @SPTR_NAME@ (new @NAME@ (FSM,K,S0,SK,D,TABLE,TYPE)); + return gnuradio::get_initial_sptr (new @NAME@ (FSM,K,S0,SK,D,TABLE,TYPE)); } @NAME@::@NAME@ ( diff --git a/gr-trellis/src/python/qa_trellis.py b/gr-trellis/src/python/qa_trellis.py index 306bf994d..cfeefea06 100755 --- a/gr-trellis/src/python/qa_trellis.py +++ b/gr-trellis/src/python/qa_trellis.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 trellis -class qa_trellis (gr_unittest.TestCase): +class test_trellis (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -68,11 +68,5 @@ class qa_trellis (gr_unittest.TestCase): i = trellis.interleaver(K,IN) self.assertEqual((K,IN,DIN),(i.K(),i.INTER(),i.DEINTER())) - - - - - - if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_trellis, "test_trellis.xml") diff --git a/gr-usrp/gnuradio-usrp.pc.in b/gr-usrp/gnuradio-usrp.pc.in index 6c1d75d43..b1f33f41b 100644 --- a/gr-usrp/gnuradio-usrp.pc.in +++ b/gr-usrp/gnuradio-usrp.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@/gnuradio Name: gnuradio-usrp Description: GNU Software Radio support for Universal Software Radio Peripheral Requires: gnuradio-core usrp -Version: @VERSION@ +Version: @LIBVER@ Libs: -L${libdir} -lgnuradio-usrp Cflags: -I${includedir} diff --git a/gr-usrp/src/Makefile.am b/gr-usrp/src/Makefile.am index 3d1cc1754..572a22485 100644 --- a/gr-usrp/src/Makefile.am +++ b/gr-usrp/src/Makefile.am @@ -56,7 +56,7 @@ libgnuradio_usrp_la_LIBADD = \ $(GNURADIO_CORE_LA) \ $(USRP_LA) -libgnuradio_usrp_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 +libgnuradio_usrp_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) grinclude_HEADERS = \ usrp_base.h \ diff --git a/gr-usrp/src/qa_usrp.py b/gr-usrp/src/qa_usrp.py index db2d32624..06e630330 100755 --- a/gr-usrp/src/qa_usrp.py +++ b/gr-usrp/src/qa_usrp.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 usrp_swig -class qa_usrp (gr_unittest.TestCase): +class test_usrp (gr_unittest.TestCase): def setUp (self): self.tb = gr.top_block () @@ -37,4 +37,4 @@ class qa_usrp (gr_unittest.TestCase): pass if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_usrp, "test_usrp.xml") diff --git a/gr-usrp/src/usrp_sink_c.cc b/gr-usrp/src/usrp_sink_c.cc index 40750b477..7054158d8 100644 --- a/gr-usrp/src/usrp_sink_c.cc +++ b/gr-usrp/src/usrp_sink_c.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006,2009 Free Software Foundation, Inc. + * Copyright 2004,2006,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -40,7 +40,7 @@ usrp_make_sink_c (int which_board, const std::string firmware_filename ) throw (std::runtime_error) { - return usrp_sink_c_sptr (new usrp_sink_c (which_board, + return gnuradio::get_initial_sptr(new usrp_sink_c (which_board, interp_rate, nchan, mux, diff --git a/gr-usrp/src/usrp_sink_s.cc b/gr-usrp/src/usrp_sink_s.cc index 1f51da24d..1ffaeed96 100644 --- a/gr-usrp/src/usrp_sink_s.cc +++ b/gr-usrp/src/usrp_sink_s.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006,2009 Free Software Foundation, Inc. + * Copyright 2004,2006,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -40,7 +40,7 @@ usrp_make_sink_s (int which_board, const std::string firmware_filename ) throw (std::runtime_error) { - return usrp_sink_s_sptr (new usrp_sink_s (which_board, + return gnuradio::get_initial_sptr(new usrp_sink_s (which_board, interp_rate, nchan, mux, diff --git a/gr-usrp/src/usrp_source_c.cc b/gr-usrp/src/usrp_source_c.cc index 26d95dc1b..9055f3ee7 100644 --- a/gr-usrp/src/usrp_source_c.cc +++ b/gr-usrp/src/usrp_source_c.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006,2009 Free Software Foundation, Inc. + * Copyright 2004,2006,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -43,7 +43,7 @@ usrp_make_source_c (int which_board, const std::string firmware_filename ) throw (std::runtime_error) { - return usrp_source_c_sptr (new usrp_source_c (which_board, + return gnuradio::get_initial_sptr(new usrp_source_c (which_board, decim_rate, nchan, mux, diff --git a/gr-usrp/src/usrp_source_s.cc b/gr-usrp/src/usrp_source_s.cc index 88b8495d3..8e1c2f188 100644 --- a/gr-usrp/src/usrp_source_s.cc +++ b/gr-usrp/src/usrp_source_s.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2006,2009 Free Software Foundation, Inc. + * Copyright 2004,2006,2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -43,7 +43,7 @@ usrp_make_source_s (int which_board, const std::string firmware_filename ) throw (std::runtime_error) { - return usrp_source_s_sptr (new usrp_source_s (which_board, + return gnuradio::get_initial_sptr(new usrp_source_s (which_board, decim_rate, nchan, mux, diff --git a/gr-usrp2/gnuradio-usrp2.pc.in b/gr-usrp2/gnuradio-usrp2.pc.in index 403e5f1c9..2222badd7 100644 --- a/gr-usrp2/gnuradio-usrp2.pc.in +++ b/gr-usrp2/gnuradio-usrp2.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@/gnuradio Name: gnuradio-usrp2 Description: GNU Software Radio support for Universal Software Radio Peripheral 2 Requires: gnuradio-core usrp2 -Version: @VERSION@ +Version: @LIBVER@ Libs: -L${libdir} -lgnuradio-usrp2 Cflags: -I${includedir} diff --git a/gr-usrp2/src/Makefile.am b/gr-usrp2/src/Makefile.am index 8425c497c..03b6d0dd9 100644 --- a/gr-usrp2/src/Makefile.am +++ b/gr-usrp2/src/Makefile.am @@ -50,6 +50,8 @@ AM_CPPFLAGS = \ lib_LTLIBRARIES = libgnuradio-usrp2.la +libgnuradio_usrp2_la_LDFLAGS = $(LTVERSIONFLAGS) + libgnuradio_usrp2_la_SOURCES = \ rx_16sc_handler.cc \ rx_32fc_handler.cc \ diff --git a/gr-usrp2/src/qa_usrp2.py b/gr-usrp2/src/qa_usrp2.py index bc6664a1b..cc994b1e9 100755 --- a/gr-usrp2/src/qa_usrp2.py +++ b/gr-usrp2/src/qa_usrp2.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 # @@ -23,7 +23,7 @@ from gnuradio import gr, gr_unittest import usrp2 -class qa_usrp2(gr_unittest.TestCase): +class test_usrp2(gr_unittest.TestCase): def setUp(self): self.tb = gr.top_block() @@ -37,4 +37,4 @@ class qa_usrp2(gr_unittest.TestCase): pass if __name__ == '__main__': - gr_unittest.main () + gr_unittest.run(test_usrp2, "test_usrp2.xml") diff --git a/gr-usrp2/src/usrp2.i b/gr-usrp2/src/usrp2.i index d1fa091f7..2a79fad44 100644 --- a/gr-usrp2/src/usrp2.i +++ b/gr-usrp2/src/usrp2.i @@ -32,6 +32,7 @@ %include <usrp2/tune_result.h> %include <usrp2/mimo_config.h> +%include <usrp2/metadata.h> %template(uint32_t_vector) std::vector<uint32_t>; @@ -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 1e7c54dcd..75cc1f4a6 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 b1e28a829..fa75b3805 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 ce473f236..c9b34a54a 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 38dc4f236..d831d4df6 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-utils/src/python/create-gnuradio-out-of-tree-project b/gr-utils/src/python/create-gnuradio-out-of-tree-project index 1f512b219..d5e32c92b 100755 --- a/gr-utils/src/python/create-gnuradio-out-of-tree-project +++ b/gr-utils/src/python/create-gnuradio-out-of-tree-project @@ -52,8 +52,8 @@ def main(): # rename file contents upper_module_name = module_name.upper() - sed_cmd = 'sed -i -e "s/howto/%s/g" -e "s/HOWTO/%s/g"' % (module_name, - upper_module_name) + sed_cmd = 'sed -i -e "s/howto-write-a-block/%s/g" -e "s/howto/%s/g" -e "s/HOWTO/%s/g"' % (module_name, module_name, \ + upper_module_name) os.system('find . -type f -print0 | xargs -0 ' + sed_cmd) sys.stdout.write(""" diff --git a/gr-video-sdl/gnuradio-video-sdl.pc.in b/gr-video-sdl/gnuradio-video-sdl.pc.in index 9a8fe7d5e..8586a2884 100644 --- a/gr-video-sdl/gnuradio-video-sdl.pc.in +++ b/gr-video-sdl/gnuradio-video-sdl.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: gnuradio-comedi Description: GNU Radio blocks for the SDL library Requires: gnuradio-core sdl -Version: @VERSION@ +Version: @LIBVER@ Libs: -L${libdir} -lgnuradio-video-sdl Cflags: -I${includedir} diff --git a/gr-video-sdl/src/Makefile.am b/gr-video-sdl/src/Makefile.am index e623eb2a9..45cedfb21 100644 --- a/gr-video-sdl/src/Makefile.am +++ b/gr-video-sdl/src/Makefile.am @@ -43,8 +43,7 @@ libgnuradio_video_sdl_la_LIBADD = \ $(SDL_LIBS) \ $(GNURADIO_CORE_LA) -libgnuradio_video_sdl_la_LDFLAGS = \ - $(NO_UNDEFINED) +libgnuradio_video_sdl_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) if PYTHON ################################# diff --git a/gr-video-sdl/src/qa_video_sdl.py b/gr-video-sdl/src/qa_video_sdl.py index 98da85f6b..8f82a60b1 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-video-sdl/src/video_sdl_sink_s.cc b/gr-video-sdl/src/video_sdl_sink_s.cc index 825cd80cb..2be3ff072 100644 --- a/gr-video-sdl/src/video_sdl_sink_s.cc +++ b/gr-video-sdl/src/video_sdl_sink_s.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -118,7 +118,7 @@ video_sdl_sink_s::~video_sdl_sink_s () video_sdl_sink_s_sptr video_sdl_make_sink_s (double framerate,int width, int height,unsigned int format,int dst_width,int dst_height) { - return video_sdl_sink_s_sptr (new video_sdl_sink_s (framerate, width, height,format,dst_width,dst_height)); + return gnuradio::get_initial_sptr(new video_sdl_sink_s (framerate, width, height,format,dst_width,dst_height)); } void diff --git a/gr-video-sdl/src/video_sdl_sink_uc.cc b/gr-video-sdl/src/video_sdl_sink_uc.cc index 2d25399a8..58e4830e4 100644 --- a/gr-video-sdl/src/video_sdl_sink_uc.cc +++ b/gr-video-sdl/src/video_sdl_sink_uc.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2006 Free Software Foundation, Inc. + * Copyright 2006,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -118,7 +118,7 @@ video_sdl_sink_uc::~video_sdl_sink_uc () video_sdl_sink_uc_sptr video_sdl_make_sink_uc (double framerate,int width, int height,unsigned int format,int dst_width,int dst_height) { - return video_sdl_sink_uc_sptr (new video_sdl_sink_uc (framerate, width, height,format,dst_width,dst_height)); + return gnuradio::get_initial_sptr(new video_sdl_sink_uc (framerate, width, height,format,dst_width,dst_height)); } void diff --git a/gr-wxgui/gr-wxgui.pc.in b/gr-wxgui/gr-wxgui.pc.in index a3e352f0f..f71389789 100644 --- a/gr-wxgui/gr-wxgui.pc.in +++ b/gr-wxgui/gr-wxgui.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: gr-wxgui Description: A simple wx gui for GNU Radio applications Requires: gnuradio-core -Version: @VERSION@ +Version: @LIBVER@ Libs: Cflags: diff --git a/gr-wxgui/src/python/common.py b/gr-wxgui/src/python/common.py index 17a7dc0de..3641ae644 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 825f71c32..9612f36dd 100644 --- a/gr-wxgui/src/python/constants.py +++ b/gr-wxgui/src/python/constants.py @@ -1,5 +1,5 @@ # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -27,6 +27,8 @@ ALPHA_KEY = 'alpha' AUTORANGE_KEY = 'autorange' AVERAGE_KEY = 'average' AVG_ALPHA_KEY = 'avg_alpha' +USE_PERSISTENCE_KEY = 'use_persistence' +PERSIST_ALPHA_KEY = 'persist_alpha' BASEBAND_FREQ_KEY = 'baseband_freq' BETA_KEY = 'beta' COLOR_MODE_KEY = 'color_mode' diff --git a/gr-wxgui/src/python/fft_window.py b/gr-wxgui/src/python/fft_window.py index 4ee5520f7..f4f485f4b 100644 --- a/gr-wxgui/src/python/fft_window.py +++ b/gr-wxgui/src/python/fft_window.py @@ -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 # @@ -37,6 +37,7 @@ import forms ################################################## SLIDER_STEPS = 100 AVG_ALPHA_MIN_EXP, AVG_ALPHA_MAX_EXP = -3, 0 +PERSIST_ALPHA_MIN_EXP, PERSIST_ALPHA_MAX_EXP = -2, 0 DEFAULT_WIN_SIZE = (600, 300) DEFAULT_FRAME_RATE = gr.prefs().get_long('wxgui', 'fft_rate', 30) DB_DIV_MIN, DB_DIV_MAX = 1, 20 @@ -97,7 +98,38 @@ class control_panel(wx.Panel): for widget in (avg_alpha_text, avg_alpha_slider): parent.subscribe(AVERAGE_KEY, widget.Enable) widget.Enable(parent[AVERAGE_KEY]) + parent.subscribe(AVERAGE_KEY, widget.ShowItems) + #allways show initially, so room is reserved for them + widget.ShowItems(True) # (parent[AVERAGE_KEY]) + + parent.subscribe(AVERAGE_KEY, self._update_layout) + + forms.check_box( + sizer=options_box, parent=self, label='Persistence', + ps=parent, key=USE_PERSISTENCE_KEY, + ) + #static text and slider for persist alpha + persist_alpha_text = forms.static_text( + sizer=options_box, parent=self, label='Persist Alpha', + converter=forms.float_converter(lambda x: '%.4f'%x), + ps=parent, key=PERSIST_ALPHA_KEY, width=50, + ) + persist_alpha_slider = forms.log_slider( + sizer=options_box, parent=self, + min_exp=PERSIST_ALPHA_MIN_EXP, + max_exp=PERSIST_ALPHA_MAX_EXP, + num_steps=SLIDER_STEPS, + ps=parent, key=PERSIST_ALPHA_KEY, + ) + for widget in (persist_alpha_text, persist_alpha_slider): + parent.subscribe(USE_PERSISTENCE_KEY, widget.Enable) + widget.Enable(parent[USE_PERSISTENCE_KEY]) + parent.subscribe(USE_PERSISTENCE_KEY, widget.ShowItems) + #allways show initially, so room is reserved for them + widget.ShowItems(True) # (parent[USE_PERSISTENCE_KEY]) + parent.subscribe(USE_PERSISTENCE_KEY, self._update_layout) + #trace menu for trace in TRACES: trace_box = wx.BoxSizer(wx.HORIZONTAL) @@ -144,6 +176,7 @@ class control_panel(wx.Panel): ) #set sizer self.SetSizerAndFit(control_box) + #mouse wheel event def on_mouse_wheel(event): if event.GetWheelRotation() < 0: self._on_incr_ref_level(event) @@ -161,6 +194,14 @@ class control_panel(wx.Panel): self.parent[Y_PER_DIV_KEY] = min(DB_DIV_MAX, common.get_clean_incr(self.parent[Y_PER_DIV_KEY])) def _on_decr_db_div(self, event): self.parent[Y_PER_DIV_KEY] = max(DB_DIV_MIN, common.get_clean_decr(self.parent[Y_PER_DIV_KEY])) + ################################################## + # subscriber handlers + ################################################## + def _update_layout(self,key): + # Just ignore the key value we get + # we only need to now that the visability or size of something has changed + self.parent.Layout() + #self.parent.Fit() ################################################## # FFT window with plotter and control panel @@ -183,7 +224,10 @@ class fft_window(wx.Panel, pubsub.pubsub): avg_alpha_key, peak_hold, msg_key, + use_persistence, + persist_alpha, ): + pubsub.pubsub.__init__(self) #setup self.samples = EMPTY_TRACE @@ -204,6 +248,8 @@ class fft_window(wx.Panel, pubsub.pubsub): self[REF_LEVEL_KEY] = ref_level self[BASEBAND_FREQ_KEY] = baseband_freq self[RUNNING_KEY] = True + self[USE_PERSISTENCE_KEY] = use_persistence + self[PERSIST_ALPHA_KEY] = persist_alpha for trace in TRACES: #a function that returns a function #so the function wont use local trace @@ -232,6 +278,8 @@ class fft_window(wx.Panel, pubsub.pubsub): self.plotter.enable_legend(True) self.plotter.enable_point_label(True) self.plotter.enable_grid_lines(True) + self.plotter.set_use_persistence(use_persistence) + self.plotter.set_persist_alpha(persist_alpha) #setup the box with plot and controls self.control_panel = control_panel(self) main_box = wx.BoxSizer(wx.HORIZONTAL) @@ -247,9 +295,12 @@ class fft_window(wx.Panel, pubsub.pubsub): Y_PER_DIV_KEY, X_DIVS_KEY, Y_DIVS_KEY, REF_LEVEL_KEY, ): self.subscribe(key, self.update_grid) + self.subscribe(USE_PERSISTENCE_KEY, self.plotter.set_use_persistence) + self.subscribe(PERSIST_ALPHA_KEY, self.plotter.set_persist_alpha) #initial update self.update_grid() + def autoscale(self, *args): """ Autoscale the fft plot to the last frame. diff --git a/gr-wxgui/src/python/fftsink_gl.py b/gr-wxgui/src/python/fftsink_gl.py index 8ddea9a8e..6cfaeff60 100644 --- a/gr-wxgui/src/python/fftsink_gl.py +++ b/gr-wxgui/src/python/fftsink_gl.py @@ -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 # @@ -19,6 +19,8 @@ # Boston, MA 02110-1301, USA. # +from __future__ import division + ################################################## # Imports ################################################## @@ -27,6 +29,7 @@ import common from gnuradio import gr, blks2 from pubsub import pubsub from constants import * +import math ################################################## # FFT sink block (wrapper for old wxgui) @@ -53,10 +56,21 @@ class _fft_sink_base(gr.hier_block2, common.wxgui_hb): size=fft_window.DEFAULT_WIN_SIZE, peak_hold=False, win=None, + use_persistence=False, + persist_alpha=None, **kwargs #do not end with a comma ): #ensure avg alpha if avg_alpha is None: avg_alpha = 2.0/fft_rate + #ensure analog alpha + if persist_alpha is None: + actual_fft_rate=float(sample_rate/fft_size)/float(max(1,int(float((sample_rate/fft_size)/fft_rate)))) + #print "requested_fft_rate ",fft_rate + #print "actual_fft_rate ",actual_fft_rate + analog_cutoff_freq=0.5 # Hertz + #calculate alpha from wanted cutoff freq + persist_alpha = 1.0 - math.exp(-2.0*math.pi*analog_cutoff_freq/actual_fft_rate) + #init gr.hier_block2.__init__( self, @@ -76,6 +90,8 @@ class _fft_sink_base(gr.hier_block2, common.wxgui_hb): ) msgq = gr.msg_queue(2) sink = gr.message_sink(gr.sizeof_float*fft_size, msgq, True) + + #controller self.controller = pubsub() self.controller.subscribe(AVERAGE_KEY, fft.set_average) @@ -103,6 +119,8 @@ class _fft_sink_base(gr.hier_block2, common.wxgui_hb): avg_alpha_key=AVG_ALPHA_KEY, peak_hold=peak_hold, msg_key=MSG_KEY, + use_persistence=use_persistence, + persist_alpha=persist_alpha, ) common.register_access_methods(self, self.win) setattr(self.win, 'set_baseband_freq', getattr(self, 'set_baseband_freq')) #BACKWARDS @@ -134,11 +152,14 @@ class test_app_block (stdgui2.std_top_block): fft_size = 256 # build our flow graph - input_rate = 20.48e3 + input_rate = 2048.0e3 + + #Generate some noise + noise =gr.noise_source_c(gr.GR_UNIFORM, 1.0/10) # Generate a complex sinusoid #src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 2e3, 1) - src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1) + src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 57.50e3, 1) # We add these throttle blocks so that this demo doesn't # suck down all the CPU available. Normally you wouldn't use these. @@ -149,17 +170,25 @@ class test_app_block (stdgui2.std_top_block): ref_level=0, y_per_div=20, y_divs=10) vbox.Add (sink1.win, 1, wx.EXPAND) - self.connect(src1, thr1, sink1) + combine1=gr.add_cc() + self.connect(src1, (combine1,0)) + self.connect(noise,(combine1,1)) + self.connect(combine1,thr1, sink1) #src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 2e3, 1) - src2 = gr.sig_source_f (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1) + src2 = gr.sig_source_f (input_rate, gr.GR_CONST_WAVE, 57.50e3, 1) thr2 = gr.throttle(gr.sizeof_float, input_rate) sink2 = fft_sink_f (panel, title="Real Data", fft_size=fft_size*2, sample_rate=input_rate, baseband_freq=100e3, ref_level=0, y_per_div=20, y_divs=10) vbox.Add (sink2.win, 1, wx.EXPAND) - self.connect(src2, thr2, sink2) + combine2=gr.add_ff() + c2f2=gr.complex_to_float() + + self.connect(src2, (combine2,0)) + self.connect(noise,c2f2,(combine2,1)) + self.connect(combine2, thr2,sink2) def main (): app = stdgui2.stdapp (test_app_block, "FFT Sink Test App") diff --git a/gr-wxgui/src/python/fftsink_nongl.py b/gr-wxgui/src/python/fftsink_nongl.py index 937eb27cc..508b4e772 100644 --- a/gr-wxgui/src/python/fftsink_nongl.py +++ b/gr-wxgui/src/python/fftsink_nongl.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2003,2004,2005,2006,2007,2009 Free Software Foundation, Inc. +# Copyright 2003,2004,2005,2006,2007,2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -37,7 +37,7 @@ class fft_sink_base(object): y_divs=8, ref_level=50, sample_rate=1, fft_size=512, fft_rate=default_fft_rate, - average=False, avg_alpha=None, title='', peak_hold=False): + average=False, avg_alpha=None, title='', peak_hold=False,use_persistence=False,persist_alpha=0.2): # initialize common attributes self.baseband_freq = baseband_freq @@ -52,6 +52,9 @@ class fft_sink_base(object): self.avg_alpha = 2.0 / fft_rate else: self.avg_alpha = avg_alpha + self.use_persistence = use_persistence + self.persist_alpha = persist_alpha + self.title = title self.peak_hold = peak_hold self.input_is_real = input_is_real @@ -75,6 +78,14 @@ class fft_sink_base(object): self.peak_hold = enable self.win.set_peak_hold(enable) + def set_use_persistence(self, enable): + self.use_persistence = enable + self.win.set_use_persistence(enable) + + def set_persist_alpha(self, persist_alpha): + self.persist_alpha = persist_alpha + self.win.set_persist_alpha(persist_alpha) + def set_avg_alpha(self, avg_alpha): self.avg_alpha = avg_alpha @@ -93,7 +104,7 @@ class fft_sink_f(gr.hier_block2, fft_sink_base): def __init__(self, parent, baseband_freq=0, ref_scale=2.0, y_per_div=10, y_divs=8, ref_level=50, sample_rate=1, fft_size=512, fft_rate=default_fft_rate, average=False, avg_alpha=None, - title='', size=default_fftsink_size, peak_hold=False, **kwargs): + title='', size=default_fftsink_size, peak_hold=False, use_persistence=False,persist_alpha=0.2, **kwargs): gr.hier_block2.__init__(self, "fft_sink_f", gr.io_signature(1, 1, gr.sizeof_float), @@ -104,7 +115,7 @@ class fft_sink_f(gr.hier_block2, fft_sink_base): sample_rate=sample_rate, fft_size=fft_size, fft_rate=fft_rate, average=average, avg_alpha=avg_alpha, title=title, - peak_hold=peak_hold) + peak_hold=peak_hold,use_persistence=use_persistence,persist_alpha=persist_alpha) self.s2p = gr.stream_to_vector(gr.sizeof_float, self.fft_size) self.one_in_n = gr.keep_one_in_n(gr.sizeof_float * self.fft_size, @@ -131,12 +142,14 @@ class fft_sink_f(gr.hier_block2, fft_sink_base): self.win = fft_window(self, parent, size=size) self.set_average(self.average) self.set_peak_hold(self.peak_hold) + self.set_use_persistence(self.use_persistence) + self.set_persist_alpha(self.persist_alpha) class fft_sink_c(gr.hier_block2, fft_sink_base): def __init__(self, parent, baseband_freq=0, ref_scale=2.0, y_per_div=10, y_divs=8, ref_level=50, sample_rate=1, fft_size=512, fft_rate=default_fft_rate, average=False, avg_alpha=None, - title='', size=default_fftsink_size, peak_hold=False, **kwargs): + title='', size=default_fftsink_size, peak_hold=False, use_persistence=False,persist_alpha=0.2, **kwargs): gr.hier_block2.__init__(self, "fft_sink_c", gr.io_signature(1, 1, gr.sizeof_gr_complex), @@ -147,7 +160,7 @@ class fft_sink_c(gr.hier_block2, fft_sink_base): sample_rate=sample_rate, fft_size=fft_size, fft_rate=fft_rate, average=average, avg_alpha=avg_alpha, title=title, - peak_hold=peak_hold) + peak_hold=peak_hold, use_persistence=use_persistence,persist_alpha=persist_alpha) self.s2p = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) self.one_in_n = gr.keep_one_in_n(gr.sizeof_gr_complex * self.fft_size, @@ -173,6 +186,8 @@ class fft_sink_c(gr.hier_block2, fft_sink_base): self.win = fft_window(self, parent, size=size) self.set_average(self.average) + self.set_use_persistence(self.use_persistence) + self.set_persist_alpha(self.persist_alpha) self.set_peak_hold(self.peak_hold) @@ -236,6 +251,9 @@ class control_panel(wx.Panel): self.average_check_box = wx.CheckBox(parent=self, style=wx.CHK_2STATE, label="Average") self.average_check_box.Bind(wx.EVT_CHECKBOX, parent.on_average) control_box.Add(self.average_check_box, 0, wx.EXPAND) + self.use_persistence_check_box = wx.CheckBox(parent=self, style=wx.CHK_2STATE, label="Persistence") + self.use_persistence_check_box.Bind(wx.EVT_CHECKBOX, parent.on_use_persistence) + control_box.Add(self.use_persistence_check_box, 0, wx.EXPAND) self.peak_hold_check_box = wx.CheckBox(parent=self, style=wx.CHK_2STATE, label="Peak Hold") self.peak_hold_check_box.Bind(wx.EVT_CHECKBOX, parent.on_peak_hold) control_box.Add(self.peak_hold_check_box, 0, wx.EXPAND) @@ -276,6 +294,7 @@ class control_panel(wx.Panel): """ #update checkboxes self.average_check_box.SetValue(self.parent.fftsink.average) + self.use_persistence_check_box.SetValue(self.parent.fftsink.use_persistence) self.peak_hold_check_box.SetValue(self.parent.fftsink.peak_hold) #update radio buttons try: @@ -306,6 +325,10 @@ class fft_window (wx.Panel): self.peak_hold = False self.peak_vals = None + + self.use_persistence=False + self.persist_alpha=0.2 + self.plot.SetEnableGrid (True) # self.SetEnableZoom (True) @@ -394,6 +417,14 @@ class fft_window (wx.Panel): y_range = ymin, ymax self.plot.Draw (graphics, xAxis=x_range, yAxis=y_range, step=self.fftsink.y_per_div) + def set_use_persistence(self, enable): + self.use_persistence = enable + self.plot.set_use_persistence( enable) + + def set_persist_alpha(self, persist_alpha): + self.persist_alpha = persist_alpha + self.plot.set_persist_alpha(persist_alpha) + def set_peak_hold(self, enable): self.peak_hold = enable self.peak_vals = None @@ -403,6 +434,11 @@ class fft_window (wx.Panel): self.fftsink.set_average(evt.IsChecked()) self.control_panel.update() + def on_use_persistence(self, evt): + # print "on_analog" + self.fftsink.set_use_persistence(evt.IsChecked()) + self.control_panel.update() + def on_peak_hold(self, evt): # print "on_peak_hold" self.fftsink.set_peak_hold(evt.IsChecked()) @@ -486,9 +522,11 @@ class fft_window (wx.Panel): self.id_y_per_div_10 = wx.NewId() self.id_y_per_div_20 = wx.NewId() self.id_average = wx.NewId() + self.id_use_persistence = wx.NewId() self.id_peak_hold = wx.NewId() self.plot.Bind(wx.EVT_MENU, self.on_average, id=self.id_average) + self.plot.Bind(wx.EVT_MENU, self.on_use_persistence, id=self.id_use_persistence) self.plot.Bind(wx.EVT_MENU, self.on_peak_hold, id=self.id_peak_hold) self.plot.Bind(wx.EVT_MENU, self.on_incr_ref_level, id=self.id_incr_ref_level) self.plot.Bind(wx.EVT_MENU, self.on_decr_ref_level, id=self.id_decr_ref_level) @@ -504,6 +542,7 @@ class fft_window (wx.Panel): menu = wx.Menu() self.popup_menu = menu menu.AppendCheckItem(self.id_average, "Average") + menu.AppendCheckItem(self.id_use_persistence, "Persistence") menu.AppendCheckItem(self.id_peak_hold, "Peak Hold") menu.Append(self.id_incr_ref_level, "Incr Ref Level") menu.Append(self.id_decr_ref_level, "Decr Ref Level") @@ -519,6 +558,7 @@ class fft_window (wx.Panel): self.checkmarks = { self.id_average : lambda : self.fftsink.average, + self.id_use_persistence : lambda : self.fftsink.use_persistence, self.id_peak_hold : lambda : self.fftsink.peak_hold, self.id_y_per_div_1 : lambda : self.fftsink.y_per_div == 1, self.id_y_per_div_2 : lambda : self.fftsink.y_per_div == 2, @@ -561,11 +601,11 @@ class test_app_block (stdgui2.std_top_block): fft_size = 256 # build our flow graph - input_rate = 20.48e3 + input_rate = 100*20.48e3 # Generate a complex sinusoid - #src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 2e3, 1) - src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1) + #src1 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 100*2e3, 1) + src1 = gr.sig_source_c (input_rate, gr.GR_CONST_WAVE, 100*5.75e3, 1) # We add these throttle blocks so that this demo doesn't # suck down all the CPU available. Normally you wouldn't use these. @@ -578,8 +618,8 @@ class test_app_block (stdgui2.std_top_block): self.connect(src1, thr1, sink1) - #src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 2e3, 1) - src2 = gr.sig_source_f (input_rate, gr.GR_CONST_WAVE, 5.75e3, 1) + #src2 = gr.sig_source_f (input_rate, gr.GR_SIN_WAVE, 100*2e3, 1) + src2 = gr.sig_source_f (input_rate, gr.GR_CONST_WAVE, 100*5.75e3, 1) thr2 = gr.throttle(gr.sizeof_float, input_rate) sink2 = fft_sink_f (panel, title="Real Data", fft_size=fft_size*2, sample_rate=input_rate, baseband_freq=100e3, diff --git a/gr-wxgui/src/python/plot.py b/gr-wxgui/src/python/plot.py index c104b0ea5..e0bc4ca60 100644 --- a/gr-wxgui/src/python/plot.py +++ b/gr-wxgui/src/python/plot.py @@ -6,7 +6,7 @@ # # Created: 2003/11/03 # RCS-ID: $Id$ -# Copyright: (c) 2002,2007 +# Copyright: (c) 2002,2007,2010 # Licence: Use as you wish. #----------------------------------------------------------------------------- # 12/15/2003 - Jeff Grimmett (grimmtooth@softhome.net) @@ -36,6 +36,9 @@ # # May 27, 2007 Johnathan Corgan (jcorgan@corganenterprises.com) # - Converted from numarray to numpy +# +# Apr 23, 2010 Martin Dudok van Heel (http://www.olifantasia.com/gnuradio/contact_olifantasia.gif) +# - Added Persistence option (emulate after glow of an analog CRT display using IIR) """ This is a simple light weight plotting module that can be used with @@ -422,6 +425,11 @@ class PlotCanvas(wx.Window): def __init__(self, parent, id = -1, pos=wx.DefaultPosition, size=wx.DefaultSize, style= wx.DEFAULT_FRAME_STYLE, name= ""): + + self.use_persistence=False + self.alpha=0.3 + self.decimation=10 + self.decim_counter=0 """Constucts a window, which can be a child of a frame, dialog or any other non-control window""" @@ -488,6 +496,14 @@ class PlotCanvas(wx.Window): # platforms at initialization, but little harm done. self.OnSize(None) # sets the initial size based on client size # UNCONDITIONAL, needed to create self._Buffer + + + def set_use_persistence(self, enable): + self.use_persistence = enable + + def set_persist_alpha(self, persist_alpha): + self.alpha = persist_alpha + # SaveFile def SaveFile(self, fileName= ''): @@ -791,12 +807,19 @@ class PlotCanvas(wx.Window): if dc == None: # sets new dc and clears it - dc = wx.BufferedDC(wx.ClientDC(self), self._Buffer) - dc.Clear() - + if self.use_persistence: + dc = wx.MemoryDC() + dc.SelectObject(self._Buffer) + dc.Clear() + else: + dc = wx.BufferedDC(wx.ClientDC(self), self._Buffer) + dc.Clear() + dc.BeginDrawing() # dc.Clear() - + + + # set font size for every thing but title and legend dc.SetFont(self._getFont(self._fontSizeAxis)) @@ -818,6 +841,15 @@ class PlotCanvas(wx.Window): self.last_draw = (graphics, xAxis, yAxis) # saves most recient values + if False: + ptx,pty,rectWidth,rectHeight= self._point2ClientCoord(p1, p2) + #dc.SetPen(wx.Pen(wx.BLACK)) + dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) ) #wx.SOLID wx.TRANSPARENT ) ) + #dc.SetLogicalFunction(wx.INVERT) #wx.XOR wx.INVERT + dc.DrawRectangle( ptx,pty, rectWidth,rectHeight) + #dc.SetBrush(wx.Brush( wx.WHITE, wx.SOLID ) ) + #dc.SetLogicalFunction(wx.COPY) + # Get ticks and textExtents for axis if required if self._xSpec is not 'none': if self._xUseScopeTicks: @@ -874,8 +906,11 @@ class PlotCanvas(wx.Window): scale = (self.plotbox_size-textSize_scale) / (p2-p1)* _numpy.array((1,-1)) shift = -p1*scale + self.plotbox_origin + textSize_shift * _numpy.array((1,-1)) self._pointScale= scale # make available for mouse events - self._pointShift= shift + self._pointShift= shift + + #dc.SetLogicalFunction(wx.INVERT) #wx.XOR wx.INVERT self._drawAxes(dc, p1, p2, scale, shift, xticks, yticks) + #dc.SetLogicalFunction(wx.COPY) graphics.scaleAndShift(scale, shift) graphics.setPrinterScale(self.printerScale) # thicken up lines and markers if printing @@ -885,11 +920,44 @@ class PlotCanvas(wx.Window): dc.SetClippingRegion(ptx,pty,rectWidth,rectHeight) # Draw the lines and markers #start = _time.clock() + graphics.draw(dc) # print "entire graphics drawing took: %f second"%(_time.clock() - start) # remove the clipping region dc.DestroyClippingRegion() dc.EndDrawing() + + + if self.use_persistence: + dc=None + self._Buffer.CopyToBuffer(self._Bufferarray) #, format=wx.BitmapBufferFormat_RGB, stride=-1) + ## do the IIR filter + alpha_int=int(float(self.alpha*256)) + if True: + _numpy.add(self._Bufferarray,0,self._Buffer3array) + _numpy.multiply(self._Buffer3array,alpha_int,self._Buffer3array) + _numpy.multiply(self._Buffer2array,(256-alpha_int),self._Buffer2array) + _numpy.add(self._Buffer3array,self._Buffer2array,self._Buffer2array) + _numpy.right_shift(self._Buffer2array,8,self._Buffer2array) + elif False: + self._Buffer2array=(self._Bufferarray.astype(_numpy.uint32) *alpha_int + self._Buffer2array*(256-alpha_int)).__rshift__(8) + elif False: + self._Buffer2array *=(256-alpha_int) + self._Buffer2array +=self._Bufferarray.astype(_numpy.uint32)*alpha_int + self._Buffer2array /=256 + + ##copy back to image buffer + self._Buffer2.CopyFromBuffer(self._Buffer2array.astype(_numpy.uint8)) #, format=wx.BitmapBufferFormat_RGB, stride=-1) + + #draw to the screen + #self.decim_counter=self.decim_counter+1 + if True: #self.decim_counter>self.decimation: + #self.decim_counter=0 + dc2 = wx.ClientDC( self ) + dc2.BeginDrawing() + dc2.DrawBitmap(self._Buffer2, 0, 0, False) + #dc2.DrawBitmap(self._Buffer, 0, 0, False) + dc2.EndDrawing() def Redraw(self, dc= None): """Redraw the existing plot.""" @@ -1031,6 +1099,8 @@ class PlotCanvas(wx.Window): if self.last_PointLabel != None: self._drawPointLabel(self.last_PointLabel) #erase old self.last_PointLabel = None + + #paint current buffer to screen dc = wx.BufferedPaintDC(self, self._Buffer) def OnSize(self,event): @@ -1041,7 +1111,23 @@ class PlotCanvas(wx.Window): # Make new offscreen bitmap: this bitmap will always have the # current drawing in it, so it can be used to save the image to # a file, or whatever. - self._Buffer = wx.EmptyBitmap(Size[0],Size[1]) + self._Buffer = wx.EmptyBitmap(Size[0],Size[1],24) + + + if True: #self.use_persistence: + #self._Bufferarray = _numpy.zeros((Size[0], Size[1],3), dtype=_numpy.uint8) + self._Bufferarray = _numpy.zeros((Size[0]* Size[1]*3), dtype=_numpy.uint8) + + # Make new second offscreen bitmap: this bitmap will always have the + # last drawing in it, so it can be used to do display time dependent processing + # like averaging (IIR) or show differences between updates + self._Buffer2 = wx.EmptyBitmap(Size[0],Size[1],24) + # now the extra buffers for the IIR processing + # note the different datatype uint32 + self._Buffer2array = _numpy.zeros((Size[0]* Size[1]*3), dtype=_numpy.uint32) #dtype=_numpy.float + self._Buffer3array = _numpy.zeros((Size[0]* Size[1]*3), dtype=_numpy.uint32) #dtype=_numpy.float + # optional you can set the ufunct buffer size to improve speed + #_numpy.setbufsize(16*((Size[0]* Size[1]*3)/16 +1)) self._setSize() self.last_PointLabel = None #reset pointLabel diff --git a/gr-wxgui/src/python/plotter/channel_plotter.py b/gr-wxgui/src/python/plotter/channel_plotter.py index ff0a3a160..a3a2b6451 100644 --- a/gr-wxgui/src/python/plotter/channel_plotter.py +++ b/gr-wxgui/src/python/plotter/channel_plotter.py @@ -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 # @@ -47,6 +47,7 @@ class channel_plotter(grid_plotter_base): """ #init grid_plotter_base.__init__(self, parent, MIN_PADDING) + self.set_use_persistence(False) #setup legend cache self._legend_cache = self.new_gl_cache(self._draw_legend, 50) self.enable_legend(False) diff --git a/gr-wxgui/src/python/plotter/gltext.py b/gr-wxgui/src/python/plotter/gltext.py index 67f62ca56..1b3c047dc 100644 --- a/gr-wxgui/src/python/plotter/gltext.py +++ b/gr-wxgui/src/python/plotter/gltext.py @@ -193,7 +193,7 @@ class TextElement(object): img = wx.ImageFromBitmap(bmp)
alpha = img.GetData()
- if isinstance(self._foreground, wx.Color):
+ if isinstance(self._foreground, wx.Colour):
"""
If we have a static color...
"""
diff --git a/gr-wxgui/src/python/plotter/plotter_base.py b/gr-wxgui/src/python/plotter/plotter_base.py index dede5a0ad..b856215e9 100644 --- a/gr-wxgui/src/python/plotter/plotter_base.py +++ b/gr-wxgui/src/python/plotter/plotter_base.py @@ -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 # @@ -87,7 +87,10 @@ class plotter_base(wx.glcanvas.GLCanvas, common.mutex): @param parent the parent widgit """ attribList = (wx.glcanvas.WX_GL_DOUBLEBUFFER, wx.glcanvas.WX_GL_RGBA) - wx.glcanvas.GLCanvas.__init__(self, parent, attribList=attribList) + wx.glcanvas.GLCanvas.__init__(self, parent, attribList=attribList); + self.use_persistence=False + self.persist_alpha=2.0/15 + self.clear_accum=True self._gl_init_flag = False self._resized_flag = True self._init_fcns = list() @@ -97,6 +100,13 @@ class plotter_base(wx.glcanvas.GLCanvas, common.mutex): self.Bind(wx.EVT_SIZE, self._on_size) self.Bind(wx.EVT_ERASE_BACKGROUND, lambda e: None) + def set_use_persistence(self,enable): + self.use_persistence=enable + self.clear_accum=True + + def set_persist_alpha(self,analog_alpha): + self.persist_alpha=analog_alpha + def new_gl_cache(self, draw_fcn, draw_pri=50): """ Create a new gl cache. @@ -131,6 +141,7 @@ class plotter_base(wx.glcanvas.GLCanvas, common.mutex): """ self.lock() self._resized_flag = True + self.clear_accum=True self.unlock() def _on_paint(self, event): @@ -160,7 +171,30 @@ class plotter_base(wx.glcanvas.GLCanvas, common.mutex): self._resized_flag = False #clear, draw functions, swap GL.glClear(GL.GL_COLOR_BUFFER_BIT) + + if False: + GL.glEnable (GL.GL_LINE_SMOOTH) + GL.glEnable (GL.GL_POLYGON_SMOOTH) + GL.glEnable (GL.GL_BLEND) + GL.glBlendFunc (GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA) + GL.glHint (GL.GL_LINE_SMOOTH_HINT, GL.GL_NICEST) #GL.GL_DONT_CARE) + GL.glHint(GL.GL_POLYGON_SMOOTH_HINT, GL.GL_NICEST) + #GL.glLineWidth (1.5) + + GL.glEnable(GL.GL_MULTISAMPLE) #Enable Multisampling anti-aliasing + + for fcn in self._draw_fcns: fcn[1]() + + if self.use_persistence: + if self.clear_accum: + #GL.glClear(GL.GL_ACCUM_BUFFER_BIT) + GL.glAccum(GL.GL_LOAD, 1.0) + self.clear_accum=False + + GL.glAccum(GL.GL_MULT, 1.0-self.persist_alpha) + GL.glAccum(GL.GL_ACCUM, self.persist_alpha) + GL.glAccum(GL.GL_RETURN, 1.0) self.SwapBuffers() self.unlock() diff --git a/gr-wxgui/src/python/scope_window.py b/gr-wxgui/src/python/scope_window.py index 08a025e1e..a9917782f 100644 --- a/gr-wxgui/src/python/scope_window.py +++ b/gr-wxgui/src/python/scope_window.py @@ -1,5 +1,5 @@ # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -36,6 +36,9 @@ import forms # Constants ################################################## 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), @@ -45,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), @@ -55,6 +59,9 @@ CHANNEL_COLOR_SPECS = ( (0.0, 0.8, 0.0), (1.0, 0.0, 0.0), (0.8, 0.0, 0.8), + (0.7, 0.7, 0.0), + (0.15, 0.90, 0.98), + ) TRIGGER_COLOR_SPEC = (1.0, 0.4, 0.0) AUTORANGE_UPDATE_RATE = 0.5 #sec @@ -85,6 +92,37 @@ class control_panel(wx.Panel): parent[SHOW_CONTROL_PANEL_KEY] = True parent.subscribe(SHOW_CONTROL_PANEL_KEY, self.Show) control_box = wx.BoxSizer(wx.VERTICAL) + + ################################################## + # Persistence + ################################################## + + forms.check_box( + sizer=control_box, parent=self, label='Persistence', + ps=parent, key=USE_PERSISTENCE_KEY, + ) + #static text and slider for analog alpha + persist_alpha_text = forms.static_text( + sizer=control_box, parent=self, label='Analog Alpha', + converter=forms.float_converter(lambda x: '%.4f'%x), + ps=parent, key=PERSIST_ALPHA_KEY, width=50, + ) + persist_alpha_slider = forms.log_slider( + sizer=control_box, parent=self, + min_exp=PERSIST_ALPHA_MIN_EXP, + max_exp=PERSIST_ALPHA_MAX_EXP, + num_steps=SLIDER_STEPS, + ps=parent, key=PERSIST_ALPHA_KEY, + ) + for widget in (persist_alpha_text, persist_alpha_slider): + parent.subscribe(USE_PERSISTENCE_KEY, widget.Enable) + widget.Enable(parent[USE_PERSISTENCE_KEY]) + parent.subscribe(USE_PERSISTENCE_KEY, widget.ShowItems) + #allways show initially, so room is reserved for them + widget.ShowItems(True) # (parent[USE_PERSISTENCE_KEY]) + + parent.subscribe(USE_PERSISTENCE_KEY, self._update_layout) + ################################################## # Axes Options ################################################## @@ -361,6 +399,15 @@ class control_panel(wx.Panel): def _on_decr_y_off(self, event): self.parent[Y_OFF_KEY] = self.parent[Y_OFF_KEY] - self.parent[Y_PER_DIV_KEY] + ################################################## + # subscriber handlers + ################################################## + def _update_layout(self,key): + # Just ignore the key value we get + # we only need to now that the visability or size of something has changed + self.parent.Layout() + #self.parent.Fit() + ################################################## # Scope window with plotter and control panel ################################################## @@ -385,6 +432,9 @@ class scope_window(wx.Panel, pubsub.pubsub): trigger_channel_key, decimation_key, msg_key, + use_persistence, + persist_alpha, + trig_mode, ): pubsub.pubsub.__init__(self) #check num inputs @@ -424,9 +474,16 @@ class scope_window(wx.Panel, pubsub.pubsub): 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 @@ -437,6 +494,8 @@ class scope_window(wx.Panel, pubsub.pubsub): self.plotter.enable_legend(True) self.plotter.enable_point_label(True) self.plotter.enable_grid_lines(True) + self.plotter.set_use_persistence(use_persistence) + self.plotter.set_persist_alpha(persist_alpha) #setup the box with plot and controls self.control_panel = control_panel(self) main_box = wx.BoxSizer(wx.HORIZONTAL) @@ -454,6 +513,9 @@ class scope_window(wx.Panel, pubsub.pubsub): XY_MODE_KEY, AUTORANGE_KEY, T_FRAC_OFF_KEY, TRIGGER_SHOW_KEY, XY_MARKER_KEY, X_CHANNEL_KEY, Y_CHANNEL_KEY, ]: self.subscribe(key, self.update_grid) + #register events for plotter settings + self.subscribe(USE_PERSISTENCE_KEY, self.plotter.set_use_persistence) + self.subscribe(PERSIST_ALPHA_KEY, self.plotter.set_persist_alpha) #initial update self.update_grid() @@ -618,3 +680,4 @@ class scope_window(wx.Panel, pubsub.pubsub): 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 358361de6..15be23d5a 100644 --- a/gr-wxgui/src/python/scopesink_gl.py +++ b/gr-wxgui/src/python/scopesink_gl.py @@ -1,5 +1,5 @@ # -# Copyright 2008 Free Software Foundation, Inc. +# Copyright 2008,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -27,6 +27,7 @@ import common from gnuradio import gr from pubsub import pubsub from constants import * +import math class ac_couple_block(gr.hier_block2): """ @@ -75,9 +76,19 @@ 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, frame_rate=scope_window.DEFAULT_FRAME_RATE, + use_persistence=False, + persist_alpha=None, **kwargs #do not end with a comma ): + #ensure analog alpha + if persist_alpha is None: + actual_frame_rate=float(frame_rate) + analog_cutoff_freq=0.5 # Hertz + #calculate alpha from wanted cutoff freq + persist_alpha = 1.0 - math.exp(-2.0*math.pi*analog_cutoff_freq/actual_frame_rate) + if not t_scale: t_scale = 10.0/sample_rate #init gr.hier_block2.__init__( @@ -122,6 +133,7 @@ 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, ac_couple_key=AC_COUPLE_KEY, trigger_level_key=TRIGGER_LEVEL_KEY, trigger_mode_key=TRIGGER_MODE_KEY, @@ -129,6 +141,8 @@ class _scope_sink_base(gr.hier_block2, common.wxgui_hb): trigger_channel_key=TRIGGER_CHANNEL_KEY, decimation_key=DECIMATION_KEY, msg_key=MSG_KEY, + use_persistence=use_persistence, + persist_alpha=persist_alpha, ) common.register_access_methods(self, self.win) #connect @@ -169,10 +183,11 @@ class test_top_block (stdgui2.std_top_block): def __init__(self, frame, panel, vbox, argv): stdgui2.std_top_block.__init__ (self, frame, panel, vbox, argv) + default_input_rate = 1e6 if len(argv) > 1: - frame_decim = int(argv[1]) + input_rate = int(argv[1]) else: - frame_decim = 1 + input_rate = default_input_rate if len(argv) > 2: v_scale = float(argv[2]) # start up at this v_scale value @@ -182,14 +197,17 @@ class test_top_block (stdgui2.std_top_block): if len(argv) > 3: t_scale = float(argv[3]) # start up at this t_scale value else: - t_scale = .00003 # old behavior + t_scale = .00003*default_input_rate/input_rate # old behavior - print "frame decim %s v_scale %s t_scale %s" % (frame_decim,v_scale,t_scale) + print "input rate %s v_scale %s t_scale %s" % (input_rate,v_scale,t_scale) - input_rate = 1e6 # Generate a complex sinusoid - self.src0 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 25.1e3, 1e3) + ampl=1.0e3 + self.src0 = gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 25.1e3*input_rate/default_input_rate, ampl) + self.noise =gr.sig_source_c (input_rate, gr.GR_SIN_WAVE, 11.1*25.1e3*input_rate/default_input_rate, ampl/10) + #self.noise =gr.noise_source_c(gr.GR_GAUSSIAN, ampl/10) + self.combine=gr.add_cc() # We add this throttle block so that this demo doesn't suck down # all the CPU available. You normally wouldn't use it... @@ -201,7 +219,9 @@ class test_top_block (stdgui2.std_top_block): # Ultimately this will be # self.connect("src0 throttle scope") - self.connect(self.src0, self.thr, scope) + self.connect(self.src0,(self.combine,0)) + self.connect(self.noise,(self.combine,1)) + self.connect(self.combine, self.thr, scope) def main (): app = stdgui2.stdapp (test_top_block, "O'Scope Test App") diff --git a/gr-wxgui/src/python/scopesink_nongl.py b/gr-wxgui/src/python/scopesink_nongl.py index 5c1379ee6..bf2c50917 100644 --- a/gr-wxgui/src/python/scopesink_nongl.py +++ b/gr-wxgui/src/python/scopesink_nongl.py @@ -217,13 +217,13 @@ class input_watcher (gru.msgq_runner): chan_data = s[start:start+bytes_per_chan] rec = numpy.fromstring (chan_data, numpy.float32) records.append (rec) - - # print "nrecords = %d, reclen = %d" % (len (records),nsamples) - - de = DataEvent (records) - wx.PostEvent (self.event_receiver, de) - records = [] - del de + + # print "nrecords = %d, reclen = %d" % (len (records),nsamples) + + de = DataEvent (records) + wx.PostEvent (self.event_receiver, de) + records = [] + del de self.iscan -= 1 diff --git a/gr-wxgui/src/python/waterfall_window.py b/gr-wxgui/src/python/waterfall_window.py index b7904e4d9..6536ada10 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 4e3839d27..18420a013 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 \ @@ -91,7 +92,6 @@ dist_ourdata_DATA = \ gr_correlate_access_code_bb.xml \ gr_costas_loop_cc.xml \ gr_cpfsk_bc.xml \ - gr_dd_mpsk_sync_cc.xml \ gr_decode_ccsds_27_fb.xml \ gr_deinterleave.xml \ gr_delay.xml \ diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml index 04568e19a..610a88102 100644 --- a/grc/blocks/block_tree.xml +++ b/grc/blocks/block_tree.xml @@ -58,6 +58,7 @@ <block>gr_add_const_vxx</block> <block>gr_multiply_const_vxx</block> + <block>gr_and_const_xx</block> <block>gr_not_xx</block> <block>gr_and_xx</block> @@ -130,7 +131,6 @@ <block>gr_pfb_clock_sync_xxx</block> <block>gr_costas_loop_cc</block> - <block>gr_dd_mpsk_sync_cc</block> <block>gr_mpsk_sync_cc</block> <block>gr_mpsk_receiver_cc</block> diff --git a/grc/blocks/gr_agc2_xx.xml b/grc/blocks/gr_agc2_xx.xml index fb3ae5704..55b20d4e8 100644 --- a/grc/blocks/gr_agc2_xx.xml +++ b/grc/blocks/gr_agc2_xx.xml @@ -9,6 +9,11 @@ <key>gr_agc2_xx</key> <import>from gnuradio import gr</import> <make>gr.agc2_$(type.fcn)($attack_rate, $decay_rate, $reference, $gain, $max_gain)</make> + <callback>set_attack_rate($attack_rate)</callback> + <callback>set_decay_rate($decay_rate)</callback> + <callback>set_reference($reference)</callback> + <callback>set_gain($gain)</callback> + <callback>set_max_gain($max_gain)</callback> <param> <name>Type</name> <key>type</key> diff --git a/grc/blocks/gr_and_const_xx.xml b/grc/blocks/gr_and_const_xx.xml new file mode 100644 index 000000000..dc9649311 --- /dev/null +++ b/grc/blocks/gr_and_const_xx.xml @@ -0,0 +1,48 @@ +<?xml version="1.0"?> +<!-- +################################################### +## And Const Block: +## all types, 1 output, 1 input & const +################################################### + --> +<block> + <name>And Const</name> + <key>gr_and_const_xx</key> + <import>from gnuradio import gr</import> + <make>gr.and_const_$(type.fcn)($const)</make> + <callback>set_k($const)</callback> + <param> + <name>IO Type</name> + <key>type</key> + <type>enum</type> + <option> + <name>Int</name> + <key>int</key> + <opt>fcn:ii</opt> + </option> + <option> + <name>Short</name> + <key>short</key> + <opt>fcn:ss</opt> + </option> + <option> + <name>Byte</name> + <key>byte</key> + <opt>fcn:bb</opt> + </option> + </param> + <param> + <name>Constant</name> + <key>const</key> + <value>0</value> + <type>int</type> + </param> + <sink> + <name>in</name> + <type>$type</type> + </sink> + <source> + <name>out</name> + <type>$type</type> + </source> +</block> diff --git a/grc/blocks/gr_dd_mpsk_sync_cc.xml b/grc/blocks/gr_dd_mpsk_sync_cc.xml deleted file mode 100644 index aed0e8d31..000000000 --- a/grc/blocks/gr_dd_mpsk_sync_cc.xml +++ /dev/null @@ -1,65 +0,0 @@ -<?xml version="1.0"?> -<!-- -################################################### -##DD MPSK Sync -################################################### - --> -<block> - <name>DD MPSK Sync</name> - <key>gr_dd_mpsk_sync_cc</key> - <import>from gnuradio import gr</import> - <make>gr.dd_mpsk_sync_cc($alpha, $beta, $max_freq, $min_freq, $ref_phase, $omega, $gain_omega, $mu, $gain_mu)</make> - <param> - <name>Alpha</name> - <key>alpha</key> - <type>real</type> - </param> - <param> - <name>Beta</name> - <key>beta</key> - <type>real</type> - </param> - <param> - <name>Max Freq</name> - <key>max_freq</key> - <type>real</type> - </param> - <param> - <name>Min Freq</name> - <key>min_freq</key> - <type>real</type> - </param> - <param> - <name>Reference Phase</name> - <key>ref_phase</key> - <type>real</type> - </param> - <param> - <name>Omega</name> - <key>omega</key> - <type>real</type> - </param> - <param> - <name>Gain Omega</name> - <key>gain_omega</key> - <type>real</type> - </param> - <param> - <name>Mu</name> - <key>mu</key> - <type>real</type> - </param> - <param> - <name>Gain Mu</name> - <key>gain_mu</key> - <type>real</type> - </param> - <sink> - <name>in</name> - <type>complex</type> - </sink> - <source> - <name>out</name> - <type>complex</type> - </source> -</block> diff --git a/grc/blocks/gr_file_sink.xml b/grc/blocks/gr_file_sink.xml index 880dc2759..0081c93f8 100644 --- a/grc/blocks/gr_file_sink.xml +++ b/grc/blocks/gr_file_sink.xml @@ -8,7 +8,9 @@ <name>File Sink</name> <key>gr_file_sink</key> <import>from gnuradio import gr</import> - <make>gr.file_sink($type.size*$vlen, $file)</make> + <make>gr.file_sink($type.size*$vlen, $file) +self.$(id).set_unbuffered($unbuffered)</make> + <callback>set_unbuffered($unbuffered)</callback> <param> <name>File</name> <key>file</key> @@ -51,6 +53,21 @@ <value>1</value> <type>int</type> </param> + <param> + <name>Unbuffered</name> + <key>unbuffered</key> + <value>False</value> + <type>bool</type> + <option> + <name>Off</name> + <key>False</key> + </option> + <option> + <name>On</name> + <key>True</key> + </option> + </param> + <check>$vlen > 0</check> <sink> <name>in</name> diff --git a/grc/blocks/gr_udp_sink.xml b/grc/blocks/gr_udp_sink.xml index e9f6c2be8..45f81075f 100644 --- a/grc/blocks/gr_udp_sink.xml +++ b/grc/blocks/gr_udp_sink.xml @@ -8,7 +8,7 @@ <name>UDP Sink</name> <key>gr_udp_sink</key> <import>from gnuradio import gr</import> - <make>gr.udp_sink($type.size*$vlen, $ipaddr_local, $port_local, $ipaddr_remote, $port_remote, $mtu)</make> + <make>gr.udp_sink($type.size*$vlen, $ipaddr, $port, $psize, $eof)</make> <callback>set_mtu($mtu)</callback> <param> <name>Input Type</name> @@ -41,34 +41,26 @@ </option> </param> <param> - <name>Local IP Address</name> - <key>ipaddr_local</key> - <value>127.0.0.1</value> + <name>Destination IP Address</name> + <key>ipaddr</key> <type>string</type> </param> <param> - <name>Local Port</name> - <key>port_local</key> - <value>0</value> + <name>Destination Port</name> + <key>port</key> <type>int</type> </param> <param> - <name>Remote IP Address</name> - <key>ipaddr_remote</key> - <value>127.0.0.1</value> - <type>string</type> - </param> - <param> - <name>Remote Port</name> - <key>port_remote</key> - <value>1234</value> + <name>Payload Size</name> + <key>psize</key> + <value>1472</value> <type>int</type> </param> <param> - <name>MTU</name> - <key>mtu</key> - <value>1024</value> - <type>int</type> + <name>Send Null Pkt as EOF</name> + <key>eof</key> + <value>True</value> + <type>bool</type> </param> <param> <name>Vec Length</name> diff --git a/grc/blocks/gr_udp_source.xml b/grc/blocks/gr_udp_source.xml index f03adf802..a1b961651 100644 --- a/grc/blocks/gr_udp_source.xml +++ b/grc/blocks/gr_udp_source.xml @@ -8,7 +8,7 @@ <name>UDP Source</name> <key>gr_udp_source</key> <import>from gnuradio import gr</import> - <make>gr.udp_source($type.size*$vlen, $ipaddr, $port, $mtu)</make> + <make>gr.udp_source($type.size*$vlen, $ipaddr, $port, $psize, $eof, $wait)</make> <callback>set_mtu($mtu)</callback> <param> <name>Output Type</name> @@ -53,12 +53,24 @@ <type>int</type> </param> <param> - <name>MTU</name> - <key>mtu</key> - <value>1024</value> + <name>Payload Size</name> + <key>psize</key> + <value>1472</value> <type>int</type> </param> <param> + <name>Null Pkt is EOF</name> + <key>eof</key> + <value>True</value> + <type>bool</type> + </param> + <param> + <name>Wait for Data</name> + <key>wait</key> + <value>True</value> + <type>bool</type> + </param> + <param> <name>Vec Length</name> <key>vlen</key> <value>1</value> diff --git a/grc/blocks/usrp2_sink_xxxx.xml b/grc/blocks/usrp2_sink_xxxx.xml index 14586cc36..f9fb25361 100644 --- a/grc/blocks/usrp2_sink_xxxx.xml +++ b/grc/blocks/usrp2_sink_xxxx.xml @@ -21,7 +21,8 @@ self.$(id).set_interp($interpolation) self.$(id).set_lo_offset($lo_offset) #end if self.$(id).set_center_freq($frequency) -self.$(id).set_gain($gain)</make> +self.$(id).set_gain($gain) +self.$(id).config_mimo($usrp2_clock_src)</make> <callback>set_interp($interpolation)</callback> <callback>#if $lo_offset() != float('inf') self.$(id).set_lo_offset($lo_offset) @@ -84,6 +85,24 @@ self.$(id).set_center_freq($frequency)</callback> <value>0</value> <type>real</type> </param> + <param> + <name>Clock Source</name> + <key>usrp2_clock_src</key> + <value>usrp2.MC_WE_DONT_LOCK</value> + <type>enum</type> + <option> + <name>Internal</name> + <key>usrp2.MC_WE_DONT_LOCK</key> + </option> + <option> + <name>External SMA</name> + <key>usrp2.MC_WE_LOCK_TO_SMA</key> + </option> + <option> + <name>External MIMO</name> + <key>usrp2.MC_WE_LOCK_TO_MIMO</key> + </option> + </param> <sink> <name>in</name> <type>$type</type> diff --git a/grc/blocks/usrp2_source_xxxx.xml b/grc/blocks/usrp2_source_xxxx.xml index 0f297dfd1..584199798 100644 --- a/grc/blocks/usrp2_source_xxxx.xml +++ b/grc/blocks/usrp2_source_xxxx.xml @@ -21,7 +21,8 @@ self.$(id).set_decim($decimation) self.$(id).set_lo_offset($lo_offset) #end if self.$(id).set_center_freq($frequency) -self.$(id).set_gain($gain)</make> +self.$(id).set_gain($gain) +self.$(id).config_mimo($usrp2_clock_src)</make> <callback>set_decim($decimation)</callback> <callback>#if $lo_offset() != float('inf') self.$(id).set_lo_offset($lo_offset) @@ -84,6 +85,24 @@ self.$(id).set_center_freq($frequency)</callback> <value>0</value> <type>real</type> </param> + <param> + <name>Clock Source</name> + <key>usrp2_clock_src</key> + <value>usrp2.MC_WE_DONT_LOCK</value> + <type>enum</type> + <option> + <name>Internal</name> + <key>usrp2.MC_WE_DONT_LOCK</key> + </option> + <option> + <name>External SMA</name> + <key>usrp2.MC_WE_LOCK_TO_SMA</key> + </option> + <option> + <name>External MIMO</name> + <key>usrp2.MC_WE_LOCK_TO_MIMO</key> + </option> + </param> <source> <name>out</name> <type>$type</type> diff --git a/grc/blocks/variable_config.xml b/grc/blocks/variable_config.xml index 1c815c347..11bff9edc 100644 --- a/grc/blocks/variable_config.xml +++ b/grc/blocks/variable_config.xml @@ -46,7 +46,7 @@ self._$(id)_config.write(open($config_file, 'w'))</callback> <option> <name>Bool</name> <key>bool</key> - <opt>get:getbool</opt> + <opt>get:getboolean</opt> </option> <option> <name>String</name> diff --git a/grc/blocks/wxgui_scopesink2.xml b/grc/blocks/wxgui_scopesink2.xml index eba45f489..50cd977be 100644 --- a/grc/blocks/wxgui_scopesink2.xml +++ b/grc/blocks/wxgui_scopesink2.xml @@ -20,6 +20,7 @@ scopesink2.$(type.fcn)( ac_couple=$ac_couple, xy_mode=$xy_mode, num_inputs=$num_inputs, + trig_mode=$trig_mode, #if $win_size() size=$win_size, #end if @@ -134,6 +135,27 @@ $(parent).GridAdd(self.$(id).win, $(', '.join(map(str, $grid_pos())))) <value></value> <type>notebook</type> </param> + <param> + <name>Trigger Mode</name> + <key>trig_mode</key> + <type>enum</type> + <option> + <name>Auto</name> + <key>gr.gr_TRIG_MODE_AUTO</key> + </option> + <option> + <name>Normal</name> + <key>gr.gr_TRIG_MODE_NORM</key> + </option> + <option> + <name>Freerun</name> + <key>gr.gr_TRIG_MODE_FREE</key> + </option> + <option> + <name>Stripchart</name> + <key>gr.gr_TRIG_MODE_STRIPCHART</key> + </option> + </param> <check>not $win_size or len($win_size) == 2</check> <check>not $xy_mode or '$type' == 'complex' or $num_inputs != 1</check> <sink> diff --git a/grc/freedesktop/Makefile.am b/grc/freedesktop/Makefile.am index bfbdee940..f6aa97a93 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 \ @@ -34,7 +33,8 @@ dist_ourdata_DATA = \ 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-grc.desktop b/grc/freedesktop/gnuradio-grc.desktop index d9c70ca92..5fd049780 100644 --- a/grc/freedesktop/gnuradio-grc.desktop +++ b/grc/freedesktop/gnuradio-grc.desktop @@ -2,7 +2,7 @@ Version=1.0 Type=Application Name=GRC -Exec=grc %F +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 db6506452..ab4ce82ef 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 @@ -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 dd39b095d..bd03eb5cd 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 6965371df..6e5a5c59f 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/grc/scripts/Makefile.am b/grc/scripts/Makefile.am index e24f88800..9019ec5cc 100644 --- a/grc/scripts/Makefile.am +++ b/grc/scripts/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,4 +21,4 @@ include $(top_srcdir)/Makefile.common -dist_bin_SCRIPTS = grc usrp2_probe usrp_probe +dist_bin_SCRIPTS = gnuradio-companion usrp2_probe usrp_probe diff --git a/grc/scripts/grc b/grc/scripts/gnuradio-companion index a4115c39f..a4115c39f 100755 --- a/grc/scripts/grc +++ b/grc/scripts/gnuradio-companion diff --git a/gruel/gruel.pc.in b/gruel/gruel.pc.in index 6377f5bb3..504c4d949 100644 --- a/gruel/gruel.pc.in +++ b/gruel/gruel.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: gruel Description: The GNU Radio Utility Etcetera Library Requires: -Version: @VERSION@ +Version: @LIBVER@ Libs: -L${libdir} -lgruel Cflags: -I${includedir} diff --git a/gruel/src/include/gruel/pmt.h b/gruel/src/include/gruel/pmt.h index c371b023b..514b24d8b 100644 --- a/gruel/src/include/gruel/pmt.h +++ b/gruel/src/include/gruel/pmt.h @@ -165,6 +165,27 @@ 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 6bde9ee27..1bcd26e90 100644 --- a/gruel/src/lib/Makefile.am +++ b/gruel/src/lib/Makefile.am @@ -34,7 +34,7 @@ noinst_PROGRAMS = test_gruel lib_LTLIBRARIES = libgruel.la # magic flags -libgruel_la_LDFLAGS = $(NO_UNDEFINED) $(BOOST_LDFLAGS) -version-info 0:0:0 +libgruel_la_LDFLAGS = $(NO_UNDEFINED) $(BOOST_LDFLAGS) $(LTVERSIONFLAGS) # ---------------------------------------------------------------- diff --git a/gruel/src/lib/pmt/pmt.cc b/gruel/src/lib/pmt/pmt.cc index aa1688d24..f9cf6b4bf 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<pmt_integer*>(x.get()); } +static pmt_uint64 * +_uint64(pmt_t x) +{ + return dynamic_cast<pmt_uint64*>(x.get()); +} + static pmt_real * _real(pmt_t x) { @@ -305,6 +311,40 @@ pmt_to_long(pmt_t 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 50683ffb5..ea28e37b4 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 179e6b72c..b909c1b64 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 f2414c72c..985361f13 100644 --- a/gruel/src/lib/pmt/qa_pmt_prims.cc +++ b/gruel/src/lib/pmt/qa_pmt_prims.cc @@ -104,6 +104,19 @@ qa_pmt_prims::test_integers() } 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() { pmt_t p1 = pmt_from_double(1); diff --git a/gruel/src/lib/pmt/qa_pmt_prims.h b/gruel/src/lib/pmt/qa_pmt_prims.h index 29ba02f11..efc5c6050 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 669303447..f4b9fc4e2 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,70 @@ */ #include <cppunit/TextTestRunner.h> +#include <cppunit/XmlOutputter.h> + +#include <stdlib.h> +#include <sys/stat.h> + #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 *grpath, 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 (grpath, 0750); + gr_mkdir (path, 0750); +} + +static void +get_unittest_path (const char *filename, char *fullpath, size_t pathsize) +{ + char path[200]; + char grpath[200]; + snprintf (grpath, sizeof(grpath), "%s/.gnuradio", getenv ("HOME")); + snprintf (path, sizeof(path), "%s/unittests", grpath); + snprintf (fullpath, pathsize, "%s/%s", path, filename); + + ensure_unittest_path(grpath, path); +} + diff --git a/mblock/.gitignore b/mblock/.gitignore deleted file mode 100644 index 36b77742f..000000000 --- a/mblock/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/Makefile -/Makefile.in -/mblock.pc diff --git a/mblock/Makefile.am b/mblock/Makefile.am deleted file mode 100644 index 69e2f22c0..000000000 --- a/mblock/Makefile.am +++ /dev/null @@ -1,31 +0,0 @@ -# -# Copyright 2004 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -EXTRA_DIST = \ - mblock.pc.in - -SUBDIRS = src -DIST_SUBDIRS = src doc - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = mblock.pc diff --git a/mblock/README b/mblock/README deleted file mode 100644 index 1f3ba697b..000000000 --- a/mblock/README +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright 2006,2007 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. -# - -The "Message block" implementation, a work in progress... - -http://gnuradio.org/trac/wiki/MessageBlocks diff --git a/mblock/doc/.gitignore b/mblock/doc/.gitignore deleted file mode 100644 index f65ab6cf7..000000000 --- a/mblock/doc/.gitignore +++ /dev/null @@ -1,18 +0,0 @@ -/Makefile -/Makefile.in -/.deps -/.libs -/*.la -/*.lo -/autom4te.cache -/*.cache -/howto-write-a-block.html -/gr_block.h.xml -/howto_1.i.xml -/howto_square_ff.cc.xml -/howto_square_ff.h.xml -/qa_howto_1.py.xml -/src_lib_Makefile_1.am.xml -/src_lib_Makefile_2.am.xml -/howto_square2_ff.cc.xml -/howto_square2_ff.h.xml diff --git a/mblock/doc/Makefile.am b/mblock/doc/Makefile.am deleted file mode 100644 index a806b25cf..000000000 --- a/mblock/doc/Makefile.am +++ /dev/null @@ -1,44 +0,0 @@ -# -# Copyright 2004,2005,2006 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. -# - -TARGETS = - - -# To avoid build problems for folks who don't have xmlto installed, we -# don't build the docs by default. - -# html: $(TARGETS) -all: $(TARGETS) - - -EXTRA_DIST = - -BUILT_XML_FILES = - - -# ---------------------------------------------------------------- - -clean: - -rm -f $(TARGETS) $(BUILT_XML_FILES) - -# This is non-portable pattern rule. -#%.html : %.xml -# xmlto html-nochunks $< diff --git a/mblock/mblock.pc.in b/mblock/mblock.pc.in deleted file mode 100644 index 3d849995b..000000000 --- a/mblock/mblock.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: mblock -Description: The GNU Radio message block library -Requires: pmt gnuradio-omnithread -Version: @VERSION@ -Libs: -L${libdir} -lmblock -Cflags: -I${includedir}
\ No newline at end of file diff --git a/mblock/src/.gitignore b/mblock/src/.gitignore deleted file mode 100644 index bb3f27777..000000000 --- a/mblock/src/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/howto.cc -/howto.py diff --git a/mblock/src/Makefile.am b/mblock/src/Makefile.am deleted file mode 100644 index 60995c972..000000000 --- a/mblock/src/Makefile.am +++ /dev/null @@ -1,22 +0,0 @@ -# -# Copyright 2004,2006,2008 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -SUBDIRS = include lib scheme diff --git a/mblock/src/include/.gitignore b/mblock/src/include/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/mblock/src/include/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/mblock/src/include/Makefile.am b/mblock/src/include/Makefile.am deleted file mode 100644 index d5672989c..000000000 --- a/mblock/src/include/Makefile.am +++ /dev/null @@ -1,24 +0,0 @@ -# -# Copyright 2008 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = mblock diff --git a/mblock/src/include/mblock/.gitignore b/mblock/src/include/mblock/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/mblock/src/include/mblock/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/mblock/src/include/mblock/Makefile.am b/mblock/src/include/mblock/Makefile.am deleted file mode 100644 index e36215aa4..000000000 --- a/mblock/src/include/mblock/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -# -# Copyright 2008 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -mbincludedir = $(includedir)/mblock - -mbinclude_HEADERS = \ - common.h \ - class_registry.h \ - exception.h \ - mblock.h \ - message.h \ - msg_accepter.h \ - msg_queue.h \ - port.h \ - protocol_class.h \ - runtime.h \ - time.h diff --git a/mblock/src/include/mblock/class_registry.h b/mblock/src/include/mblock/class_registry.h deleted file mode 100644 index e4341f7d1..000000000 --- a/mblock/src/include/mblock/class_registry.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_CLASS_REGISTRY_H -#define INCLUDED_MB_CLASS_REGISTRY_H - -#include <mblock/common.h> - -//! conceptually, pointer to constructor -typedef mb_mblock_sptr (*mb_mblock_maker_t)(mb_runtime *runtime, - const std::string &instance_name, - pmt::pmt_t user_arg); - -/* - * \brief Maintain mapping between mblock class_name and factory (maker) - */ -class mb_class_registry : public boost::noncopyable { -public: - static bool register_maker(const std::string &name, mb_mblock_maker_t maker); - static bool lookup_maker(const std::string &name, mb_mblock_maker_t *maker); -}; - -template<class mblock> -mb_mblock_sptr mb_mblock_maker(mb_runtime *runtime, - const std::string &instance_name, - pmt::pmt_t user_arg) -{ - return mb_mblock_sptr(new mblock(runtime, instance_name, user_arg)); -} - -#define REGISTER_MBLOCK_CLASS(name) \ - bool __RBC__ ## name = mb_class_registry::register_maker(#name, &mb_mblock_maker<name>) - -#endif /* INCLUDED_MB_CLASS_REGISTRY_H */ diff --git a/mblock/src/include/mblock/common.h b/mblock/src/include/mblock/common.h deleted file mode 100644 index 054b9987e..000000000 --- a/mblock/src/include/mblock/common.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_COMMON_H -#define INCLUDED_MB_COMMON_H - -#include <gruel/pmt.h> -#include <vector> -#include <stdexcept> -#include <boost/utility.hpp> -#include <boost/enable_shared_from_this.hpp> -#include <boost/weak_ptr.hpp> - -/* - * The priority type and valid range - */ -typedef unsigned int mb_pri_t; -static const mb_pri_t MB_PRI_BEST = 0; -static const mb_pri_t MB_PRI_DEFAULT = 4; -static const mb_pri_t MB_PRI_WORST = 7; -static const mb_pri_t MB_NPRI = MB_PRI_WORST + 1; // number of valid priorities - -/*! - * \brief return true iff priority a is better than priority b - */ -inline static bool -mb_pri_better(mb_pri_t a, mb_pri_t b) -{ - return a < b; -} - -/*! - * \brief return true iff priority a is worse than priority b - */ -inline static bool -mb_pri_worse(mb_pri_t a, mb_pri_t b) -{ - return a > b; -} - -/*! - * \brief ensure that pri is valid - */ -inline static mb_pri_t -mb_pri_clamp(mb_pri_t p) -{ - return p < MB_NPRI ? p : MB_NPRI - 1; -} - -class mb_runtime; -typedef boost::shared_ptr<mb_runtime> mb_runtime_sptr; - -//class mb_runtime_impl; -//typedef boost::shared_ptr<mb_runtime_impl> mb_runtime_impl_sptr; - -class mb_mblock; -typedef boost::shared_ptr<mb_mblock> mb_mblock_sptr; - -class mb_mblock_impl; -typedef boost::shared_ptr<mb_mblock_impl> mb_mblock_impl_sptr; - -class mb_port; -typedef boost::shared_ptr<mb_port> mb_port_sptr; - -//class mb_port_detail; -//typedef boost::shared_ptr<mb_port_detail> mb_port_detail_sptr; - -class mb_msg_accepter; -typedef boost::shared_ptr<mb_msg_accepter> mb_msg_accepter_sptr; - -class mb_message; -typedef boost::shared_ptr<mb_message> mb_message_sptr; - -class mb_msg_queue; -typedef boost::shared_ptr<mb_msg_queue> mb_msg_queue_sptr; - -#endif /* INCLUDED_MB_COMMON_H */ diff --git a/mblock/src/include/mblock/exception.h b/mblock/src/include/mblock/exception.h deleted file mode 100644 index 6cc456656..000000000 --- a/mblock/src/include/mblock/exception.h +++ /dev/null @@ -1,118 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_EXCEPTION_H -#define INCLUDED_MB_EXCEPTION_H - -#include <stdexcept> - -class mb_mblock; - - -class mbe_base : public std::logic_error -{ -public: - mbe_base(mb_mblock *mb, const std::string &msg); -}; - -class mbe_not_implemented : public mbe_base -{ -public: - mbe_not_implemented(mb_mblock *mb, const std::string &msg); -}; - -class mbe_no_such_class : public mbe_base -{ -public: - mbe_no_such_class(mb_mblock *, const std::string &class_name); -}; - -class mbe_no_such_component : public mbe_base -{ -public: - mbe_no_such_component(mb_mblock *, const std::string &component_name); -}; - -class mbe_duplicate_component : public mbe_base -{ -public: - mbe_duplicate_component(mb_mblock *, const std::string &component_name); -}; - -class mbe_no_such_port : public mbe_base -{ -public: - mbe_no_such_port(mb_mblock *, const std::string &port_name); -}; - - -class mbe_duplicate_port : public mbe_base -{ -public: - mbe_duplicate_port(mb_mblock *, const std::string &port_name); -}; - -class mbe_already_connected : public mbe_base -{ -public: - mbe_already_connected(mb_mblock *, const std::string &comp_name, - const std::string &port_name); -}; - -class mbe_incompatible_ports : public mbe_base -{ -public: - mbe_incompatible_ports(mb_mblock *, - const std::string &comp1_name, - const std::string &port1_name, - const std::string &comp2_name, - const std::string &port2_name); -}; - -class mbe_invalid_port_type : public mbe_base -{ -public: - mbe_invalid_port_type(mb_mblock *, const std::string &comp_name, - const std::string &port_name); -}; - -class mbe_mblock_failed : public mbe_base -{ -public: - mbe_mblock_failed(mb_mblock *, const std::string &msg); -}; - - - -// not derived from mbe_base to simplify try/catch -class mbe_terminate -{ -public: - mbe_terminate(); -}; - -// not derived from mbe_base to simplify try/catch -class mbe_exit -{ -public: - mbe_exit(); -}; - -#endif /* INCLUDED_MB_EXCEPTION_H */ diff --git a/mblock/src/include/mblock/mblock.h b/mblock/src/include/mblock/mblock.h deleted file mode 100644 index 2f036e414..000000000 --- a/mblock/src/include/mblock/mblock.h +++ /dev/null @@ -1,318 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_MBLOCK_H -#define INCLUDED_MB_MBLOCK_H - -#include <mblock/common.h> -#include <mblock/message.h> -#include <mblock/port.h> -#include <mblock/time.h> - - -/*! - * Abstract class implementing visitor pattern - * \ingroup internal - */ -class mb_visitor -{ -public: - virtual ~mb_visitor(); - virtual bool operator()(mb_mblock *mblock) = 0; -}; - -// ---------------------------------------------------------------------- - -/*! - * \brief Parent class for all message passing blocks - * - * Subclass this to define your mblocks. - */ -class mb_mblock : boost::noncopyable, - public boost::enable_shared_from_this<mb_mblock> -{ -private: - mb_mblock_impl_sptr d_impl; // implementation details - - friend class mb_runtime; - friend class mb_mblock_impl; - friend class mb_worker; - -protected: - /*! - * \brief mblock constructor. - * - * Initializing all mblocks in the system is a 3 step procedure. - * - * The top level mblock's constructor is run. That constructor - * (a) registers all of its ports using define_port, (b) registers any - * subcomponents it may have via the define_component method, and - * then (c) issues connect calls to wire its subcomponents together. - * - * \param runtime the runtime associated with this mblock - * \param instance_name specify the name of this instance - * (for debugging, NUMA mapping, etc) - * \param user_arg argument passed by user to constructor - * (ignored by the mb_mblock base class) - */ - mb_mblock(mb_runtime *runtime, const std::string &instance_name, pmt::pmt_t user_arg); - -public: - /*! - * \brief Called by the runtime system to execute the initial - * transition of the finite state machine. - * - * This method is called by the runtime after all blocks are - * constructed and before the first message is delivered. Override - * this to initialize your finite state machine. - */ - virtual void initial_transition(); - -protected: - /*! - * \brief Called by the runtime system when there's a message to handle. - * - * Override this to define your behavior. - * - * Do not issue any potentially blocking calls in this method. This - * includes things such reads or writes on sockets, pipes or slow - * i/o devices. - */ - virtual void handle_message(mb_message_sptr msg); - - /*! - * \brief Define a port. - * - * EXTERNAL and RELAY ports are part of our peer interface. - * INTERNAL ports are used to talk to sub-components. - * - * \param port_name The name of the port (must be unique within this mblock). - * \param protocol_class_name The name of the protocol class associated with - * this port. It must already be defined. - * \param conjugated Are the incoming and outgoing message sets swapped? - * \param port_type INTERNAL, EXTERNAL or RELAY. - */ - mb_port_sptr - define_port(const std::string &port_name, - const std::string &protocol_class_name, - bool conjugated, - mb_port::port_type_t port_type); - - /*! - * \brief Define a subcomponent by name. - * - * Called within the constructor to tell the system the - * names and identities of our sub-component mblocks. - * - * \param component_name The name of the sub-component (must be unique with this mblock). - * \param class_name The class of the instance that is to be created. - * \param user_arg The argument to pass to the constructor of the component. - */ - void - define_component(const std::string &component_name, - const std::string &class_name, - pmt::pmt_t user_arg = pmt::PMT_NIL); - - /*! - * \brief connect endpoint_1 to endpoint_2 - * - * \param comp_name1 component on one end of the connection - * \param port_name1 the name of the port on comp1 - * \param comp_name2 component on the other end of the connection - * \param port_name2 the name of the port on comp2 - * - * An endpoint is specified by the component's local name (given as - * component_name in the call to register_component) and the name of - * the port on that component. - * - * To connect an internal or relay port, use "self" as the component name. - */ - void - connect(const std::string &comp_name1, const std::string &port_name1, - const std::string &comp_name2, const std::string &port_name2); - - /*! - * \brief disconnect endpoint_1 from endpoint_2 - * - * \param comp_name1 component on one end of the connection - * \param port_name1 the name of the port on comp1 - * \param comp_name2 component on the other end of the connection - * \param port_name2 the name of the port on comp2 - * - * An endpoint is specified by the component's local name (given as - * component_name in the call to register_component) and the name of - * the port on that component. - * - * To disconnect an internal or relay port, use "self" as the component name. - */ - void - disconnect(const std::string &comp_name1, const std::string &port_name1, - const std::string &comp_name2, const std::string &port_name2); - - /*! - * \brief disconnect all connections to specified component - * \param component_name component to disconnect - */ - void - disconnect_component(const std::string &component_name); - - /*! - * \brief disconnect all connections to all components - */ - void - disconnect_all(); - - /*! - * \brief Return number of connections (QA mostly) - */ - int - nconnections() const; - - //! Set the class name - void set_class_name(const std::string &name); - - /*! - * \brief Tell runtime that we are done. - * - * This method does not return. - */ - void exit(); - - /*! - * \brief Ask runtime to execute the shutdown procedure for all blocks. - * - * \param result sets value of \p result output argument of runtime->run(...) - * - * The runtime first sends a maximum priority %shutdown message to - * all blocks. All blocks should handle the %shutdown message, - * perform whatever clean up is required, and call this->exit(); - * - * After a period of time (~100ms), any blocks which haven't yet - * called this->exit() are sent a maximum priority %halt message. - * %halt is detected in main_loop, and this->exit() is called. - * - * After an additional period of time (~100ms), any blocks which - * still haven't yet called this->exit() are sent a SIG<FOO> (TBD) - * signal, which will blow them out of any blocking system calls and - * raise an mbe_terminate exception. The default top-level - * runtime-provided exception handler will call this->exit() to - * finish the process. - * - * runtime->run(...) returns when all blocks have called exit. - */ - void shutdown_all(pmt::pmt_t result); - - /*! - * \brief main event dispatching loop - * - * Although it is possible to override this, the default implementation - * should work for virtually all cases. - */ - virtual void main_loop(); - -public: - virtual ~mb_mblock(); - - //! Return instance name of this block - std::string instance_name() const; - - //! Return the class name of this block - std::string class_name() const; - - //! Set the instance name of this block. - void set_instance_name(const std::string &name); - - //! Return the parent of this mblock, or 0 if we're the top-level block. - mb_mblock *parent() const; - - /*! - * \brief Schedule a "one shot" timeout. - * - * \param abs_time the absolute time at which the timeout should fire - * \param user_data the data passed in the %timeout message. - * - * When the timeout fires, a message will be sent to the mblock. - * - * The message will have port_id = %sys-port, signal = %timeout, - * data = user_data, metadata = the handle returned from - * schedule_one_shot_timeout, pri = MB_PRI_BEST. - * - * \returns a handle that can be used in cancel_timeout, and is passed - * as the metadata field of the generated %timeout message. - * - * To cancel a pending timeout, call cancel_timeout. - */ - pmt::pmt_t - schedule_one_shot_timeout(const mb_time &abs_time, pmt::pmt_t user_data); - - /*! - * \brief Schedule a periodic timeout. - * - * \param first_abs_time The absolute time at which the first timeout should fire. - * \param delta_time The relative delay between the first and successive timeouts. - * \param user_data the data passed in the %timeout message. - * - * When the timeout fires, a message will be sent to the mblock, and a - * new timeout will be scheduled for previous absolute time + delta_time. - * - * The message will have port_id = %sys-port, signal = %timeout, - * data = user_data, metadata = the handle returned from - * schedule_one_shot_timeout, pri = MB_PRI_BEST. - * - * \returns a handle that can be used in cancel_timeout, and is passed - * as the metadata field of the generated %timeout message. - * - * To cancel a pending timeout, call cancel_timeout. - */ - pmt::pmt_t - schedule_periodic_timeout(const mb_time &first_abs_time, - const mb_time &delta_time, - pmt::pmt_t user_data); - - /*! - * \brief Attempt to cancel a pending timeout. - * - * Note that this only stops a future timeout from firing. It is - * possible that a timeout may have already fired and enqueued a - * %timeout message, but that that message has not yet been seen by - * handle_message. - * - * \param handle returned from schedule_one_shot_timeout or schedule_periodic_timeout. - */ - void cancel_timeout(pmt::pmt_t handle); - - /*! - * \brief Perform a pre-order depth-first traversal of the hierarchy. - * - * The traversal stops and returns false if any call to visitor returns false. - */ - bool - walk_tree(mb_visitor *visitor); - - - //! \internal - // internal use only - mb_mblock_impl_sptr - impl() const { return d_impl; } - -}; - - -#endif /* INCLUDED_MB_MBLOCK_H */ diff --git a/mblock/src/include/mblock/message.h b/mblock/src/include/mblock/message.h deleted file mode 100644 index 4051d0c8e..000000000 --- a/mblock/src/include/mblock/message.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_MESSAGE_H -#define INCLUDED_MB_MESSAGE_H - -#include <mblock/common.h> -#include <iosfwd> - -#define MB_MESSAGE_LOCAL_ALLOCATOR 0 // define to 0 or 1 - -class mb_message; -typedef boost::shared_ptr<mb_message> mb_message_sptr; - -/*! - * \brief construct a message and return boost::shared_ptr - * - * \param signal identifier of the message - * \param data the data to be operated on - * \param metadata information about the data - * \param priority urgency - */ -mb_message_sptr -mb_make_message(pmt::pmt_t signal, - pmt::pmt_t data = pmt::PMT_NIL, - pmt::pmt_t metadata = pmt::PMT_NIL, - mb_pri_t priority = MB_PRI_DEFAULT); - -class mb_message { - mb_message_sptr d_next; // link field for msg queue - pmt::pmt_t d_signal; - pmt::pmt_t d_data; - pmt::pmt_t d_metadata; - mb_pri_t d_priority; - pmt::pmt_t d_port_id; // name of port msg was rcvd on (symbol) - - friend class mb_msg_queue; - - friend mb_message_sptr - mb_make_message(pmt::pmt_t signal, pmt::pmt_t data, pmt::pmt_t metadata, mb_pri_t priority); - - // private constructor - mb_message(pmt::pmt_t signal, pmt::pmt_t data, pmt::pmt_t metadata, mb_pri_t priority); - -public: - ~mb_message(); - - pmt::pmt_t signal() const { return d_signal; } - pmt::pmt_t data() const { return d_data; } - pmt::pmt_t metadata() const { return d_metadata; } - mb_pri_t priority() const { return d_priority; } - pmt::pmt_t port_id() const { return d_port_id; } - - void set_port_id(pmt::pmt_t port_id){ d_port_id = port_id; } - -#if (MB_MESSAGE_LOCAL_ALLOCATOR) - void *operator new(size_t); - void operator delete(void *, size_t); -#endif -}; - -std::ostream& operator<<(std::ostream& os, const mb_message &msg); - -inline -std::ostream& operator<<(std::ostream& os, const mb_message_sptr msg) -{ - os << *(msg.get()); - return os; -} - -#endif /* INCLUDED_MB_MESSAGE_H */ diff --git a/mblock/src/include/mblock/msg_accepter.h b/mblock/src/include/mblock/msg_accepter.h deleted file mode 100644 index 7dc1e50cb..000000000 --- a/mblock/src/include/mblock/msg_accepter.h +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_MSG_ACCEPTER_H -#define INCLUDED_MB_MSG_ACCEPTER_H - -#include <mblock/common.h> - -/*! - * \brief Abstract class that accepts messages - * - * The mb_port::send method ultimately resolves the (local) - * destination of a send to an object of this type. The resulting - * object is called to deliver the message. - * - * Expect derived classes such as these: - * - * smp : target is visible in this address space - * mpi : target is on the other end of an MPI link - * ppe->spe : sending from Cell PPE to Cell SPE - * spe->ppe : sending from Cell SPE to Cell PPE - */ -class mb_msg_accepter { -public: - mb_msg_accepter(){}; - virtual ~mb_msg_accepter(); - - virtual void operator()(pmt::pmt_t signal, pmt::pmt_t data, pmt::pmt_t metadata, mb_pri_t priority) = 0; -}; - -#endif /* INCLUDED_MB_MSG_ACCEPTER_H */ diff --git a/mblock/src/include/mblock/msg_queue.h b/mblock/src/include/mblock/msg_queue.h deleted file mode 100644 index a23397081..000000000 --- a/mblock/src/include/mblock/msg_queue.h +++ /dev/null @@ -1,82 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_MSG_QUEUE_H -#define INCLUDED_MB_MSG_QUEUE_H - -#include <mblock/common.h> -#include <gnuradio/omnithread.h> -#include <mblock/time.h> - -/*! - * \brief priority queue for mblock messages - */ -class mb_msg_queue : boost::noncopyable -{ - // When empty both head and tail are zero. - struct subq { - mb_message_sptr head; - mb_message_sptr tail; - - bool empty_p() const { return head == 0; } - }; - - omni_mutex d_mutex; - omni_condition d_not_empty; // reader waits on this - - // FIXME add bitmap to indicate which queues are non-empty. - subq d_queue[MB_NPRI]; - - mb_message_sptr get_highest_pri_msg_helper(); - -public: - mb_msg_queue(); - ~mb_msg_queue(); - - //! Insert \p msg into priority queue. - void insert(mb_message_sptr msg); - - /* - * \brief Delete highest pri message from the queue and return it. - * Returns equivalent of zero pointer if queue is empty. - */ - mb_message_sptr get_highest_pri_msg_nowait(); - - /* - * \brief Delete highest pri message from the queue and return it. - * If the queue is empty, this call blocks until it can return a message. - */ - mb_message_sptr get_highest_pri_msg(); - - /* - * \brief Delete highest pri message from the queue and return it. - * If the queue is empty, this call blocks until it can return a message - * or real-time exceeds the absolute time, abs_time. - * - * \param abs_time specifies the latest absolute time to wait until. - * \sa mb_time::time - * - * \returns a valid mb_message_sptr, or the equivalent of a zero pointer - * if the call timed out while waiting. - */ - mb_message_sptr get_highest_pri_msg_timedwait(const mb_time &abs_time); -}; - -#endif /* INCLUDED_MB_MSG_QUEUE_H */ diff --git a/mblock/src/include/mblock/port.h b/mblock/src/include/mblock/port.h deleted file mode 100644 index 1664765db..000000000 --- a/mblock/src/include/mblock/port.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_PORT_H -#define INCLUDED_MB_PORT_H - -#include <mblock/common.h> - -/*! - * \brief Abstract port characteristics - */ -class mb_port : boost::noncopyable -{ -public: - - //! port classification - enum port_type_t { - EXTERNAL, //< Externally visible - RELAY, //< Externally visible but really connected to a sub-component - INTERNAL //< Visible to self only - }; - -private: - - std::string d_port_name; - pmt::pmt_t d_port_symbol; // the port_name as a pmt::pmt symbol - pmt::pmt_t d_protocol_class; - bool d_conjugated; - port_type_t d_port_type; - -protected: - mb_mblock *d_mblock; // mblock we're defined in - - // protected constructor - mb_port(mb_mblock *mblock, - const std::string &port_name, - const std::string &protocol_class_name, - bool conjugated, - mb_port::port_type_t port_type); - - mb_mblock *mblock() const { return d_mblock; } - -public: - std::string port_name() const { return d_port_name; } - pmt::pmt_t port_symbol() const { return d_port_symbol; } - pmt::pmt_t protocol_class() const { return d_protocol_class; } - bool conjugated() const { return d_conjugated; } - port_type_t port_type() const { return d_port_type; } - - pmt::pmt_t incoming_message_set() const; - pmt::pmt_t outgoing_message_set() const; - - virtual ~mb_port(); - - /*! - * \brief send a message - * - * \param signal the event name - * \param data optional data - * \param metadata optional metadata - * \param priority the urgency at which the message is sent - */ - virtual void - send(pmt::pmt_t signal, - pmt::pmt_t data = pmt::PMT_F, - pmt::pmt_t metadata = pmt::PMT_F, - mb_pri_t priority = MB_PRI_DEFAULT) = 0; - - /* - * \brief Invalidate any cached peer resolutions - * \internal - */ - virtual void invalidate_cache() = 0; -}; - -#endif /* INCLUDED_MB_PORT_H */ diff --git a/mblock/src/include/mblock/protocol_class.h b/mblock/src/include/mblock/protocol_class.h deleted file mode 100644 index a01e68d8f..000000000 --- a/mblock/src/include/mblock/protocol_class.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_PROTOCOL_CLASS_H -#define INCLUDED_MB_PROTOCOL_CLASS_H - -#include <mblock/common.h> - -/*! - * \brief construct a protocol_class - * - * \param name the name of the class (symbol) - * \param incoming incoming message set (list of symbols) - * \param outgoing outgoing message set (list of symbols) - */ -pmt::pmt_t mb_make_protocol_class(pmt::pmt_t name, pmt::pmt_t incoming, pmt::pmt_t outgoing); - -// Accessors -pmt::pmt_t mb_protocol_class_name(pmt::pmt_t pc); //< return name of protocol class -pmt::pmt_t mb_protocol_class_incoming(pmt::pmt_t pc); //< return incoming message set -pmt::pmt_t mb_protocol_class_outgoing(pmt::pmt_t pc); //< return outgoing message set - -pmt::pmt_t mb_protocol_class_lookup(pmt::pmt_t name); //< lookup an existing protocol class by name - - -/*! - * \brief Initialize one or more protocol class from a serialized description. - * Used by machine generated code. - */ -class mb_protocol_class_init { -public: - mb_protocol_class_init(const char *data, size_t len); -}; - -#endif /* INCLUDED_MB_PROTOCOL_CLASS_H */ diff --git a/mblock/src/include/mblock/runtime.h b/mblock/src/include/mblock/runtime.h deleted file mode 100644 index 9afc38b76..000000000 --- a/mblock/src/include/mblock/runtime.h +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_RUNTIME_H -#define INCLUDED_MB_RUNTIME_H - -#include <mblock/common.h> -#include <gnuradio/omnithread.h> - -/*! - * \brief Public constructor (factory) for mb_runtime objects. - */ -mb_runtime_sptr mb_make_runtime(); - -/*! - * \brief Abstract runtime support for m-blocks - * - * There should generally be only a single instance of this class. - */ -class mb_runtime : boost::noncopyable, - public boost::enable_shared_from_this<mb_runtime> -{ -protected: - mb_mblock_sptr d_top; - -public: - mb_runtime(){} - virtual ~mb_runtime(); - - /*! - * \brief Construct and run the specified mblock hierarchy. - * - * This routine turns into the m-block scheduler, and - * blocks until the system is shutdown. - * - * \param instance_name name of the top-level mblock (conventionally "top") - * \param class_name The class of the top-level mblock to create. - * \param user_arg The argument to pass to the top-level mblock constructor - * \param result The value passed to shutdown_all. - * - * \returns true if the system ran successfully. - */ - virtual bool run(const std::string &instance_name, - const std::string &class_name, - pmt::pmt_t user_arg, - pmt::pmt_t *result = 0) = 0; - - // QA only... - mb_mblock_sptr top() { return d_top; } -}; - -#endif /* INCLUDED_MB_RUNTIME_H */ diff --git a/mblock/src/include/mblock/time.h b/mblock/src/include/mblock/time.h deleted file mode 100644 index 630fa845c..000000000 --- a/mblock/src/include/mblock/time.h +++ /dev/null @@ -1,27 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_TIME_H -#define INCLUDED_MB_TIME_H - -#include <gnuradio/omni_time.h> -typedef omni_time mb_time; - -#endif /* INCLUDED_MB_TIME_H */ diff --git a/mblock/src/lib/.gitignore b/mblock/src/lib/.gitignore deleted file mode 100644 index b2a2f45a7..000000000 --- a/mblock/src/lib/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/test_mblock -/qa_bitset_mbh.cc -/benchmark_send -/getres diff --git a/mblock/src/lib/Makefile.am b/mblock/src/lib/Makefile.am deleted file mode 100644 index dbdfcdd9d..000000000 --- a/mblock/src/lib/Makefile.am +++ /dev/null @@ -1,132 +0,0 @@ -# -# Copyright 2006,2007,2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -AM_CPPFLAGS = $(DEFINES) $(OMNITHREAD_INCLUDES) $(GRUEL_INCLUDES) \ - $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) $(WITH_INCLUDES) \ - $(MBLOCK_INCLUDES) - -# disable test until we fix ticket:180 -# TESTS = test_mblock - -lib_LTLIBRARIES = libmblock.la libmblock-qa.la - -EXTRA_DIST = \ - README.locking \ - qa_bitset.mbh - - -BUILT_SOURCES = \ - qa_bitset_mbh.cc - -qa_bitset_mbh.cc : qa_bitset.mbh - $(COMPILE_MBH) $(srcdir)/qa_bitset.mbh qa_bitset_mbh.cc - -# These are the source files that go into the mblock shared library -libmblock_la_SOURCES = \ - mb_class_registry.cc \ - mb_connection.cc \ - mb_endpoint.cc \ - mb_exception.cc \ - mb_gettid.cc \ - mb_mblock.cc \ - mb_mblock_impl.cc \ - mb_message.cc \ - mb_msg_accepter.cc \ - mb_msg_accepter_msgq.cc \ - mb_msg_accepter_smp.cc \ - mb_msg_queue.cc \ - mb_port.cc \ - mb_port_simple.cc \ - mb_protocol_class.cc \ - mb_runtime.cc \ - mb_runtime_base.cc \ - mb_runtime_nop.cc \ - mb_runtime_thread_per_block.cc \ - mb_timer_queue.cc \ - mb_util.cc \ - mb_worker.cc - - -# magic flags -libmblock_la_LDFLAGS = $(NO_UNDEFINED) - -# link the library against the c++ standard library -libmblock_la_LIBADD = \ - $(OMNITHREAD_LA) \ - $(GRUEL_LA) \ - -lstdc++ - -noinst_HEADERS = \ - mb_gettid.h \ - mb_msg_accepter_msgq.h \ - mb_port_simple.h \ - mb_util.h \ - mb_connection.h \ - mb_endpoint.h \ - mb_mblock_impl.h \ - mb_msg_accepter_smp.h \ - mb_runtime_base.h \ - mb_runtime_nop.h \ - mb_runtime_thread_per_block.h \ - mb_timer_queue.h \ - mb_worker.h \ - mbi_runtime_lock.h \ - qa_mblock.h \ - qa_mblock_prims.h \ - qa_mblock_send.h \ - qa_mblock_sys.h \ - qa_timeouts.h - - -# Build the qa code into its own library - -libmblock_qa_la_SOURCES = \ - qa_bitset.cc \ - qa_bitset_mbh.cc \ - qa_disconnect.cc \ - qa_mblock.cc \ - qa_mblock_prims.cc \ - qa_mblock_send.cc \ - qa_mblock_sys.cc \ - qa_timeouts.cc - - -# magic flags -libmblock_qa_la_LDFLAGS = $(NO_UNDEFINED) -avoid-version - -# link the library against the c++ standard library -libmblock_qa_la_LIBADD = \ - libmblock.la \ - $(CPPUNIT_LIBS) \ - -lstdc++ - - -noinst_PROGRAMS = \ - test_mblock \ - benchmark_send - -test_mblock_SOURCES = test_mblock.cc -test_mblock_LDADD = libmblock-qa.la - -benchmark_send_SOURCES = benchmark_send.cc -benchmark_send_LDADD = libmblock-qa.la diff --git a/mblock/src/lib/README.locking b/mblock/src/lib/README.locking deleted file mode 100644 index 12d4735e7..000000000 --- a/mblock/src/lib/README.locking +++ /dev/null @@ -1,4 +0,0 @@ -The Big Runtime Lock must be held when: - -Manipulating or traversing any mblock's d_port_map, d_comp_map or d_conn_table. - diff --git a/mblock/src/lib/benchmark_send.cc b/mblock/src/lib/benchmark_send.cc deleted file mode 100644 index a02b37c0d..000000000 --- a/mblock/src/lib/benchmark_send.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <mblock/runtime.h> -#include <iostream> - -using namespace pmt; - -int -main(int argc, char **argv) -{ - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - long nmsgs = 1000000; - long batch_size = 100; - - pmt_t arg = pmt_list2(pmt_from_long(nmsgs), // # of messages to send through pipe - pmt_from_long(batch_size)); - - rt->run("top", "qa_bitset_top", arg, &result); - - if (!pmt_equal(PMT_T, result)){ - std::cerr << "benchmark_send: incorrect result"; - return 1; - } - - return 0; -} diff --git a/mblock/src/lib/getres.cc b/mblock/src/lib/getres.cc deleted file mode 100644 index c05ba792a..000000000 --- a/mblock/src/lib/getres.cc +++ /dev/null @@ -1,32 +0,0 @@ -#include <time.h> -#include <stdio.h> - -int -main(int argc, char **argv) -{ - bool ok = true; - struct timespec ts; - int r; - - r = clock_getres(CLOCK_REALTIME, &ts); - if (r != 0){ - perror("clock_getres(CLOCK_REALTIME, ...)"); - ok = false; - } - else - printf("clock_getres(CLOCK_REALTIME, ...) => %11.9f\n", - (double) ts.tv_sec + ts.tv_nsec * 1e-9); - - - r = clock_getres(CLOCK_MONOTONIC, &ts); - if (r != 0){ - perror("clock_getres(CLOCK_MONOTONIC, ..."); - ok = false; - } - else - printf("clock_getres(CLOCK_MONOTONIC, ...) => %11.9f\n", - (double) ts.tv_sec + ts.tv_nsec * 1e-9); - - - return ok == true ? 0 : 1; -} diff --git a/mblock/src/lib/mb_class_registry.cc b/mblock/src/lib/mb_class_registry.cc deleted file mode 100644 index 7ccee2969..000000000 --- a/mblock/src/lib/mb_class_registry.cc +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mblock/class_registry.h> -#include <map> - -static std::map<std::string, mb_mblock_maker_t> s_registry; - -bool -mb_class_registry::register_maker(const std::string &name, mb_mblock_maker_t maker) -{ - s_registry[name] = maker; - return true; -} - -bool -mb_class_registry::lookup_maker(const std::string &name, mb_mblock_maker_t *maker) -{ - if (s_registry.count(name) == 0){ // not registered - *maker = (mb_mblock_maker_t) 0; - return false; - } - - *maker = s_registry[name]; - return true; -} diff --git a/mblock/src/lib/mb_connection.cc b/mblock/src/lib/mb_connection.cc deleted file mode 100644 index 7e3bb8977..000000000 --- a/mblock/src/lib/mb_connection.cc +++ /dev/null @@ -1,126 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mb_connection.h> - -bool -mb_conn_table::lookup_conn_by_name(const std::string &component_name, - const std::string &port_name, - mb_conn_iter *itp, int *which_ep) -{ - mb_conn_iter end = d_connections.end(); - for (mb_conn_iter it = d_connections.begin(); it != end; ++it){ - - if (it->d_ep[0].component_name() == component_name - && it->d_ep[0].port_name() == port_name){ - *itp = it; - *which_ep = 0; - return true; - } - - if (it->d_ep[1].component_name() == component_name - && it->d_ep[1].port_name() == port_name){ - *itp = it; - *which_ep = 1; - return true; - } - } - - return false; -} - -bool -mb_conn_table::lookup_conn_by_port(const mb_port *port, - mb_conn_iter *itp, int *which_ep) -{ - mb_conn_iter end = d_connections.end(); - for (mb_conn_iter it = d_connections.begin(); it != end; ++it){ - if (it->d_ep[0].port().get() == port){ - *itp = it; - *which_ep = 0; - return true; - } - if (it->d_ep[1].port().get() == port){ - *itp = it; - *which_ep = 1; - return true; - } - } - - return false; -} - -void -mb_conn_table::create_conn(const mb_endpoint &ep0, const mb_endpoint &ep1) -{ - d_connections.push_back(mb_connection(ep0, ep1)); -} - -void -mb_conn_table::disconnect(const std::string &comp_name1, const std::string &port_name1, - const std::string &comp_name2, const std::string &port_name2) -{ - mb_conn_iter it; - int which_ep; - - // look for comp_name1/port_name1 - bool found = lookup_conn_by_name(comp_name1, port_name1, &it, &which_ep); - - if (!found) // no error if not found - return; - - // FIXME if/when we do replicated ports, we may have one-to-many, - // or many-to-many bindings. For now, be paranoid - assert(it->d_ep[which_ep^1].component_name() == comp_name2); - assert(it->d_ep[which_ep^1].port_name() == port_name2); - - d_connections.erase(it); // Poof! -} - -void -mb_conn_table::disconnect_component(const std::string component_name) -{ - mb_conn_iter next; - mb_conn_iter end = d_connections.end(); - for (mb_conn_iter it = d_connections.begin(); it != end; it = next){ - if (it->d_ep[0].component_name() == component_name - || it->d_ep[1].component_name() == component_name) - next = d_connections.erase(it); // Poof! - else - next = ++it; - } -} - -void -mb_conn_table::disconnect_all() -{ - d_connections.clear(); // All gone! -} - -int -mb_conn_table::nconnections() const -{ - return d_connections.size(); -} diff --git a/mblock/src/lib/mb_connection.h b/mblock/src/lib/mb_connection.h deleted file mode 100644 index 2aa604054..000000000 --- a/mblock/src/lib/mb_connection.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef INCLUDED_MB_CONNECTION_H -#define INCLUDED_MB_CONNECTION_H - -#include <mb_endpoint.h> -#include <list> - -/*! - * \brief Representation of a connection - */ -struct mb_connection { - mb_endpoint d_ep[2]; - - mb_connection(const mb_endpoint &ep0, const mb_endpoint &ep1){ - d_ep[0] = ep0; - d_ep[1] = ep1; - } -}; - -typedef std::list<mb_connection>::iterator mb_conn_iter; -typedef std::list<mb_connection>::const_iterator mb_conn_const_iter; - -/*! - * \brief data structure that keeps track of connections - */ -class mb_conn_table { - std::list<mb_connection> d_connections; - -public: - bool - lookup_conn_by_name(const std::string &component_name, - const std::string &port_name, - mb_conn_iter *it, int *which_ep); - - bool - lookup_conn_by_port(const mb_port *port, - mb_conn_iter *it, int *which_ep); - - void - create_conn(const mb_endpoint &ep0, const mb_endpoint &ep1); - - - void - disconnect(const std::string &comp_name1, const std::string &port_name1, - const std::string &comp_name2, const std::string &port_name2); - - void - disconnect_component(const std::string component_name); - - void - disconnect_all(); - - int - nconnections() const; - -}; - -#endif /* INCLUDED_MB_CONNECTION_H */ diff --git a/mblock/src/lib/mb_endpoint.cc b/mblock/src/lib/mb_endpoint.cc deleted file mode 100644 index 721c66b8c..000000000 --- a/mblock/src/lib/mb_endpoint.cc +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mb_endpoint.h> - -using namespace pmt; - -bool -mb_endpoint::inside_of_relay_port_p() const -{ - return d_port->port_type() == mb_port::RELAY && d_component_name == "self"; -} - -pmt_t -mb_endpoint::incoming_message_set() const -{ - if (inside_of_relay_port_p()) // swap incoming and outgoing - return port()->outgoing_message_set(); - else - return port()->incoming_message_set(); -} - -pmt_t -mb_endpoint::outgoing_message_set() const -{ - if (inside_of_relay_port_p()) // swap incoming and outgoing - return port()->incoming_message_set(); - else - return port()->outgoing_message_set(); -} diff --git a/mblock/src/lib/mb_endpoint.h b/mblock/src/lib/mb_endpoint.h deleted file mode 100644 index c4d8b6114..000000000 --- a/mblock/src/lib/mb_endpoint.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef INCLUDED_MB_ENDPOINT_H -#define INCLUDED_MB_ENDPOINT_H - -#include <string> -#include <mblock/port.h> - -/*! - * \brief Endpoint specification for connection - */ -class mb_endpoint -{ - std::string d_component_name; - std::string d_port_name; - mb_port_sptr d_port; // the port object that this maps to - -public: - mb_endpoint(){} - - mb_endpoint(const std::string &component_name, - const std::string &port_name, - mb_port_sptr port) - : d_component_name(component_name), - d_port_name(port_name), - d_port(port) {} - - const std::string &component_name() const { return d_component_name; } - const std::string &port_name() const { return d_port_name; } - mb_port_sptr port() const { return d_port; } - - //! Does this endpoint represent the inside of a relay port - bool inside_of_relay_port_p() const; - - pmt::pmt_t incoming_message_set() const; - pmt::pmt_t outgoing_message_set() const; -}; - -#endif /* INCLUDED_MB_ENDPOINT_H */ diff --git a/mblock/src/lib/mb_exception.cc b/mblock/src/lib/mb_exception.cc deleted file mode 100644 index 810131840..000000000 --- a/mblock/src/lib/mb_exception.cc +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/exception.h> -#include <mblock/mblock.h> -#include <mb_util.h> - - -mbe_base::mbe_base(mb_mblock *mb, const std::string &msg) - : logic_error(msg) // FIXME extract block class name and id and add to msg -{ -} - -mbe_not_implemented::mbe_not_implemented(mb_mblock *mb, const std::string &msg) - : mbe_base(mb, "Not implemented: " + msg) -{ -} - -mbe_no_such_class::mbe_no_such_class(mb_mblock *mb, const std::string &class_name) - : mbe_base(mb, "No such class: " + class_name) -{ -} - -mbe_no_such_component::mbe_no_such_component(mb_mblock *mb, const std::string &component_name) - : mbe_base(mb, "No such component: " + component_name) -{ -} - - -mbe_duplicate_component::mbe_duplicate_component(mb_mblock *mb, const std::string &component_name) - : mbe_base(mb, "Duplicate component: " + component_name) -{ -} - -mbe_no_such_port::mbe_no_such_port(mb_mblock *mb, const std::string &port_name) - : mbe_base(mb, "No such port: " + port_name) -{ -} - -mbe_duplicate_port::mbe_duplicate_port(mb_mblock *mb, const std::string &port_name) - : mbe_base(mb, "Duplicate port: " + port_name) -{ -} - -mbe_already_connected::mbe_already_connected(mb_mblock *mb, - const std::string &comp_name, - const std::string &port_name) - : mbe_base(mb, "Port already connected: " + mb_util::join_names(comp_name, port_name)) -{ -} - - - -mbe_incompatible_ports::mbe_incompatible_ports(mb_mblock *mb, - const std::string &comp1_name, - const std::string &port1_name, - const std::string &comp2_name, - const std::string &port2_name) - : mbe_base(mb, "Incompatible ports: " - + mb_util::join_names(comp1_name, port1_name) + " " - + mb_util::join_names(comp2_name, port2_name)) -{ -} - -mbe_invalid_port_type::mbe_invalid_port_type(mb_mblock *mb, - const std::string &comp_name, - const std::string &port_name) - : mbe_base(mb, "Invalid port type for connection: " + mb_util::join_names(comp_name, port_name)) -{ -} - -mbe_mblock_failed::mbe_mblock_failed(mb_mblock *mb, - const std::string &msg) - : mbe_base(mb, "Message block failed: " + msg) -{ -} - -mbe_terminate::mbe_terminate() -{ -} - -mbe_exit::mbe_exit() -{ -} diff --git a/mblock/src/lib/mb_gettid.cc b/mblock/src/lib/mb_gettid.cc deleted file mode 100644 index 9383d35ac..000000000 --- a/mblock/src/lib/mb_gettid.cc +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mb_gettid.h> - -#define NEED_STUB - -#if defined(HAVE_SYS_SYSCALL_H) && defined(HAVE_UNISTD_H) - -#include <sys/syscall.h> -#include <unistd.h> - -#if defined(SYS_gettid) -#undef NEED_STUB - -int mb_gettid() -{ - return syscall(SYS_gettid); -} - -#endif -#endif - -#if defined(NEED_STUB) - -int -mb_gettid() -{ - return 0; -} - -#endif diff --git a/mblock/src/lib/mb_gettid.h b/mblock/src/lib/mb_gettid.h deleted file mode 100644 index adbad126c..000000000 --- a/mblock/src/lib/mb_gettid.h +++ /dev/null @@ -1,26 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -/*! - * \brief Return Linux taskid, or 0 if not available - */ -int mb_gettid(); - diff --git a/mblock/src/lib/mb_mblock.cc b/mblock/src/lib/mb_mblock.cc deleted file mode 100644 index 2e77dc4af..000000000 --- a/mblock/src/lib/mb_mblock.cc +++ /dev/null @@ -1,230 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/mblock.h> -#include <mb_mblock_impl.h> -#include <mblock/runtime.h> -#include <mblock/exception.h> -#include <iostream> - -using namespace pmt; - -static pmt_t s_sys_port = pmt_intern("%sys-port"); -static pmt_t s_halt = pmt_intern("%halt"); - -mb_visitor::~mb_visitor() -{ - // nop base case for virtual destructor. -} - - -mb_mblock::mb_mblock(mb_runtime *runtime, - const std::string &instance_name, - pmt_t user_arg) - : d_impl(mb_mblock_impl_sptr( - new mb_mblock_impl(dynamic_cast<mb_runtime_base*>(runtime), - this, instance_name))) -{ -} - -mb_mblock::~mb_mblock() -{ -} - - -void -mb_mblock::initial_transition() -{ - // default implementation does nothing -} - -void -mb_mblock::handle_message(mb_message_sptr msg) -{ - // default implementation does nothing -} - - -void -mb_mblock::main_loop() -{ - while (1){ - mb_message_sptr msg; - try { - while (1){ - msg = impl()->msgq().get_highest_pri_msg(); - - // check for %halt from %sys-port - if (pmt_eq(msg->port_id(), s_sys_port) && pmt_eq(msg->signal(), s_halt)) - exit(); - - handle_message(msg); - } - } - catch (pmt_exception e){ - std::cerr << "\nmb_mblock::main_loop: ignored pmt_exception: " - << e.what() - << "\nin mblock instance \"" << instance_name() - << "\" while handling message:" - << "\n port_id = " << msg->port_id() - << "\n signal = " << msg->signal() - << "\n data = " << msg->data() - << "\n metatdata = " << msg->metadata() << std::endl; - } - } -} - -//////////////////////////////////////////////////////////////////////// -// Forward other methods to implementation class // -//////////////////////////////////////////////////////////////////////// - -mb_port_sptr -mb_mblock::define_port(const std::string &port_name_string, - const std::string &protocol_class_name, - bool conjugated, - mb_port::port_type_t port_type) -{ - return d_impl->define_port(port_name_string, protocol_class_name, - conjugated, port_type); -} - -void -mb_mblock::define_component(const std::string &component_name, - const std::string &class_name, - pmt_t user_arg) - -{ - d_impl->define_component(component_name, class_name, user_arg); -} - -void -mb_mblock::connect(const std::string &comp_name1, const std::string &port_name1, - const std::string &comp_name2, const std::string &port_name2) -{ - d_impl->connect(comp_name1, port_name1, - comp_name2, port_name2); -} - - -void -mb_mblock::disconnect(const std::string &comp_name1, const std::string &port_name1, - const std::string &comp_name2, const std::string &port_name2) -{ - d_impl->disconnect(comp_name1, port_name1, - comp_name2, port_name2); -} - -void -mb_mblock::disconnect_component(const std::string &component_name) -{ - d_impl->disconnect_component(component_name); -} - -void -mb_mblock::disconnect_all() -{ - d_impl->disconnect_all(); -} - -int -mb_mblock::nconnections() const -{ - return d_impl->nconnections(); -} - -bool -mb_mblock::walk_tree(mb_visitor *visitor) -{ - return d_impl->walk_tree(visitor); -} - -std::string -mb_mblock::instance_name() const -{ - return d_impl->instance_name(); -} - -void -mb_mblock::set_instance_name(const std::string &name) -{ - d_impl->set_instance_name(name); -} - -std::string -mb_mblock::class_name() const -{ - return d_impl->class_name(); -} - -void -mb_mblock::set_class_name(const std::string &name) -{ - d_impl->set_class_name(name); -} - -mb_mblock * -mb_mblock::parent() const -{ - return d_impl->mblock_parent(); -} - -void -mb_mblock::exit() -{ - throw mbe_exit(); // adios... -} - -void -mb_mblock::shutdown_all(pmt_t result) -{ - d_impl->runtime()->request_shutdown(result); -} - -pmt_t -mb_mblock::schedule_one_shot_timeout(const mb_time &abs_time, pmt_t user_data) -{ - mb_msg_accepter_sptr accepter = impl()->make_accepter(s_sys_port); - return d_impl->runtime()->schedule_one_shot_timeout(abs_time, user_data, - accepter); -} - -pmt_t -mb_mblock::schedule_periodic_timeout(const mb_time &first_abs_time, - const mb_time &delta_time, - pmt_t user_data) -{ - mb_msg_accepter_sptr accepter = impl()->make_accepter(s_sys_port); - return d_impl->runtime()->schedule_periodic_timeout(first_abs_time, - delta_time, - user_data, - accepter); -} - -void -mb_mblock::cancel_timeout(pmt_t handle) -{ - d_impl->runtime()->cancel_timeout(handle); -} - diff --git a/mblock/src/lib/mb_mblock_impl.cc b/mblock/src/lib/mb_mblock_impl.cc deleted file mode 100644 index 8a1784f4d..000000000 --- a/mblock/src/lib/mb_mblock_impl.cc +++ /dev/null @@ -1,328 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mb_mblock_impl.h> -#include <mblock/mblock.h> -#include <mblock/protocol_class.h> -#include <mblock/port.h> -#include <mb_port_simple.h> -#include <mblock/exception.h> -#include <mb_util.h> -#include <mb_msg_accepter_smp.h> -#include <mbi_runtime_lock.h> -#include <iostream> - -using namespace pmt; - -static pmt_t s_self = pmt_intern("self"); - -//////////////////////////////////////////////////////////////////////// - -bool -mb_mblock_impl::port_is_defined(const std::string &name) -{ - return d_port_map.count(name) != 0; -} - -bool -mb_mblock_impl::comp_is_defined(const std::string &name) -{ - return name == "self" || d_comp_map.count(name) != 0; -} - -//////////////////////////////////////////////////////////////////////// - -mb_mblock_impl::mb_mblock_impl(mb_runtime_base *runtime, mb_mblock *mb, - const std::string &instance_name) - : d_runtime(runtime), d_mb(mb), d_mb_parent(0), - d_instance_name(instance_name), d_class_name("mblock") -{ -} - -mb_mblock_impl::~mb_mblock_impl() -{ - d_mb = 0; // we don't own it -} - - -mb_port_sptr -mb_mblock_impl::define_port(const std::string &port_name, - const std::string &protocol_class_name, - bool conjugated, - mb_port::port_type_t port_type) -{ - mbi_runtime_lock l(this); - - if (port_is_defined(port_name)) - throw mbe_duplicate_port(d_mb, port_name); - - mb_port_sptr p = - mb_port_sptr(new mb_port_simple(d_mb, - port_name, protocol_class_name, - conjugated, port_type)); - d_port_map[port_name] = p; - return p; -} - -void -mb_mblock_impl::define_component(const std::string &name, - const std::string &class_name, - pmt_t user_arg) -{ - { - mbi_runtime_lock l(this); - - if (comp_is_defined(name)) // check for duplicate name - throw mbe_duplicate_component(d_mb, name); - } - - // We ask the runtime to create the component so that it can worry about - // mblock placement on a NUMA machine or on a distributed multicomputer - - mb_mblock_sptr component = - d_runtime->create_component(instance_name() + "/" + name, - class_name, user_arg); - { - mbi_runtime_lock l(this); - - component->d_impl->d_mb_parent = d_mb; // set component's parent link - d_comp_map[name] = component; - } -} - -void -mb_mblock_impl::connect(const std::string &comp_name1, - const std::string &port_name1, - const std::string &comp_name2, - const std::string &port_name2) -{ - mbi_runtime_lock l(this); - - mb_endpoint ep0 = check_and_resolve_endpoint(comp_name1, port_name1); - mb_endpoint ep1 = check_and_resolve_endpoint(comp_name2, port_name2); - - if (!endpoints_are_compatible(ep0, ep1)) - throw mbe_incompatible_ports(d_mb, - comp_name1, port_name1, - comp_name2, port_name2); - // FIXME more checks? - - d_conn_table.create_conn(ep0, ep1); -} - -void -mb_mblock_impl::disconnect(const std::string &comp_name1, - const std::string &port_name1, - const std::string &comp_name2, - const std::string &port_name2) -{ - mbi_runtime_lock l(this); - - d_conn_table.disconnect(comp_name1, port_name1, comp_name2, port_name2); - invalidate_all_port_caches(); -} - -void -mb_mblock_impl::disconnect_component(const std::string component_name) -{ - mbi_runtime_lock l(this); - - d_conn_table.disconnect_component(component_name); - invalidate_all_port_caches(); -} - -void -mb_mblock_impl::disconnect_all() -{ - mbi_runtime_lock l(this); - - d_conn_table.disconnect_all(); - invalidate_all_port_caches(); -} - -int -mb_mblock_impl::nconnections() -{ - mbi_runtime_lock l(this); - - return d_conn_table.nconnections(); -} - -//////////////////////////////////////////////////////////////////////// - -mb_endpoint -mb_mblock_impl::check_and_resolve_endpoint(const std::string &comp_name, - const std::string &port_name) -{ - mb_conn_iter it; - int which_ep; - mb_port_sptr port = resolve_port(comp_name, port_name); - - // Confirm that we're not trying to connect to the inside of one of - // our EXTERNAL ports. Connections that include "self" as the - // component name must be either INTERNAL or RELAY. - - if (comp_name == "self" && port->port_type() == mb_port::EXTERNAL) - throw mbe_invalid_port_type(d_mb, comp_name, port_name); - - // Is this endpoint already connected? - if (d_conn_table.lookup_conn_by_name(comp_name, port_name, &it, &which_ep)) - throw mbe_already_connected(d_mb, comp_name, port_name); - - return mb_endpoint(comp_name, port_name, port); -} - -mb_port_sptr -mb_mblock_impl::resolve_port(const std::string &comp_name, - const std::string &port_name) -{ - if (comp_name == "self"){ - // Look through our ports. - if (!port_is_defined(port_name)) - throw mbe_no_such_port(d_mb, mb_util::join_names("self", port_name)); - return d_port_map[port_name]; - } - else { - // Look through the specified child's ports. - if (!comp_is_defined(comp_name)) - throw mbe_no_such_component(d_mb, comp_name); - - mb_mblock_impl_sptr c_impl = d_comp_map[comp_name]->d_impl; // childs impl pointer - if (!c_impl->port_is_defined(port_name)) - throw mbe_no_such_port(d_mb, mb_util::join_names(comp_name, port_name)); - - mb_port_sptr c_port = c_impl->d_port_map[port_name]; - - if (c_port->port_type() == mb_port::INTERNAL) // can't "see" a child's internal ports - throw mbe_no_such_port(d_mb, mb_util::join_names(comp_name, port_name)); - - return c_port; - } -} - - - -bool -mb_mblock_impl::endpoints_are_compatible(const mb_endpoint &ep0, - const mb_endpoint &ep1) -{ - pmt_t p0_outgoing = ep0.outgoing_message_set(); - pmt_t p0_incoming = ep0.incoming_message_set(); - - pmt_t p1_outgoing = ep1.outgoing_message_set(); - pmt_t p1_incoming = ep1.incoming_message_set(); - - return (pmt_subsetp(p0_outgoing, p1_incoming) - && pmt_subsetp(p1_outgoing, p0_incoming)); -} - -bool -mb_mblock_impl::walk_tree(mb_visitor *visitor) -{ - if (!(*visitor)(d_mb)) - return false; - - mb_comp_map_t::iterator it; - for (it = d_comp_map.begin(); it != d_comp_map.end(); ++it) - if (!(it->second->walk_tree(visitor))) - return false; - - return true; -} - -mb_msg_accepter_sptr -mb_mblock_impl::make_accepter(pmt_t port_name) -{ - // FIXME this should probably use some kind of configurable factory - mb_msg_accepter *ma = - new mb_msg_accepter_smp(d_mb->shared_from_this(), port_name); - - return mb_msg_accepter_sptr(ma); -} - -bool -mb_mblock_impl::lookup_other_endpoint(const mb_port *port, mb_endpoint *ep) -{ - mb_conn_iter it; - int which_ep = 0; - - if (!d_conn_table.lookup_conn_by_port(port, &it, &which_ep)) - return false; - - *ep = it->d_ep[which_ep^1]; - return true; -} - -mb_mblock_sptr -mb_mblock_impl::component(const std::string &comp_name) -{ - if (comp_name == "self") - return d_mb->shared_from_this(); - - if (d_comp_map.count(comp_name) == 0) - return mb_mblock_sptr(); // null pointer - - return d_comp_map[comp_name]; -} - -void -mb_mblock_impl::set_instance_name(const std::string &name) -{ - d_instance_name = name; -} - -void -mb_mblock_impl::set_class_name(const std::string &name) -{ - d_class_name = name; -} - -/* - * This is the "Big Hammer" port cache invalidator. - * It invalidates _all_ of the port caches in the entire mblock tree. - * It's overkill, but was simple to code. - */ -void -mb_mblock_impl::invalidate_all_port_caches() -{ - class invalidator : public mb_visitor - { - public: - bool operator()(mb_mblock *mblock) - { - mb_mblock_impl_sptr impl = mblock->impl(); - mb_port_map_t::iterator it = impl->d_port_map.begin(); - mb_port_map_t::iterator end = impl->d_port_map.end(); - for (; it != end; ++it) - it->second->invalidate_cache(); - return true; - } - }; - - invalidator visitor; - - // Always true, except in early QA code - if (runtime()->top()) - runtime()->top()->walk_tree(&visitor); -} diff --git a/mblock/src/lib/mb_mblock_impl.h b/mblock/src/lib/mb_mblock_impl.h deleted file mode 100644 index f460ecc5b..000000000 --- a/mblock/src/lib/mb_mblock_impl.h +++ /dev/null @@ -1,226 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_MBLOCK_IMPL_H -#define INCLUDED_MB_MBLOCK_IMPL_H - -#include <mblock/mblock.h> -#include <mb_runtime_base.h> -#include <mb_connection.h> -#include <mblock/msg_queue.h> -#include <list> -#include <map> - - -typedef std::map<std::string, mb_port_sptr> mb_port_map_t; -typedef std::map<std::string, mb_mblock_sptr> mb_comp_map_t; - - -/*! - * \brief The private implementation details of the mblock system. - */ -class mb_mblock_impl : boost::noncopyable -{ - mb_runtime_base *d_runtime; // pointer to runtime - mb_mblock *d_mb; // pointer to our associated mblock - mb_mblock *d_mb_parent; // pointer to our parent - - std::string d_instance_name; // hierarchical name - std::string d_class_name; // name of this (derived) class - - mb_port_map_t d_port_map; // our ports - mb_comp_map_t d_comp_map; // our components - mb_conn_table d_conn_table; // our connections - - mb_msg_queue d_msgq; // incoming messages for us - -public: - mb_mblock_impl(mb_runtime_base *runtime, mb_mblock *mb, - const std::string &instance_name); - ~mb_mblock_impl(); - - /*! - * \brief Define a port. - * - * EXTERNAL and RELAY ports are part of our peer interface. - * INTERNAL ports are used to talk to sub-components. - * - * \param port_name The name of the port (must be unique within this mblock). - * \param protocol_class_name The name of the protocol class associated with - * this port. It must already be defined. - * \param conjugated Are the incoming and outgoing message sets swapped? - * \param port_type INTERNAL, EXTERNAL or RELAY. - */ - mb_port_sptr - define_port(const std::string &port_name, - const std::string &protocol_class_name, - bool conjugated, - mb_port::port_type_t port_type); - - /*! - * \brief Define a subcomponent by name. - * - * Called within the constructor to tell the system the - * names and identities of our sub-component mblocks. - * - * \param component_name The name of the sub-component (must be unique with this mblock). - * \param class_name The class of the instance that is to be created. - * \param user_arg The argument to pass to the constructor of the component. - */ - void - define_component(const std::string &component_name, - const std::string &class_name, - pmt::pmt_t user_arg); - - /*! - * \brief connect endpoint_1 to endpoint_2 - * - * \param comp_name1 component on one end of the connection - * \param port_name1 the name of the port on comp1 - * \param comp_name2 component on the other end of the connection - * \param port_name2 the name of the port on comp2 - * - * An endpoint is specified by the component's local name (given as - * component_name in the call to register_component) and the name of - * the port on that component. - * - * To connect an internal or relay port, use "self" as the component name. - */ - void - connect(const std::string &comp_name1, const std::string &port_name1, - const std::string &comp_name2, const std::string &port_name2); - - /*! - * \brief disconnect endpoint_1 from endpoint_2 - * - * \param comp_name1 component on one end of the connection - * \param port_name1 the name of the port on comp1 - * \param comp_name2 component on the other end of the connection - * \param port_name2 the name of the port on comp2 - * - * An endpoint is specified by the component's local name (given as - * component_name in the call to register_component) and the name of - * the port on that component. - * - * To disconnect an internal or relay port, use "self" as the component name. - */ - void - disconnect(const std::string &comp_name1, const std::string &port_name1, - const std::string &comp_name2, const std::string &port_name2); - - /*! - * \brief disconnect all connections to specified component - * \param component_name component to disconnect - */ - void - disconnect_component(const std::string component_name); - - /*! - * \brief disconnect all connections to all components - */ - void - disconnect_all(); - - /*! - * \brief Return number of connections (QA mostly) - */ - int - nconnections(); - - bool - walk_tree(mb_visitor *visitor); - - mb_msg_accepter_sptr - make_accepter(pmt::pmt_t port_name); - - mb_msg_queue & - msgq() { return d_msgq; } - - //! Return instance name of this block - std::string instance_name() const { return d_instance_name; } - - //! Set the instance name of this block - void set_instance_name(const std::string &name); - - //! Return the class name of this block - std::string class_name() const { return d_class_name; } - - //! Set the class name - void set_class_name(const std::string &name); - - /*! - * \brief If bound, store endpoint from the other end of the connection. - * - * \param port [in] port the port that we're searching for. - * \param ep [out] the other end point from the matching connection. - * - * \returns true iff there's a matching connection. - */ - bool - lookup_other_endpoint(const mb_port *port, mb_endpoint *ep); - - - //! Return point to associated mblock - mb_mblock *mblock() const { return d_mb; } - - //! Return pointer to the parent of our mblock - mb_mblock *mblock_parent() const { return d_mb_parent; } - - //! Lookup a component by name - mb_mblock_sptr component(const std::string &comp_name); - - //! Return the runtime instance - mb_runtime_base *runtime() { return d_runtime; } - - //! Set the runtime instance - void set_runtime(mb_runtime_base *runtime) { d_runtime = runtime; } - - /* - * Our implementation methods - */ -private: - //bool port_is_defined(pmt::pmt_t name); - bool port_is_defined(const std::string &name); - //bool comp_is_defined(pmt::pmt_t name); - bool comp_is_defined(const std::string &name); - - mb_endpoint - check_and_resolve_endpoint(const std::string &comp_name, - const std::string &port_name); - - - mb_port_sptr - resolve_port(const std::string &comp_name, - const std::string &port_name); - - static bool - endpoints_are_compatible(const mb_endpoint &ep0, - const mb_endpoint &ep1); - - /*! - * \brief walk mblock tree and invalidate all port resolution caches. - * \internal - */ - void - invalidate_all_port_caches(); -}; - - -#endif /* INCLUDED_MB_MBLOCK_IMPL_H */ diff --git a/mblock/src/lib/mb_message.cc b/mblock/src/lib/mb_message.cc deleted file mode 100644 index 4daa34079..000000000 --- a/mblock/src/lib/mb_message.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mblock/message.h> -#include <stdio.h> -#include <gruel/pmt_pool.h> - -using namespace pmt; - -static const int CACHE_LINE_SIZE = 64; // good guess -static const int MAX_MESSAGES = 1024; // KLUDGE max number of messages in sys - // 0 -> no limit -#if MB_MESSAGE_LOCAL_ALLOCATOR - -static pmt_pool -global_msg_pool(sizeof(mb_message), CACHE_LINE_SIZE, 16*1024, MAX_MESSAGES); - -void * -mb_message::operator new(size_t size) -{ - void *p = global_msg_pool.malloc(); - - // fprintf(stderr, "mb_message::new p = %p\n", p); - assert((reinterpret_cast<intptr_t>(p) & (CACHE_LINE_SIZE - 1)) == 0); - return p; -} - -void -mb_message::operator delete(void *p, size_t size) -{ - global_msg_pool.free(p); -} - -#endif - - -mb_message_sptr -mb_make_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority) -{ - return mb_message_sptr(new mb_message(signal, data, metadata, priority)); -} - -mb_message::mb_message(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority) - : d_signal(signal), d_data(data), d_metadata(metadata), d_priority(priority), - d_port_id(PMT_NIL) -{ -} - -mb_message::~mb_message() -{ - // NOP -} - -std::ostream& -operator<<(std::ostream& os, const mb_message &msg) -{ - os << "<msg: signal=" << msg.signal() - << " port_id=" << msg.port_id() - << " data=" << msg.data() - << " metadata=" << msg.metadata() - << " pri=" << msg.priority() - << ">"; - - return os; -} diff --git a/mblock/src/lib/mb_msg_accepter.cc b/mblock/src/lib/mb_msg_accepter.cc deleted file mode 100644 index 88b92394c..000000000 --- a/mblock/src/lib/mb_msg_accepter.cc +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/msg_accepter.h> - -mb_msg_accepter::~mb_msg_accepter() -{ - // nop -} diff --git a/mblock/src/lib/mb_msg_accepter_msgq.cc b/mblock/src/lib/mb_msg_accepter_msgq.cc deleted file mode 100644 index 6c74ac47a..000000000 --- a/mblock/src/lib/mb_msg_accepter_msgq.cc +++ /dev/null @@ -1,48 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mb_msg_accepter_msgq.h> -#include <mblock/message.h> - -using namespace pmt; - -pmt_t s_sys_port = pmt_intern("%sys-port"); - -mb_msg_accepter_msgq::mb_msg_accepter_msgq(mb_msg_queue *msgq) - : d_msgq(msgq) -{ -} - -mb_msg_accepter_msgq::~mb_msg_accepter_msgq() -{ -} - -void -mb_msg_accepter_msgq::operator()(pmt_t signal, pmt_t data, - pmt_t metadata, mb_pri_t priority) -{ - mb_message_sptr msg = mb_make_message(signal, data, metadata, priority); - msg->set_port_id(s_sys_port); - d_msgq->insert(msg); -} diff --git a/mblock/src/lib/mb_msg_accepter_msgq.h b/mblock/src/lib/mb_msg_accepter_msgq.h deleted file mode 100644 index f84bca596..000000000 --- a/mblock/src/lib/mb_msg_accepter_msgq.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_MSG_ACCEPTER_MSGQ_H -#define INCLUDED_MB_MSG_ACCEPTER_MSGQ_H - -#include <mblock/msg_accepter.h> -#include <mblock/msg_queue.h> - -/*! - * \brief Concrete class that accepts messages and inserts them into a message queue. - */ -class mb_msg_accepter_msgq : public mb_msg_accepter { - mb_msg_queue *d_msgq; - -public: - mb_msg_accepter_msgq(mb_msg_queue *msgq); - ~mb_msg_accepter_msgq(); - void operator()(pmt::pmt_t signal, pmt::pmt_t data, pmt::pmt_t metadata, mb_pri_t priority); -}; - -#endif /* INCLUDED_MB_MSG_ACCEPTER_MSGQ_H */ diff --git a/mblock/src/lib/mb_msg_accepter_smp.cc b/mblock/src/lib/mb_msg_accepter_smp.cc deleted file mode 100644 index 1ec8c5bfd..000000000 --- a/mblock/src/lib/mb_msg_accepter_smp.cc +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mb_msg_accepter_smp.h> -#include <mblock/common.h> -#include <mblock/mblock.h> -#include <mb_mblock_impl.h> -#include <mblock/message.h> - -using namespace pmt; - -mb_msg_accepter_smp::mb_msg_accepter_smp(mb_mblock_sptr mblock, pmt_t port_name) - : d_mb(mblock), d_port_name(port_name) -{ -} - -mb_msg_accepter_smp::~mb_msg_accepter_smp() -{ - // nop -} - -void -mb_msg_accepter_smp::operator()(pmt_t signal, pmt_t data, - pmt_t metadata, mb_pri_t priority) -{ - mb_message_sptr msg = mb_make_message(signal, data, metadata, priority); - msg->set_port_id(d_port_name); - d_mb->impl()->msgq().insert(msg); -} diff --git a/mblock/src/lib/mb_msg_accepter_smp.h b/mblock/src/lib/mb_msg_accepter_smp.h deleted file mode 100644 index 3028484f7..000000000 --- a/mblock/src/lib/mb_msg_accepter_smp.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_MSG_ACCEPTER_SMP_H -#define INCLUDED_MB_MSG_ACCEPTER_SMP_H - -#include <mblock/msg_accepter.h> - -/*! - * \brief Concrete message acceptor that does an mb_msg_queue insertion - */ -class mb_msg_accepter_smp : public mb_msg_accepter -{ - mb_mblock_sptr d_mb; - pmt::pmt_t d_port_name; - -public: - mb_msg_accepter_smp(mb_mblock_sptr mblock, pmt::pmt_t port_name); - ~mb_msg_accepter_smp(); - - void operator()(pmt::pmt_t signal, pmt::pmt_t data, pmt::pmt_t metadata, mb_pri_t priority); -}; - - -#endif /* INCLUDED_MB_MSG_ACCEPTER_SMP_H */ diff --git a/mblock/src/lib/mb_msg_queue.cc b/mblock/src/lib/mb_msg_queue.cc deleted file mode 100644 index c68c5fd64..000000000 --- a/mblock/src/lib/mb_msg_queue.cc +++ /dev/null @@ -1,128 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mblock/msg_queue.h> -#include <mblock/message.h> - - -mb_msg_queue::mb_msg_queue() - : d_not_empty(&d_mutex) -{ -} - -mb_msg_queue::~mb_msg_queue() -{ -} - -void -mb_msg_queue::insert(mb_message_sptr msg) -{ - omni_mutex_lock l(d_mutex); - - mb_pri_t q = mb_pri_clamp(msg->priority()); - - if (d_queue[q].empty_p()){ - d_queue[q].tail = d_queue[q].head = msg; - msg->d_next.reset(); //msg->d_next = 0; - } - else { - d_queue[q].tail->d_next = msg; - d_queue[q].tail = msg; - msg->d_next.reset(); // msg->d_next = 0; - } - - // FIXME set bit in bitmap - - d_not_empty.signal(); -} - -/* - * Delete highest pri message from the queue and return it. - * Returns equivalent of zero pointer if queue is empty. - * - * Caller must be holding d_mutex - */ -mb_message_sptr -mb_msg_queue::get_highest_pri_msg_helper() -{ - // FIXME use bitmap and ffz to find best queue in O(1) - - for (mb_pri_t q = 0; q <= MB_PRI_WORST; q++){ - - if (!d_queue[q].empty_p()){ - mb_message_sptr msg = d_queue[q].head; - d_queue[q].head = msg->d_next; - if (d_queue[q].head == 0){ - d_queue[q].tail.reset(); // d_queue[q].tail = 0; - // FIXME clear bit in bitmap - } - - msg->d_next.reset(); // msg->d_next = 0; - return msg; - } - } - - return mb_message_sptr(); // eqv to a zero pointer -} - - -mb_message_sptr -mb_msg_queue::get_highest_pri_msg_nowait() -{ - omni_mutex_lock l(d_mutex); - - return get_highest_pri_msg_helper(); -} - -mb_message_sptr -mb_msg_queue::get_highest_pri_msg() -{ - omni_mutex_lock l(d_mutex); - - while (1){ - mb_message_sptr msg = get_highest_pri_msg_helper(); - if (msg) // Got one; return it - return msg; - - d_not_empty.wait(); // Wait for something - } -} - -mb_message_sptr -mb_msg_queue::get_highest_pri_msg_timedwait(const mb_time &abs_time) -{ - unsigned long secs = abs_time.d_secs; - unsigned long nsecs = abs_time.d_nsecs; - - omni_mutex_lock l(d_mutex); - - while (1){ - mb_message_sptr msg = get_highest_pri_msg_helper(); - if (msg) // Got one; return it - return msg; - - if (!d_not_empty.timedwait(secs, nsecs)) // timed out - return mb_message_sptr(); // eqv to zero pointer - } -} diff --git a/mblock/src/lib/mb_port.cc b/mblock/src/lib/mb_port.cc deleted file mode 100644 index a26a2c414..000000000 --- a/mblock/src/lib/mb_port.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/port.h> -#include <mblock/protocol_class.h> - -using namespace pmt; - -mb_port::mb_port(mb_mblock *mblock, - const std::string &port_name, - const std::string &protocol_class_name, - bool conjugated, - mb_port::port_type_t port_type) - : d_port_name(port_name), d_port_symbol(pmt_intern(port_name)), - d_conjugated(conjugated), d_port_type(port_type), - d_mblock(mblock) -{ - pmt_t pc = mb_protocol_class_lookup(pmt_intern(protocol_class_name)); - if (pmt_is_null(pc)){ - throw std::runtime_error("mb_port: unknown protocol class '" - + protocol_class_name + "'"); - } - d_protocol_class = pc; -} - -mb_port::~mb_port() -{ - // nop -} - -pmt_t -mb_port::incoming_message_set() const -{ - if (!conjugated()) - return mb_protocol_class_incoming(protocol_class()); - else // swap the sets - return mb_protocol_class_outgoing(protocol_class()); -} - -pmt_t -mb_port::outgoing_message_set() const -{ - if (!conjugated()) - return mb_protocol_class_outgoing(protocol_class()); - else // swap the sets - return mb_protocol_class_incoming(protocol_class()); -} diff --git a/mblock/src/lib/mb_port_simple.cc b/mblock/src/lib/mb_port_simple.cc deleted file mode 100644 index 235e59de2..000000000 --- a/mblock/src/lib/mb_port_simple.cc +++ /dev/null @@ -1,152 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mb_port_simple.h> -#include <mblock/msg_accepter.h> -#include <mblock/exception.h> -#include <mblock/mblock.h> -#include <mb_mblock_impl.h> -#include <assert.h> -#include <mbi_runtime_lock.h> - -using namespace pmt; - -mb_port_simple::mb_port_simple(mb_mblock *mblock, - const std::string &port_name, - const std::string &protocol_class_name, - bool conjugated, - mb_port::port_type_t port_type) - : mb_port(mblock, port_name, protocol_class_name, conjugated, port_type), - d_cache_valid(false) -{ -} - -mb_port_simple::~mb_port_simple() -{ - // nop -} - -void -mb_port_simple::send(pmt_t signal, pmt_t data, pmt_t metadata, mb_pri_t priority) -{ - if (port_type() == mb_port::RELAY) // Can't send directly to a RELAY port - throw mbe_invalid_port_type(mblock(), mblock()->instance_name(), port_name()); - - mb_msg_accepter_sptr accepter = find_accepter(this); - if (accepter) - (*accepter)(signal, data, metadata, priority); -} - - -mb_msg_accepter_sptr -mb_port_simple::find_accepter(mb_port_simple *start) -{ - mb_port_simple *p = start; - mb_port_simple *pp = 0; - mb_mblock *context = 0; - mb_endpoint peer_ep; - mb_msg_accepter_sptr r; - - if (start->d_cache_valid) - return start->d_cached_accepter; - - mbi_runtime_lock l(p->mblock()); - - // Set up initial context. - - switch(p->port_type()){ - case mb_port::INTERNAL: // binding is in our name space - context = p->mblock(); - break; - - case mb_port::EXTERNAL: // binding is in parent's name space - context = p->mblock()->parent(); - if (!context) // can't be bound if there's no parent - return mb_msg_accepter_sptr(); // not bound - break; - - default: - throw std::logic_error("Can't happen: mb_port_simple::find_accepter [1]"); - } - - - traverse: - - if (!context->impl()->lookup_other_endpoint(p, &peer_ep)) - return mb_msg_accepter_sptr(); // not bound - - pp = dynamic_cast<mb_port_simple *>(peer_ep.port().get()); // peer port - assert(pp); - - switch (pp->port_type()){ - case mb_port::INTERNAL: // Terminate here. - case mb_port::EXTERNAL: - r = pp->make_accepter(); - - // cache the result - - start->d_cached_accepter = r; - start->d_cache_valid = true; - return r; - - case mb_port::RELAY: // Traverse to other side of relay port. - if (peer_ep.inside_of_relay_port_p()){ - // We're on inside of relay port, headed out. - p = pp; - context = p->mblock()->parent(); - - // Corner case: we're attempting to traverse a relay port on the border - // of the top block... - if (!context) - return mb_msg_accepter_sptr(); // not bound - - goto traverse; - } - else { - // We're on the outside of relay port, headed in. - p = pp; - context = p->mblock(); - goto traverse; - } - break; - - default: - throw std::logic_error("Can't happen: mb_port_simple::find_accepter [2]"); - } -} - - -mb_msg_accepter_sptr -mb_port_simple::make_accepter() -{ - return d_mblock->impl()->make_accepter(port_symbol()); -} - -void -mb_port_simple::invalidate_cache() -{ - d_cache_valid = false; - d_cached_accepter.reset(); -} diff --git a/mblock/src/lib/mb_port_simple.h b/mblock/src/lib/mb_port_simple.h deleted file mode 100644 index 485c809fe..000000000 --- a/mblock/src/lib/mb_port_simple.h +++ /dev/null @@ -1,72 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_PORT_SIMPLE_H -#define INCLUDED_MB_PORT_SIMPLE_H - -#include <mblock/port.h> - -/*! - * \brief Concrete port realization - */ -class mb_port_simple : public mb_port -{ - bool d_cache_valid; - mb_msg_accepter_sptr d_cached_accepter; - -protected: - static mb_msg_accepter_sptr - find_accepter(mb_port_simple *start); - - mb_msg_accepter_sptr - make_accepter(); - -public: - mb_port_simple(mb_mblock *mblock, - const std::string &port_name, - const std::string &protocol_class_name, - bool conjugated, - mb_port::port_type_t port_type); - - ~mb_port_simple(); - - /*! - * \brief send a message - * - * \param signal the event name - * \param data optional data - * \param metadata optional metadata - * \param priority the urgency at which the message is sent - */ - void - send(pmt::pmt_t signal, - pmt::pmt_t data = pmt::PMT_NIL, - pmt::pmt_t metadata = pmt::PMT_NIL, - mb_pri_t priority = MB_PRI_DEFAULT); - - /* - * \brief Invalidate any cached peer resolutions - * \internal - */ - void invalidate_cache(); - -}; - -#endif /* INCLUDED_MB_PORT_SIMPLE_H */ diff --git a/mblock/src/lib/mb_protocol_class.cc b/mblock/src/lib/mb_protocol_class.cc deleted file mode 100644 index 1c696fb7c..000000000 --- a/mblock/src/lib/mb_protocol_class.cc +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/protocol_class.h> -#include <iostream> - -using namespace pmt; - -static pmt_t s_ALL_PROTOCOL_CLASSES = PMT_NIL; - -pmt_t -mb_make_protocol_class(pmt_t name, pmt_t incoming, pmt_t outgoing) -{ - // (protocol-class <name> <incoming> <outgoing>) - - if (!pmt_is_symbol(name)) - throw pmt_wrong_type("mb_make_protocol_class: NAME must be symbol", name); - if (!(pmt_is_pair(incoming) || pmt_is_null(incoming))) - throw pmt_wrong_type("mb_make_protocol_class: INCOMING must be a list", name); - if (!(pmt_is_pair(outgoing) || pmt_is_null(outgoing))) - throw pmt_wrong_type("mb_make_protocol_class: OUTGOING must be a list", name); - - pmt_t t = pmt_cons(pmt_intern("protocol-class"), - pmt_cons(name, - pmt_cons(incoming, - pmt_cons(outgoing, PMT_NIL)))); - - // Remember this protocol class. - s_ALL_PROTOCOL_CLASSES = pmt_cons(t, s_ALL_PROTOCOL_CLASSES); - return t; -} - -pmt_t -mb_protocol_class_name(pmt_t pc) -{ - return pmt_nth(1, pc); -} - -pmt_t -mb_protocol_class_incoming(pmt_t pc) -{ - return pmt_nth(2, pc); -} - -pmt_t -mb_protocol_class_outgoing(pmt_t pc) -{ - return pmt_nth(3, pc); -} - -pmt_t -mb_protocol_class_lookup(pmt_t name) -{ - pmt_t lst = s_ALL_PROTOCOL_CLASSES; - - while (pmt_is_pair(lst)){ - if (pmt_eq(name, mb_protocol_class_name(pmt_car(lst)))) - return pmt_car(lst); - lst = pmt_cdr(lst); - } - - return PMT_NIL; -} - -mb_protocol_class_init::mb_protocol_class_init(const char *data, size_t len) -{ - std::stringbuf sb; - sb.str(std::string(data, len)); - - while (1){ - pmt_t obj = pmt_deserialize(sb); - - if (0){ - pmt_write(obj, std::cout); - std::cout << std::endl; - } - - if (pmt_is_eof_object(obj)) - return; - - mb_make_protocol_class(pmt_nth(0, obj), // protocol-class name - pmt_nth(1, obj), // list of incoming msg names - pmt_nth(2, obj)); // list of outgoing msg names - } -} diff --git a/mblock/src/lib/mb_runtime.cc b/mblock/src/lib/mb_runtime.cc deleted file mode 100644 index 57a05c416..000000000 --- a/mblock/src/lib/mb_runtime.cc +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/runtime.h> -#include <mb_runtime_thread_per_block.h> - -mb_runtime_sptr -mb_make_runtime() -{ - return mb_runtime_sptr(new mb_runtime_thread_per_block()); -} - -mb_runtime::~mb_runtime() -{ - // nop -} - diff --git a/mblock/src/lib/mb_runtime_base.cc b/mblock/src/lib/mb_runtime_base.cc deleted file mode 100644 index f259a690d..000000000 --- a/mblock/src/lib/mb_runtime_base.cc +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mb_runtime_base.h> - -using namespace pmt; - -/* - * Default nop implementations... - */ - -void -mb_runtime_base::request_shutdown(pmt_t result) -{ -} - -pmt_t -mb_runtime_base::schedule_one_shot_timeout(const mb_time &abs_time, - pmt_t user_data, - mb_msg_accepter_sptr accepter) -{ - return PMT_F; -} - -pmt_t -mb_runtime_base::schedule_periodic_timeout(const mb_time &first_abs_time, - const mb_time &delta_time, - pmt_t user_data, - mb_msg_accepter_sptr accepter) -{ - return PMT_F; -} - -void -mb_runtime_base::cancel_timeout(pmt_t handle) -{ -} - diff --git a/mblock/src/lib/mb_runtime_base.h b/mblock/src/lib/mb_runtime_base.h deleted file mode 100644 index 78be2922d..000000000 --- a/mblock/src/lib/mb_runtime_base.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef INCLUDED_MB_RUNTIME_BASE_H -#define INCLUDED_MB_RUNTIME_BASE_H - -#include <mblock/runtime.h> -#include <gnuradio/omnithread.h> -#include <mblock/time.h> - -/* - * \brief This is the runtime class used by the implementation. - */ -class mb_runtime_base : public mb_runtime -{ - omni_mutex d_brl; // big runtime lock (avoid using this if possible...) - -protected: - mb_msg_accepter_sptr d_accepter; - -public: - - /*! - * \brief lock the big runtime lock - * \internal - */ - inline void lock() { d_brl.lock(); } - - /*! - * \brief unlock the big runtime lock - * \internal - */ - inline void unlock() { d_brl.unlock(); } - - virtual void request_shutdown(pmt::pmt_t result); - - virtual mb_mblock_sptr - create_component(const std::string &instance_name, - const std::string &class_name, - pmt::pmt_t user_arg) = 0; - - virtual pmt::pmt_t - schedule_one_shot_timeout(const mb_time &abs_time, pmt::pmt_t user_data, - mb_msg_accepter_sptr accepter); - - virtual pmt::pmt_t - schedule_periodic_timeout(const mb_time &first_abs_time, - const mb_time &delta_time, - pmt::pmt_t user_data, - mb_msg_accepter_sptr accepter); - virtual void - cancel_timeout(pmt::pmt_t handle); - - mb_msg_accepter_sptr - accepter() { return d_accepter; } - -}; - - -#endif /* INCLUDED_MB_RUNTIME_BASE_H */ diff --git a/mblock/src/lib/mb_runtime_nop.cc b/mblock/src/lib/mb_runtime_nop.cc deleted file mode 100644 index 8293e0c24..000000000 --- a/mblock/src/lib/mb_runtime_nop.cc +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mb_runtime_nop.h> -#include <mblock/mblock.h> -#include <mblock/class_registry.h> -#include <mblock/exception.h> - -using namespace pmt; - -mb_runtime_sptr -mb_make_runtime_nop() -{ - return mb_runtime_sptr(new mb_runtime_nop()); -} - - -mb_runtime_nop::mb_runtime_nop() -{ - // nop for now -} - -mb_runtime_nop::~mb_runtime_nop() -{ - // nop for now -} - - -bool -mb_runtime_nop::run(const std::string &instance_name, - const std::string &class_name, - pmt_t user_arg, pmt_t *result) -{ - class initial_visitor : public mb_visitor - { - public: - bool operator()(mb_mblock *mblock) - { - mblock->initial_transition(); - return true; - } - }; - - initial_visitor visitor; - - if (result) - *result = PMT_T; - - d_top = create_component(instance_name, class_name, user_arg); - d_top->walk_tree(&visitor); - - return true; -} - -mb_mblock_sptr -mb_runtime_nop::create_component(const std::string &instance_name, - const std::string &class_name, - pmt_t user_arg) -{ - mb_mblock_maker_t maker; - if (!mb_class_registry::lookup_maker(class_name, &maker)) - throw mbe_no_such_class(0, class_name + " (in " + instance_name + ")"); - - return maker(this, instance_name, user_arg); -} diff --git a/mblock/src/lib/mb_runtime_nop.h b/mblock/src/lib/mb_runtime_nop.h deleted file mode 100644 index 735c0405e..000000000 --- a/mblock/src/lib/mb_runtime_nop.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_RUNTIME_NOP_H -#define INCLUDED_MB_RUNTIME_NOP_H - -#include <mb_runtime_base.h> - -/*! - * \brief Public constructor (factory) for mb_runtime_nop objects. - */ -mb_runtime_sptr mb_make_runtime_nop(); - -/*! - * \brief Concrete runtime that does nothing. Used only during early QA tests. - */ -class mb_runtime_nop : public mb_runtime_base -{ -public: - mb_runtime_nop(); - ~mb_runtime_nop(); - - bool run(const std::string &instance_name, - const std::string &class_name, - pmt::pmt_t user_arg, - pmt::pmt_t *result); - -protected: - mb_mblock_sptr - create_component(const std::string &instance_name, - const std::string &class_name, - pmt::pmt_t user_arg); -}; - -#endif /* INCLUDED_MB_RUNTIME_NOP_H */ diff --git a/mblock/src/lib/mb_runtime_thread_per_block.cc b/mblock/src/lib/mb_runtime_thread_per_block.cc deleted file mode 100644 index b16009436..000000000 --- a/mblock/src/lib/mb_runtime_thread_per_block.cc +++ /dev/null @@ -1,350 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mb_runtime_thread_per_block.h> -#include <mblock/mblock.h> -#include <mb_mblock_impl.h> -#include <mblock/class_registry.h> -#include <mblock/exception.h> -#include <mb_worker.h> -#include <gnuradio/omnithread.h> -#include <iostream> -#include <mb_msg_accepter_msgq.h> - -using namespace pmt; - -static pmt_t s_halt = pmt_intern("%halt"); -static pmt_t s_sys_port = pmt_intern("%sys-port"); -static pmt_t s_shutdown = pmt_intern("%shutdown"); -static pmt_t s_request_shutdown = pmt_intern("%request-shutdown"); -static pmt_t s_worker_state_changed = pmt_intern("%worker-state-changed"); -static pmt_t s_timeout = pmt_intern("%timeout"); -static pmt_t s_request_timeout = pmt_intern("%request-timeout"); -static pmt_t s_cancel_timeout = pmt_intern("%cancel-timeout"); -static pmt_t s_send_halt = pmt_intern("send-halt"); -static pmt_t s_exit_now = pmt_intern("exit-now"); - -static void -send_sys_msg(mb_msg_queue &msgq, pmt_t signal, - pmt_t data = PMT_F, pmt_t metadata = PMT_F, - mb_pri_t priority = MB_PRI_BEST) -{ - mb_message_sptr msg = mb_make_message(signal, data, metadata, priority); - msg->set_port_id(s_sys_port); - msgq.insert(msg); -} - - -mb_runtime_thread_per_block::mb_runtime_thread_per_block() - : d_shutdown_in_progress(false), - d_shutdown_result(PMT_T) -{ - d_accepter = mb_msg_accepter_sptr(new mb_msg_accepter_msgq(&d_msgq)); -} - -mb_runtime_thread_per_block::~mb_runtime_thread_per_block() -{ - // FIXME iterate over workers and ensure that they are dead. - - if (!d_workers.empty()) - std::cerr << "\nmb_runtime_thread_per_block: dtor (# workers = " - << d_workers.size() << ")\n"; -} - -void -mb_runtime_thread_per_block::request_shutdown(pmt_t result) -{ - (*accepter())(s_request_shutdown, result, PMT_F, MB_PRI_BEST); -} - -bool -mb_runtime_thread_per_block::run(const std::string &instance_name, - const std::string &class_name, - pmt_t user_arg, pmt_t *result) -{ - if (result) // set it to something now, in case we throw - *result = PMT_F; - - // reset the shutdown state - d_shutdown_in_progress = false; - d_shutdown_result = PMT_T; - - assert(d_workers.empty()); - - while (!d_timer_queue.empty()) // ensure timer queue is empty - d_timer_queue.pop(); - - /* - * Create the top-level component, and recursively all of its - * subcomponents. - */ - d_top = create_component(instance_name, class_name, user_arg); - - try { - run_loop(); - } - catch (...){ - d_top.reset(); - throw; - } - - if (result) - *result = d_shutdown_result; - - d_top.reset(); - return true; -} - -void -mb_runtime_thread_per_block::run_loop() -{ - while (1){ - mb_message_sptr msg; - - if (d_timer_queue.empty()) // Any timeouts pending? - msg = d_msgq.get_highest_pri_msg(); // Nope. Block forever. - - else { - mb_timeout_sptr to = d_timer_queue.top(); // Yep. Get earliest timeout. - - // wait for a msg or the timeout... - msg = d_msgq.get_highest_pri_msg_timedwait(to->d_when); - - if (!msg){ // We timed out. - d_timer_queue.pop(); // Remove timeout from timer queue. - - // send the %timeout msg - (*to->d_accepter)(s_timeout, to->d_user_data, to->handle(), MB_PRI_BEST); - - if (to->d_is_periodic){ - to->d_when = to->d_when + to->d_delta; // update time of next firing - d_timer_queue.push(to); // push it back into the queue - } - continue; - } - } - - pmt_t signal = msg->signal(); - - if (pmt_eq(signal, s_worker_state_changed)){ // %worker-state-changed - omni_mutex_lock l1(d_workers_mutex); - reap_dead_workers(); - if (d_workers.empty()) // no work left to do... - return; - } - else if (pmt_eq(signal, s_request_shutdown)){ // %request-shutdown - if (!d_shutdown_in_progress){ - d_shutdown_in_progress = true; - d_shutdown_result = msg->data(); - - // schedule a timeout for ourselves... - schedule_one_shot_timeout(mb_time::time(0.100), s_send_halt, d_accepter); - send_all_sys_msg(s_shutdown); - } - } - else if (pmt_eq(signal, s_request_timeout)){ // %request-timeout - mb_timeout_sptr to = - boost::any_cast<mb_timeout_sptr>(pmt_any_ref(msg->data())); - d_timer_queue.push(to); - } - else if (pmt_eq(signal, s_cancel_timeout)){ // %cancel-timeout - d_timer_queue.cancel(msg->data()); - } - else if (pmt_eq(signal, s_timeout) - && pmt_eq(msg->data(), s_send_halt)){ // %timeout, send-halt - - // schedule another timeout for ourselves... - schedule_one_shot_timeout(mb_time::time(0.100), s_exit_now, d_accepter); - send_all_sys_msg(s_halt); - } - else if (pmt_eq(signal, s_timeout) - && pmt_eq(msg->data(), s_exit_now)){ // %timeout, exit-now - - // We only get here if we've sent all workers %shutdown followed - // by %halt, and one or more of them is still alive. They must - // be blocked in the kernel. FIXME We could add one more step: - // pthread_kill(...) but for now, we'll just ignore them... - return; - } - else { - std::cerr << "mb_runtime_thread_per_block: unhandled msg: " << msg << std::endl; - } - } -} - -void -mb_runtime_thread_per_block::reap_dead_workers() -{ - // Already holding mutex - // omni_mutex_lock l1(d_workers_mutex); - - for (worker_iter_t wi = d_workers.begin(); wi != d_workers.end(); ){ - bool is_dead; - - // We can't join while holding the worker mutex, since that would - // attempt to destroy the mutex we're holding (omnithread's join - // deletes the omni_thread object after the pthread_join - // completes) Instead, we lock just long enough to figure out if - // the worker is dead. - { - omni_mutex_lock l2((*wi)->d_mutex); - is_dead = (*wi)->d_state == mb_worker::TS_DEAD; - } - - if (is_dead){ - if (0) - std::cerr << "\nruntime: " - << "(" << (*wi)->id() << ") " - << (*wi)->d_mblock->instance_name() << " is TS_DEAD\n"; - void *ignore; - (*wi)->join(&ignore); - wi = d_workers.erase(wi); - continue; - } - ++wi; - } -} - -// -// Create the thread, then create the component in the thread. -// Return a pointer to the created mblock. -// -// Can be invoked from any thread -// -mb_mblock_sptr -mb_runtime_thread_per_block::create_component(const std::string &instance_name, - const std::string &class_name, - pmt_t user_arg) -{ - mb_mblock_maker_t maker; - if (!mb_class_registry::lookup_maker(class_name, &maker)) - throw mbe_no_such_class(0, class_name + " (in " + instance_name + ")"); - - // FIXME here's where we'd lookup NUMA placement requests & mblock - // priorities and communicate them to the worker we're creating... - - // Create the worker thread - mb_worker *w = - new mb_worker(this, maker, instance_name, user_arg); - - w->start_undetached(); // start it - - // Wait for it to reach TS_RUNNING or TS_DEAD - - bool is_dead; - mb_worker::cause_of_death_t why_dead; - { - omni_mutex_lock l(w->d_mutex); - while (!(w->d_state == mb_worker::TS_RUNNING - || w->d_state == mb_worker::TS_DEAD)) - w->d_state_cond.wait(); - - is_dead = w->d_state == mb_worker::TS_DEAD; - why_dead = w->d_why_dead; - } - - // If the worker failed to init (constructor or initial_transition - // raised an exception), reap the worker now and raise an exception. - - if (is_dead && why_dead != mb_worker::RIP_EXIT){ - - void *ignore; - w->join(&ignore); - - // FIXME with some work we ought to be able to propagate the - // exception from the worker. - throw mbe_mblock_failed(0, instance_name); - } - - assert(w->d_mblock); - - // Add w to the vector of workers, and return the mblock. - { - omni_mutex_lock l(d_workers_mutex); - d_workers.push_back(w); - } - - if (0) - std::cerr << "\nruntime: created " - << "(" << w->id() << ") " - << w->d_mblock->instance_name() << "\n"; - - return w->d_mblock; -} - -void -mb_runtime_thread_per_block::send_all_sys_msg(pmt_t signal, - pmt_t data, - pmt_t metadata, - mb_pri_t priority) -{ - omni_mutex_lock l1(d_workers_mutex); - - for (worker_iter_t wi = d_workers.begin(); wi != d_workers.end(); ++wi){ - send_sys_msg((*wi)->d_mblock->impl()->msgq(), - signal, data, metadata, priority); - } -} - -// -// Can be invoked from any thread. -// Sends a message to the runtime. -// -pmt_t -mb_runtime_thread_per_block::schedule_one_shot_timeout - (const mb_time &abs_time, - pmt_t user_data, - mb_msg_accepter_sptr accepter) -{ - mb_timeout_sptr to(new mb_timeout(abs_time, user_data, accepter)); - (*d_accepter)(s_request_timeout, pmt_make_any(to), PMT_F, MB_PRI_BEST); - return to->handle(); -} - -// -// Can be invoked from any thread. -// Sends a message to the runtime. -// -pmt_t -mb_runtime_thread_per_block::schedule_periodic_timeout - (const mb_time &first_abs_time, - const mb_time &delta_time, - pmt_t user_data, - mb_msg_accepter_sptr accepter) -{ - mb_timeout_sptr to(new mb_timeout(first_abs_time, delta_time, - user_data, accepter)); - (*d_accepter)(s_request_timeout, pmt_make_any(to), PMT_F, MB_PRI_BEST); - return to->handle(); -} - -// -// Can be invoked from any thread. -// Sends a message to the runtime. -// -void -mb_runtime_thread_per_block::cancel_timeout(pmt_t handle) -{ - (*d_accepter)(s_cancel_timeout, handle, PMT_F, MB_PRI_BEST); -} diff --git a/mblock/src/lib/mb_runtime_thread_per_block.h b/mblock/src/lib/mb_runtime_thread_per_block.h deleted file mode 100644 index 74ed6073a..000000000 --- a/mblock/src/lib/mb_runtime_thread_per_block.h +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MB_RUNTIME_THREAD_PER_BLOCK_H -#define INCLUDED_MB_RUNTIME_THREAD_PER_BLOCK_H - -#include <mb_runtime_base.h> -#include <mb_worker.h> -#include <mblock/msg_queue.h> -#include <mb_timer_queue.h> - -/*! - * \brief Concrete runtime that uses a thread per mblock - * \internal - * - * These are all implementation details. - */ -class mb_runtime_thread_per_block : public mb_runtime_base -{ -public: - omni_mutex d_workers_mutex; // hold while manipulating d_workers - std::vector<mb_worker*> d_workers; - bool d_shutdown_in_progress; - pmt::pmt_t d_shutdown_result; - mb_msg_queue d_msgq; - mb_timer_queue d_timer_queue; - - typedef std::vector<mb_worker*>::iterator worker_iter_t; - - mb_runtime_thread_per_block(); - ~mb_runtime_thread_per_block(); - - bool run(const std::string &instance_name, - const std::string &class_name, - pmt::pmt_t user_arg, - pmt::pmt_t *result); - - void request_shutdown(pmt::pmt_t result); - -protected: - mb_mblock_sptr - create_component(const std::string &instance_name, - const std::string &class_name, - pmt::pmt_t user_arg); - - pmt::pmt_t - schedule_one_shot_timeout(const mb_time &abs_time, pmt::pmt_t user_data, - mb_msg_accepter_sptr accepter); - - pmt::pmt_t - schedule_periodic_timeout(const mb_time &first_abs_time, - const mb_time &delta_time, - pmt::pmt_t user_data, - mb_msg_accepter_sptr accepter); - void - cancel_timeout(pmt::pmt_t handle); - -private: - void reap_dead_workers(); - void run_loop(); - - void send_all_sys_msg(pmt::pmt_t signal, pmt::pmt_t data = pmt::PMT_F, - pmt::pmt_t metadata = pmt::PMT_F, - mb_pri_t priority = MB_PRI_BEST); -}; - -#endif /* INCLUDED_MB_RUNTIME_THREAD_PER_BLOCK_H */ diff --git a/mblock/src/lib/mb_timer_queue.cc b/mblock/src/lib/mb_timer_queue.cc deleted file mode 100644 index 411900c59..000000000 --- a/mblock/src/lib/mb_timer_queue.cc +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mb_timer_queue.h> - -using namespace pmt; - -static pmt_t -make_handle() -{ - static long counter = 0; - pmt_t n = pmt_from_long(counter++); - return pmt_list1(n); // guaranteed to be a unique object -} - -// one-shot constructor -mb_timeout::mb_timeout(const mb_time &abs_time, - pmt_t user_data, mb_msg_accepter_sptr accepter) - : d_when(abs_time), d_is_periodic(false), - d_user_data(user_data), d_handle(make_handle()), d_accepter(accepter) -{ -} - -// periodic constructor -mb_timeout::mb_timeout(const mb_time &first_abs_time, const mb_time &delta_time, - pmt_t user_data, mb_msg_accepter_sptr accepter) - : d_when(first_abs_time), d_delta(delta_time), d_is_periodic(true), - d_user_data(user_data), d_handle(make_handle()), d_accepter(accepter) -{ -} - -void -mb_timer_queue::cancel(pmt_t handle) -{ - container_type::iterator it; - - for (it = c.begin(); it != c.end();){ - if (pmt_equal((*it)->handle(), handle)) - it = c.erase(it); - else - ++it; - } - std::make_heap(c.begin(), c.end(), comp); -} diff --git a/mblock/src/lib/mb_timer_queue.h b/mblock/src/lib/mb_timer_queue.h deleted file mode 100644 index 7a1ad6fa3..000000000 --- a/mblock/src/lib/mb_timer_queue.h +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef INCLUDED_MB_TIMER_QUEUE_H -#define INCLUDED_MB_TIMER_QUEUE_H - -#include <mblock/time.h> -#include <vector> -#include <queue> -#include <gruel/pmt.h> -#include <mblock/msg_accepter.h> - -class mb_timeout { -public: - mb_time d_when; // absolute time to fire timeout - mb_time d_delta; // if periodic, delta_t to next timeout - bool d_is_periodic; // true iff this is a periodic timeout - pmt::pmt_t d_user_data; // data from %timeout msg - pmt::pmt_t d_handle; // handle for cancellation - mb_msg_accepter_sptr d_accepter; // where to send the message - - // one-shot constructor - mb_timeout(const mb_time &abs_time, - pmt::pmt_t user_data, mb_msg_accepter_sptr accepter); - - // periodic constructor - mb_timeout(const mb_time &first_abs_time, const mb_time &delta_time, - pmt::pmt_t user_data, mb_msg_accepter_sptr accepter); - - pmt::pmt_t handle() const { return d_handle; } -}; - -typedef boost::shared_ptr<mb_timeout> mb_timeout_sptr; - - -//! Sort criterion for priority_queue -class timeout_later -{ -public: - bool operator() (const mb_timeout_sptr t1, const mb_timeout_sptr t2) - { - return t1->d_when > t2->d_when; - } -}; - - -class mb_timer_queue : public std::priority_queue<mb_timeout_sptr, - std::vector<mb_timeout_sptr>, - timeout_later> -{ -public: - void cancel(pmt::pmt_t handle); -}; - -#endif /* INCLUDED_MB_TIMER_QUEUE_H */ diff --git a/mblock/src/lib/mb_util.cc b/mblock/src/lib/mb_util.cc deleted file mode 100644 index 60a0e44fb..000000000 --- a/mblock/src/lib/mb_util.cc +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mb_util.h> - - -std::string -mb_util::join_names(const std::string &comp_name, - const std::string &port_name) -{ - return comp_name + ":" + port_name; -} diff --git a/mblock/src/lib/mb_util.h b/mblock/src/lib/mb_util.h deleted file mode 100644 index fe420d6ed..000000000 --- a/mblock/src/lib/mb_util.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef INCLUDED_MB_UTIL_H -#define INCLUDED_MB_UTIL_H - -#include <string> - -class mb_util -{ -public: - static std::string - join_names(const std::string &comp_name, - const std::string &port_name); -}; - -#endif /* INCLUDED_MB_UTIL_H */ diff --git a/mblock/src/lib/mb_worker.cc b/mblock/src/lib/mb_worker.cc deleted file mode 100644 index 7d2896a11..000000000 --- a/mblock/src/lib/mb_worker.cc +++ /dev/null @@ -1,180 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mb_worker.h> -#include <mb_runtime_thread_per_block.h> -#include <mblock/exception.h> -#include <mblock/mblock.h> -#include <mb_gettid.h> -#include <mblock/msg_accepter.h> -#include <iostream> -#include <cstdio> -#ifdef HAVE_SCHED_H -#include <sched.h> -#endif - -#define VERBOSE 0 // define to 0 or 1 - -using namespace pmt; - -static pmt_t s_worker_state_changed = pmt_intern("%worker-state-changed"); - - -mb_worker::mb_worker(mb_runtime_thread_per_block *runtime, - mb_mblock_maker_t maker, - const std::string &instance_name, - pmt_t user_arg) - : omni_thread((void *) 0, PRIORITY_NORMAL), - d_runtime(runtime), d_maker(maker), - d_instance_name(instance_name), d_user_arg(user_arg), - d_state_cond(&d_mutex), d_state(TS_UNINITIALIZED), - d_why_dead(RIP_NOT_DEAD_YET) -{ -} - -#if 0 -mb_worker::~mb_worker() -{ -} -#endif - -#ifdef HAVE_SCHED_SETAFFINITY -static void -set_affinity(const std::string &instance_name, const std::string &class_name) -{ - //static int counter = 0; - cpu_set_t mask; - CPU_ZERO(&mask); - - if (0){ - - //CPU_SET(counter & 0x1, &mask); - //counter++; - CPU_SET(0, &mask); - - int r = sched_setaffinity(mb_gettid(), sizeof(mask), &mask); - if (r == -1) - perror("sched_setaffinity"); - } -} -#else -static void -set_affinity(const std::string &instance_name, const std::string &class_name) -{ -} -#endif - -void -mb_worker::set_state(worker_state_t state) -{ - { - omni_mutex_lock l2(d_mutex); - - d_state = state; // update our state - d_state_cond.broadcast(); // Notify everybody who cares... - } - - // send msg to runtime, telling it something changed. - (*d_runtime->accepter())(s_worker_state_changed, PMT_F, PMT_F, MB_PRI_BEST); -} - -void * -mb_worker::run_undetached(void *ignored) -{ - // FIXME add pthread_sigmask stuff - - //set_affinity(d_instance_name, d_class_name); - set_affinity(d_instance_name, ""); - - try { - worker_thread_top_level(); - d_why_dead = RIP_EXIT; - } - catch (mbe_terminate){ - d_why_dead = RIP_TERMINATE; - } - catch (mbe_exit){ - d_why_dead = RIP_EXIT; - } - catch (std::logic_error e){ - if (d_why_dead == RIP_NOT_DEAD_YET) - d_why_dead = RIP_UNHANDLED_EXCEPTION; - - std::cerr << "\nmb_worker::run_undetached: unhandled exception:\n"; - std::cerr << " " << e.what() << std::endl; - } - catch (...){ - if (d_why_dead == RIP_NOT_DEAD_YET) - d_why_dead = RIP_UNHANDLED_EXCEPTION; - } - - if (VERBOSE) - std::cerr << "\nrun_undetached: about to return, d_why_dead = " - << d_why_dead << std::endl; - - set_state(TS_DEAD); - return 0; -} - -void -mb_worker::worker_thread_top_level() -{ - if (VERBOSE) - std::cerr << "worker_thread_top_level (enter):" << std::endl - << " instance_name: " << d_instance_name << std::endl - << " omnithread id: " << id() << std::endl - << " gettid: " << mb_gettid() << std::endl - << " getpid: " << getpid() << std::endl; - - cause_of_death_t pending_cause_of_death = RIP_NOT_DEAD_YET; - - try { - pending_cause_of_death = RIP_CTOR_EXCEPTION; - d_mblock = d_maker(d_runtime, d_instance_name, d_user_arg); - - if (VERBOSE) - std::cerr << "worker_thread_top_level (post-construction):" << std::endl - << " instance_name: " << d_instance_name << std::endl; - - pending_cause_of_death = RIP_INIT_EXCEPTION; - d_mblock->initial_transition(); - - if (VERBOSE) - std::cerr << "worker_thread_top_level (post-initial-transition):" << std::endl - << " instance_name: " << d_instance_name << std::endl; - - set_state(TS_RUNNING); - - pending_cause_of_death = RIP_UNHANDLED_EXCEPTION; - d_mblock->main_loop(); - } - catch (...){ - d_why_dead = pending_cause_of_death; - throw; - } - - if (VERBOSE) - std::cerr << "worker_thread_top_level (exit):" << std::endl - << " instance_name: " << d_instance_name << std::endl; -} diff --git a/mblock/src/lib/mb_worker.h b/mblock/src/lib/mb_worker.h deleted file mode 100644 index 0037d131f..000000000 --- a/mblock/src/lib/mb_worker.h +++ /dev/null @@ -1,106 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef INCLUDED_MB_WORKER_H -#define INCLUDED_MB_WORKER_H - -#include <gnuradio/omnithread.h> -#include <mblock/common.h> -#include <mblock/class_registry.h> - - -class mb_worker; -//typedef boost::shared_ptr<mb_worker> mb_worker_sptr; - -class mb_runtime_thread_per_block; - -/*! - * \brief Worker thread for thread_per_block runtime - * \internal - */ -class mb_worker : public omni_thread -{ -public: - //! worker thread states - enum worker_state_t { - TS_UNINITIALIZED, // new, uninitialized - TS_RUNNING, // normal steady-state condition. - TS_DEAD // thread is dead - }; - - //! why we're dead - enum cause_of_death_t { - RIP_NOT_DEAD_YET, // not dead - RIP_EXIT, // normal exit - RIP_TERMINATE, // caught terminate exception - RIP_CTOR_EXCEPTION, // constructor raised an exception - RIP_INIT_EXCEPTION, // initial_transition rasised an exception - RIP_UNHANDLED_EXCEPTION // somebody (most likely handle_message) raised an exception - }; - - /* - * Args used by new thread to create mb_mblock - */ - mb_runtime_thread_per_block *d_runtime; - mb_mblock_maker_t d_maker; - std::string d_instance_name; - pmt::pmt_t d_user_arg; - - mb_mblock_sptr d_mblock; //< holds pointer to created mblock - - /*! - * \brief General mutex for all these fields. - * - * They are accessed by both the main runtime thread and the newly - * created thread that runs the mblock's main loop. - */ - omni_mutex d_mutex; - omni_condition d_state_cond; //< state change notifications - worker_state_t d_state; - cause_of_death_t d_why_dead; - - mb_worker(mb_runtime_thread_per_block *runtime, - mb_mblock_maker_t maker, - const std::string &instance_name, - pmt::pmt_t user_arg); - - // ~mb_worker(); - - - /*! - * \brief This code runs as the top-level of the new thread - */ - void worker_thread_top_level(); - - /*! - * \brief Invokes the top-level of the new thread (name kind of sucks) - */ - void *run_undetached(void *arg); - -private: - // Neither d_mutex nor runtime->d_mutex may be held while calling this. - // It locks and unlocks them itself. - void set_state(worker_state_t state); -}; - - - -#endif /* INCLUDED_MB_WORKER_H */ diff --git a/mblock/src/lib/mbi_runtime_lock.h b/mblock/src/lib/mbi_runtime_lock.h deleted file mode 100644 index 020cd733c..000000000 --- a/mblock/src/lib/mbi_runtime_lock.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef INCLUDED_MBI_RUNTIME_LOCK_H -#define INCLUDED_MBI_RUNTIME_LOCK_H - -#include <mblock/runtime.h> -#include <mb_mblock_impl.h> -#include <boost/utility.hpp> - -/*! - * \brief acquire and release big runtime lock - * - * As an alternative to: - * { - * rt->lock(); - * ..... - * rt->unlock(); - * } - * - * you can use a single instance of the mbi_runtime_lock class: - * - * { - * mbi_runtime_lock l(rt); - * .... - * } - * - * This has the advantage that rt->unlock() will be called automatically - * when an exception is thrown. - */ - -class mbi_runtime_lock : boost::noncopyable { - mb_runtime_base *d_rt; -public: - mbi_runtime_lock(mb_runtime_base *rt) : d_rt(rt) { d_rt->lock(); } - mbi_runtime_lock(mb_mblock_impl *mi) : d_rt(mi->runtime()) { d_rt->lock(); } - mbi_runtime_lock(mb_mblock *mb) : d_rt(mb->impl()->runtime()) { d_rt->lock(); } - ~mbi_runtime_lock(void) { d_rt->unlock(); } - -}; - -#endif /* INCLUDED_MBI_RUNTIME_LOCK_H */ - diff --git a/mblock/src/lib/qa_bitset.cc b/mblock/src/lib/qa_bitset.cc deleted file mode 100644 index 7cfd83856..000000000 --- a/mblock/src/lib/qa_bitset.cc +++ /dev/null @@ -1,496 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mblock/mblock.h> -#include <mblock/protocol_class.h> -#include <mblock/message.h> -#include <mblock/class_registry.h> -#include <iostream> -#include <cstdio> -#include <sstream> -#include <bitset> - -using namespace pmt; - -static pmt_t s_in = pmt_intern("in"); -static pmt_t s_out = pmt_intern("out"); -static pmt_t s_data = pmt_intern("data"); -static pmt_t s_start = pmt_intern("start"); -static pmt_t s_send_batch = pmt_intern("send-batch"); -static pmt_t s_long0 = pmt_from_long(0); - -static std::string -str(long x) -{ - std::ostringstream s; - s << x; - return s.str(); -} - -/*! - * \brief mblock used for QA. - * - * Messages arriving on "in" consist of a pair containing a (long) - * message number in the car, and a (long) bitmap in the cdr. For - * each message received on "in", a new message is sent on "out". The - * new message is the same format as the input, but the bitmap in - * the cdr has a "1" or'd into it that corresponds to the bit number - * specified in the constructor. - * - * The bitmap can be used by the ultimate receiver to confirm - * traversal of a set of blocks, if the blocks are assigned unique bit - * numbers. - */ -class qa_bitset : public mb_mblock -{ - mb_port_sptr d_in; - mb_port_sptr d_out; - int d_bitno; - -public: - qa_bitset(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - void handle_message(mb_message_sptr msg); -}; - -qa_bitset::qa_bitset(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - d_bitno = pmt_to_long(user_arg); // The bit we are to set - - d_in = define_port("in", "qa-bitset", false, mb_port::EXTERNAL); - d_out = define_port("out", "qa-bitset", true, mb_port::EXTERNAL); -} - -void -qa_bitset::handle_message(mb_message_sptr msg) -{ - if (pmt_eq(msg->port_id(), s_in) && pmt_eq(msg->signal(), s_data)){ - d_out->send(s_data, - pmt_cons(pmt_car(msg->data()), - pmt_from_long((1L << d_bitno) | pmt_to_long(pmt_cdr(msg->data()))))); - } -} - -REGISTER_MBLOCK_CLASS(qa_bitset); - -// ------------------------------------------------------------------------ - -/*! - * \brief mblock used for QA. Compose two qa_bitset mblocks. - */ -class qa_bitset2 : public mb_mblock -{ - mb_port_sptr d_in; - mb_port_sptr d_out; - -public: - qa_bitset2(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); -}; - -qa_bitset2::qa_bitset2(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - long bitno = pmt_to_long(user_arg); // The bit we are to set - - d_in = define_port("in", "qa-bitset", false, mb_port::RELAY); - d_out = define_port("out", "qa-bitset", true, mb_port::RELAY); - - define_component("bs0", "qa_bitset", pmt_from_long(bitno)); - define_component("bs1", "qa_bitset", pmt_from_long(bitno + 1)); - connect("self", "in", "bs0", "in"); - connect("bs0", "out", "bs1", "in"); - connect("bs1", "out", "self", "out"); -} - -REGISTER_MBLOCK_CLASS(qa_bitset2); - -// ------------------------------------------------------------------------ - -/*! - * \brief mblock used for QA. Compose two qa_bitset2 mblocks. - */ -class qa_bitset4 : public mb_mblock -{ - mb_port_sptr d_in; - mb_port_sptr d_out; - -public: - qa_bitset4(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); -}; - -qa_bitset4::qa_bitset4(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - long bitno = pmt_to_long(user_arg); // The bit we are to set - - d_in = define_port("in", "qa-bitset", false, mb_port::RELAY); - d_out = define_port("out", "qa-bitset", true, mb_port::RELAY); - - define_component("bs0", "qa_bitset2", pmt_from_long(bitno)); - define_component("bs1", "qa_bitset2", pmt_from_long(bitno + 2)); - connect("self", "in", "bs0", "in"); - connect("bs0", "out", "bs1", "in"); - connect("bs1", "out", "self", "out"); -} - -REGISTER_MBLOCK_CLASS(qa_bitset4); - -// ------------------------------------------------------------------------ - -/*! - * \brief mblock used for QA. Compose two qa_bitset4 mblocks. - */ -class qa_bitset8 : public mb_mblock -{ - mb_port_sptr d_in; - mb_port_sptr d_out; - -public: - qa_bitset8(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); -}; - -qa_bitset8::qa_bitset8(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - long bitno = pmt_to_long(user_arg); // The bit we are to set - - d_in = define_port("in", "qa-bitset", false, mb_port::RELAY); - d_out = define_port("out", "qa-bitset", true, mb_port::RELAY); - - define_component("bs0", "qa_bitset4", pmt_from_long(bitno)); - define_component("bs1", "qa_bitset4", pmt_from_long(bitno + 4)); - connect("self", "in", "bs0", "in"); - connect("bs0", "out", "bs1", "in"); - connect("bs1", "out", "self", "out"); -} - -REGISTER_MBLOCK_CLASS(qa_bitset8); - -// ------------------------------------------------------------------------ - -/*! - * \brief mblock used for QA. Compose two qa_bitset8 mblocks. - */ -class qa_bitset16 : public mb_mblock -{ - mb_port_sptr d_in; - mb_port_sptr d_out; - -public: - qa_bitset16(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); -}; - -qa_bitset16::qa_bitset16(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - long bitno = pmt_to_long(user_arg); // The bit we are to set - - d_in = define_port("in", "qa-bitset", false, mb_port::RELAY); - d_out = define_port("out", "qa-bitset", true, mb_port::RELAY); - - define_component("bs0", "qa_bitset8", pmt_from_long(bitno)); - define_component("bs1", "qa_bitset8", pmt_from_long(bitno + 8)); - connect("self", "in", "bs0", "in"); - connect("bs0", "out", "bs1", "in"); - connect("bs1", "out", "self", "out"); -} - -REGISTER_MBLOCK_CLASS(qa_bitset16); - -// ------------------------------------------------------------------------ - -/*! - * \brief mblock used for QA. Compose two qa_bitset16 mblocks. - */ -class qa_bitset32 : public mb_mblock -{ - mb_port_sptr d_in; - mb_port_sptr d_out; - -public: - qa_bitset32(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); -}; - -qa_bitset32::qa_bitset32(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - long bitno = pmt_to_long(user_arg); // The bit we are to set - - d_in = define_port("in", "qa-bitset", false, mb_port::RELAY); - d_out = define_port("out", "qa-bitset", true, mb_port::RELAY); - - define_component("bs0", "qa_bitset16", pmt_from_long(bitno)); - define_component("bs1", "qa_bitset16", pmt_from_long(bitno + 16)); - connect("self", "in", "bs0", "in"); - connect("bs0", "out", "bs1", "in"); - connect("bs1", "out", "self", "out"); -} - -REGISTER_MBLOCK_CLASS(qa_bitset32); - -// ------------------------------------------------------------------------ - -class qa_bitset_src : public mb_mblock -{ - mb_port_sptr d_cs_top; - mb_port_sptr d_cs; - - mb_port_sptr d_out; - - long d_msg_number; // starting message number - long d_nmsgs_to_send; // # of messages to send - long d_batch_size; // # of messages to send per batch - -public: - qa_bitset_src(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - void handle_message(mb_message_sptr msg); - -protected: - void send_one(); - void send_batch(); -}; - -qa_bitset_src::qa_bitset_src(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - d_msg_number = pmt_to_long(pmt_nth(0, user_arg)); - d_nmsgs_to_send = pmt_to_long(pmt_nth(1, user_arg)); - d_batch_size = pmt_to_long(pmt_nth(2, user_arg)); - - d_cs_top = define_port("cs_top", "qa-bitset-cs", true, mb_port::EXTERNAL); - d_cs = define_port("cs", "qa-bitset-cs", true, mb_port::EXTERNAL); - - d_out = define_port("out", "qa-bitset", true, mb_port::EXTERNAL); -} - -void -qa_bitset_src::handle_message(mb_message_sptr msg) -{ - if ((pmt_eq(msg->port_id(), d_cs_top->port_symbol()) - || pmt_eq(msg->port_id(), d_cs->port_symbol())) - && pmt_eq(msg->signal(), s_send_batch)){ - send_batch(); - } -} - -void -qa_bitset_src::send_batch() -{ - for (int i = 0; i < d_batch_size; i++) - send_one(); -} - -void -qa_bitset_src::send_one() -{ - if (d_nmsgs_to_send > 0){ - pmt_t msg_number = pmt_from_long(d_msg_number++); - d_out->send(s_data, pmt_cons(msg_number, s_long0)); - } - if (--d_nmsgs_to_send <= 0) - exit(); -} - -REGISTER_MBLOCK_CLASS(qa_bitset_src); - -// ------------------------------------------------------------------------ - -class qa_bitset_sink : public mb_mblock -{ - // Maximum number of messages we can track - static const size_t MAX_MSGS = 1 * 1024 * 1024; - - mb_port_sptr d_cs0; - mb_port_sptr d_cs1; - mb_port_sptr d_cs2; - mb_port_sptr d_cs3; - - mb_port_sptr d_in0; - mb_port_sptr d_in1; - mb_port_sptr d_in2; - mb_port_sptr d_in3; - - long d_nmsgs_to_recv; // # of messages to receive - long d_batch_size; // # of messages to receive per batch - uint32_t d_expected_mask; - - std::bitset<MAX_MSGS> d_bitset; - long d_nrecvd; - -public: - qa_bitset_sink(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - void handle_message(mb_message_sptr msg); - -protected: - void receive_one(mb_message_sptr msg); -}; - -qa_bitset_sink::qa_bitset_sink(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_nrecvd(0) -{ - d_nmsgs_to_recv = pmt_to_long(pmt_nth(0, user_arg)); - d_batch_size = pmt_to_long(pmt_nth(1, user_arg)); - d_expected_mask = pmt_to_long(pmt_nth(2, user_arg)); - - if (d_nmsgs_to_recv > (long) MAX_MSGS) - throw std::out_of_range("qa_bitset_sink: nmsgs_to_recv is too big"); - - if (d_batch_size < 1) - throw std::out_of_range("qa_bitset_sink: batch_size must be >= 1"); - - d_cs0 = define_port("cs0", "qa-bitset-cs", true, mb_port::EXTERNAL); - d_cs1 = define_port("cs1", "qa-bitset-cs", true, mb_port::EXTERNAL); - d_cs2 = define_port("cs2", "qa-bitset-cs", true, mb_port::EXTERNAL); - d_cs3 = define_port("cs3", "qa-bitset-cs", true, mb_port::EXTERNAL); - - d_in0 = define_port("in0", "qa-bitset", false, mb_port::EXTERNAL); - d_in1 = define_port("in1", "qa-bitset", false, mb_port::EXTERNAL); - d_in2 = define_port("in2", "qa-bitset", false, mb_port::EXTERNAL); - d_in3 = define_port("in3", "qa-bitset", false, mb_port::EXTERNAL); -} - -void -qa_bitset_sink::handle_message(mb_message_sptr msg) -{ - if ((pmt_eq(msg->port_id(), d_in0->port_symbol()) - || pmt_eq(msg->port_id(), d_in1->port_symbol()) - || pmt_eq(msg->port_id(), d_in2->port_symbol()) - || pmt_eq(msg->port_id(), d_in3->port_symbol())) - && pmt_eq(msg->signal(), s_data)){ - - receive_one(msg); - } -} - -void -qa_bitset_sink::receive_one(mb_message_sptr msg) -{ - long msg_number = pmt_to_long(pmt_car(msg->data())); - uint32_t mask = pmt_to_long(pmt_cdr(msg->data())); - - // std::cout << msg->data() << std::endl; - - d_nrecvd++; - if (d_nrecvd % d_batch_size == d_batch_size - 1){ - d_cs0->send(s_send_batch); - d_cs1->send(s_send_batch); - d_cs2->send(s_send_batch); - d_cs3->send(s_send_batch); - } - - if (msg_number >= d_nmsgs_to_recv){ - std::cerr << "qa_bitset_sink::receive_one: msg_number too big (" - << msg_number << ")\n"; - shutdown_all(PMT_F); - return; - } - if (mask != d_expected_mask){ - fprintf(stderr, - "qa_bitset_sink::receive_one: Wrong mask. Expected 0x%08x, got 0x%08x\n", - d_expected_mask, mask); - shutdown_all(PMT_F); - return; - } - - if (d_bitset.test((size_t) msg_number)){ - std::cerr << "qa_bitset_sink::receive_one: duplicate msg_number (" - << msg_number << ")\n"; - shutdown_all(PMT_F); - return; - } - - d_bitset.set((size_t) msg_number); - if (d_nrecvd == d_nmsgs_to_recv) - shutdown_all(PMT_T); // we're done! -} - -REGISTER_MBLOCK_CLASS(qa_bitset_sink); - -// ------------------------------------------------------------------------ - -class qa_bitset_top : public mb_mblock -{ - static const int NPIPES = 4; - - std::vector<mb_port_sptr> d_cs; - - long d_nmsgs; // # of messages to send - long d_batch_size; // # of messages to receive per batch - -public: - qa_bitset_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - void initial_transition(); -}; - -qa_bitset_top::qa_bitset_top(mb_runtime *runtime, - const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - d_nmsgs = pmt_to_long(pmt_nth(0, user_arg)); - d_nmsgs = (d_nmsgs / NPIPES) * NPIPES; - d_batch_size = pmt_to_long(pmt_nth(1, user_arg)); - - /* - * We build NPIPES sources which feed NPIPES pipelines, each of which - * consists of 8-mblocks. All pipelines feed into a single sink - * which keeps track the results. - */ - for (int i = 0; i < NPIPES; i++){ - d_cs.push_back(define_port("cs"+str(i), "qa-bitset-cs", false, mb_port::INTERNAL)); - - // sources of test messages - define_component("src"+str(i), "qa_bitset_src", - pmt_list3(pmt_from_long(i * d_nmsgs/NPIPES), - pmt_from_long(d_nmsgs/NPIPES), - pmt_from_long(d_batch_size))); - - // 8-mblock processing pipelines - define_component("pipeline"+str(i), "qa_bitset8", pmt_from_long(0)); - } - - // sink for output of pipelines - define_component("sink", "qa_bitset_sink", - pmt_list3(pmt_from_long(d_nmsgs), - pmt_from_long(d_batch_size * NPIPES), - pmt_from_long(0x000000ff))); - - for (int i = 0; i < NPIPES; i++){ - connect("self", "cs"+str(i), "src"+str(i), "cs_top"); - connect("src"+str(i), "out", "pipeline"+str(i), "in"); - connect("src"+str(i), "cs", "sink", "cs"+str(i)); - connect("pipeline"+str(i), "out", "sink", "in"+str(i)); - } -} - -void -qa_bitset_top::initial_transition() -{ - for (int i = 0; i < NPIPES; i++){ - d_cs[i]->send(s_send_batch); // prime the pump - d_cs[i]->send(s_send_batch); - } -} - -REGISTER_MBLOCK_CLASS(qa_bitset_top); diff --git a/mblock/src/lib/qa_bitset.mbh b/mblock/src/lib/qa_bitset.mbh deleted file mode 100644 index 3fbcb80db..000000000 --- a/mblock/src/lib/qa_bitset.mbh +++ /dev/null @@ -1,61 +0,0 @@ -;; -*- scheme -*- ; not really, but tells emacs how to format this -;; -;; Copyright 2007 Free Software Foundation, Inc. -;; -;; This file is part of GNU Radio -;; -;; GNU Radio is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. -;; -;; GNU Radio is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License along -;; with this program; if not, write to the Free Software Foundation, Inc., -;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -;; - -;; ---------------------------------------------------------------- -;; qa-bitset -- interface to mblock QA code -;; - -(define-protocol-class qa-bitset - - (:incoming - - (data n bitmask) - - ) - ) - -(define-protocol-class qa-bitset-cs - - (:outgoing - - (send-batch) - - ) - ) - -;; ---------------------------------------------------------------- -;; qa-disconnect -- interface to mblock QA code -;; - -(define-protocol-class qa-disconnect-cs - - (:outgoing - - (select-pipe n) - - ) - - (:incoming - - (ack n) - - ) - ) diff --git a/mblock/src/lib/qa_disconnect.cc b/mblock/src/lib/qa_disconnect.cc deleted file mode 100644 index c7619bfc3..000000000 --- a/mblock/src/lib/qa_disconnect.cc +++ /dev/null @@ -1,241 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <mblock/mblock.h> -#include <mblock/protocol_class.h> -#include <mblock/message.h> -#include <mblock/class_registry.h> -#include <iostream> -#include <cstdio> -#include <sstream> -#include <bitset> - -using namespace pmt; - -static pmt_t s_in = pmt_intern("in"); -static pmt_t s_out = pmt_intern("out"); -static pmt_t s_data = pmt_intern("data"); -static pmt_t s_ack = pmt_intern("ack"); -static pmt_t s_select_pipe = pmt_intern("select-pipe"); -static pmt_t s_long0 = pmt_from_long(0); -static pmt_t s_sys_port = pmt_intern("%sys-port"); -static pmt_t s_shutdown = pmt_intern("%shutdown"); - -class qa_disconnect_mux : public mb_mblock -{ - mb_port_sptr d_in; - mb_port_sptr d_out; - mb_port_sptr d_cs; - -public: - qa_disconnect_mux(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - void initial_transition(); - void handle_message(mb_message_sptr msg); -}; - -qa_disconnect_mux::qa_disconnect_mux(mb_runtime *runtime, - const std::string &instance_name, - pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - d_in = define_port("in", "qa-bitset", false, mb_port::RELAY); - d_out = define_port("out", "qa-bitset", true, mb_port::RELAY); - d_cs = define_port("cs", "qa-disconnect-cs", true, mb_port::EXTERNAL); - - define_component("pipeline0", "qa_bitset8", pmt_from_long(0)); - define_component("pipeline1", "qa_bitset8", pmt_from_long(8)); -} - -void -qa_disconnect_mux::initial_transition(){} - -void -qa_disconnect_mux::handle_message(mb_message_sptr msg) -{ - if (pmt_eq(msg->port_id(), d_cs->port_symbol()) // select-pipe on cs - && pmt_eq(msg->signal(), s_select_pipe)){ - - long which_pipe = pmt_to_long(pmt_nth(0, msg->data())); - - disconnect_component("pipeline0"); - disconnect_component("pipeline1"); - - switch(which_pipe){ - - case 0: - connect("self", "in", "pipeline0", "in"); - connect("self", "out", "pipeline0", "out"); - break; - - case 1: - connect("self", "in", "pipeline1", "in"); - connect("self", "out", "pipeline1", "out"); - break; - } - - d_cs->send(s_ack, msg->data()); - return; - } -} - -REGISTER_MBLOCK_CLASS(qa_disconnect_mux); - -// ------------------------------------------------------------------------ - -class qa_disconnect_top : public mb_mblock -{ - enum state_t { - UNINITIALIZED, - WAIT_FOR_ACK, - WAIT_FOR_DATA - }; - - state_t d_state; - int d_msg_number; - int d_nmsgs_to_send; - - mb_port_sptr d_in; - mb_port_sptr d_out; - mb_port_sptr d_cs; - - void check_pipe_send_next_msg(); - void send_next_msg(); - void select_pipe(int n); - - // alternate pipes every 128 messages - static int which_pipe(int msg_number) { return (msg_number >> 7) & 0x1; } - bool time_to_switch() { return (d_msg_number & 0x7f) == 0; } - -public: - qa_disconnect_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - void initial_transition(); - void handle_message(mb_message_sptr msg); -}; - -qa_disconnect_top::qa_disconnect_top(mb_runtime *runtime, - const std::string &instance_name, - pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_state(UNINITIALIZED), d_msg_number(0) -{ - d_nmsgs_to_send = pmt_to_long(pmt_nth(0, user_arg)); - - d_in = define_port("in", "qa-bitset", false, mb_port::INTERNAL); - d_out = define_port("out", "qa-bitset", true, mb_port::INTERNAL); - d_cs = define_port("cs", "qa-disconnect-cs", false, mb_port::INTERNAL); - - define_component("mux", "qa_disconnect_mux", PMT_F); - - connect("self", "cs", "mux", "cs"); - connect("self", "out", "mux", "in"); - connect("self", "in", "mux", "out"); -} - -void -qa_disconnect_top::initial_transition() -{ - check_pipe_send_next_msg(); -} - -void -qa_disconnect_top::handle_message(mb_message_sptr msg) -{ - if (0) - std::cerr << "qa_disconnect_top::handle_msg state = " - << d_state << "\n msg = " << msg << std::endl; - - if (pmt_eq(msg->port_id(), d_cs->port_symbol()) // ack on cs - && pmt_eq(msg->signal(), s_ack) - && d_state == WAIT_FOR_ACK){ - - send_next_msg(); - return; - } - - if (pmt_eq(msg->port_id(), d_in->port_symbol()) // data on in - && pmt_eq(msg->signal(), s_data) - && d_state == WAIT_FOR_DATA){ - - /* - * Confirm that msg passed through the pipe that we expect... - */ - static const long expected_mask[2] = { 0x000000ff, 0x0000ff00 }; - - long msg_number = pmt_to_long(pmt_car(msg->data())); - long mask = pmt_to_long(pmt_cdr(msg->data())); - - if (mask != expected_mask[which_pipe(msg_number)]){ - fprintf(stderr, "\nqa_disconnect_top: wrong mask in msg_number = 0x%08lx\n", - msg_number); - fprintf(stderr, " expected = 0x%08lx, actual = 0x%08lx\n", - expected_mask[which_pipe(msg_number)], mask); - shutdown_all(PMT_F); - return; - } - - if (msg_number == d_nmsgs_to_send - 1){ // we're done (and were successful) - shutdown_all(PMT_T); - return; - } - - check_pipe_send_next_msg(); - return; - } - - if (pmt_eq(msg->port_id(), s_sys_port) // ignore %shutdown on %sys-port - && pmt_eq(msg->signal(), s_shutdown)) - return; - - std::cerr << "qa_disconnect_top: unhandled msg: state = " - << d_state << "\n msg = " << msg << std::endl; -} - -void -qa_disconnect_top::select_pipe(int n) -{ - d_cs->send(s_select_pipe, pmt_list1(pmt_from_long(n))); - d_state = WAIT_FOR_ACK; -} - -void -qa_disconnect_top::send_next_msg() -{ - d_state = WAIT_FOR_DATA; - if (d_msg_number == d_nmsgs_to_send) // we've sent all we're supposed to - return; - - d_out->send(s_data, pmt_cons(pmt_from_long(d_msg_number), s_long0)); - d_msg_number++; -} - -void -qa_disconnect_top::check_pipe_send_next_msg() -{ - if (time_to_switch()) - select_pipe(which_pipe(d_msg_number)); - else - send_next_msg(); -} - -REGISTER_MBLOCK_CLASS(qa_disconnect_top); diff --git a/mblock/src/lib/qa_mblock.cc b/mblock/src/lib/qa_mblock.cc deleted file mode 100644 index c0629790d..000000000 --- a/mblock/src/lib/qa_mblock.cc +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 2006 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -/* - * This class gathers together all the test cases for mblock into - * a single test suite. As you create new test cases, add them here. - */ - -#include <qa_mblock.h> -#include <qa_mblock_prims.h> -#include <qa_mblock_send.h> -#include <qa_mblock_sys.h> -#include <qa_timeouts.h> - -CppUnit::TestSuite * -qa_mblock::suite() -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite("mblock"); - - s->addTest (qa_mblock_prims::suite()); - s->addTest (qa_mblock_send::suite()); - s->addTest (qa_mblock_sys::suite()); - s->addTest (qa_timeouts::suite()); - - return s; -} diff --git a/mblock/src/lib/qa_mblock.h b/mblock/src/lib/qa_mblock.h deleted file mode 100644 index 056c42237..000000000 --- a/mblock/src/lib/qa_mblock.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef INCLUDED_QA_MBLOCK_H -#define INCLUDED_QA_MBLOCK_H - -#include <cppunit/TestSuite.h> - -//! collect all the tests for mblock - -class qa_mblock { - public: - //! return suite of tests for all of mblock - static CppUnit::TestSuite *suite(); -}; - -#endif /* INCLUDED_QA_MBLOCK_H */ diff --git a/mblock/src/lib/qa_mblock_prims.cc b/mblock/src/lib/qa_mblock_prims.cc deleted file mode 100644 index e49bd60d4..000000000 --- a/mblock/src/lib/qa_mblock_prims.cc +++ /dev/null @@ -1,448 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_mblock_prims.h> -#include <cppunit/TestAssert.h> -#include <mblock/mblock.h> -#include <mblock/runtime.h> -#include <mblock/protocol_class.h> -#include <mblock/exception.h> -#include <mblock/msg_queue.h> -#include <mblock/message.h> -#include <mb_mblock_impl.h> -#include <mblock/msg_accepter.h> -#include <mblock/class_registry.h> -#include <stdio.h> - -using namespace pmt; - -static pmt_t s_cs = pmt_intern("cs"); -static pmt_t s_debug = pmt_intern("debug"); -static pmt_t s_in = pmt_intern("in"); -static pmt_t s_out = pmt_intern("out"); - - -// ================================================================ - -class dp_1 : public mb_mblock -{ -public: - dp_1(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~dp_1(); -}; - -dp_1::dp_1(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ -} - -dp_1::~dp_1(){} - -REGISTER_MBLOCK_CLASS(dp_1); - -// ---------------------------------------------------------------- - -class dp_2 : public mb_mblock -{ -public: - dp_2(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~dp_2(); -}; - -dp_2::dp_2(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - define_port("cs", "cs-protocol", false, mb_port::EXTERNAL); -} - -dp_2::~dp_2(){} - -REGISTER_MBLOCK_CLASS(dp_2); - -// ---------------------------------------------------------------- - -class dp_3 : public mb_mblock -{ -public: - dp_3(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~dp_3(); -}; - -dp_3::dp_3(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - define_port("cs", "cs-protocol", false, mb_port::EXTERNAL); - define_port("cs", "cs-protocol", false, mb_port::EXTERNAL); // duplicate def -} - -dp_3::~dp_3(){} - -REGISTER_MBLOCK_CLASS(dp_3); - -// ---------------------------------------------------------------- - -void -qa_mblock_prims::test_define_ports() -{ - - mb_runtime_sptr rts = mb_make_runtime(); - mb_runtime *rt = rts.get(); - - // Should work - mb_mblock_sptr mb1 = mb_mblock_sptr(new dp_1(rt, "top", PMT_F)); - - // raises runtime_error because of unknown protocol "cs-protocol" - CPPUNIT_ASSERT_THROW(mb_mblock_sptr(new dp_2(rt, "top", PMT_F)), - std::runtime_error); - - // define the protocol class - pmt_t pc = mb_make_protocol_class(pmt_intern("cs-protocol"), - pmt_list2(pmt_intern("start"), - pmt_intern("stop")), - PMT_NIL); - - // std::cout << "pc = " << pc << '\n'; - - mb_mblock_sptr mb2 = mb_mblock_sptr(new dp_2(rt, "top", PMT_F)); - - // raises pmt_exception because of duplicate port definition of "cs" - CPPUNIT_ASSERT_THROW(mb_mblock_sptr(new dp_3(rt, "top", PMT_F)), - mbe_duplicate_port); -} - -// ================================================================ - -class dc_0 : public mb_mblock -{ -public: - dc_0(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~dc_0(); -}; - -dc_0::dc_0(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ -} - -dc_0::~dc_0() {} - -REGISTER_MBLOCK_CLASS(dc_0); - -// ---------------------------------------------------------------- - -class dc_ok : public mb_mblock -{ -public: - dc_ok(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~dc_ok(); -}; - -dc_ok::dc_ok(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - define_component("c0", "dc_0"); - define_component("c1", "dc_0"); - define_component("c2", "dc_0"); -} - -dc_ok::~dc_ok(){} - -REGISTER_MBLOCK_CLASS(dc_ok); - -// ---------------------------------------------------------------- - -class dc_not_ok : public mb_mblock -{ -public: - dc_not_ok(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~dc_not_ok(); -}; - -dc_not_ok::dc_not_ok(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - define_component("c0", "dc_0"); - define_component("c0", "dc_0"); // duplicate name -} - -dc_not_ok::~dc_not_ok(){} - -REGISTER_MBLOCK_CLASS(dc_not_ok); - -// ---------------------------------------------------------------- - -void -qa_mblock_prims::test_define_components() -{ - mb_runtime_sptr rts = mb_make_runtime(); - mb_runtime *rt = rts.get(); - - // Should work - mb_mblock_sptr mb1 = mb_mblock_sptr(new dc_ok(rt, "top", PMT_F)); - - // raises pmt_exception because of duplicate component definition of "c0" - CPPUNIT_ASSERT_THROW(mb_mblock_sptr(new dc_not_ok(rt, "top", PMT_F)), - mbe_duplicate_component); -} - -// ================================================================ - -class tc_norm : public mb_mblock -{ -public: - tc_norm(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) - { - define_port("data", "i/o", false, mb_port::EXTERNAL); - define_port("norm", "i/o", false, mb_port::EXTERNAL); - define_port("conj", "i/o", true, mb_port::EXTERNAL); - define_port("int", "i/o", false, mb_port::INTERNAL); - } - - ~tc_norm(); -}; - -tc_norm::~tc_norm(){} - -REGISTER_MBLOCK_CLASS(tc_norm); - -//////////////////////////////////////////////////////////////// - -class tc_0 : public mb_mblock -{ -public: - tc_0(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) - { - define_port("norm", "i/o", false, mb_port::EXTERNAL); - define_port("conj", "i/o", true, mb_port::EXTERNAL); - define_port("int", "i/o", false, mb_port::INTERNAL); - - define_component("c0", "tc_norm"); - define_component("c1", "tc_norm"); - define_component("c2", "tc_norm"); - define_component("c3", "tc_norm"); - define_component("c4", "tc_norm"); - define_component("c5", "tc_norm"); - - // OK - connect("c0", "norm", "c1", "conj"); - - // No: No such component name - CPPUNIT_ASSERT_THROW(connect("foo", "data", "c1", "norm"), mbe_no_such_component); - - // No: No such port name - CPPUNIT_ASSERT_THROW(connect("c0", "data", "c1", "foo"), mbe_no_such_port); - - // No: already connected - CPPUNIT_ASSERT_THROW(connect("c0", "norm", "c2", "data"), mbe_already_connected); - - // No: already connected - CPPUNIT_ASSERT_THROW(connect("c2", "data", "c0", "norm"), mbe_already_connected); - - // No: incompatible ports - CPPUNIT_ASSERT_THROW(connect("c1", "norm", "c2", "norm"), mbe_incompatible_ports); - - // OK - connect("c1", "norm", "c2", "conj"); - - // No: No such port name - CPPUNIT_ASSERT_THROW(connect("c2", "norm", "self", "foo"), mbe_no_such_port); - - // No: can't connect to child's internal port - CPPUNIT_ASSERT_THROW(connect("c0", "conj", "c2", "int"), mbe_no_such_port); - - // No: can't connect to our own external port - CPPUNIT_ASSERT_THROW(connect("self", "norm", "c0", "conj"), mbe_invalid_port_type); - - // OK: connecting to one of our internal ports - connect("self", "int", "c3", "conj"); - - // ===== Now test disconnecting some stuff ===== - - // Confirm we're already connected - CPPUNIT_ASSERT_THROW(connect("self", "int", "c3", "conj"), mbe_already_connected); - - int nc = nconnections(); - disconnect("self", "int", "c3", "conj"); // disconnect - CPPUNIT_ASSERT_EQUAL(nc-1, nconnections()); - - connect("self", "int", "c3", "conj"); // reconnect - CPPUNIT_ASSERT_EQUAL(nc, nconnections()); - - // confirm we're already connected - CPPUNIT_ASSERT_THROW(connect("self", "int", "c3", "conj"), mbe_already_connected); - - - connect("c0", "conj", "c5", "data"); - connect("c4", "norm", "c5", "conj"); - connect("c4", "conj", "c5", "norm"); - - nc = nconnections(); - disconnect_component("c4"); - CPPUNIT_ASSERT_EQUAL(nc-2, nconnections()); - - disconnect_component("c5"); - CPPUNIT_ASSERT_EQUAL(nc-3, nconnections()); - - disconnect_all(); - CPPUNIT_ASSERT_EQUAL(0, nconnections()); - - } - - ~tc_0(); -}; - -tc_0::~tc_0(){} - -REGISTER_MBLOCK_CLASS(tc_0); - -//////////////////////////////////////////////////////////////// - -class tc_1 : public mb_mblock -{ -public: - tc_1(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) - { - define_component("c0", "tc_norm"); - define_component("c1", "tc_norm"); - - connect("c0", "norm", "c1", "conj"); - } - - ~tc_1(); -}; - -tc_1::~tc_1(){} - -REGISTER_MBLOCK_CLASS(tc_1); - -//////////////////////////////////////////////////////////////// - -void -qa_mblock_prims::test_connect() -{ - // define the protocol class - mb_make_protocol_class(pmt_intern("data"), // name of class - pmt_list1(pmt_intern("data")), // in - PMT_NIL); // out - - mb_make_protocol_class(pmt_intern("i/o"), // name of class - pmt_list1(pmt_intern("in")), // in - pmt_list1(pmt_intern("out"))); // out - - mb_runtime_sptr rts = mb_make_runtime(); - mb_runtime *rt = rts.get(); - - mb_mblock_sptr mb0 = mb_mblock_sptr(new tc_0(rt, "top", PMT_F)); -} - -//////////////////////////////////////////////////////////////// - -void -qa_mblock_prims::test_msg_queue() -{ - mb_msg_queue q; - - // check initial state - CPPUNIT_ASSERT(q.get_highest_pri_msg_nowait() == 0); - - CPPUNIT_ASSERT(MB_NPRI >= 5); // sanity check for this test - - // insert three messages at the same pri and ensure that they come out in order - // signal data metadata pri - q.insert(mb_make_message(PMT_NIL, pmt_from_long(0), PMT_NIL, MB_PRI_BEST + 2)); - q.insert(mb_make_message(PMT_NIL, pmt_from_long(1), PMT_NIL, MB_PRI_BEST + 2)); - q.insert(mb_make_message(PMT_NIL, pmt_from_long(2), PMT_NIL, MB_PRI_BEST + 2)); - - CPPUNIT_ASSERT_EQUAL(0L, pmt_to_long(q.get_highest_pri_msg_nowait()->data())); - CPPUNIT_ASSERT_EQUAL(1L, pmt_to_long(q.get_highest_pri_msg_nowait()->data())); - CPPUNIT_ASSERT_EQUAL(2L, pmt_to_long(q.get_highest_pri_msg_nowait()->data())); - - CPPUNIT_ASSERT(q.get_highest_pri_msg_nowait() == 0); - - - // insert messages of different priorities in pseudo-random order - // signal data metadata pri - q.insert(mb_make_message(PMT_NIL, PMT_NIL, PMT_NIL, MB_PRI_BEST + 3)); - q.insert(mb_make_message(PMT_NIL, PMT_NIL, PMT_NIL, MB_PRI_BEST + 2)); - q.insert(mb_make_message(PMT_NIL, PMT_NIL, PMT_NIL, MB_PRI_BEST + 4)); - q.insert(mb_make_message(PMT_NIL, PMT_NIL, PMT_NIL, MB_PRI_BEST + 0)); - q.insert(mb_make_message(PMT_NIL, PMT_NIL, PMT_NIL, MB_PRI_BEST + 1)); - q.insert(mb_make_message(PMT_NIL, PMT_NIL, PMT_NIL, MB_PRI_BEST + 3)); - q.insert(mb_make_message(PMT_NIL, PMT_NIL, PMT_NIL, MB_PRI_BEST + 2)); - q.insert(mb_make_message(PMT_NIL, PMT_NIL, PMT_NIL, MB_PRI_BEST + 4)); - q.insert(mb_make_message(PMT_NIL, PMT_NIL, PMT_NIL, MB_PRI_BEST + 0)); - q.insert(mb_make_message(PMT_NIL, PMT_NIL, PMT_NIL, MB_PRI_BEST + 1)); - - // confirm that they come out in order - CPPUNIT_ASSERT_EQUAL(MB_PRI_BEST + 0, q.get_highest_pri_msg_nowait()->priority()); - CPPUNIT_ASSERT_EQUAL(MB_PRI_BEST + 0, q.get_highest_pri_msg_nowait()->priority()); - CPPUNIT_ASSERT_EQUAL(MB_PRI_BEST + 1, q.get_highest_pri_msg_nowait()->priority()); - CPPUNIT_ASSERT_EQUAL(MB_PRI_BEST + 1, q.get_highest_pri_msg_nowait()->priority()); - CPPUNIT_ASSERT_EQUAL(MB_PRI_BEST + 2, q.get_highest_pri_msg_nowait()->priority()); - CPPUNIT_ASSERT_EQUAL(MB_PRI_BEST + 2, q.get_highest_pri_msg_nowait()->priority()); - CPPUNIT_ASSERT_EQUAL(MB_PRI_BEST + 3, q.get_highest_pri_msg_nowait()->priority()); - CPPUNIT_ASSERT_EQUAL(MB_PRI_BEST + 3, q.get_highest_pri_msg_nowait()->priority()); - CPPUNIT_ASSERT_EQUAL(MB_PRI_BEST + 4, q.get_highest_pri_msg_nowait()->priority()); - CPPUNIT_ASSERT_EQUAL(MB_PRI_BEST + 4, q.get_highest_pri_msg_nowait()->priority()); - - // check final state - CPPUNIT_ASSERT(q.get_highest_pri_msg_nowait() == 0); -} - -//////////////////////////////////////////////////////////////// - -void -qa_mblock_prims::test_make_accepter() -{ - mb_runtime_sptr rts = mb_make_runtime(); - mb_runtime *rt = rts.get(); - - // create a block - mb_mblock_sptr mb = mb_mblock_sptr(new dp_2(rt, "top", PMT_F)); - - // use "internal use only" method... - mb_msg_accepter_sptr accepter = mb->impl()->make_accepter(pmt_intern("cs")); - - // Now push a few messages into it... - // signal data metadata pri - (*accepter)(PMT_NIL, pmt_from_long(0), PMT_NIL, MB_PRI_BEST + 2); - (*accepter)(PMT_NIL, pmt_from_long(1), PMT_NIL, MB_PRI_BEST + 2); - (*accepter)(PMT_NIL, pmt_from_long(2), PMT_NIL, MB_PRI_BEST + 2); - - // try to pull them out - - pmt_t cs = pmt_intern("cs"); - - mb_message_sptr msg = mb->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(pmt_eq(cs, msg->port_id())); // confirm that port_id is set - CPPUNIT_ASSERT_EQUAL(0L, pmt_to_long(msg->data())); // and that data is correct - - CPPUNIT_ASSERT_EQUAL(1L, pmt_to_long(mb->impl()->msgq().get_highest_pri_msg_nowait()->data())); - CPPUNIT_ASSERT_EQUAL(2L, pmt_to_long(mb->impl()->msgq().get_highest_pri_msg_nowait()->data())); -} diff --git a/mblock/src/lib/qa_mblock_prims.h b/mblock/src/lib/qa_mblock_prims.h deleted file mode 100644 index cf928ee4f..000000000 --- a/mblock/src/lib/qa_mblock_prims.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_QA_MBLOCK_PRIMS_H -#define INCLUDED_QA_MBLOCK_PRIMS_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_mblock_prims : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE(qa_mblock_prims); - CPPUNIT_TEST(test_define_ports); - CPPUNIT_TEST(test_define_components); - CPPUNIT_TEST(test_connect); - CPPUNIT_TEST(test_msg_queue); - CPPUNIT_TEST(test_make_accepter); - CPPUNIT_TEST_SUITE_END(); - - private: - void test_define_ports(); - void test_define_components(); - void test_connect(); - void test_msg_queue(); - void test_make_accepter(); -}; - -#endif /* INCLUDED_QA_MBLOCK_PRIMS_H */ - diff --git a/mblock/src/lib/qa_mblock_send.cc b/mblock/src/lib/qa_mblock_send.cc deleted file mode 100644 index 53f93927b..000000000 --- a/mblock/src/lib/qa_mblock_send.cc +++ /dev/null @@ -1,477 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_mblock_send.h> -#include <cppunit/TestAssert.h> -#include <mblock/mblock.h> -#include <mblock/runtime.h> -#include <mb_runtime_nop.h> // QA only -#include <mblock/protocol_class.h> -#include <mblock/exception.h> -#include <mblock/msg_queue.h> -#include <mblock/message.h> -#include <mb_mblock_impl.h> -#include <mblock/msg_accepter.h> -#include <mblock/class_registry.h> -#include <stdio.h> - -using namespace pmt; - -static pmt_t s_data = pmt_intern("data"); -static pmt_t s_status = pmt_intern("status"); -static pmt_t s_control = pmt_intern("control"); -static pmt_t s_p0 = pmt_intern("p0"); -static pmt_t s_p1 = pmt_intern("p1"); -static pmt_t s_p2 = pmt_intern("p2"); -static pmt_t s_p3 = pmt_intern("p3"); -static pmt_t s_e1 = pmt_intern("e1"); -static pmt_t s_r1 = pmt_intern("r1"); - -static void -define_protocol_classes() -{ - // Defined from client point-of-view. - mb_make_protocol_class(pmt_intern("qa-send-cs"), // name - pmt_list1(s_status), // incoming - pmt_list1(s_control)); // outgoing - -} - -mb_mblock_sptr -get_top(mb_runtime_sptr rts) -{ - return dynamic_cast<mb_runtime_nop *>(rts.get())->top(); -} - -// ================================================================ -// test_simple_routing -// ================================================================ - -// sub-block for test_simple_routing - -class sr1 : public mb_mblock -{ - mb_port_sptr d_p1; - mb_port_sptr d_p2; - mb_port_sptr d_p3; - -public: - sr1(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~sr1(); - void initial_transition(); -}; - -sr1::sr1(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - d_p1 = define_port("p1", "qa-send-cs", true, mb_port::EXTERNAL); - d_p2 = define_port("p2", "qa-send-cs", true, mb_port::EXTERNAL); - d_p3 = define_port("p3", "qa-send-cs", false, mb_port::EXTERNAL); -} - -sr1::~sr1(){} - -void -sr1::initial_transition() -{ - // std::cout << instance_name() << "[sr1]: initial_transition\n"; - - // send two messages to each port - pmt_t our_name = pmt_intern(instance_name()); - d_p1->send(s_status, pmt_list3(our_name, s_p1, pmt_from_long(0))); - d_p1->send(s_status, pmt_list3(our_name, s_p1, pmt_from_long(1))); - - d_p2->send(s_status, pmt_list3(our_name, s_p2, pmt_from_long(0))); - d_p2->send(s_status, pmt_list3(our_name, s_p2, pmt_from_long(1))); -} - -REGISTER_MBLOCK_CLASS(sr1); - -// ---------------------------------------------------------------- - -// top-level container block for test_simple_routing -class sr0 : public mb_mblock -{ - mb_port_sptr d_p0; - -public: - sr0(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~sr0(); - void initial_transition(); -}; - -sr0::sr0(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - d_p0 = define_port("p0", "qa-send-cs", false, mb_port::INTERNAL); - - define_component("mb1", "sr1"); - define_component("mb2", "sr1"); - - connect("self", "p0", "mb1", "p1"); - connect("mb1", "p2", "mb2", "p3"); - connect("mb1", "p3", "mb2", "p2"); -} - -sr0::~sr0(){} - -void -sr0::initial_transition() -{ - // std::cout << instance_name() << "[sr0]: initial_transition\n"; - - // send two messages to p0 - pmt_t our_name = pmt_intern(instance_name()); - d_p0->send(s_control, pmt_list3(our_name, s_p0, pmt_from_long(0))); - d_p0->send(s_control, pmt_list3(our_name, s_p0, pmt_from_long(1))); -} - -REGISTER_MBLOCK_CLASS(sr0); - -// ---------------------------------------------------------------- - -/* - * This tests basic message routing using INTERNAL and EXTERNAL ports. - * It does not rely on the guts of the runtime being complete, - * which is good, because at the time this is being written, it isn't. - */ -void -qa_mblock_send::test_simple_routing() -{ - define_protocol_classes(); - - mb_message_sptr msg; - - mb_runtime_sptr rt = mb_make_runtime_nop(); - rt->run("top", "sr0", PMT_F); - - mb_mblock_sptr mb0 = get_top(rt); - - // Reach into the guts and see if the messages ended up where they should have - - // mb0 should have received two messages sent from mb1 via its p1 - msg = mb0->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - // std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p0, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/mb1"), s_p1, pmt_from_long(0)), - msg->data())); - - msg = mb0->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - // std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p0, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/mb1"), s_p1, pmt_from_long(1)), - msg->data())); - - // mb1 should have received - // two messages from mb0 via its p0 and - // two messages from mb2 via its p3 - - mb_mblock_sptr mb1 = mb0->impl()->component("mb1"); - - msg = mb1->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - // std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p1, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top"), s_p0, pmt_from_long(0)), - msg->data())); - - msg = mb1->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - // std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p1, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top"), s_p0, pmt_from_long(1)), - msg->data())); - - msg = mb1->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - // std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p3, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/mb2"), s_p2, pmt_from_long(0)), - msg->data())); - - msg = mb1->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - // std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p3, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/mb2"), s_p2, pmt_from_long(1)), - msg->data())); - - - // mb2 should have received - // two messages from mb2 via its p2 - - mb_mblock_sptr mb2 = mb0->impl()->component("mb2"); - - msg = mb2->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - // std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p3, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/mb1"), s_p2, pmt_from_long(0)), - msg->data())); - - msg = mb2->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - // std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p3, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/mb1"), s_p2, pmt_from_long(1)), - msg->data())); -} - -// ================================================================ -// test_relay_routing_1 -// ================================================================ - -// internal block for test_relay_routing - -class rr2 : public mb_mblock -{ - mb_port_sptr d_p1; - mb_port_sptr d_p2; - -public: - rr2(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~rr2(); - void initial_transition(); -}; - -rr2::rr2(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - d_p1 = define_port("p1", "qa-send-cs", true, mb_port::EXTERNAL); - d_p2 = define_port("p2", "qa-send-cs", false, mb_port::EXTERNAL); -} - -rr2::~rr2(){} - -void -rr2::initial_transition() -{ - // std::cout << instance_name() << "[rr2]: initial_transition\n"; - - // send two messages via p1 - pmt_t our_name = pmt_intern(instance_name()); - d_p1->send(s_status, pmt_list3(our_name, s_p1, pmt_from_long(0))); - d_p1->send(s_status, pmt_list3(our_name, s_p1, pmt_from_long(1))); -} - -REGISTER_MBLOCK_CLASS(rr2); - -// ---------------------------------------------------------------- - -// intermediate block for test_relay_routing - -class rr1 : public mb_mblock -{ - mb_port_sptr d_p1; - mb_port_sptr d_p2; - -public: - rr1(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~rr1(); -}; - -rr1::rr1(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - d_p1 = define_port("p1", "qa-send-cs", true, mb_port::RELAY); - d_p2 = define_port("p2", "qa-send-cs", false, mb_port::RELAY); - - define_component("c0", "rr2"); - - connect("self", "p1", "c0", "p1"); - connect("self", "p2", "c0", "p2"); -} - -rr1::~rr1(){} - -REGISTER_MBLOCK_CLASS(rr1); - -// ---------------------------------------------------------------- - -// top-level container for test_relay_routing - -class rr0_a : public mb_mblock -{ -public: - rr0_a(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~rr0_a(); -}; - -rr0_a::rr0_a(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - define_component("c0", "rr1"); - define_component("c1", "rr2"); - - connect("c0", "p1", "c1", "p2"); - connect("c0", "p2", "c1", "p1"); -} - -rr0_a::~rr0_a(){} - -REGISTER_MBLOCK_CLASS(rr0_a); - -/* - * This tests basic message routing using RELAY and EXTERNAL ports. - * It does not rely on the guts of the runtime being complete, - * which is good, because at the time this is being written, it isn't. - */ -void -qa_mblock_send::test_relay_routing_1() -{ - mb_message_sptr msg; - - mb_runtime_sptr rt = mb_make_runtime_nop(); - rt->run("top", "rr0_a", PMT_F); - mb_mblock_sptr top = get_top(rt); - - // Reach into the guts and see if the messages ended up where they should have - - mb_mblock_sptr c0 = top->impl()->component("c0"); - mb_mblock_sptr c0c0 = c0->impl()->component("c0"); - - mb_mblock_sptr c1 = top->impl()->component("c1"); - - // c0c0 should have received - // two message from c1 via its p2 - - msg = c0c0->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - //std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p2, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/c1"), s_p1, pmt_from_long(0)), - msg->data())); - - msg = c0c0->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - //std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p2, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/c1"), s_p1, pmt_from_long(1)), - msg->data())); - - // c1 should have received - // two message from c0c0 via its p2 - - msg = c1->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - //std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p2, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/c0/c0"), s_p1, pmt_from_long(0)), - msg->data())); - - msg = c1->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - //std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p2, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/c0/c0"), s_p1, pmt_from_long(1)), - msg->data())); -} - -// ================================================================ -// test_relay_routing_2 -// ================================================================ - -// top-level container for test_relay_routing_2 - -class rr0_b : public mb_mblock -{ -public: - rr0_b(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~rr0_b(); -}; - -rr0_b::rr0_b(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - define_component("c0", "rr1"); - define_component("c1", "rr1"); - - connect("c0", "p1", "c1", "p2"); - connect("c0", "p2", "c1", "p1"); -} - -rr0_b::~rr0_b(){} - -REGISTER_MBLOCK_CLASS(rr0_b); - -/* - * This tests basic message routing using RELAY and EXTERNAL ports. - * It does not rely on the guts of the runtime being complete, - * which is good, because at the time this is being written, it isn't. - */ -void -qa_mblock_send::test_relay_routing_2() -{ - mb_message_sptr msg; - - mb_runtime_sptr rt = mb_make_runtime_nop(); - rt->run("top", "rr0_b", PMT_F); - mb_mblock_sptr top = get_top(rt); - - // Reach into the guts and see if the messages ended up where they should have - - mb_mblock_sptr c0 = top->impl()->component("c0"); - mb_mblock_sptr c0c0 = c0->impl()->component("c0"); - - mb_mblock_sptr c1 = top->impl()->component("c1"); - mb_mblock_sptr c1c0 = c1->impl()->component("c0"); - - // c0c0 should have received - // two message from c1c0 via its p2 - - msg = c0c0->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - // std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p2, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/c1/c0"), s_p1, pmt_from_long(0)), - msg->data())); - - msg = c0c0->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - // std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p2, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/c1/c0"), s_p1, pmt_from_long(1)), - msg->data())); - - // c1c0 should have received - // two message from c0c0 via its p2 - - msg = c1c0->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - // std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p2, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/c0/c0"), s_p1, pmt_from_long(0)), - msg->data())); - - msg = c1c0->impl()->msgq().get_highest_pri_msg_nowait(); - CPPUNIT_ASSERT(msg); - // std::cerr << msg->data() << std::endl; - CPPUNIT_ASSERT_EQUAL(s_p2, msg->port_id()); - CPPUNIT_ASSERT(pmt_equal(pmt_list3(pmt_intern("top/c0/c0"), s_p1, pmt_from_long(1)), - msg->data())); -} diff --git a/mblock/src/lib/qa_mblock_send.h b/mblock/src/lib/qa_mblock_send.h deleted file mode 100644 index b1a6832ce..000000000 --- a/mblock/src/lib/qa_mblock_send.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_QA_MBLOCK_SEND_H -#define INCLUDED_QA_MBLOCK_SEND_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_mblock_send : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE(qa_mblock_send); - CPPUNIT_TEST(test_simple_routing); - CPPUNIT_TEST(test_relay_routing_1); - CPPUNIT_TEST(test_relay_routing_2); - CPPUNIT_TEST_SUITE_END(); - - private: - void test_simple_routing(); - void test_relay_routing_1(); - void test_relay_routing_2(); -}; - -#endif /* INCLUDED_QA_MBLOCK_SEND_H */ - diff --git a/mblock/src/lib/qa_mblock_sys.cc b/mblock/src/lib/qa_mblock_sys.cc deleted file mode 100644 index 8c8dbbf0a..000000000 --- a/mblock/src/lib/qa_mblock_sys.cc +++ /dev/null @@ -1,272 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_mblock_sys.h> -#include <cppunit/TestAssert.h> -#include <mblock/mblock.h> -#include <mblock/runtime.h> -#include <mb_runtime_nop.h> // QA only -#include <mblock/protocol_class.h> -#include <mblock/exception.h> -#include <mblock/msg_queue.h> -#include <mblock/message.h> -#include <mb_mblock_impl.h> -#include <mblock/msg_accepter.h> -#include <mblock/class_registry.h> -#include <stdio.h> -#include <string.h> -#include <iostream> - -using namespace pmt; - -static pmt_t s_data = pmt_intern("data"); -static pmt_t s_status = pmt_intern("status"); -static pmt_t s_control = pmt_intern("control"); -static pmt_t s_p0 = pmt_intern("p0"); -static pmt_t s_p1 = pmt_intern("p1"); -static pmt_t s_p2 = pmt_intern("p2"); -static pmt_t s_p3 = pmt_intern("p3"); -static pmt_t s_e1 = pmt_intern("e1"); -static pmt_t s_r1 = pmt_intern("r1"); - -static void -define_protocol_classes() -{ - mb_make_protocol_class(s_data, // name - pmt_list1(s_data), // incoming - pmt_list1(s_data)); // outgoing -} - - -// ================================================================ -// test_sys_1 -// ================================================================ - -class sys_1 : public mb_mblock -{ - pmt_t d_user_arg; - mb_port_sptr d_data; - -public: - sys_1(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~sys_1(); - void initial_transition(); -}; - -sys_1::sys_1(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_user_arg(user_arg) -{ - d_data = define_port("data", "data", true, mb_port::EXTERNAL); -} - -sys_1::~sys_1(){} - -void -sys_1::initial_transition() -{ - shutdown_all(d_user_arg); -} - -REGISTER_MBLOCK_CLASS(sys_1); - -void -qa_mblock_sys::test_sys_1() -{ - define_protocol_classes(); - - pmt_t result; - pmt_t n1 = pmt_from_long(1); - pmt_t n2 = pmt_from_long(2); - - mb_runtime_sptr rt1 = mb_make_runtime(); - -#if 0 - try { - rt1->run("top-1", "sys_1", n1, &result); - } - catch (omni_thread_fatal e){ - std::cerr << "caught omni_thread_fatal: error = " << e.error - << ": " << strerror(e.error) << std::endl; - } - catch (omni_thread_invalid){ - std::cerr << "caught omni_thread_invalid\n"; - } -#else - rt1->run("top-1", "sys_1", n1, &result); -#endif - CPPUNIT_ASSERT(pmt_equal(n1, result)); - - // Execute run a second time, with the same rt, to ensure sanity. - rt1->run("top-2", "sys_1", n2, &result); - CPPUNIT_ASSERT(pmt_equal(n2, result)); -} - -// ================================================================ -// test_sys_2 -// ================================================================ - -class squarer : public mb_mblock -{ - mb_port_sptr d_data; - -public: - squarer(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - - void handle_message(mb_message_sptr msg); -}; - -squarer::squarer(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - d_data = define_port("data", "data", true, mb_port::EXTERNAL); -} - -void -squarer::handle_message(mb_message_sptr msg) -{ - if (!pmt_eq(msg->signal(), s_data)) // we only handle the "data" message - return; - - // long x -> (long x . long (x * x)) - - pmt_t x_pmt = msg->data(); - long x = pmt_to_long(x_pmt); - d_data->send(s_data, pmt_cons(x_pmt, pmt_from_long(x * x))); -} - -REGISTER_MBLOCK_CLASS(squarer); - -// ---------------------------------------------------------------- - -class sys_2 : public mb_mblock -{ - mb_port_sptr d_data; - -public: - sys_2(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - void initial_transition(); - void handle_message(mb_message_sptr msg); -}; - -sys_2::sys_2(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - d_data = define_port("data", "data", true, mb_port::INTERNAL); - define_component("squarer", "squarer"); - connect("self", "data", "squarer", "data"); -} - -void -sys_2::initial_transition() -{ - // FIXME start timer to detect general failure - - d_data->send(s_data, pmt_from_long(0)); // send initial message -} - -void -sys_2::handle_message(mb_message_sptr msg) -{ - if (!pmt_eq(msg->signal(), s_data)) // we only handle the "data" message - return; - - // first check correctness of message - - long x = pmt_to_long(pmt_car(msg->data())); - long y = pmt_to_long(pmt_cdr(msg->data())); - - // std::cout << msg->data() << std::endl; - - if (y != x * x){ - std::cerr << "sys_2::handle_message: Expected y == x * x. Got y = " - << y << " for x = " << x << std::endl; - - shutdown_all(PMT_F); // failed - } - - if (x == 100) - shutdown_all(PMT_T); // done, OK - else - d_data->send(s_data, pmt_from_long(x + 1)); // send next request -} - -REGISTER_MBLOCK_CLASS(sys_2); - -// ---------------------------------------------------------------- - -void -qa_mblock_sys::test_sys_2() -{ - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - // std::cerr << "qa_mblock_sys::test_sys_2 (enter)\n"; - - rt->run("top-sys-2", "sys_2", PMT_F, &result); - CPPUNIT_ASSERT(pmt_equal(PMT_T, result)); -} - -// ================================================================ -// test_bitset_1 -// ================================================================ - -void -qa_mblock_sys::test_bitset_1() -{ - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - long nmsgs = 1000; - long batch_size = 8; - - pmt_t arg = pmt_list2(pmt_from_long(nmsgs), // # of messages to send through pipe - pmt_from_long(batch_size)); - - rt->run("top", "qa_bitset_top", arg, &result); - - CPPUNIT_ASSERT(pmt_equal(PMT_T, result)); -} - -// ================================================================ -// test_disconnect -// ================================================================ - -void -qa_mblock_sys::test_disconnect() -{ - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - long nmsgs = 10240; - - pmt_t arg = pmt_list1(pmt_from_long(nmsgs)); // # of messages to send through pipe - - - rt->run("top", "qa_disconnect_top", arg, &result); - - CPPUNIT_ASSERT(pmt_equal(PMT_T, result)); -} diff --git a/mblock/src/lib/qa_mblock_sys.h b/mblock/src/lib/qa_mblock_sys.h deleted file mode 100644 index 0e0053a5d..000000000 --- a/mblock/src/lib/qa_mblock_sys.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_QA_MBLOCK_SYS_H -#define INCLUDED_QA_MBLOCK_SYS_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_mblock_sys : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE(qa_mblock_sys); - CPPUNIT_TEST(test_sys_1); - CPPUNIT_TEST(test_sys_2); - CPPUNIT_TEST(test_bitset_1); - CPPUNIT_TEST(test_disconnect); - CPPUNIT_TEST_SUITE_END(); - - private: - void test_sys_1(); - void test_sys_2(); - void test_bitset_1(); - void test_disconnect(); -}; - -#endif /* INCLUDED_QA_MBLOCK_SYS_H */ - diff --git a/mblock/src/lib/qa_timeouts.cc b/mblock/src/lib/qa_timeouts.cc deleted file mode 100644 index b230f86d8..000000000 --- a/mblock/src/lib/qa_timeouts.cc +++ /dev/null @@ -1,291 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <qa_timeouts.h> -#include <cppunit/TestAssert.h> -#include <mblock/mblock.h> -#include <mblock/runtime.h> -#include <mblock/protocol_class.h> -#include <mblock/message.h> -#include <mblock/msg_accepter.h> -#include <mblock/class_registry.h> -#include <mb_timer_queue.h> -#include <string.h> -#include <iostream> - -using namespace pmt; - -static pmt_t s_timeout = pmt_intern("%timeout"); -static pmt_t s_done = pmt_intern("done"); - - -// ------------------------------------------------------------------------ -// Exercise the priority queue used to implement timeouts. -// ------------------------------------------------------------------------ -void -qa_timeouts::test_timer_queue() -{ - mb_timer_queue tq; - mb_msg_accepter_sptr accepter; - - mb_timeout_sptr t1000_000 = - mb_timeout_sptr(new mb_timeout(mb_time(1000,0), PMT_F, accepter)); - - mb_timeout_sptr t2000_000 = - mb_timeout_sptr(new mb_timeout(mb_time(2000,0), PMT_F, accepter)); - - mb_timeout_sptr t3000_000 = - mb_timeout_sptr(new mb_timeout(mb_time(3000,0), PMT_F, accepter)); - - mb_timeout_sptr t3000_125 = - mb_timeout_sptr(new mb_timeout(mb_time(3000,125), PMT_F, accepter)); - - mb_timeout_sptr t3000_250 = - mb_timeout_sptr(new mb_timeout(mb_time(3000,250), PMT_F, accepter)); - - mb_timeout_sptr t4000_000 = - mb_timeout_sptr(new mb_timeout(mb_time(4000,0), PMT_F, accepter)); - - // insert in pseudo-random order - - tq.push(t3000_125); - tq.push(t1000_000); - tq.push(t4000_000); - tq.push(t3000_250); - tq.push(t2000_000); - tq.push(t3000_000); - - CPPUNIT_ASSERT_EQUAL(t1000_000, tq.top()); - tq.pop(); - - CPPUNIT_ASSERT_EQUAL(t2000_000, tq.top()); - tq.pop(); - - CPPUNIT_ASSERT_EQUAL(t3000_000, tq.top()); - tq.pop(); - - CPPUNIT_ASSERT_EQUAL(t3000_125, tq.top()); - tq.pop(); - - CPPUNIT_ASSERT_EQUAL(t3000_250, tq.top()); - tq.pop(); - - CPPUNIT_ASSERT_EQUAL(t4000_000, tq.top()); - tq.pop(); - - CPPUNIT_ASSERT(tq.empty()); - - // insert in pseudo-random order - - tq.push(t3000_000); - tq.push(t4000_000); - tq.push(t3000_125); - tq.push(t1000_000); - tq.push(t2000_000); - tq.push(t3000_250); - - tq.cancel(t1000_000->handle()); - - CPPUNIT_ASSERT_EQUAL(t2000_000, tq.top()); - tq.pop(); - - CPPUNIT_ASSERT_EQUAL(t3000_000, tq.top()); - tq.pop(); - - tq.cancel(t3000_250->handle()); - - CPPUNIT_ASSERT_EQUAL(t3000_125, tq.top()); - tq.pop(); - - CPPUNIT_ASSERT_EQUAL(t4000_000, tq.top()); - tq.pop(); - - CPPUNIT_ASSERT(tq.empty()); -} - -// ------------------------------------------------------------------------ -// Test one-shot timeouts -// ------------------------------------------------------------------------ - -// FWIW, on SuSE 10.1 for x86-64, clock_getres returns 0.004 seconds. - -// #define TIMING_MARGIN 0.010 // seconds // was failing on some systems -#define TIMING_MARGIN 0.025 // seconds (really sloppy; consider enabling RT scheduler) - - -class qa_timeouts_1_top : public mb_mblock -{ - int d_nleft; - int d_nerrors; - mb_time d_t0; - -public: - qa_timeouts_1_top(mb_runtime *runtime, - const std::string &instance_name, pmt_t user_arg); - - void initial_transition(); - void handle_message(mb_message_sptr msg); -}; - -qa_timeouts_1_top::qa_timeouts_1_top(mb_runtime *runtime, - const std::string &instance_name, - pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_nleft(0), d_nerrors(0) -{ -} - -void -qa_timeouts_1_top::initial_transition() -{ - d_t0 = mb_time::time(); // now - - schedule_one_shot_timeout(d_t0 + 0.200, pmt_from_double(0.200)); - schedule_one_shot_timeout(d_t0 + 0.125, pmt_from_double(0.125)); - schedule_one_shot_timeout(d_t0 + 0.075, pmt_from_double(0.075)); - schedule_one_shot_timeout(d_t0 + 0.175, pmt_from_double(0.175)); - - d_nleft = 4; -} - -void -qa_timeouts_1_top::handle_message(mb_message_sptr msg) -{ - if (pmt_eq(msg->signal(), s_timeout)){ - mb_time t_now = mb_time::time(); - double expected_delta_t = pmt_to_double(msg->data()); - double actual_delta_t = (t_now - d_t0).double_time(); - double delta = expected_delta_t - actual_delta_t; - - if (fabs(delta) > TIMING_MARGIN){ - std::cerr << "qa_timeouts_1_top: expected_delta_t = " << expected_delta_t - << " actual_delta_t = " << actual_delta_t << std::endl; - d_nerrors++; - } - - if (--d_nleft <= 0) - shutdown_all(d_nerrors == 0 ? PMT_T : PMT_F); - } -} - -REGISTER_MBLOCK_CLASS(qa_timeouts_1_top); - -void -qa_timeouts::test_timeouts_1() -{ - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - rt->run("top", "qa_timeouts_1_top", PMT_F, &result); - - CPPUNIT_ASSERT(pmt_equal(PMT_T, result)); -} - -// ------------------------------------------------------------------------ -// Test periodic timeouts -// ------------------------------------------------------------------------ - -class qa_timeouts_2_top : public mb_mblock -{ - int d_nhandled; - int d_nerrors; - double d_delta_t; - mb_time d_t0; - -public: - qa_timeouts_2_top(mb_runtime *runtime, - const std::string &instance_name, pmt_t user_arg); - - void initial_transition(); - void handle_message(mb_message_sptr msg); -}; - -qa_timeouts_2_top::qa_timeouts_2_top(mb_runtime *runtime, - const std::string &instance_name, - pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_nhandled(0), d_nerrors(0), d_delta_t(0.075) -{ -} - -void -qa_timeouts_2_top::initial_transition() -{ - d_t0 = mb_time::time(); // now - - schedule_periodic_timeout(d_t0 + d_delta_t, mb_time(d_delta_t), PMT_T); -} - -void -qa_timeouts_2_top::handle_message(mb_message_sptr msg) -{ - static const int NMSGS_TO_HANDLE = 5; - - if (pmt_eq(msg->signal(), s_timeout) - && !pmt_eq(msg->data(), s_done)){ - - mb_time t_now = mb_time::time(); - - d_nhandled++; - - double expected_delta_t = d_delta_t * d_nhandled; - double actual_delta_t = (t_now - d_t0).double_time(); - double delta = expected_delta_t - actual_delta_t; - - if (fabs(delta) > TIMING_MARGIN){ - std::cerr << "qa_timeouts_2_top: expected_delta_t = " << expected_delta_t - << " actual_delta_t = " << actual_delta_t << std::endl; - d_nerrors++; - } - - if (d_nhandled == NMSGS_TO_HANDLE){ - cancel_timeout(msg->metadata()); // test cancel_timeout... - schedule_one_shot_timeout(d_t0 + (d_delta_t * (d_nhandled + 2)), s_done); - } - } - - if (pmt_eq(msg->signal(), s_timeout) - && pmt_eq(msg->data(), s_done)){ - if (d_nhandled != NMSGS_TO_HANDLE){ - std::cerr << "qa_timeouts_2_top: d_nhandled = " << d_nhandled - << " expected d_nhandled = " << NMSGS_TO_HANDLE - << " (cancel_timeout didn't work)\n"; - d_nerrors++; - } - shutdown_all(d_nerrors == 0 ? PMT_T : PMT_F); - } -} - -REGISTER_MBLOCK_CLASS(qa_timeouts_2_top); - -void -qa_timeouts::test_timeouts_2() -{ - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - rt->run("top", "qa_timeouts_2_top", PMT_F, &result); - - CPPUNIT_ASSERT(pmt_equal(PMT_T, result)); -} diff --git a/mblock/src/lib/qa_timeouts.h b/mblock/src/lib/qa_timeouts.h deleted file mode 100644 index 7c6443646..000000000 --- a/mblock/src/lib/qa_timeouts.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006,2007 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#ifndef INCLUDED_QA_TIMEOUTS_H -#define INCLUDED_QA_TIMEOUTS_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_timeouts : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE(qa_timeouts); - CPPUNIT_TEST(test_timer_queue); - CPPUNIT_TEST(test_timeouts_1); - CPPUNIT_TEST(test_timeouts_2); - CPPUNIT_TEST_SUITE_END(); - - private: - void test_timer_queue(); - void test_timeouts_1(); - void test_timeouts_2(); -}; - -#endif /* INCLUDED_QA_TIMEOUTS_H */ - diff --git a/mblock/src/lib/test_mblock.cc b/mblock/src/lib/test_mblock.cc deleted file mode 100644 index b98d1b5a7..000000000 --- a/mblock/src/lib/test_mblock.cc +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2006 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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#include <cppunit/TextTestRunner.h> -#include <qa_mblock.h> - -int -main(int argc, char **argv) -{ - - CppUnit::TextTestRunner runner; - - runner.addTest(qa_mblock::suite ()); - - bool was_successful = runner.run("", false); - - return was_successful ? 0 : 1; -} diff --git a/mblock/src/scheme/.gitignore b/mblock/src/scheme/.gitignore deleted file mode 100644 index a02b6ff73..000000000 --- a/mblock/src/scheme/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo diff --git a/mblock/src/scheme/Makefile.am b/mblock/src/scheme/Makefile.am deleted file mode 100644 index 4980063d7..000000000 --- a/mblock/src/scheme/Makefile.am +++ /dev/null @@ -1,21 +0,0 @@ -# -# Copyright 2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -SUBDIRS = gnuradio diff --git a/mblock/src/scheme/gnuradio/.gitignore b/mblock/src/scheme/gnuradio/.gitignore deleted file mode 100644 index a02b6ff73..000000000 --- a/mblock/src/scheme/gnuradio/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo diff --git a/mblock/src/scheme/gnuradio/Makefile.am b/mblock/src/scheme/gnuradio/Makefile.am deleted file mode 100644 index e9bfc88e9..000000000 --- a/mblock/src/scheme/gnuradio/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -EXTRA_DIST = \ - compile-mbh.scm - diff --git a/mblock/src/scheme/gnuradio/compile-mbh.scm b/mblock/src/scheme/gnuradio/compile-mbh.scm deleted file mode 100755 index 30085340f..000000000 --- a/mblock/src/scheme/gnuradio/compile-mbh.scm +++ /dev/null @@ -1,231 +0,0 @@ -#!/usr/bin/guile \ --e main -s -!# -;; -*-scheme-*- -;; -;; Copyright 2007,2008 Free Software Foundation, Inc. -;; -;; This file is part of GNU Radio -;; -;; GNU Radio is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. -;; -;; GNU Radio is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License along -;; with this program; if not, write to the Free Software Foundation, Inc., -;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -;; - -;; usage: compile-mbh <input-file> <output-file> - -(use-modules (ice-9 getopt-long)) -(use-modules (ice-9 format)) -(use-modules (ice-9 pretty-print)) -;(use-modules (ice-9 slib)) -(use-modules (gnuradio pmt-serialize)) -(use-modules (gnuradio macros-etc)) - -(debug-enable 'backtrace) - -;; ---------------------------------------------------------------- - -(define (main args) - - (define (usage) - (format 0 "usage: ~a input-file output-file~%" (car args))) - - (when (not (= (length args) 3)) - (usage) - (exit 1)) - - (let ((input-filename (cadr args)) - (output-filename (caddr args))) - (if (compile-mbh-file input-filename output-filename) - (exit 0) - (exit 1)))) - - -;; ---------------------------------------------------------------- -;; constructor and accessors for protocol-class - -(define %protocol-class-tag (string->symbol "[PROTOCOL-CLASS-TAG]")) - -(define (make-protocol-class name incoming outgoing) - (vector %protocol-class-tag name incoming outgoing)) - -(define (protocol-class? obj) - (and (vector? obj) (eq? %protocol-class-tag (vector-ref obj 0)))) - -(define (protocol-class-name pc) - (vector-ref pc 1)) - -(define (protocol-class-incoming pc) - (vector-ref pc 2)) - -(define (protocol-class-outgoing pc) - (vector-ref pc 3)) - - -;; ---------------------------------------------------------------- - -(define (syntax-error msg e) - (throw 'syntax-error msg e)) - -(define (unrecognized-form form) - (syntax-error "Unrecognized form" form)) - - -(define (mbh-chk-length= e y n) - (cond ((and (null? y)(zero? n)) - #f) - ((null? y) - (syntax-error "Expression has too few subexpressions" e)) - ((atom? y) - (syntax-error (if (atom? e) - "List expected" - "Expression ends with `dotted' atom") - e)) - ((zero? n) - (syntax-error "Expression has too many subexpressions" e)) - (else - (mbh-chk-length= e (cdr y) (- n 1))))) - -(define (mbh-chk-length>= e y n) - (cond ((and (null? y)(< n 1)) - #f) - ((atom? y) - (mbh-chk-length= e y -1)) - (else - (mbh-chk-length>= e (cdr y) (- n 1))))) - - -(define (compile-mbh-file input-filename output-filename) - (let ((i-port (open-input-file input-filename)) - (o-port (open-output-file output-filename))) - - (letrec - ((protocol-classes '()) ; alist - - (lookup-protocol-class ; returns protocol-class or #f - (lambda (name) - (cond ((assq name protocol-classes) => cdr) - (else #f)))) - - (register-protocol-class - (lambda (pc) - (set! protocol-classes (acons (protocol-class-name pc) - pc protocol-classes)) - pc)) - - (parse-top-level-form - (lambda (form) - (mbh-chk-length>= form form 1) - (case (car form) - ((define-protocol-class) (parse-define-protocol-class form)) - (else (syntax-error form))))) - - (parse-define-protocol-class - (lambda (form) - (mbh-chk-length>= form form 2) - ;; form => (define-protocol-class name - ;; (:include protocol-class-name) - ;; (:incoming list-of-msgs) - ;; (:outgoing list-of-msgs)) - (let ((name (cadr form)) - (incoming '()) - (outgoing '())) - (if (lookup-protocol-class name) - (syntax-error "Duplicate protocol-class name" name)) - (for-each - (lambda (sub-form) - (mbh-chk-length>= sub-form sub-form 1) - (case (car sub-form) - ((:include) - (mbh-chk-length>= sub-form sub-form 2) - (cond ((lookup-protocol-class (cadr sub-form)) => - (lambda (pc) - (set! incoming (append incoming (protocol-class-incoming pc))) - (set! outgoing (append outgoing (protocol-class-outgoing pc))))) - (else - (syntax-error "Unknown protocol-class-name" (cadr sub-form))))) - ((:incoming) - (set! incoming (append incoming (cdr sub-form)))) - ((:outgoing) - (set! outgoing (append outgoing (cdr sub-form)))) - (else - (unrecognized-form (car sub-form))))) - (cddr form)) - - (register-protocol-class (make-protocol-class name incoming outgoing))))) - - ) ; end of bindings - - (for-each-in-file i-port parse-top-level-form) - - ;; generate the output here... - - (letrec ((classes (map cdr protocol-classes)) - (so-stream (make-serial-output-stream)) - (format-output-for-c++ - (lambda (output) - (format o-port "//~%") - (format o-port "// Machine generated by compile-mbh from ~a~%" input-filename) - (format o-port "//~%") - (format o-port "// protocol-classes: ~{~a ~}~%" (map car protocol-classes)) - (format o-port "//~%") - - (format o-port "#include <mblock/protocol_class.h>~%") - (format o-port "#include <unistd.h>~%") - (format o-port - "static const char~%protocol_class_init_data[~d] = {~% " - (length output)) - - (do ((lst output (cdr lst)) - (i 0 (+ i 1))) - ((null? lst) #t) - (format o-port "~a, " (car lst)) - (when (= 15 (modulo i 16)) - (format o-port "~% "))) - - (format o-port "~&};~%") - (format o-port "static mb_protocol_class_init _init_(protocol_class_init_data, sizeof(protocol_class_init_data));~%") - ))) - - - (map (lambda (pc) - (let ((obj-to-dump - (list (protocol-class-name pc) ; class name - (map car (protocol-class-incoming pc)) ; incoming msg names - (map car (protocol-class-outgoing pc)) ; outgoing msg names - ;;(protocol-class-incoming pc) ; full incoming msg descriptions - ;;(protocol-class-outgoing pc) ; full outgoing msg descriptions - ))) - ;;(pretty-print obj-to-dump) - (pmt-serialize obj-to-dump (so-stream 'put-byte)))) - classes) - - (format-output-for-c++ ((so-stream 'get-output))) - - #t)))) - - -(define (make-serial-output-stream) - (letrec ((output '()) - (put-byte - (lambda (byte) - (set! output (cons byte output)))) - (get-output - (lambda () - (reverse output)))) - (lambda (key) - (case key - ((put-byte) put-byte) - ((get-output) get-output) - (else (error "Unknown key" key)))))) - diff --git a/omnithread/.gitignore b/omnithread/.gitignore deleted file mode 100644 index 5a51e3bc3..000000000 --- a/omnithread/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/gnuradio-omnithread.pc diff --git a/omnithread/Makefile.am b/omnithread/Makefile.am deleted file mode 100644 index 291cc8beb..000000000 --- a/omnithread/Makefile.am +++ /dev/null @@ -1,71 +0,0 @@ -# -# Copyright 2003,2008 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = gnuradio - -# This is the omnithread package, -# extracted from the omniORB-4.0.1 distribution - -# we should do some configure hacking to determine these on the fly -OMNITHREAD_DEFINES = -DPthreadDraftVersion=10 - -AM_CPPFLAGS = $(DEFINES) $(OMNITHREAD_DEFINES) $(OMNITHREAD_INCLUDES) \ - $(WITH_INCLUDES) - -# we call it libgromnithread to avoid a collision with libomnithread on Debian -lib_LTLIBRARIES = libgromnithread.la - -# At this point we only support the posix and nt pthreads i/f... - -if OMNITHREAD_POSIX -libgromnithread_la_SOURCES = \ - omni_time.cc \ - posix.cc -endif - -if OMNITHREAD_NT -libgromnithread_la_SOURCES = \ - omni_time.cc \ - nt.cc -endif - -libgromnithread_la_LDFLAGS = $(NO_UNDEFINED) - -libgromnithread_la_LIBADD = \ - $(PTHREAD_LIBS) - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = gnuradio-omnithread.pc - -# ... but this code also came with the package - -EXTRA_DIST = \ - gnuradio-omnithread.pc.in \ - mach.cc \ - nt.cc \ - posix.cc \ - solaris.cc \ - threaddata.cc \ - vxWorks.cc \ - dir.mk \ - README diff --git a/omnithread/README b/omnithread/README deleted file mode 100644 index 1943d0ed5..000000000 --- a/omnithread/README +++ /dev/null @@ -1,2 +0,0 @@ -The code in this directory is deprecated, please use the Boost thread -library for new code. diff --git a/omnithread/dir.mk b/omnithread/dir.mk deleted file mode 100644 index d53803417..000000000 --- a/omnithread/dir.mk +++ /dev/null @@ -1,229 +0,0 @@ -ifeq ($(ThreadSystem),Solaris) -CXXSRCS = solaris.cc -DIR_CPPFLAGS = $(OMNITHREAD_CPPFLAGS) -endif - -ifeq ($(ThreadSystem),Posix) -CXXSRCS = posix.cc -DIR_CPPFLAGS = $(OMNITHREAD_CPPFLAGS) $(OMNITHREAD_POSIX_CPPFLAGS) -endif - -ifeq ($(ThreadSystem),NT) -CXXSRCS = nt.cc -DIR_CPPFLAGS = $(OMNITHREAD_CPPFLAGS) -MSVC_STATICLIB_CXXNODEBUGFLAGS += -D_WINSTATIC -MSVC_STATICLIB_CXXDEBUGFLAGS += -D_WINSTATIC -MSVC_DLL_CXXNODEBUGFLAGS += -D_OMNITHREAD_DLL -MSVC_DLL_CXXDEBUGFLAGS += -D_OMNITHREAD_DLL -endif - -ifeq ($(ThreadSystem),NTPosix) -CXXSRCS = posix.cc -DIR_CPPFLAGS = $(OMNITHREAD_CPPFLAGS) -MSVC_STATICLIB_CXXNODEBUGFLAGS += -D_WINSTATIC -MSVC_STATICLIB_CXXDEBUGFLAGS += -D_WINSTATIC -MSVC_DLL_CXXNODEBUGFLAGS += -D_OMNITHREAD_DLL -MSVC_DLL_CXXDEBUGFLAGS += -D_OMNITHREAD_DLL -endif - -ifeq ($(ThreadSystem),Mach) -CXXSRCS = mach.cc -DIR_CPPFLAGS = $(OMNITHREAD_CPPFLAGS) -endif - -ifeq ($(ThreadSystem),vxWorks) -CXXSRCS = vxWorks.cc -OBJS = vxWorks.o -DIR_CPPFLAGS = $(OMNITHREAD_CPPFLAGS) -endif - -LIB_NAME := omnithread -LIB_VERSION := $(OMNITHREAD_VERSION) -LIB_OBJS := $(CXXSRCS:.cc=.o) -LIB_IMPORTS := $(OMNITHREAD_PLATFORM_LIB) - -all:: mkstatic mkshared - -export:: mkstatic mkshared - -ifdef INSTALLTARGET -install:: mkstatic mkshared -endif - -vers := $(subst ., ,$(LIB_VERSION)) -ifeq ($(words $(vers)), 2) - vers := _ $(vers) - major := "" -else - major := $(word 1, $(vers)) -endif - -namespec := $(LIB_NAME) $(vers) - -############################################################################## -# Build Static library -############################################################################## - -ifndef NoStaticLibrary - -staticlib := static/$(patsubst %,$(LibNoDebugPattern),$(LIB_NAME)$(major)) - -mkstatic:: - @(dir=static; $(CreateDir)) - -mkstatic:: $(staticlib) - -$(staticlib): $(patsubst %, static/%, $(LIB_OBJS)) - @$(StaticLinkLibrary) - -export:: $(staticlib) - @$(ExportLibrary) - -ifdef INSTALLTARGET -install:: $(staticlib) - @$(InstallLibrary) -endif - -clean:: - $(RM) static/*.o - $(RM) $(staticlib) - -veryclean:: - $(RM) static/*.o - $(RM) $(staticlib) - -else - -mkstatic:: - -endif - - -############################################################################## -# Build Shared library -############################################################################## -ifdef BuildSharedLibrary - -shlib := shared/$(shell $(SharedLibraryFullName) $(namespec)) - -ifdef Win32Platform -# in case of Win32 lossage: - imps := $(patsubst $(DLLDebugSearchPattern),$(DLLNoDebugSearchPattern), \ - $(LIB_IMPORTS)) -else - imps := $(LIB_IMPORTS) -endif - -mkshared:: - @(dir=shared; $(CreateDir)) - -mkshared:: $(shlib) - -$(shlib): $(patsubst %, shared/%, $(LIB_OBJS)) - @(namespec="$(namespec)" extralibs="$(imps)" nodeffile=1; \ - $(MakeCXXSharedLibrary)) - -export:: $(shlib) - @(namespec="$(namespec)"; \ - $(ExportSharedLibrary)) - -ifdef INSTALLTARGET -install:: $(shlib) - @(namespec="$(namespec)"; \ - $(InstallSharedLibrary)) -endif - -clean:: - $(RM) shared/*.o - (dir=shared; $(CleanSharedLibrary)) - -veryclean:: - $(RM) shared/*.o - @(dir=shared; $(CleanSharedLibrary)) - -else - -mkshared:: - -endif - -############################################################################## -# Build debug libraries for Win32 -############################################################################## -ifdef Win32Platform - -ifdef BuildSharedLibrary - -all:: mkstaticdbug mkshareddbug - -export:: mkstaticdbug mkshareddbug - -else - -all:: mkstaticdbug - -export:: mkstaticdbug - -endif - - -##################################################### -# Static debug libraries -##################################################### - -dbuglib := debug/$(patsubst %,$(LibDebugPattern),$(LIB_NAME)$(major)) - -mkstaticdbug:: - @(dir=debug; $(CreateDir)) - -mkstaticdbug:: $(dbuglib) - -$(dbuglib): $(patsubst %, debug/%, $(LIB_OBJS)) - @$(StaticLinkLibrary) - -export:: $(dbuglib) - @$(ExportLibrary) - -clean:: - $(RM) debug/*.o - $(RM) $(dbuglib) - -veryclean:: - $(RM) debug/*.o - $(RM) $(dbuglib) - -##################################################### -# DLL debug libraries -##################################################### - -ifdef BuildSharedLibrary - -dbugshlib := shareddebug/$(shell $(SharedLibraryDebugFullName) $(namespec)) - -dbugimps := $(patsubst $(DLLNoDebugSearchPattern),$(DLLDebugSearchPattern), \ - $(LIB_IMPORTS)) - -mkshareddbug:: - @(dir=shareddebug; $(CreateDir)) - -mkshareddbug:: $(dbugshlib) - -$(dbugshlib): $(patsubst %, shareddebug/%, $(LIB_OBJS)) - (namespec="$(namespec)" debug=1 extralibs="$(dbugimps)" nodeffile=1; \ - $(MakeCXXSharedLibrary)) - -export:: $(dbugshlib) - @(namespec="$(namespec)" debug=1; \ - $(ExportSharedLibrary)) - -clean:: - $(RM) shareddebug/*.o - @(dir=shareddebug; $(CleanSharedLibrary)) - -veryclean:: - $(RM) shareddebug/*.o - @(dir=shareddebug; $(CleanSharedLibrary)) - -endif -endif - diff --git a/omnithread/gnuradio-omnithread.pc.in b/omnithread/gnuradio-omnithread.pc.in deleted file mode 100644 index 0a94562e9..000000000 --- a/omnithread/gnuradio-omnithread.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@/gnuradio - -Name: gnuradio-omnithread -Description: The GNU Radio omniORB threading library -Requires: -Version: @VERSION@ -Libs: -L${libdir} -lgromnithread -Cflags: -I${includedir} @DEFINES@ @PTHREAD_CFLAGS@ diff --git a/omnithread/gnuradio/.gitignore b/omnithread/gnuradio/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/omnithread/gnuradio/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/omnithread/gnuradio/Makefile.am b/omnithread/gnuradio/Makefile.am deleted file mode 100644 index 1ec561299..000000000 --- a/omnithread/gnuradio/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -grinclude_HEADERS = \ - omnithread.h \ - omni_time.h \ - ot_mach.h \ - ot_nt.h \ - ot_posix.h \ - ot_pthread_nt.h \ - ot_solaris.h \ - ot_VxThread.h diff --git a/omnithread/gnuradio/omni_time.h b/omnithread/gnuradio/omni_time.h deleted file mode 100644 index bfb151610..000000000 --- a/omnithread/gnuradio/omni_time.h +++ /dev/null @@ -1,89 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_OMNI_TIME_H -#define INCLUDED_OMNI_TIME_H - -struct omni_time { - long int d_secs; // seconds. - long int d_nsecs; // nanoseconds. Always in [0, 1e9-1] - - omni_time() : d_secs(0), d_nsecs(0) {} - omni_time(long secs, long nanosecs=0) : d_secs(secs), d_nsecs(nanosecs) {} - - // N.B., this only makes sense for differences between times. - // Double doesn't have enough bits to precisely represent an absolute time. - omni_time(double secs); - - // N.B. This only makes sense for differences between times. - // Double doesn't have enough bits to precisely represent an absolute time. - double double_time() const { return (double)d_secs + d_nsecs * 1e-9; } - - /*! - * \brief Return an absolute time suitable for use with - * schedule_one_shot_timeout & schedule_periodic_timeout - * - * The return value is the current time plus the given relative offset. - */ - static omni_time time(const omni_time &relative_offset = omni_time()); -}; - - -inline static bool -operator<(const omni_time &x, const omni_time &y) -{ - return ((x.d_secs < y.d_secs) - || (x.d_secs == y.d_secs && x.d_nsecs < y.d_nsecs)); -} - -inline static bool -operator>(const omni_time &x, const omni_time &y) -{ - return ((x.d_secs > y.d_secs) - || (x.d_secs == y.d_secs && x.d_nsecs > y.d_nsecs)); -} - -inline static bool -operator>=(const omni_time &x, const omni_time &y) -{ - return ((x.d_secs > y.d_secs) - || (x.d_secs == y.d_secs && x.d_nsecs >= y.d_nsecs)); -} - -inline static bool -operator<=(const omni_time &x, const omni_time &y) -{ - return ((x.d_secs < y.d_secs) - || (x.d_secs == y.d_secs && x.d_nsecs <= y.d_nsecs)); -} - -inline static bool -operator==(const omni_time &x, const omni_time &y) -{ - return (x.d_secs == y.d_secs && x.d_nsecs == y.d_nsecs); -} - - -omni_time operator+(const omni_time &x, const omni_time &y); -omni_time operator+(const omni_time &x, double y); -omni_time operator-(const omni_time &x, const omni_time &y); -omni_time operator-(const omni_time &x, double y); - -#endif /* INCLUDED_OMNI_TIME_H */ diff --git a/omnithread/gnuradio/omnithread.h b/omnithread/gnuradio/omnithread.h deleted file mode 100644 index 8e8162b10..000000000 --- a/omnithread/gnuradio/omnithread.h +++ /dev/null @@ -1,626 +0,0 @@ -// -*- Mode: C++; -*- -// Package : omnithread -// omnithread.h Created : 7/94 tjr -// -// Copyright (C) 2006 Free Software Foundation, Inc. -// Copyright (C) 1994,1995,1996, 1997 Olivetti & Oracle Research Laboratory -// -// This file is part of the omnithread library -// -// The omnithread library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Boston, MA -// 02110-1301, USA -// - -// -// Interface to OMNI thread abstraction. -// -// This file declares classes for threads and synchronisation objects -// (mutexes, condition variables and counting semaphores). -// -// Wherever a seemingly arbitrary choice has had to be made as to the interface -// provided, the intention here has been to be as POSIX-like as possible. This -// is why there is no semaphore timed wait, for example. -// - -#ifndef __omnithread_h_ -#define __omnithread_h_ - -#ifndef NULL -#define NULL 0 -#endif - -class omni_mutex; -class omni_condition; -class omni_semaphore; -class omni_thread; - -// -// OMNI_THREAD_EXPOSE can be defined as public or protected to expose the -// implementation class - this may be useful for debugging. Hopefully this -// won't change the underlying structure which the compiler generates so that -// this can work without recompiling the library. -// - -#ifndef OMNI_THREAD_EXPOSE -#define OMNI_THREAD_EXPOSE private -#endif - -// -// Include implementation-specific header file. -// -// This must define 4 CPP macros of the form OMNI_x_IMPLEMENTATION for mutex, -// condition variable, semaphore and thread. Each should define any -// implementation-specific members of the corresponding classes. -// - - -// -// For now, we assume they've always got a Posix Threads implementation. -// If not, it'll take some configure hacking to sort it out, along with -// the relevant libraries to link with, etc. -// - -#if !defined(OMNITHREAD_POSIX) && !defined(OMNITHREAD_NT) && defined HAVE_CONFIG_H -// #include <config.h> // No, No, No! Never include <config.h> from a header -#endif - -#if defined(OMNITHREAD_POSIX) -#include <gnuradio/ot_posix.h> - -#elif defined(OMNITHREAD_NT) -#include <gnuradio/ot_nt.h> - -#ifdef _MSC_VER - -// Using MSVC++ to compile. If compiling library as a DLL, -// define _OMNITHREAD_DLL. If compiling as a statuc library, define -// _WINSTATIC -// If compiling an application that is to be statically linked to omnithread, -// define _WINSTATIC (if the application is to be dynamically linked, -// there is no need to define any of these macros). - -#if defined (_OMNITHREAD_DLL) && defined(_WINSTATIC) -#error "Both _OMNITHREAD_DLL and _WINSTATIC are defined." -#elif defined(_OMNITHREAD_DLL) -#define _OMNITHREAD_NTDLL_ __declspec(dllexport) -#elif !defined(_WINSTATIC) -#define _OMNITHREAD_NTDLL_ __declspec(dllimport) -#elif defined(_WINSTATIC) -#define _OMNITHREAD_NTDLL_ -#endif - // _OMNITHREAD_DLL && _WINSTATIC - -#else - -// Not using MSVC++ to compile -#define _OMNITHREAD_NTDLL_ - -#endif - // _MSC_VER - -#elif defined(__vxWorks__) -#include <gnuradio/ot_VxThread.h> - -#elif defined(__sunos__) -#if __OSVERSION__ != 5 -// XXX Workaround for SUN C++ compiler (seen on 4.2) Template.DB code -// regeneration bug. See omniORB2/CORBA_sysdep.h for details. -#if !defined(__SUNPRO_CC) || __OSVERSION__ != '5' -#error "Only SunOS 5.x or later is supported." -#endif -#endif -#ifdef UseSolarisThreads -#include <gnuradio/ot_solaris.h> -#else -#include <gnuradio/ot_posix.h> -#endif - -#elif defined(__rtems__) -#include <gnuradio/ot_posix.h> -#include <sched.h> - -#elif defined(__macos__) -#include <gnuradio/ot_posix.h> -#include <sched.h> - -#else -#error "No implementation header file" -#endif - - -#if !defined(__WIN32__) -#define _OMNITHREAD_NTDLL_ -#endif - -#if (!defined(OMNI_MUTEX_IMPLEMENTATION) || \ - !defined(OMNI_MUTEX_LOCK_IMPLEMENTATION) || \ - !defined(OMNI_MUTEX_TRYLOCK_IMPLEMENTATION)|| \ - !defined(OMNI_MUTEX_UNLOCK_IMPLEMENTATION) || \ - !defined(OMNI_CONDITION_IMPLEMENTATION) || \ - !defined(OMNI_SEMAPHORE_IMPLEMENTATION) || \ - !defined(OMNI_THREAD_IMPLEMENTATION)) -#error "Implementation header file incomplete" -#endif - - -// -// This exception is thrown in the event of a fatal error. -// - -class _OMNITHREAD_NTDLL_ omni_thread_fatal { -public: - int error; - omni_thread_fatal(int e = 0) : error(e) {} -}; - - -// -// This exception is thrown when an operation is invoked with invalid -// arguments. -// - -class _OMNITHREAD_NTDLL_ omni_thread_invalid {}; - - -/////////////////////////////////////////////////////////////////////////// -// -// Mutex -// -/////////////////////////////////////////////////////////////////////////// - -class _OMNITHREAD_NTDLL_ omni_mutex { - -public: - omni_mutex(void); - ~omni_mutex(void); - - inline void lock(void) { OMNI_MUTEX_LOCK_IMPLEMENTATION } - inline void unlock(void) { OMNI_MUTEX_UNLOCK_IMPLEMENTATION } - inline int trylock(void) { return OMNI_MUTEX_TRYLOCK_IMPLEMENTATION } - // if mutex is unlocked, lock it and return 1 (true). - // If it's already locked then return 0 (false). - - inline void acquire(void) { lock(); } - inline void release(void) { unlock(); } - // the names lock and unlock are preferred over acquire and release - // since we are attempting to be as POSIX-like as possible. - - friend class omni_condition; - -private: - // dummy copy constructor and operator= to prevent copying - omni_mutex(const omni_mutex&); - omni_mutex& operator=(const omni_mutex&); - -OMNI_THREAD_EXPOSE: - OMNI_MUTEX_IMPLEMENTATION -}; - -// -// As an alternative to: -// { -// mutex.lock(); -// ..... -// mutex.unlock(); -// } -// -// you can use a single instance of the omni_mutex_lock class: -// -// { -// omni_mutex_lock l(mutex); -// .... -// } -// -// This has the advantage that mutex.unlock() will be called automatically -// when an exception is thrown. -// - -class _OMNITHREAD_NTDLL_ omni_mutex_lock { - omni_mutex& mutex; -public: - omni_mutex_lock(omni_mutex& m) : mutex(m) { mutex.lock(); } - ~omni_mutex_lock(void) { mutex.unlock(); } -private: - // dummy copy constructor and operator= to prevent copying - omni_mutex_lock(const omni_mutex_lock&); - omni_mutex_lock& operator=(const omni_mutex_lock&); -}; - - -/////////////////////////////////////////////////////////////////////////// -// -// Condition variable -// -/////////////////////////////////////////////////////////////////////////// - -class _OMNITHREAD_NTDLL_ omni_condition { - - omni_mutex* mutex; - -public: - omni_condition(omni_mutex* m); - // constructor must be given a pointer to an existing mutex. The - // condition variable is then linked to the mutex, so that there is an - // implicit unlock and lock around wait() and timed_wait(). - - ~omni_condition(void); - - void wait(void); - // wait for the condition variable to be signalled. The mutex is - // implicitly released before waiting and locked again after waking up. - // If wait() is called by multiple threads, a signal may wake up more - // than one thread. See POSIX threads documentation for details. - - int timedwait(unsigned long secs, unsigned long nanosecs = 0); - // timedwait() is given an absolute time to wait until. To wait for a - // relative time from now, use omni_thread::get_time. See POSIX threads - // documentation for why absolute times are better than relative. - // Returns 1 (true) if successfully signalled, 0 (false) if time - // expired. - - void signal(void); - // if one or more threads have called wait(), signal wakes up at least - // one of them, possibly more. See POSIX threads documentation for - // details. - - void broadcast(void); - // broadcast is like signal but wakes all threads which have called - // wait(). - -private: - // dummy copy constructor and operator= to prevent copying - omni_condition(const omni_condition&); - omni_condition& operator=(const omni_condition&); - -OMNI_THREAD_EXPOSE: - OMNI_CONDITION_IMPLEMENTATION -}; - - -/////////////////////////////////////////////////////////////////////////// -// -// Counting (or binary) semaphore -// -/////////////////////////////////////////////////////////////////////////// - -class _OMNITHREAD_NTDLL_ omni_semaphore { - -public: - // if max_count == 1, you've got a binary semaphore. - omni_semaphore(unsigned int initial = 1, unsigned int max_count = 0x7fffffff); - ~omni_semaphore(void); - - void wait(void); - // if semaphore value is > 0 then decrement it and carry on. If it's - // already 0 then block. - - int trywait(void); - // if semaphore value is > 0 then decrement it and return 1 (true). - // If it's already 0 then return 0 (false). - - void post(void); - // if any threads are blocked in wait(), wake one of them up. Otherwise - // increment the value of the semaphore. - -private: - // dummy copy constructor and operator= to prevent copying - omni_semaphore(const omni_semaphore&); - omni_semaphore& operator=(const omni_semaphore&); - -OMNI_THREAD_EXPOSE: - OMNI_SEMAPHORE_IMPLEMENTATION -}; - -// -// A helper class for semaphores, similar to omni_mutex_lock above. -// - -class _OMNITHREAD_NTDLL_ omni_semaphore_lock { - omni_semaphore& sem; -public: - omni_semaphore_lock(omni_semaphore& s) : sem(s) { sem.wait(); } - ~omni_semaphore_lock(void) { sem.post(); } -private: - // dummy copy constructor and operator= to prevent copying - omni_semaphore_lock(const omni_semaphore_lock&); - omni_semaphore_lock& operator=(const omni_semaphore_lock&); -}; - - -/////////////////////////////////////////////////////////////////////////// -// -// Thread -// -/////////////////////////////////////////////////////////////////////////// - -class _OMNITHREAD_NTDLL_ omni_thread { - -public: - - enum priority_t { - PRIORITY_LOW, - PRIORITY_NORMAL, - PRIORITY_HIGH - }; - - enum state_t { - STATE_NEW, // thread object exists but thread hasn't - // started yet. - STATE_RUNNING, // thread is running. - STATE_TERMINATED // thread has terminated but storage has not - // been reclaimed (i.e. waiting to be joined). - }; - - // - // Constructors set up the thread object but the thread won't start until - // start() is called. The create method can be used to construct and start - // a thread in a single call. - // - - omni_thread(void (*fn)(void*), void* arg = NULL, - priority_t pri = PRIORITY_NORMAL); - omni_thread(void* (*fn)(void*), void* arg = NULL, - priority_t pri = PRIORITY_NORMAL); - // these constructors create a thread which will run the given function - // when start() is called. The thread will be detached if given a - // function with void return type, undetached if given a function - // returning void*. If a thread is detached, storage for the thread is - // reclaimed automatically on termination. Only an undetached thread - // can be joined. - - void start(void); - // start() causes a thread created with one of the constructors to - // start executing the appropriate function. - -protected: - - omni_thread(void* arg = NULL, priority_t pri = PRIORITY_NORMAL); - // this constructor is used in a derived class. The thread will - // execute the run() or run_undetached() member functions depending on - // whether start() or start_undetached() is called respectively. - -public: - - void start_undetached(void); - // can be used with the above constructor in a derived class to cause - // the thread to be undetached. In this case the thread executes the - // run_undetached member function. - -protected: - - virtual ~omni_thread(void); - // destructor cannot be called by user (except via a derived class). - // Use exit() or cancel() instead. This also means a thread object must - // be allocated with new - it cannot be statically or automatically - // allocated. The destructor of a class that inherits from omni_thread - // shouldn't be public either (otherwise the thread object can be - // destroyed while the underlying thread is still running). - -public: - - void join(void**); - // join causes the calling thread to wait for another's completion, - // putting the return value in the variable of type void* whose address - // is given (unless passed a null pointer). Only undetached threads - // may be joined. Storage for the thread will be reclaimed. - - void set_priority(priority_t); - // set the priority of the thread. - - static omni_thread* create(void (*fn)(void*), void* arg = NULL, - priority_t pri = PRIORITY_NORMAL); - static omni_thread* create(void* (*fn)(void*), void* arg = NULL, - priority_t pri = PRIORITY_NORMAL); - // create spawns a new thread executing the given function with the - // given argument at the given priority. Returns a pointer to the - // thread object. It simply constructs a new thread object then calls - // start. - - static void exit(void* return_value = NULL); - // causes the calling thread to terminate. - - static omni_thread* self(void); - // returns the calling thread's omni_thread object. If the - // calling thread is not the main thread and is not created - // using this library, returns 0. (But see create_dummy() - // below.) - - static void yield(void); - // allows another thread to run. - - static void sleep(unsigned long secs, unsigned long nanosecs = 0); - // sleeps for the given time. - - static void get_time(unsigned long* abs_sec, unsigned long* abs_nsec, - unsigned long rel_sec = 0, unsigned long rel_nsec=0); - // calculates an absolute time in seconds and nanoseconds, suitable for - // use in timed_waits on condition variables, which is the current time - // plus the given relative offset. - - - static void stacksize(unsigned long sz); - static unsigned long stacksize(); - // Use this value as the stack size when spawning a new thread. - // The default value (0) means that the thread library default is - // to be used. - - - // Per-thread data - // - // These functions allow you to attach additional data to an - // omni_thread. First allocate a key for yourself with - // allocate_key(). Then you can store any object whose class is - // derived from value_t. Any values still stored in the - // omni_thread when the thread exits are deleted. - // - // These functions are NOT thread safe, so you should be very - // careful about setting/getting data in a different thread to the - // current thread. - - typedef unsigned int key_t; - static key_t allocate_key(); - - class value_t { - public: - virtual ~value_t() {} - }; - - value_t* set_value(key_t k, value_t* v); - // Sets a value associated with the given key. The key must - // have been allocated with allocate_key(). If a value has - // already been set with the specified key, the old value_t - // object is deleted and replaced. Returns the value which was - // set, or zero if the key is invalid. - - value_t* get_value(key_t k); - // Returns the value associated with the key. If the key is - // invalid, or there is no value for the key, returns zero. - - value_t* remove_value(key_t k); - // Removes the value associated with the key and returns it. - // If the key is invalid, or there is no value for the key, - // returns zero. - - - // Dummy omni_thread - // - // Sometimes, an application finds itself with threads created - // outside of omnithread which must interact with omnithread - // features such as the per-thread data. In this situation, - // omni_thread::self() would normally return 0. These functions - // allow the application to create a suitable dummy omni_thread - // object. - - static omni_thread* create_dummy(void); - // creates a dummy omni_thread for the calling thread. Future - // calls to self() will return the dummy omni_thread. Throws - // omni_thread_invalid if this thread already has an - // associated omni_thread (real or dummy). - - static void release_dummy(); - // release the dummy omni_thread for this thread. This - // function MUST be called before the thread exits. Throws - // omni_thread_invalid if the calling thread does not have a - // dummy omni_thread. - - // class ensure_self should be created on the stack. If created in - // a thread without an associated omni_thread, it creates a dummy - // thread which is released when the ensure_self object is deleted. - - class ensure_self { - public: - inline ensure_self() : _dummy(0) - { - _self = omni_thread::self(); - if (!_self) { - _dummy = 1; - _self = omni_thread::create_dummy(); - } - } - inline ~ensure_self() - { - if (_dummy) - omni_thread::release_dummy(); - } - inline omni_thread* self() { return _self; } - private: - omni_thread* _self; - int _dummy; - }; - - -private: - - virtual void run(void* /*arg*/) {} - virtual void* run_undetached(void* /*arg*/) { return NULL; } - // can be overridden in a derived class. When constructed using the - // the constructor omni_thread(void*, priority_t), these functions are - // called by start() and start_undetached() respectively. - - void common_constructor(void* arg, priority_t pri, int det); - // implements the common parts of the constructors. - - omni_mutex mutex; - // used to protect any members which can change after construction, - // i.e. the following 2 members. - - state_t _state; - priority_t _priority; - - static omni_mutex* next_id_mutex; - static int next_id; - int _id; - - void (*fn_void)(void*); - void* (*fn_ret)(void*); - void* thread_arg; - int detached; - int _dummy; - value_t** _values; - unsigned long _value_alloc; - - omni_thread(const omni_thread&); - omni_thread& operator=(const omni_thread&); - // Not implemented - -public: - - priority_t priority(void) { - - // return this thread's priority. - - omni_mutex_lock l(mutex); - return _priority; - } - - state_t state(void) { - - // return thread state (invalid, new, running or terminated). - - omni_mutex_lock l(mutex); - return _state; - } - - int id(void) { return _id; } - // return unique thread id within the current process. - - - // This class plus the instance of it declared below allows us to execute - // some initialisation code before main() is called. - - class _OMNITHREAD_NTDLL_ init_t { - public: - init_t(void); - ~init_t(void); - }; - - friend class init_t; - friend class omni_thread_dummy; - -OMNI_THREAD_EXPOSE: - OMNI_THREAD_IMPLEMENTATION -}; - -#ifndef __rtems__ -static omni_thread::init_t omni_thread_init; -#else -// RTEMS calls global Ctor/Dtor in a context that is not -// a posix thread. Calls to functions to pthread_self() in -// that context returns NULL. -// So, for RTEMS we will make the thread initialization at the -// beginning of the Init task that has a posix context. -#endif - -#endif diff --git a/omnithread/gnuradio/ot_VxThread.h b/omnithread/gnuradio/ot_VxThread.h deleted file mode 100644 index e96c036cc..000000000 --- a/omnithread/gnuradio/ot_VxThread.h +++ /dev/null @@ -1,118 +0,0 @@ -#ifndef __VXTHREAD_H__ -#define __VXTHREAD_H__ -/* -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% Project: omniORB -%% Filename: $Filename$ -%% Author: Guillaume/Bill ARRECKX -%% Copyright Wavetek Wandel & Goltermann, Plymouth. -%% Description: OMNI thread implementation classes for VxWorks threads -%% Notes: -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% $Log$ -%% Revision 1.1 2004/04/10 18:00:52 eb -%% Initial revision -%% -%% Revision 1.1.1.1 2004/03/01 00:20:27 eb -%% initial checkin -%% -%% Revision 1.1 2003/05/25 05:29:04 eb -%% see ChangeLog -%% -%% Revision 1.1.2.1 2003/02/17 02:03:07 dgrisby -%% vxWorks port. (Thanks Michael Sturm / Acterna Eningen GmbH). -%% -%% Revision 1.1.1.1 2002/11/19 14:55:21 sokcevti -%% OmniOrb4.0.0 VxWorks port -%% -%% Revision 1.2 2002/06/14 12:45:50 engeln -%% unnecessary members in condition removed. -%% --- -%% -%% Revision 1.1.1.1 2002/04/02 10:08:49 sokcevti -%% omniORB4 initial realease -%% -%% Revision 1.1 2001/03/23 16:50:23 hartmut -%% Initial Version 2.8 -%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -*/ - - -/////////////////////////////////////////////////////////////////////////// -// Includes -/////////////////////////////////////////////////////////////////////////// -#include <vxWorks.h> -#include <semLib.h> -#include <taskLib.h> - - -/////////////////////////////////////////////////////////////////////////// -// Externs prototypes -/////////////////////////////////////////////////////////////////////////// -extern "C" void omni_thread_wrapper(void* ptr); - - -/////////////////////////////////////////////////////////////////////////// -// Exported macros -// Note: These are added as private members in each class implementation. -/////////////////////////////////////////////////////////////////////////// -#define OMNI_MUTEX_IMPLEMENTATION \ - SEM_ID mutexID; \ - bool m_bConstructed; - -#define OMNI_CONDITION_IMPLEMENTATION \ - long waiters_; \ - SEM_ID waiters_lock_; \ - SEM_ID sema_; - -#define OMNI_SEMAPHORE_IMPLEMENTATION \ - SEM_ID semID; - -#define OMNI_MUTEX_LOCK_IMPLEMENTATION \ - if(semTake(mutexID, WAIT_FOREVER) != OK) \ - { \ - throw omni_thread_fatal(errno); \ - } - -#define OMNI_MUTEX_UNLOCK_IMPLEMENTATION \ - if(semGive(mutexID) != OK) \ - { \ - throw omni_thread_fatal(errno); \ - } - -#define OMNI_THREAD_IMPLEMENTATION \ - friend void omni_thread_wrapper(void* ptr); \ - static int vxworks_priority(priority_t); \ - omni_condition *running_cond; \ - void* return_val; \ - int tid; \ - public: \ - static void attach(void); \ - static void detach(void); \ - static void show(void); - - -/////////////////////////////////////////////////////////////////////////// -// Porting macros -/////////////////////////////////////////////////////////////////////////// -// This is a wrapper function for the 'main' function which does not exists -// as such in VxWorks. The wrapper creates a launch function instead, -// which spawns the application wrapped in a omni_thread. -// Argc will always be null. -/////////////////////////////////////////////////////////////////////////// -#define main( discarded_argc, discarded_argv ) \ - omni_discard_retval() \ - { \ - throw; \ - } \ - int omni_main( int argc, char **argv ); \ - void launch( ) \ - { \ - omni_thread* th = new omni_thread( (void(*)(void*))omni_main );\ - th->start();\ - }\ - int omni_main( int argc, char **argv ) - - -#endif // ndef __VXTHREAD_H__ diff --git a/omnithread/gnuradio/ot_mach.h b/omnithread/gnuradio/ot_mach.h deleted file mode 100644 index 76361926c..000000000 --- a/omnithread/gnuradio/ot_mach.h +++ /dev/null @@ -1,51 +0,0 @@ -// Package : omnithread -// omnithread/posix.h Created : 7/97 lars immisch lars@ibp.de -// -// Copyright (C) 1994,1995,1996, 1997 Immisch, becker & Partner -// -// This file is part of the omnithread library -// -// The omnithread library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Boston, MA -// 02110-1301, USA -// -// -// OMNI thread implementation classes for posix threads -// - -#ifndef __omnithread_mach_h_ -#define __omnithread_mach_h_ - -#include <mach/cthreads.h> - -extern "C" void* omni_thread_wrapper(void* ptr); - -#define OMNI_MUTEX_IMPLEMENTATION \ - struct mutex mach_mutex; - -#define OMNI_CONDITION_IMPLEMENTATION \ - struct condition mach_cond; - -#define OMNI_SEMAPHORE_IMPLEMENTATION \ - omni_mutex m; \ - omni_condition c; \ - int value; - - -#define OMNI_THREAD_IMPLEMENTATION \ - cthread_t mach_thread; \ - static int mach_priority(priority_t); \ - friend void* omni_thread_wrapper(void* ptr); - -#endif diff --git a/omnithread/gnuradio/ot_nt.h b/omnithread/gnuradio/ot_nt.h deleted file mode 100644 index 551ccf2f1..000000000 --- a/omnithread/gnuradio/ot_nt.h +++ /dev/null @@ -1,85 +0,0 @@ -// Package : omnithread -// omnithread/nt.h Created : 6/95 tjr -// -// Copyright (C) 1995, 1996, 1997 Olivetti & Oracle Research Laboratory -// -// This file is part of the omnithread library -// -// The omnithread library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Boston, MA -// 02110-1301, USA -// -// -// OMNI thread implementation classes for NT threads. -// - -#ifndef __omnithread_nt_h_ -#define __omnithread_nt_h_ - -#ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# define OMNI_DEFINED_WIN32_LEAN_AND_MEAN -#endif - -#include <windows.h> - -#ifdef OMNI_DEFINED_WIN32_LEAN_AND_MEAN -# undef WIN32_LEAN_AND_MEAN -# undef OMNI_DEFINED_WIN32_LEAN_AND_MEAN -#endif - - -#ifndef __BCPLUSPLUS__ -#define OMNI_THREAD_WRAPPER \ - unsigned __stdcall omni_thread_wrapper(LPVOID ptr); -#else -#define OMNI_THREAD_WRAPPER \ - void _USERENTRY omni_thread_wrapper(void *ptr); -#endif - -extern "C" OMNI_THREAD_WRAPPER; - -#define OMNI_MUTEX_IMPLEMENTATION \ - CRITICAL_SECTION crit; - -#define OMNI_MUTEX_LOCK_IMPLEMENTATION \ - EnterCriticalSection(&crit); - -#define OMNI_MUTEX_TRYLOCK_IMPLEMENTATION \ - TryEnterCriticalSection(&crit); - -#define OMNI_MUTEX_UNLOCK_IMPLEMENTATION \ - LeaveCriticalSection(&crit); - -#define OMNI_CONDITION_IMPLEMENTATION \ - CRITICAL_SECTION crit; \ - omni_thread* waiting_head; \ - omni_thread* waiting_tail; - -#define OMNI_SEMAPHORE_IMPLEMENTATION \ - HANDLE nt_sem; - -#define OMNI_THREAD_IMPLEMENTATION \ - HANDLE handle; \ - DWORD nt_id; \ - void* return_val; \ - HANDLE cond_semaphore; \ - omni_thread* cond_next; \ - omni_thread* cond_prev; \ - BOOL cond_waiting; \ - static int nt_priority(priority_t); \ - friend class omni_condition; \ - friend OMNI_THREAD_WRAPPER; - -#endif diff --git a/omnithread/gnuradio/ot_posix.h b/omnithread/gnuradio/ot_posix.h deleted file mode 100644 index 666ccc089..000000000 --- a/omnithread/gnuradio/ot_posix.h +++ /dev/null @@ -1,81 +0,0 @@ -// Package : omnithread -// omnithread/posix.h Created : 7/94 tjr -// -// Copyright (C) 2006 Free Software Foundation, Inc. -// Copyright (C) 1994,1995,1996, 1997 Olivetti & Oracle Research Laboratory -// -// This file is part of the omnithread library -// -// The omnithread library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Boston, MA -// 02110-1301, USA -// -// -// OMNI thread implementation classes for posix threads -// - -#ifndef __omnithread_posix_h_ -#define __omnithread_posix_h_ - -#if defined(__alpha__) && defined(__osf1__) || defined(__hpux__) -// stop unnecessary definitions of TRY, etc on OSF -#ifndef EXC_HANDLING -#define EXC_HANDLING -#endif -#endif - -#ifndef __POSIX_NT__ -# include <pthread.h> -#else -# ifndef WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -# define OMNI_DEFINED_WIN32_LEAN_AND_MEAN -# endif -# include <windows.h> -# include "pthread_nt.h" -# ifdef OMNI_DEFINED_WIN32_LEAN_AND_MEAN -# undef WIN32_LEAN_AND_MEAN -# undef OMNI_DEFINED_WIN32_LEAN_AND_MEAN -# endif -#endif - -extern "C" void* omni_thread_wrapper(void* ptr); - -#define OMNI_MUTEX_IMPLEMENTATION \ - pthread_mutex_t posix_mutex; - -#define OMNI_MUTEX_LOCK_IMPLEMENTATION \ - pthread_mutex_lock(&posix_mutex); - -#define OMNI_MUTEX_TRYLOCK_IMPLEMENTATION \ - (pthread_mutex_trylock(&posix_mutex)==0); - -#define OMNI_MUTEX_UNLOCK_IMPLEMENTATION \ - pthread_mutex_unlock(&posix_mutex); - -#define OMNI_CONDITION_IMPLEMENTATION \ - pthread_cond_t posix_cond; - -#define OMNI_SEMAPHORE_IMPLEMENTATION \ - omni_mutex m; \ - omni_condition c; \ - int value; \ - int max_count; - -#define OMNI_THREAD_IMPLEMENTATION \ - pthread_t posix_thread; \ - static int posix_priority(priority_t); \ - friend void* omni_thread_wrapper(void* ptr); - -#endif diff --git a/omnithread/gnuradio/ot_pthread_nt.h b/omnithread/gnuradio/ot_pthread_nt.h deleted file mode 100644 index 324b5257f..000000000 --- a/omnithread/gnuradio/ot_pthread_nt.h +++ /dev/null @@ -1,186 +0,0 @@ -/* Package : omnithread - omnithread/pthread_nt.h Created : Steven Brenneis <brennes1@rjrt.com> - - Copyright (C) 1998 Steven Brennes - - This file is part of the omnithread library - - The omnithread library is free software; you can redistribute it and/or - modify it under the terms of the GNU Library General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - This library 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 - Library General Public License for more details. - - You should have received a copy of the GNU Library General Public - License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Boston, MA - 02110-1301, USA - - Posix Threads implementation for Windows NT, version 4.0 -*/ - -#ifndef PTHREAD_NT_H_INCLUDED -#define PTHREAD_NT_H_INCLUDED - -#include <errno.h> - -#ifndef ETIMEDOUT -// May have to be changed if NT starts supporting more errno values -#define ETIMEDOUT 60 -#endif - -#undef PthreadDraftVersion -#define PthreadDraftVersion 10 - -#define NoNanoSleep - -#define PthreadSupportThreadPriority - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef _TIMERS_T_ -#define _TIMERS_T_ - typedef struct timespec { - unsigned long tv_sec; - long tv_nsec; - } timespec_t; -#endif - -typedef char* __pthreadLongString_t; -typedef void* __pthreadLongAddr_t; -typedef __pthreadLongAddr_t* __pthreadLongAddr_p; -typedef long __pthreadLongInt_t; -typedef unsigned long __pthreadLongUint_t; -typedef __pthreadLongAddr_p __pthreadTsd_t; - -typedef struct __pthread_mutex_t { - unsigned int lock; /* LOCK, SLOW, TYPE, RECURSIVE */ - unsigned int valid; /* Validation info */ - __pthreadLongString_t name; /* Name of mutex */ - unsigned int arg; /* printf argument for name */ - unsigned int depth; /* Recursive lock depth */ - unsigned long sequence; /* Mutex sequence number */ - unsigned long owner; /* Current owner (if known */ - __pthreadLongAddr_t block; /* Pointer to blocking struct */ -} pthread_mutex_t; - -typedef struct __pthread_mutexattr_t { - long valid; - __pthreadLongUint_t reserved[15]; -} pthread_mutexattr_t; - -typedef struct __pthread_cond_t { - unsigned int state; /* EVENT, SLOW, REFCNT */ - unsigned int valid; /* Validation info */ - __pthreadLongString_t name; /* Name of condition variable */ - unsigned int arg; /* printf argument for name */ - unsigned long sequence; /* Condition variable seq # */ - __pthreadLongAddr_t block; /* Pointer to blocking struct */ -} pthread_cond_t ; - -typedef struct __pthread_condattr_t { - long valid; - __pthreadLongUint_t reserved[13]; -} pthread_condattr_t ; - -typedef struct __pthread_transp_t { - __pthreadLongAddr_t reserved1; /* Reserved to posix_nt */ - __pthreadLongAddr_t reserved2; /* Reserved to posix_nt */ - unsigned short size; /* Size of data structure */ - unsigned char reserved3[2]; /* Reserved to posix_nt */ - __pthreadLongAddr_t reserved4; /* Reserved to posix_nt */ - __pthreadLongUint_t sequence; /* Thread sequence number */ - __pthreadLongUint_t reserved5[2]; /* Reserved to posix_nt */ - __pthreadLongAddr_t per_kt_area; /* Pointer to kernel context */ - __pthreadLongAddr_t stack_base; /* Current stack base */ - __pthreadLongAddr_t stack_reserve; /* Current stack reserve zone */ - __pthreadLongAddr_t stack_yellow; /* Current stack yellow zone */ - __pthreadLongAddr_t stack_guard; /* Current stack guard zone */ - __pthreadLongUint_t stack_size; /* Size of stack */ - __pthreadTsd_t tsd_values; /* TSD array (indexed by key) */ - unsigned long tsd_count; /* Number of TSD cells */ - __pthreadLongAddr_t reserved6; /* Reserved to posix_nt */ - __pthreadLongAddr_t reserved7; /* Reserved to posix_nt */ - unsigned int thread_flags; /* Dynamic external state */ -} pthread_transp_t, *pthread_transp_p; - -typedef pthread_transp_p pthread_t; - -typedef struct __pthread_attr_t { - long valid; - __pthreadLongString_t name; - __pthreadLongUint_t arg; - __pthreadLongUint_t reserved[19]; -} pthread_attr_t ; - -typedef unsigned int pthread_key_t; - -typedef struct sched_param { - int sched_priority; -} sched_param_t; - -/* Function Prototypes */ - -int pthread_create(pthread_t *thread, const pthread_attr_t *attr, - void *(*start_routine)(void*), void *arg); -int pthread_detach(pthread_t thread); -int pthread_join(pthread_t thread, void **value_ptr); -void pthread_exit(void *value_ptr); -int pthread_attr_init(pthread_attr_t *attr); -int pthread_attr_destroy(pthread_attr_t *attr); -int pthread_attr_setstacksize(pthread_attr_t *attr, size_t stacksize); -int pthread_attr_getstacksize(const pthread_attr_t *attr, - size_t *stacksize); -int pthread_cond_init(pthread_cond_t *cond, - const pthread_condattr_t *attr); -int pthread_cond_destroy(pthread_cond_t *cond); -int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex); -int pthread_cond_timedwait(pthread_cond_t *cond, - pthread_mutex_t *mutex, - const struct timespec *abstime); -int pthread_cond_signal(pthread_cond_t *cond); -int pthread_cond_broadcast(pthread_cond_t *cond); -int pthread_key_create(pthread_key_t *key, void (*destructor)(void*)); -int pthread_key_delete(pthread_key_t key); -int pthread_mutex_destroy(pthread_mutex_t *mutex); -int pthread_mutex_init(pthread_mutex_t *mutex, - const pthread_mutexattr_t *attr); -int pthread_mutex_lock(pthread_mutex_t *mutex); -int pthread_mutex_trylock(pthread_mutex_t *mutex); -int pthread_mutex_unlock(pthread_mutex_t *mutex); -pthread_t pthread_self(); -int pthread_setspecific(pthread_key_t key, const void *value); -void *pthread_getspecific(pthread_key_t key); -int pthread_getschedparam(pthread_t thread, int *policy, - struct sched_param *param); -int pthread_setschedparam(pthread_t thread, int policy, - const struct sched_param *param); -int pthread_attr_setschedparam(pthread_attr_t *attr, - const struct sched_param *param); -int pthread_attr_getschedparam(const pthread_attr_t *attr, - struct sched_param *param); - -int pthread_delay_np(const struct timespec *interval); -int pthread_get_expiration_np(const struct timespec *delta, - struct timespec *abstime); - -# define SCHED_FIFO 1 -# define SCHED_RR 2 -# define SCHED_OTHER 3 - -int sched_yield(); -int sched_get_priority_max(int policy); -int sched_get_priority_min(int policy); - - -#ifdef __cplusplus -} -#endif - -#endif // PTHREAD_NT_H_INCLUDED diff --git a/omnithread/gnuradio/ot_solaris.h b/omnithread/gnuradio/ot_solaris.h deleted file mode 100644 index f4fea0b11..000000000 --- a/omnithread/gnuradio/ot_solaris.h +++ /dev/null @@ -1,47 +0,0 @@ -// Package : omnithread -// omnithread/solaris.h Created : 7/94 tjr -// -// Copyright (C) 1994,1995,1996, 1997 Olivetti & Oracle Research Laboratory -// -// This file is part of the omnithread library -// -// The omnithread library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Boston, MA -// 02110-1301, USA -// -// OMNI thread implementation classes for solaris threads. -// - -#ifndef __omnithread_solaris_h_ -#define __omnithread_solaris_h_ - -#include <thread.h> - -extern "C" void* omni_thread_wrapper(void* ptr); - -#define OMNI_MUTEX_IMPLEMENTATION \ - mutex_t sol_mutex; - -#define OMNI_CONDITION_IMPLEMENTATION \ - cond_t sol_cond; - -#define OMNI_SEMAPHORE_IMPLEMENTATION \ - sema_t sol_sem; - -#define OMNI_THREAD_IMPLEMENTATION \ - thread_t sol_thread; \ - static int sol_priority(priority_t); \ - friend void* omni_thread_wrapper(void* ptr); - -#endif diff --git a/omnithread/mach.cc b/omnithread/mach.cc deleted file mode 100644 index aa0465f41..000000000 --- a/omnithread/mach.cc +++ /dev/null @@ -1,714 +0,0 @@ -// Package : omnithread -// omnithread/mach.cc Created : 7/97 lars immisch lars@ibp.de -// -// Copyright (C) 1997 Immisch, Becker & Partner -// -// This file is part of the omnithread library -// -// The omnithread library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Boston, MA -// 02110-1301, USA -// - -// -// Implementation of OMNI thread abstraction for mach threads -// -// to the author's pleasure, mach cthreads are very similar to posix threads -// - -#include <stdlib.h> -#include <errno.h> -#include <sys/time.h> -#include <mach/cthreads.h> -#include "gnuradio/omnithread.h" - -#define DB(x) // x -// #include <iostream> or #include <iostream.h> if DB is on. - -#define ERRNO(x) (x) - -// -// static variables -// - -int omni_thread::init_t::count = 0; - -omni_mutex* omni_thread::next_id_mutex; -int omni_thread::next_id = 0; - -static int normal_priority; -static int highest_priority; - -static size_t stack_size = 0; - -/////////////////////////////////////////////////////////////////////////// -// -// Mutex -// -/////////////////////////////////////////////////////////////////////////// - - -omni_mutex::omni_mutex(void) -{ - mutex_init(&mach_mutex); -} - - -omni_mutex::~omni_mutex(void) -{ - mutex_clear(&mach_mutex); -} - - -void omni_mutex::lock(void) -{ - mutex_lock(&mach_mutex); -} - - -void omni_mutex::unlock(void) -{ - mutex_unlock(&mach_mutex); -} - - - -/////////////////////////////////////////////////////////////////////////// -// -// Condition variable -// -/////////////////////////////////////////////////////////////////////////// - - -omni_condition::omni_condition(omni_mutex* m) : mutex(m) -{ - condition_init(&mach_cond); -} - - -omni_condition::~omni_condition(void) -{ - condition_clear(&mach_cond); -} - -void -omni_condition::wait(void) -{ - condition_wait(&mach_cond, &mutex->mach_mutex); -} - -typedef struct alarmclock_args { - unsigned long secs; - unsigned long nsecs; - bool wakeup; - condition_t condition; - mutex_t mutex; -}; - -any_t alarmclock(any_t arg) -{ - alarmclock_args* alarm = (alarmclock_args*)arg; - - omni_thread::sleep(alarm->secs, alarm->nsecs); - - mutex_lock(alarm->mutex); - - alarm->wakeup = TRUE; - - condition_signal(alarm->condition); - - mutex_unlock(alarm->mutex); - - return (any_t)TRUE; -} - -int omni_condition::timedwait(unsigned long abs_secs, unsigned long abs_nsecs) -{ - alarmclock_args alarm; - - omni_thread::get_time(&alarm.secs, &alarm.nsecs, 0, 0); - - if (abs_secs < alarm.secs || (abs_secs == alarm.secs && abs_nsecs <= alarm.nsecs)) - return ETIMEDOUT; - - alarm.secs = abs_secs - alarm.secs; - if (abs_nsecs <= alarm.nsecs) { - alarm.nsecs = 1000000 - alarm.nsecs + abs_nsecs; - alarm.secs--; - } - else { - alarm.nsecs = abs_nsecs - alarm.nsecs; - } - - alarm.mutex = &mutex->mach_mutex; - alarm.condition = &mach_cond; - alarm.wakeup = FALSE; - - cthread_t ct = cthread_fork((cthread_fn_t)alarmclock, (any_t)&alarm); - cthread_detach(ct); - - condition_wait(&mach_cond, &mutex->mach_mutex); - - if (alarm.wakeup) { - return 0; - } - - // interrupt the alarmclock thread sleep - cthread_abort(ct); - - // wait until it has signalled the condition - condition_wait(&mach_cond, &mutex->mach_mutex); - - return 1; -} - - -void omni_condition::signal(void) -{ - condition_signal(&mach_cond); -} - - -void omni_condition::broadcast(void) -{ - condition_signal(&mach_cond); -} - - - -/////////////////////////////////////////////////////////////////////////// -// -// Counting semaphore -// -/////////////////////////////////////////////////////////////////////////// - - -omni_semaphore::omni_semaphore(unsigned int initial) : c(&m) -{ - value = initial; -} - - -omni_semaphore::~omni_semaphore(void) -{ -} - - -void -omni_semaphore::wait(void) -{ - omni_mutex_lock l(m); - - while (value == 0) - c.wait(); - - value--; -} - - -int -omni_semaphore::trywait(void) -{ - omni_mutex_lock l(m); - - if (value == 0) - return 0; - - value--; - return 1; -} - - -void -omni_semaphore::post(void) -{ - omni_mutex_lock l(m); - - if (value == 0) - c.signal(); - - value++; -} - - - -/////////////////////////////////////////////////////////////////////////// -// -// Thread -// -/////////////////////////////////////////////////////////////////////////// - - - -// -// Initialisation function (gets called before any user code). -// - -omni_thread::init_t::init_t(void) -{ - if (count++ != 0) // only do it once however many objects get created. - return; - - // - // find base and max priority. - // This is the initial thread, so the max priority of this - // thread also applies to any newly created thread. - // - - kern_return_t error; - struct thread_sched_info info; - unsigned int info_count = THREAD_SCHED_INFO_COUNT; - - error = thread_info(thread_self(), THREAD_SCHED_INFO, (thread_info_t)&info, &info_count); - if (error != KERN_SUCCESS) { - DB(cerr << "omni_thread::init: error determining thread_info" << endl); - ::exit(1); - } - else { - normal_priority = info.base_priority; - highest_priority = info.max_priority; - } - - next_id_mutex = new omni_mutex; - - // - // Create object for this (i.e. initial) thread. - // - - omni_thread* t = new omni_thread; - - if (t->_state != STATE_NEW) { - DB(cerr << "omni_thread::init: problem creating initial thread object\n"); - ::exit(1); - } - - t->_state = STATE_RUNNING; - - t->mach_thread = cthread_self(); - - DB(cerr << "initial thread " << t->id() << endl); - - cthread_set_data(t->mach_thread, (any_t)t); -} - - -// -// Wrapper for thread creation. -// - -extern "C" void* -omni_thread_wrapper(void* ptr) -{ - omni_thread* me = (omni_thread*)ptr; - - DB(cerr << "omni_thread::wrapper: thread " << me->id() - << " started\n"); - - cthread_set_data(cthread_self(), (any_t)me); - - // - // Now invoke the thread function with the given argument. - // - - if (me->fn_void != NULL) { - (*me->fn_void)(me->thread_arg); - omni_thread::exit(); - } - - if (me->fn_ret != NULL) { - void* return_value = (*me->fn_ret)(me->thread_arg); - omni_thread::exit(return_value); - } - - if (me->detached) { - me->run(me->thread_arg); - omni_thread::exit(); - } else { - void* return_value = me->run_undetached(me->thread_arg); - omni_thread::exit(return_value); - } - - // should never get here. - - return NULL; -} - - -// -// Constructors for omni_thread - set up the thread object but don't -// start it running. -// - -// construct a detached thread running a given function. - -omni_thread::omni_thread(void (*fn)(void*), void* arg, priority_t pri) -{ - common_constructor(arg, pri, 1); - fn_void = fn; - fn_ret = NULL; -} - -// construct an undetached thread running a given function. - -omni_thread::omni_thread(void* (*fn)(void*), void* arg, priority_t pri) -{ - common_constructor(arg, pri, 0); - fn_void = NULL; - fn_ret = fn; -} - -// construct a thread which will run either run() or run_undetached(). - -omni_thread::omni_thread(void* arg, priority_t pri) -{ - common_constructor(arg, pri, 1); - fn_void = NULL; - fn_ret = NULL; -} - -// common part of all constructors. - -void omni_thread::common_constructor(void* arg, priority_t pri, int det) -{ - _state = STATE_NEW; - _priority = pri; - - next_id_mutex->lock(); - _id = next_id++; - next_id_mutex->unlock(); - - thread_arg = arg; - detached = det; // may be altered in start_undetached() - - _dummy = 0; - _values = 0; - _value_alloc = 0; - // posix_thread is set up in initialisation routine or start(). -} - - -// -// Destructor for omni_thread. -// - -omni_thread::~omni_thread(void) -{ - DB(cerr << "destructor called for thread " << id() << endl); - if (_values) { - for (key_t i=0; i < _value_alloc; i++) { - if (_values[i]) { - delete _values[i]; - } - } - delete [] _values; - } -} - - -// -// Start the thread -// - -void -omni_thread::start(void) -{ - omni_mutex_lock l(mutex); - - int rc; - - if (_state != STATE_NEW) - throw omni_thread_invalid(); - - mach_thread = cthread_fork(omni_thread_wrapper, (any_t)this); - - _state = STATE_RUNNING; - - if (detached) { - cthread_detach(mach_thread); - } -} - -// -// Start a thread which will run the member function run_undetached(). -// - -void -omni_thread::start_undetached(void) -{ - if ((fn_void != NULL) || (fn_ret != NULL)) - throw omni_thread_invalid(); - - detached = 0; - start(); -} - - -// -// join - simply check error conditions & call cthread_join. -// - -void -omni_thread::join(void** status) -{ - mutex.lock(); - - if ((_state != STATE_RUNNING) && (_state != STATE_TERMINATED)) { - mutex.unlock(); - throw omni_thread_invalid(); - } - - mutex.unlock(); - - if (this == self()) - throw omni_thread_invalid(); - - if (detached) - throw omni_thread_invalid(); - - DB(cerr << "omni_thread::join: doing cthread_join\n"); - - *status = cthread_join(mach_thread); - - delete this; -} - - -// -// Change this thread's priority. -// - -void -omni_thread::set_priority(priority_t pri) -{ - omni_mutex_lock l(mutex); - - if (_state != STATE_RUNNING) - throw omni_thread_invalid(); - - _priority = pri; - - kern_return_t rc = cthread_priority(mach_thread, mach_priority(pri), FALSE); - - if (rc != KERN_SUCCESS) - throw omni_thread_fatal(errno); -} - -// -// create - construct a new thread object and start it running. Returns thread -// object if successful, null pointer if not. -// - -// detached version - -omni_thread* -omni_thread::create(void (*fn)(void*), void* arg, priority_t pri) -{ - omni_thread* t = new omni_thread(fn, arg, pri); - - t->start(); - - return t; -} - -// undetached version - -omni_thread* -omni_thread::create(void* (*fn)(void*), void* arg, priority_t pri) -{ - omni_thread* t = new omni_thread(fn, arg, pri); - - t->start(); - - return t; -} - -// -// exit() _must_ lock the mutex even in the case of a detached thread. This is -// because a thread may run to completion before the thread that created it has -// had a chance to get out of start(). By locking the mutex we ensure that the -// creating thread must have reached the end of start() before we delete the -// thread object. Of course, once the call to start() returns, the user can -// still incorrectly refer to the thread object, but that's their problem. -// - -void omni_thread::exit(void* return_value) -{ - omni_thread* me = self(); - - if (me) - { - me->mutex.lock(); - - if (me->_state != STATE_RUNNING) - DB(cerr << "omni_thread::exit: thread not in \"running\" state\n"); - - me->_state = STATE_TERMINATED; - - me->mutex.unlock(); - - DB(cerr << "omni_thread::exit: thread " << me->id() << " detached " - << me->detached << " return value " << return_value << endl); - - if (me->detached) - delete me; - } - else - { - DB(cerr << "omni_thread::exit: called with a non-omnithread. Exit quietly." << endl); - } - cthread_exit(return_value); -} - -omni_thread* omni_thread::self(void) -{ - omni_thread* me; - - me = (omni_thread*)cthread_data(cthread_self()); - - if (!me) { - // This thread is not created by omni_thread::start because it - // doesn't has a class omni_thread instance attached to its key. - DB(cerr << "omni_thread::self: called with a non-ominthread. NULL is returned." << endl); - } - - return me; -} - -void omni_thread::yield(void) -{ - cthread_yield(); -} - -#define MAX_SLEEP_SECONDS (unsigned)4294966 // (2**32-2)/1000 - -void -omni_thread::sleep(unsigned long secs, unsigned long nanosecs) -{ - if (secs <= MAX_SLEEP_SECONDS) { - thread_switch(THREAD_NULL, SWITCH_OPTION_WAIT, secs * 1000 + nanosecs / 1000000); - return; - } - - unsigned no_of_max_sleeps = secs / MAX_SLEEP_SECONDS; - - for (unsigned i = 0; i < no_of_max_sleeps; i++) - thread_switch(THREAD_NULL, SWITCH_OPTION_WAIT, MAX_SLEEP_SECONDS * 1000); - - thread_switch(THREAD_NULL, SWITCH_OPTION_WAIT, - (secs % MAX_SLEEP_SECONDS) * 1000 + nanosecs / 1000000); - - return; -} - -void -omni_thread::get_time(unsigned long* abs_sec, unsigned long* abs_nsec, - unsigned long rel_sec, unsigned long rel_nsec) -{ - int rc; - unsigned long tv_sec; - unsigned long tv_nsec; - struct timeval tv; - - rc = gettimeofday(&tv, NULL); - if (rc) throw omni_thread_fatal(rc); - - tv_sec = tv.tv_sec; - tv_nsec = tv.tv_usec * 1000; - - tv_nsec += rel_nsec; - tv_sec += rel_sec + tv_nsec / 1000000000; - tv_nsec = tv_nsec % 1000000000; - - *abs_sec = tv_sec; - *abs_nsec = tv_nsec; -} - - -int -omni_thread::mach_priority(priority_t pri) -{ - switch (pri) { - - case PRIORITY_LOW: - return 0; - - case PRIORITY_NORMAL: - return normal_priority; - - case PRIORITY_HIGH: - return highest_priority; - - default: - return -1; - } -} - -void -omni_thread::stacksize(unsigned long sz) -{ - stack_size = sz; -} - -unsigned long -omni_thread::stacksize() -{ - return stack_size; -} - - -// -// Dummy thread -// - -#error This dummy thread code is not tested. It might work if you're lucky. - -class omni_thread_dummy : public omni_thread { -public: - inline omni_thread_dummy() : omni_thread() - { - _dummy = 1; - _state = STATE_RUNNING; - mach_thread = cthread_self(); - cthread_set_data(mach_thread, (any_t)this)); - } - inline ~omni_thread_dummy() - { - cthread_set_data(mach_thread, (any_t)0)); - } -}; - -omni_thread* -omni_thread::create_dummy() -{ - if (omni_thread::self()) - throw omni_thread_invalid(); - - return new omni_thread_dummy; -} - -void -omni_thread::release_dummy() -{ - omni_thread* self = omni_thread::self(); - if (!self || !self->_dummy) - throw omni_thread_invalid(); - - omni_thread_dummy* dummy = (omni_thread_dummy*)self; - delete dummy; -} - - -#define INSIDE_THREAD_IMPL_CC -#include "threaddata.cc" -#undef INSIDE_THREAD_IMPL_CC diff --git a/omnithread/nt.cc b/omnithread/nt.cc deleted file mode 100644 index 2c97d6213..000000000 --- a/omnithread/nt.cc +++ /dev/null @@ -1,969 +0,0 @@ -// Package : omnithread -// omnithread/nt.cc Created : 6/95 tjr -// -// Copyright (C) 2006 Free Software Foundation, Inc. -// Copyright (C) 1995-1999 AT&T Laboratories Cambridge -// -// This file is part of the omnithread library -// -// The omnithread library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Boston, MA -// 02110-1301, USA -// - -// -// Implementation of OMNI thread abstraction for NT threads -// - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdlib.h> -#include <errno.h> -#include <WinError.h> -#include <gnuradio/omnithread.h> -#include <process.h> - -#define DB(x) // x -//#include <iostream.h> or #include <iostream> if DB is on. - -static void get_time_now(unsigned long* abs_sec, unsigned long* abs_nsec); - -/////////////////////////////////////////////////////////////////////////// -// -// Mutex -// -/////////////////////////////////////////////////////////////////////////// - - -omni_mutex::omni_mutex(void) -{ - InitializeCriticalSection(&crit); -} - -omni_mutex::~omni_mutex(void) -{ - DeleteCriticalSection(&crit); -} - - - -/////////////////////////////////////////////////////////////////////////// -// -// Condition variable -// -/////////////////////////////////////////////////////////////////////////// - - -// -// Condition variables are tricky to implement using NT synchronisation -// primitives, since none of them have the atomic "release mutex and wait to be -// signalled" which is central to the idea of a condition variable. To get -// around this the solution is to record which threads are waiting and -// explicitly wake up those threads. -// -// Here we implement a condition variable using a list of waiting threads -// (protected by a critical section), and a per-thread semaphore (which -// actually only needs to be a binary semaphore). -// -// To wait on the cv, a thread puts itself on the list of waiting threads for -// that cv, then releases the mutex and waits on its own personal semaphore. A -// signalling thread simply takes a thread from the head of the list and kicks -// that thread's semaphore. Broadcast is simply implemented by kicking the -// semaphore of each waiting thread. -// -// The only other tricky part comes when a thread gets a timeout from a timed -// wait on its semaphore. Between returning with a timeout from the wait and -// entering the critical section, a signalling thread could get in, kick the -// waiting thread's semaphore and remove it from the list. If this happens, -// the waiting thread's semaphore is now out of step so it needs resetting, and -// the thread should indicate that it was signalled rather than that it timed -// out. -// -// It is possible that the thread calling wait or timedwait is not a -// omni_thread. In this case we have to provide a temporary data structure, -// i.e. for the duration of the call, for the thread to link itself on the -// list of waiting threads. _internal_omni_thread_dummy provides such -// a data structure and _internal_omni_thread_helper is a helper class to -// deal with this special case for wait() and timedwait(). Once created, -// the _internal_omni_thread_dummy is cached for use by the next wait() or -// timedwait() call from a non-omni_thread. This is probably worth doing -// because creating a Semaphore is quite heavy weight. - -class _internal_omni_thread_helper; - -class _internal_omni_thread_dummy : public omni_thread { -public: - inline _internal_omni_thread_dummy() : next(0) { } - inline ~_internal_omni_thread_dummy() { } - friend class _internal_omni_thread_helper; -private: - _internal_omni_thread_dummy* next; -}; - -class _internal_omni_thread_helper { -public: - inline _internal_omni_thread_helper() { - d = 0; - t = omni_thread::self(); - if (!t) { - omni_mutex_lock sync(cachelock); - if (cache) { - d = cache; - cache = cache->next; - } - else { - d = new _internal_omni_thread_dummy; - } - t = d; - } - } - inline ~_internal_omni_thread_helper() { - if (d) { - omni_mutex_lock sync(cachelock); - d->next = cache; - cache = d; - } - } - inline operator omni_thread* () { return t; } - inline omni_thread* operator->() { return t; } - - static _internal_omni_thread_dummy* cache; - static omni_mutex cachelock; - -private: - _internal_omni_thread_dummy* d; - omni_thread* t; -}; - -_internal_omni_thread_dummy* _internal_omni_thread_helper::cache = 0; -omni_mutex _internal_omni_thread_helper::cachelock; - - -omni_condition::omni_condition(omni_mutex* m) : mutex(m) -{ - InitializeCriticalSection(&crit); - waiting_head = waiting_tail = NULL; -} - - -omni_condition::~omni_condition(void) -{ - DeleteCriticalSection(&crit); - DB( if (waiting_head != NULL) { - cerr << "omni_condition::~omni_condition: list of waiting threads " - << "is not empty\n"; - } ) -} - - -void -omni_condition::wait(void) -{ - _internal_omni_thread_helper me; - - EnterCriticalSection(&crit); - - me->cond_next = NULL; - me->cond_prev = waiting_tail; - if (waiting_head == NULL) - waiting_head = me; - else - waiting_tail->cond_next = me; - waiting_tail = me; - me->cond_waiting = TRUE; - - LeaveCriticalSection(&crit); - - mutex->unlock(); - - DWORD result = WaitForSingleObject(me->cond_semaphore, INFINITE); - - mutex->lock(); - - if (result != WAIT_OBJECT_0) - throw omni_thread_fatal(GetLastError()); -} - - -int -omni_condition::timedwait(unsigned long abs_sec, unsigned long abs_nsec) -{ - _internal_omni_thread_helper me; - - EnterCriticalSection(&crit); - - me->cond_next = NULL; - me->cond_prev = waiting_tail; - if (waiting_head == NULL) - waiting_head = me; - else - waiting_tail->cond_next = me; - waiting_tail = me; - me->cond_waiting = TRUE; - - LeaveCriticalSection(&crit); - - mutex->unlock(); - - unsigned long now_sec, now_nsec; - - get_time_now(&now_sec, &now_nsec); - - DWORD timeout; - if ((abs_sec <= now_sec) && ((abs_sec < now_sec) || (abs_nsec < now_nsec))) - timeout = 0; - else { - timeout = (abs_sec-now_sec) * 1000; - - if( abs_nsec < now_nsec ) timeout -= (now_nsec-abs_nsec) / 1000000; - else timeout += (abs_nsec-now_nsec) / 1000000; - } - - DWORD result = WaitForSingleObject(me->cond_semaphore, timeout); - - if (result == WAIT_TIMEOUT) { - EnterCriticalSection(&crit); - - if (me->cond_waiting) { - if (me->cond_prev != NULL) - me->cond_prev->cond_next = me->cond_next; - else - waiting_head = me->cond_next; - if (me->cond_next != NULL) - me->cond_next->cond_prev = me->cond_prev; - else - waiting_tail = me->cond_prev; - me->cond_waiting = FALSE; - - LeaveCriticalSection(&crit); - - mutex->lock(); - return 0; - } - - // - // We timed out but another thread still signalled us. Wait for - // the semaphore (it _must_ have been signalled) to decrement it - // again. Return that we were signalled, not that we timed out. - // - - LeaveCriticalSection(&crit); - - result = WaitForSingleObject(me->cond_semaphore, INFINITE); - } - - if (result != WAIT_OBJECT_0) - throw omni_thread_fatal(GetLastError()); - - mutex->lock(); - return 1; -} - - -void -omni_condition::signal(void) -{ - EnterCriticalSection(&crit); - - if (waiting_head != NULL) { - omni_thread* t = waiting_head; - waiting_head = t->cond_next; - if (waiting_head == NULL) - waiting_tail = NULL; - else - waiting_head->cond_prev = NULL; - t->cond_waiting = FALSE; - - if (!ReleaseSemaphore(t->cond_semaphore, 1, NULL)) { - int rc = GetLastError(); - LeaveCriticalSection(&crit); - throw omni_thread_fatal(rc); - } - } - - LeaveCriticalSection(&crit); -} - - -void -omni_condition::broadcast(void) -{ - EnterCriticalSection(&crit); - - while (waiting_head != NULL) { - omni_thread* t = waiting_head; - waiting_head = t->cond_next; - if (waiting_head == NULL) - waiting_tail = NULL; - else - waiting_head->cond_prev = NULL; - t->cond_waiting = FALSE; - - if (!ReleaseSemaphore(t->cond_semaphore, 1, NULL)) { - int rc = GetLastError(); - LeaveCriticalSection(&crit); - throw omni_thread_fatal(rc); - } - } - - LeaveCriticalSection(&crit); -} - - - -/////////////////////////////////////////////////////////////////////////// -// -// Counting semaphore -// -/////////////////////////////////////////////////////////////////////////// - - -#define SEMAPHORE_MAX 0x7fffffff - - -omni_semaphore::omni_semaphore(unsigned int initial, unsigned int max_count) -{ - if (max_count > SEMAPHORE_MAX) - max_count= SEMAPHORE_MAX; - - nt_sem = CreateSemaphore(NULL, initial, max_count, NULL); - - if (nt_sem == NULL) { - DB( cerr << "omni_semaphore::omni_semaphore: CreateSemaphore error " - << GetLastError() << endl ); - throw omni_thread_fatal(GetLastError()); - } -} - - -omni_semaphore::~omni_semaphore(void) -{ - if (!CloseHandle(nt_sem)) { - DB( cerr << "omni_semaphore::~omni_semaphore: CloseHandle error " - << GetLastError() << endl ); - throw omni_thread_fatal(GetLastError()); - } -} - - -void -omni_semaphore::wait(void) -{ - if (WaitForSingleObject(nt_sem, INFINITE) != WAIT_OBJECT_0) - throw omni_thread_fatal(GetLastError()); -} - - -int -omni_semaphore::trywait(void) -{ - switch (WaitForSingleObject(nt_sem, 0)) { - - case WAIT_OBJECT_0: - return 1; - case WAIT_TIMEOUT: - return 0; - } - - throw omni_thread_fatal(GetLastError()); - return 0; /* keep msvc++ happy */ -} - - -void -omni_semaphore::post(void) -{ - if (!ReleaseSemaphore(nt_sem, 1, NULL) - && GetLastError() != ERROR_TOO_MANY_POSTS ) // MinGW fix--see ticket:95 in trac - throw omni_thread_fatal(GetLastError()); -} - - - -/////////////////////////////////////////////////////////////////////////// -// -// Thread -// -/////////////////////////////////////////////////////////////////////////// - - -// -// Static variables -// - -omni_mutex* omni_thread::next_id_mutex; -int omni_thread::next_id = 0; -static DWORD self_tls_index; - -static unsigned int stack_size = 0; - -// -// Initialisation function (gets called before any user code). -// - -static int& count() { - static int the_count = 0; - return the_count; -} - -omni_thread::init_t::init_t(void) -{ - if (count()++ != 0) // only do it once however many objects get created. - return; - - DB(cerr << "omni_thread::init: NT implementation initialising\n"); - - self_tls_index = TlsAlloc(); - - if (self_tls_index == 0xffffffff) - throw omni_thread_fatal(GetLastError()); - - next_id_mutex = new omni_mutex; - - // - // Create object for this (i.e. initial) thread. - // - - omni_thread* t = new omni_thread; - - t->_state = STATE_RUNNING; - - if (!DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), - GetCurrentProcess(), &t->handle, - 0, FALSE, DUPLICATE_SAME_ACCESS)) - throw omni_thread_fatal(GetLastError()); - - t->nt_id = GetCurrentThreadId(); - - DB(cerr << "initial thread " << t->id() << " NT thread id " << t->nt_id - << endl); - - if (!TlsSetValue(self_tls_index, (LPVOID)t)) - throw omni_thread_fatal(GetLastError()); - - if (!SetThreadPriority(t->handle, nt_priority(PRIORITY_NORMAL))) - throw omni_thread_fatal(GetLastError()); -} - -omni_thread::init_t::~init_t(void) -{ - if (--count() != 0) return; - - omni_thread* self = omni_thread::self(); - if (!self) return; - - TlsSetValue(self_tls_index, (LPVOID)0); - delete self; - - delete next_id_mutex; - - TlsFree(self_tls_index); -} - -// -// Wrapper for thread creation. -// - -extern "C" -#ifndef __BCPLUSPLUS__ -unsigned __stdcall -#else -void _USERENTRY -#endif -omni_thread_wrapper(void* ptr) -{ - omni_thread* me = (omni_thread*)ptr; - - DB(cerr << "omni_thread_wrapper: thread " << me->id() - << " started\n"); - - if (!TlsSetValue(self_tls_index, (LPVOID)me)) - throw omni_thread_fatal(GetLastError()); - - // - // Now invoke the thread function with the given argument. - // - - if (me->fn_void != NULL) { - (*me->fn_void)(me->thread_arg); - omni_thread::exit(); - } - - if (me->fn_ret != NULL) { - void* return_value = (*me->fn_ret)(me->thread_arg); - omni_thread::exit(return_value); - } - - if (me->detached) { - me->run(me->thread_arg); - omni_thread::exit(); - } else { - void* return_value = me->run_undetached(me->thread_arg); - omni_thread::exit(return_value); - } - - // should never get here. -#ifndef __BCPLUSPLUS__ - return 0; -#endif -} - - -// -// Constructors for omni_thread - set up the thread object but don't -// start it running. -// - -// construct a detached thread running a given function. - -omni_thread::omni_thread(void (*fn)(void*), void* arg, priority_t pri) -{ - common_constructor(arg, pri, 1); - fn_void = fn; - fn_ret = NULL; -} - -// construct an undetached thread running a given function. - -omni_thread::omni_thread(void* (*fn)(void*), void* arg, priority_t pri) -{ - common_constructor(arg, pri, 0); - fn_void = NULL; - fn_ret = fn; -} - -// construct a thread which will run either run() or run_undetached(). - -omni_thread::omni_thread(void* arg, priority_t pri) -{ - common_constructor(arg, pri, 1); - fn_void = NULL; - fn_ret = NULL; -} - -// common part of all constructors. - -void -omni_thread::common_constructor(void* arg, priority_t pri, int det) -{ - _state = STATE_NEW; - _priority = pri; - - next_id_mutex->lock(); - _id = next_id++; - next_id_mutex->unlock(); - - thread_arg = arg; - detached = det; // may be altered in start_undetached() - - cond_semaphore = CreateSemaphore(NULL, 0, SEMAPHORE_MAX, NULL); - - if (cond_semaphore == NULL) - throw omni_thread_fatal(GetLastError()); - - cond_next = cond_prev = NULL; - cond_waiting = FALSE; - - handle = NULL; - - _dummy = 0; - _values = 0; - _value_alloc = 0; -} - - -// -// Destructor for omni_thread. -// - -omni_thread::~omni_thread(void) -{ - DB(cerr << "destructor called for thread " << id() << endl); - if (_values) { - for (key_t i=0; i < _value_alloc; i++) { - if (_values[i]) { - delete _values[i]; - } - } - delete [] _values; - } - if (handle && !CloseHandle(handle)) - throw omni_thread_fatal(GetLastError()); - if (cond_semaphore && !CloseHandle(cond_semaphore)) - throw omni_thread_fatal(GetLastError()); -} - - -// -// Start the thread -// - -void -omni_thread::start(void) -{ - omni_mutex_lock l(mutex); - - if (_state != STATE_NEW) - throw omni_thread_invalid(); - -#ifndef __BCPLUSPLUS__ - // MSVC++ or compatiable - unsigned int t; - handle = (HANDLE)_beginthreadex( - NULL, - stack_size, - omni_thread_wrapper, - (LPVOID)this, - CREATE_SUSPENDED, - &t); - nt_id = t; - if (handle == NULL) - throw omni_thread_fatal(GetLastError()); -#else - // Borland C++ - handle = (HANDLE)_beginthreadNT(omni_thread_wrapper, - stack_size, - (void*)this, - NULL, - CREATE_SUSPENDED, - &nt_id); - if (handle == INVALID_HANDLE_VALUE) - throw omni_thread_fatal(errno); -#endif - - if (!SetThreadPriority(handle, nt_priority(_priority))) - throw omni_thread_fatal(GetLastError()); - - if (ResumeThread(handle) == 0xffffffff) - throw omni_thread_fatal(GetLastError()); - - _state = STATE_RUNNING; -} - - -// -// Start a thread which will run the member function run_undetached(). -// - -void -omni_thread::start_undetached(void) -{ - if ((fn_void != NULL) || (fn_ret != NULL)) - throw omni_thread_invalid(); - - detached = 0; - start(); -} - - -// -// join - simply check error conditions & call WaitForSingleObject. -// - -void -omni_thread::join(void** status) -{ - mutex.lock(); - - if ((_state != STATE_RUNNING) && (_state != STATE_TERMINATED)) { - mutex.unlock(); - throw omni_thread_invalid(); - } - - mutex.unlock(); - - if (this == self()) - throw omni_thread_invalid(); - - if (detached) - throw omni_thread_invalid(); - - DB(cerr << "omni_thread::join: doing WaitForSingleObject\n"); - - if (WaitForSingleObject(handle, INFINITE) != WAIT_OBJECT_0) - throw omni_thread_fatal(GetLastError()); - - DB(cerr << "omni_thread::join: WaitForSingleObject succeeded\n"); - - if (status) - *status = return_val; - - delete this; -} - - -// -// Change this thread's priority. -// - -void -omni_thread::set_priority(priority_t pri) -{ - omni_mutex_lock l(mutex); - - if (_state != STATE_RUNNING) - throw omni_thread_invalid(); - - _priority = pri; - - if (!SetThreadPriority(handle, nt_priority(pri))) - throw omni_thread_fatal(GetLastError()); -} - - -// -// create - construct a new thread object and start it running. Returns thread -// object if successful, null pointer if not. -// - -// detached version - -omni_thread* -omni_thread::create(void (*fn)(void*), void* arg, priority_t pri) -{ - omni_thread* t = new omni_thread(fn, arg, pri); - t->start(); - return t; -} - -// undetached version - -omni_thread* -omni_thread::create(void* (*fn)(void*), void* arg, priority_t pri) -{ - omni_thread* t = new omni_thread(fn, arg, pri); - t->start(); - return t; -} - - -// -// exit() _must_ lock the mutex even in the case of a detached thread. This is -// because a thread may run to completion before the thread that created it has -// had a chance to get out of start(). By locking the mutex we ensure that the -// creating thread must have reached the end of start() before we delete the -// thread object. Of course, once the call to start() returns, the user can -// still incorrectly refer to the thread object, but that's their problem. -// - -void -omni_thread::exit(void* return_value) -{ - omni_thread* me = self(); - - if (me) - { - me->mutex.lock(); - - me->_state = STATE_TERMINATED; - - me->mutex.unlock(); - - DB(cerr << "omni_thread::exit: thread " << me->id() << " detached " - << me->detached << " return value " << return_value << endl); - - if (me->detached) { - delete me; - } else { - me->return_val = return_value; - } - } - else - { - DB(cerr << "omni_thread::exit: called with a non-omnithread. Exit quietly." << endl); - } -#ifndef __BCPLUSPLUS__ - // MSVC++ or compatiable - // _endthreadex() does not automatically closes the thread handle. - // The omni_thread dtor closes the thread handle. - _endthreadex(0); -#else - // Borland C++ - // _endthread() does not automatically closes the thread handle. - // _endthreadex() is only available if __MFC_COMPAT__ is defined and - // all it does is to call _endthread(). - _endthread(); -#endif -} - - -omni_thread* -omni_thread::self(void) -{ - LPVOID me; - - me = TlsGetValue(self_tls_index); - - if (me == NULL) { - DB(cerr << "omni_thread::self: called with a non-ominthread. NULL is returned." << endl); - } - return (omni_thread*)me; -} - - -void -omni_thread::yield(void) -{ - Sleep(0); -} - - -#define MAX_SLEEP_SECONDS (DWORD)4294966 // (2**32-2)/1000 - -void -omni_thread::sleep(unsigned long secs, unsigned long nanosecs) -{ - if (secs <= MAX_SLEEP_SECONDS) { - Sleep(secs * 1000 + nanosecs / 1000000); - return; - } - - DWORD no_of_max_sleeps = secs / MAX_SLEEP_SECONDS; - - for (DWORD i = 0; i < no_of_max_sleeps; i++) - Sleep(MAX_SLEEP_SECONDS * 1000); - - Sleep((secs % MAX_SLEEP_SECONDS) * 1000 + nanosecs / 1000000); -} - - -void -omni_thread::get_time(unsigned long* abs_sec, unsigned long* abs_nsec, - unsigned long rel_sec, unsigned long rel_nsec) -{ - get_time_now(abs_sec, abs_nsec); - *abs_nsec += rel_nsec; - *abs_sec += rel_sec + *abs_nsec / 1000000000; - *abs_nsec = *abs_nsec % 1000000000; -} - - -int -omni_thread::nt_priority(priority_t pri) -{ - switch (pri) { - - case PRIORITY_LOW: - return THREAD_PRIORITY_LOWEST; - - case PRIORITY_NORMAL: - return THREAD_PRIORITY_NORMAL; - - case PRIORITY_HIGH: - return THREAD_PRIORITY_HIGHEST; - } - - throw omni_thread_invalid(); - return 0; /* keep msvc++ happy */ -} - - -static void -get_time_now(unsigned long* abs_sec, unsigned long* abs_nsec) -{ - static int days_in_preceding_months[12] - = { 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 }; - static int days_in_preceding_months_leap[12] - = { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335 }; - - SYSTEMTIME st; - - GetSystemTime(&st); - *abs_nsec = st.wMilliseconds * 1000000; - - // this formula should work until 1st March 2100 - - DWORD days = ((st.wYear - 1970) * 365 + (st.wYear - 1969) / 4 - + ((st.wYear % 4) - ? days_in_preceding_months[st.wMonth - 1] - : days_in_preceding_months_leap[st.wMonth - 1]) - + st.wDay - 1); - - *abs_sec = st.wSecond + 60 * (st.wMinute + 60 * (st.wHour + 24 * days)); -} - -void -omni_thread::stacksize(unsigned long sz) -{ - stack_size = sz; -} - -unsigned long -omni_thread::stacksize() -{ - return stack_size; -} - -// -// Dummy thread -// - -class omni_thread_dummy : public omni_thread { -public: - inline omni_thread_dummy() : omni_thread() - { - _dummy = 1; - _state = STATE_RUNNING; - - if (!DuplicateHandle(GetCurrentProcess(), GetCurrentThread(), - GetCurrentProcess(), &handle, - 0, FALSE, DUPLICATE_SAME_ACCESS)) - throw omni_thread_fatal(GetLastError()); - - nt_id = GetCurrentThreadId(); - - if (!TlsSetValue(self_tls_index, (LPVOID)this)) - throw omni_thread_fatal(GetLastError()); - } - inline ~omni_thread_dummy() - { - if (!TlsSetValue(self_tls_index, (LPVOID)0)) - throw omni_thread_fatal(GetLastError()); - } -}; - -omni_thread* -omni_thread::create_dummy() -{ - if (omni_thread::self()) - throw omni_thread_invalid(); - - return new omni_thread_dummy; -} - -void -omni_thread::release_dummy() -{ - omni_thread* self = omni_thread::self(); - if (!self || !self->_dummy) - throw omni_thread_invalid(); - - omni_thread_dummy* dummy = (omni_thread_dummy*)self; - delete dummy; -} - - -#if defined(__DMC__) && defined(_WINDLL) -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - return TRUE; -} -#endif - - -#define INSIDE_THREAD_IMPL_CC -#include "threaddata.cc" -#undef INSIDE_THREAD_IMPL_CC diff --git a/omnithread/omni_time.cc b/omnithread/omni_time.cc deleted file mode 100644 index 4920a6839..000000000 --- a/omnithread/omni_time.cc +++ /dev/null @@ -1,84 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <gnuradio/omni_time.h> -#include <gnuradio/omnithread.h> -#include <math.h> -#include <assert.h> - - -omni_time::omni_time(double real_secs) -{ - double floor_secs = floor(real_secs); - d_secs = (long) floor_secs; - d_nsecs = (long) ((real_secs - floor_secs) * 1e9); // always positive -} - -omni_time -omni_time::time(const omni_time &delta_t) -{ - unsigned long abs_sec, abs_nsec; - unsigned long rel_sec = delta_t.d_secs; - unsigned long rel_nsec = delta_t.d_nsecs; - - omni_thread::get_time(&abs_sec, &abs_nsec, rel_sec, rel_nsec); - return omni_time(abs_sec, abs_nsec); -} - - -omni_time -operator+(const omni_time &x, const omni_time &y) -{ - omni_time r(x.d_secs + y.d_secs, x.d_nsecs + y.d_nsecs); - while (r.d_nsecs >= 1000000000){ - r.d_nsecs -= 1000000000; - r.d_secs++; - } - return r; -} - -omni_time -operator-(const omni_time &x, const omni_time &y) -{ - // assert(!(x < y)); - - omni_time r(x.d_secs - y.d_secs, x.d_nsecs - y.d_nsecs); - while (r.d_nsecs < 0){ - r.d_nsecs += 1000000000; - r.d_secs--; - } - return r; -} - -omni_time -operator+(const omni_time &x, double y) -{ - return x + omni_time(y); -} - -omni_time -operator-(const omni_time &x, double y) -{ - return x - omni_time(y); -} diff --git a/omnithread/posix.cc b/omnithread/posix.cc deleted file mode 100644 index 5574a8a0d..000000000 --- a/omnithread/posix.cc +++ /dev/null @@ -1,982 +0,0 @@ -// Package : omnithread -// omnithread/posix.cc Created : 7/94 tjr -// -// Copyright (C) 2006 Free Software Foundation, Inc. -// Copyright (C) 1994-1999 AT&T Laboratories Cambridge -// -// This file is part of the omnithread library -// -// The omnithread library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Boston, MA -// 02110-1301, USA -// - -// -// Implementation of OMNI thread abstraction for posix threads -// -// The source below tests for the definition of the macros: -// PthreadDraftVersion -// PthreadSupportThreadPriority -// NoNanoSleep -// NeedPthreadInit -// -// As different draft versions of the pthread standard P1003.4a/P1003.1c -// define slightly different APIs, the macro 'PthreadDraftVersion' -// identifies the draft version supported by this particular platform. -// -// Some unix variants do not support thread priority unless a real-time -// kernel option is installed. The macro 'PthreadSupportThreadPriority', -// if defined, enables the use of thread priority. If it is not defined, -// setting or changing thread priority will be silently ignored. -// -// nanosleep() is defined in Posix P1003.4 since Draft 9 (?). -// Not all platforms support this standard. The macro 'NoNanoSleep' -// identifies platform that don't. -// - -#include <config.h> -#include <stdlib.h> -#include <errno.h> -#include <time.h> -#include <gnuradio/omnithread.h> - -#if (PthreadDraftVersion == 0) -#error "PthreadDraftVersion not defined. If not sure, define it to 10" -#endif - -#ifdef HAVE_NANOSLEEP -#undef NoNanoSleep -#else -#define NoNanoSleep -#endif - -#ifdef HAVE_SYS_TIME_H -// typedef of struct timeval and gettimeofday(); -#include <sys/time.h> -#include <unistd.h> -#endif - -#if defined(__linux__) && defined(_MIT_POSIX_THREADS) -#include <pthread/mit/sys/timers.h> -#endif - -#if defined(__irix__) && defined(PthreadSupportThreadPriority) -#if _POSIX_THREAD_PRIORITY_SCHEDULING -#include <sched.h> -#endif -#endif - -#if 1 -#define DB(x) // x -#else -#define DB(x) x -#include <iostream> -using std::cerr; -using std::endl; -#endif - -#if (PthreadDraftVersion <= 6) -#define ERRNO(x) (((x) != 0) ? (errno) : 0) -#ifdef __VMS -// pthread_setprio returns old priority on success (draft version 4: -// OpenVms version < 7) -#define THROW_ERRORS(x) { if ((x) == -1) throw omni_thread_fatal(errno); } -#else -#define THROW_ERRORS(x) { if ((x) != 0) throw omni_thread_fatal(errno); } -#endif -#else -#define ERRNO(x) (x) -#define THROW_ERRORS(x) { int rc = (x); \ - if (rc != 0) throw omni_thread_fatal(rc); } -#endif - - - -/////////////////////////////////////////////////////////////////////////// -// -// Mutex -// -/////////////////////////////////////////////////////////////////////////// - - -omni_mutex::omni_mutex(void) -{ -#if (PthreadDraftVersion == 4) - THROW_ERRORS(pthread_mutex_init(&posix_mutex, pthread_mutexattr_default)); -#else - THROW_ERRORS(pthread_mutex_init(&posix_mutex, 0)); -#endif -} - -omni_mutex::~omni_mutex(void) -{ - THROW_ERRORS(pthread_mutex_destroy(&posix_mutex)); -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Condition variable -// -/////////////////////////////////////////////////////////////////////////// - - -omni_condition::omni_condition(omni_mutex* m) : mutex(m) -{ -#if (PthreadDraftVersion == 4) - THROW_ERRORS(pthread_cond_init(&posix_cond, pthread_condattr_default)); -#else - THROW_ERRORS(pthread_cond_init(&posix_cond, 0)); -#endif -} - -omni_condition::~omni_condition(void) -{ - THROW_ERRORS(pthread_cond_destroy(&posix_cond)); -} - -void -omni_condition::wait(void) -{ - THROW_ERRORS(pthread_cond_wait(&posix_cond, &mutex->posix_mutex)); -} - -int -omni_condition::timedwait(unsigned long secs, unsigned long nanosecs) -{ - timespec rqts = { secs, nanosecs }; - -again: - int rc = ERRNO(pthread_cond_timedwait(&posix_cond, - &mutex->posix_mutex, &rqts)); - if (rc == 0) - return 1; - -#if (PthreadDraftVersion <= 6) - if (rc == EAGAIN) - return 0; -#endif - - // Some versions of unix produces this errno when the wait was - // interrupted by a unix signal or fork. - // Some versions of the glibc 2.0.x produces this errno when the - // program is debugged under gdb. Straightly speaking this is non-posix - // compliant. We catch this here to make debugging possible. - if (rc == EINTR) - goto again; - - if (rc == ETIMEDOUT) - return 0; - - throw omni_thread_fatal(rc); -#ifdef _MSC_VER - return 0; -#endif -} - -void -omni_condition::signal(void) -{ - THROW_ERRORS(pthread_cond_signal(&posix_cond)); -} - -void -omni_condition::broadcast(void) -{ - THROW_ERRORS(pthread_cond_broadcast(&posix_cond)); -} - - - -/////////////////////////////////////////////////////////////////////////// -// -// Counting (or binary) semaphore -// -/////////////////////////////////////////////////////////////////////////// - - -omni_semaphore::omni_semaphore(unsigned int initial, unsigned int _max_count) : c(&m) -{ - value = initial; - max_count = _max_count; - if (value < 0 || max_count < 1) - throw omni_thread_fatal(0); -} - -omni_semaphore::~omni_semaphore(void) -{ -} - -void -omni_semaphore::wait(void) -{ - omni_mutex_lock l(m); - - while (value == 0) - c.wait(); - - value--; -} - -int -omni_semaphore::trywait(void) -{ - omni_mutex_lock l(m); - - if (value == 0) - return 0; - - value--; - return 1; -} - -void -omni_semaphore::post(void) -{ - { - omni_mutex_lock l(m); - if (value < max_count) - value++; - } - - c.signal(); -} - - - -/////////////////////////////////////////////////////////////////////////// -// -// Thread -// -/////////////////////////////////////////////////////////////////////////// - - -// -// static variables -// - -omni_mutex* omni_thread::next_id_mutex; -int omni_thread::next_id = 0; - -static pthread_key_t self_key; - -#ifdef PthreadSupportThreadPriority -static int lowest_priority; -static int normal_priority; -static int highest_priority; -#endif - -#if defined(__osf1__) && defined(__alpha__) || defined(__VMS) -// omniORB requires a larger stack size than the default (21120) on OSF/1 -static size_t stack_size = 32768; -#elif defined(__rtems__) -static size_t stack_size = ThreadStackSize; -#elif defined(__aix__) -static size_t stack_size = 262144; -#else -static size_t stack_size = 0; -#endif - -// -// Initialisation function (gets called before any user code). -// - -static int& count() { - static int the_count = 0; - return the_count; -} - -omni_thread::init_t::init_t(void) -{ - if (count()++ != 0) // only do it once however many objects get created. - return; - - DB(cerr << "omni_thread::init: posix 1003.4a/1003.1c (draft " - << PthreadDraftVersion << ") implementation initialising\n"); - -#ifdef NeedPthreadInit - - pthread_init(); - -#endif - -#if (PthreadDraftVersion == 4) - THROW_ERRORS(pthread_keycreate(&self_key, NULL)); -#else - THROW_ERRORS(pthread_key_create(&self_key, NULL)); -#endif - -#ifdef PthreadSupportThreadPriority - -#if defined(__osf1__) && defined(__alpha__) || defined(__VMS) - - lowest_priority = PRI_OTHER_MIN; - highest_priority = PRI_OTHER_MAX; - -#elif defined(__hpux__) - - lowest_priority = PRI_OTHER_MIN; - highest_priority = PRI_OTHER_MAX; - -#elif defined(__sunos__) && (__OSVERSION__ == 5) - - // a bug in pthread_attr_setschedparam means lowest priority is 1 not 0 - - lowest_priority = 1; - highest_priority = 3; - -#else - - lowest_priority = sched_get_priority_min(SCHED_FIFO); - highest_priority = sched_get_priority_max(SCHED_FIFO); - -#endif - - switch (highest_priority - lowest_priority) { - - case 0: - case 1: - normal_priority = lowest_priority; - break; - - default: - normal_priority = lowest_priority + 1; - break; - } - -#endif /* PthreadSupportThreadPriority */ - - next_id_mutex = new omni_mutex; - - // - // Create object for this (i.e. initial) thread. - // - - omni_thread* t = new omni_thread; - - t->_state = STATE_RUNNING; - - t->posix_thread = pthread_self (); - - DB(cerr << "initial thread " << t->id() << endl); - - THROW_ERRORS(pthread_setspecific(self_key, (void*)t)); - -#ifdef PthreadSupportThreadPriority - -#if (PthreadDraftVersion == 4) - - THROW_ERRORS(pthread_setprio(t->posix_thread, - posix_priority(PRIORITY_NORMAL))); - -#elif (PthreadDraftVersion == 6) - - pthread_attr_t attr; - pthread_attr_init(&attr); - - THROW_ERRORS(pthread_attr_setprio(&attr, posix_priority(PRIORITY_NORMAL))); - - THROW_ERRORS(pthread_setschedattr(t->posix_thread, attr)); - -#else - - struct sched_param sparam; - - sparam.sched_priority = posix_priority(PRIORITY_NORMAL); - - THROW_ERRORS(pthread_setschedparam(t->posix_thread, SCHED_OTHER, &sparam)); - -#endif /* PthreadDraftVersion */ - -#endif /* PthreadSupportThreadPriority */ -} - -omni_thread::init_t::~init_t(void) -{ - if (--count() != 0) return; - - omni_thread* self = omni_thread::self(); - if (!self) return; - - pthread_setspecific(self_key, 0); - delete self; - - delete next_id_mutex; -} - -// -// Wrapper for thread creation. -// - -extern "C" void* -omni_thread_wrapper(void* ptr) -{ - omni_thread* me = (omni_thread*)ptr; - - DB(cerr << "omni_thread_wrapper: thread " << me->id() - << " started\n"); - - THROW_ERRORS(pthread_setspecific(self_key, me)); - - // - // Now invoke the thread function with the given argument. - // - - if (me->fn_void != NULL) { - (*me->fn_void)(me->thread_arg); - omni_thread::exit(); - } - - if (me->fn_ret != NULL) { - void* return_value = (*me->fn_ret)(me->thread_arg); - omni_thread::exit(return_value); - } - - if (me->detached) { - me->run(me->thread_arg); - omni_thread::exit(); - } else { - void* return_value = me->run_undetached(me->thread_arg); - omni_thread::exit(return_value); - } - - // should never get here. - - return NULL; -} - - -// -// Constructors for omni_thread - set up the thread object but don't -// start it running. -// - -// construct a detached thread running a given function. - -omni_thread::omni_thread(void (*fn)(void*), void* arg, priority_t pri) -{ - common_constructor(arg, pri, 1); - fn_void = fn; - fn_ret = NULL; -} - -// construct an undetached thread running a given function. - -omni_thread::omni_thread(void* (*fn)(void*), void* arg, priority_t pri) -{ - common_constructor(arg, pri, 0); - fn_void = NULL; - fn_ret = fn; -} - -// construct a thread which will run either run() or run_undetached(). - -omni_thread::omni_thread(void* arg, priority_t pri) -{ - common_constructor(arg, pri, 1); - fn_void = NULL; - fn_ret = NULL; -} - -// common part of all constructors. - -void -omni_thread::common_constructor(void* arg, priority_t pri, int det) -{ - _state = STATE_NEW; - _priority = pri; - - next_id_mutex->lock(); - _id = next_id++; - next_id_mutex->unlock(); - - thread_arg = arg; - detached = det; // may be altered in start_undetached() - - _dummy = 0; - _values = 0; - _value_alloc = 0; - // posix_thread is set up in initialisation routine or start(). -} - - -// -// Destructor for omni_thread. -// - -omni_thread::~omni_thread(void) -{ - DB(cerr << "destructor called for thread " << id() << endl); - if (_values) { - for (key_t i=0; i < _value_alloc; i++) { - if (_values[i]) { - delete _values[i]; - } - } - delete [] _values; - } -} - - -// -// Start the thread -// - -void -omni_thread::start(void) -{ - omni_mutex_lock l(mutex); - - if (_state != STATE_NEW) - throw omni_thread_invalid(); - - pthread_attr_t attr; - -#if (PthreadDraftVersion == 4) - pthread_attr_create(&attr); -#else - pthread_attr_init(&attr); -#endif - -#if (PthreadDraftVersion == 8) - pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_UNDETACHED); -#endif - -#ifdef PthreadSupportThreadPriority - -#if (PthreadDraftVersion <= 6) - - THROW_ERRORS(pthread_attr_setprio(&attr, posix_priority(_priority))); - -#else - - struct sched_param sparam; - - sparam.sched_priority = posix_priority(_priority); - - THROW_ERRORS(pthread_attr_setschedparam(&attr, &sparam)); - -#endif /* PthreadDraftVersion */ - -#endif /* PthreadSupportThreadPriority */ - -#if !defined(__linux__) - if (stack_size) { - THROW_ERRORS(pthread_attr_setstacksize(&attr, stack_size)); - } -#endif - - -#if (PthreadDraftVersion == 4) - THROW_ERRORS(pthread_create(&posix_thread, attr, omni_thread_wrapper, - (void*)this)); - pthread_attr_delete(&attr); -#else - THROW_ERRORS(pthread_create(&posix_thread, &attr, omni_thread_wrapper, - (void*)this)); - pthread_attr_destroy(&attr); -#endif - - _state = STATE_RUNNING; - - if (detached) { - -#if (PthreadDraftVersion <= 6) - THROW_ERRORS(pthread_detach(&posix_thread)); -#else - THROW_ERRORS(pthread_detach(posix_thread)); -#endif - } -} - - -// -// Start a thread which will run the member function run_undetached(). -// - -void -omni_thread::start_undetached(void) -{ - if ((fn_void != NULL) || (fn_ret != NULL)) - throw omni_thread_invalid(); - - detached = 0; - start(); -} - - -// -// join - simply check error conditions & call pthread_join. -// - -void -omni_thread::join(void** status) -{ - mutex.lock(); - - if ((_state != STATE_RUNNING) && (_state != STATE_TERMINATED)) { - mutex.unlock(); - throw omni_thread_invalid(); - } - - mutex.unlock(); - - if (this == self()) - throw omni_thread_invalid(); - - if (detached) - throw omni_thread_invalid(); - - DB(cerr << "omni_thread::join: doing pthread_join\n"); - - THROW_ERRORS(pthread_join(posix_thread, status)); - - DB(cerr << "omni_thread::join: pthread_join succeeded\n"); - -#if (PthreadDraftVersion == 4) - // With draft 4 pthreads implementations (HPUX 10.x and - // Digital Unix 3.2), have to detach the thread after - // join. If not, the storage for the thread will not be - // be reclaimed. - THROW_ERRORS(pthread_detach(&posix_thread)); -#endif - - delete this; -} - - -// -// Change this thread's priority. -// - -void -omni_thread::set_priority(priority_t pri) -{ - omni_mutex_lock l(mutex); - - if (_state != STATE_RUNNING) - throw omni_thread_invalid(); - - _priority = pri; - -#ifdef PthreadSupportThreadPriority - -#if (PthreadDraftVersion == 4) - - THROW_ERRORS(pthread_setprio(posix_thread, posix_priority(pri))); - -#elif (PthreadDraftVersion == 6) - - pthread_attr_t attr; - pthread_attr_init(&attr); - - THROW_ERRORS(pthread_attr_setprio(&attr, posix_priority(pri))); - - THROW_ERRORS(pthread_setschedattr(posix_thread, attr)); - -#else - - struct sched_param sparam; - - sparam.sched_priority = posix_priority(pri); - - THROW_ERRORS(pthread_setschedparam(posix_thread, SCHED_OTHER, &sparam)); - -#endif /* PthreadDraftVersion */ - -#endif /* PthreadSupportThreadPriority */ -} - - -// -// create - construct a new thread object and start it running. Returns thread -// object if successful, null pointer if not. -// - -// detached version - -omni_thread* -omni_thread::create(void (*fn)(void*), void* arg, priority_t pri) -{ - omni_thread* t = new omni_thread(fn, arg, pri); - - t->start(); - - return t; -} - -// undetached version - -omni_thread* -omni_thread::create(void* (*fn)(void*), void* arg, priority_t pri) -{ - omni_thread* t = new omni_thread(fn, arg, pri); - - t->start(); - - return t; -} - - -// -// exit() _must_ lock the mutex even in the case of a detached thread. This is -// because a thread may run to completion before the thread that created it has -// had a chance to get out of start(). By locking the mutex we ensure that the -// creating thread must have reached the end of start() before we delete the -// thread object. Of course, once the call to start() returns, the user can -// still incorrectly refer to the thread object, but that's their problem. -// - -void -omni_thread::exit(void* return_value) -{ - omni_thread* me = self(); - - if (me) - { - me->mutex.lock(); - - me->_state = STATE_TERMINATED; - - me->mutex.unlock(); - - DB(cerr << "omni_thread::exit: thread " << me->id() << " detached " - << me->detached << " return value " << return_value << endl); - - if (me->detached) - delete me; - } - else - { - DB(cerr << "omni_thread::exit: called with a non-omnithread. Exit quietly." << endl); - } - - pthread_exit(return_value); -} - - -omni_thread* -omni_thread::self(void) -{ - omni_thread* me; - -#if (PthreadDraftVersion <= 6) - - THROW_ERRORS(pthread_getspecific(self_key, (void**)&me)); - -#else - - me = (omni_thread *)pthread_getspecific(self_key); - -#endif - - if (!me) { - // This thread is not created by omni_thread::start because it - // doesn't has a class omni_thread instance attached to its key. - DB(cerr << "omni_thread::self: called with a non-omnithread. NULL is returned." << endl); - } - - return me; -} - - -void -omni_thread::yield(void) -{ -#if (PthreadDraftVersion == 6) - - pthread_yield(NULL); - -#elif (PthreadDraftVersion < 9) - - pthread_yield(); - -#else - - THROW_ERRORS(sched_yield()); - -#endif -} - - -void -omni_thread::sleep(unsigned long secs, unsigned long nanosecs) -{ - timespec rqts = { secs, nanosecs }; - -#ifndef NoNanoSleep - - timespec remain; - while (nanosleep(&rqts, &remain)) { - if (errno == EINTR) { - rqts.tv_sec = remain.tv_sec; - rqts.tv_nsec = remain.tv_nsec; - continue; - } - else - throw omni_thread_fatal(errno); - } -#else - -#if defined(__osf1__) && defined(__alpha__) || defined(__hpux__) && (__OSVERSION__ == 10) || defined(__VMS) || defined(__SINIX__) || defined (__POSIX_NT__) - - if (pthread_delay_np(&rqts) != 0) - throw omni_thread_fatal(errno); - -#elif defined(__linux__) || defined(__aix__) - - if (secs > 2000) { - while ((secs = ::sleep(secs))) ; - } else { - usleep(secs * 1000000 + (nanosecs / 1000)); - } - -#elif defined(__darwin__) || defined(__macos__) - - // Single UNIX Specification says argument of usleep() must be - // less than 1,000,000. - secs += nanosecs / 1000000000; - nanosecs %= 1000000000; - while ((secs = ::sleep(secs))) ; - usleep(nanosecs / 1000); - -#else - - throw omni_thread_invalid(); - -#endif -#endif /* NoNanoSleep */ -} - - -void -omni_thread::get_time(unsigned long* abs_sec, unsigned long* abs_nsec, - unsigned long rel_sec, unsigned long rel_nsec) -{ - timespec abs; - -#if defined(__osf1__) && defined(__alpha__) || defined(__hpux__) && (__OSVERSION__ == 10) || defined(__VMS) || defined(__SINIX__) || defined(__POSIX_NT__) - - timespec rel; - rel.tv_sec = rel_sec; - rel.tv_nsec = rel_nsec; - THROW_ERRORS(pthread_get_expiration_np(&rel, &abs)); - -#else - -#ifdef HAVE_CLOCK_GETTIME /* __linux__ || __aix__ */ - - clock_gettime(CLOCK_REALTIME, &abs); - -#elif defined(HAVE_GETTIMEOFDAY) /* defined(__linux__) || defined(__aix__) || defined(__SCO_VERSION__) || defined(__darwin__) || defined(__macos__) */ - - struct timeval tv; - gettimeofday(&tv, NULL); - abs.tv_sec = tv.tv_sec; - abs.tv_nsec = tv.tv_usec * 1000; - -#else -#error no get time support -#endif /* __linux__ || __aix__ */ - - abs.tv_nsec += rel_nsec; - abs.tv_sec += rel_sec + abs.tv_nsec / 1000000000; - abs.tv_nsec = abs.tv_nsec % 1000000000; - -#endif /* __osf1__ && __alpha__ */ - - *abs_sec = abs.tv_sec; - *abs_nsec = abs.tv_nsec; -} - - -int -omni_thread::posix_priority(priority_t pri) -{ -#ifdef PthreadSupportThreadPriority - switch (pri) { - - case PRIORITY_LOW: - return lowest_priority; - - case PRIORITY_NORMAL: - return normal_priority; - - case PRIORITY_HIGH: - return highest_priority; - - } -#endif - - throw omni_thread_invalid(); -#ifdef _MSC_VER - return 0; -#endif -} - -void -omni_thread::stacksize(unsigned long sz) -{ - stack_size = sz; -} - -unsigned long -omni_thread::stacksize() -{ - return stack_size; -} - -// -// Dummy thread -// - -class omni_thread_dummy : public omni_thread { -public: - inline omni_thread_dummy() : omni_thread() - { - _dummy = 1; - _state = STATE_RUNNING; - posix_thread = pthread_self(); - THROW_ERRORS(pthread_setspecific(self_key, (void*)this)); - } - inline ~omni_thread_dummy() - { - THROW_ERRORS(pthread_setspecific(self_key, 0)); - } -}; - -omni_thread* -omni_thread::create_dummy() -{ - if (omni_thread::self()) - throw omni_thread_invalid(); - - return new omni_thread_dummy; -} - -void -omni_thread::release_dummy() -{ - omni_thread* self = omni_thread::self(); - if (!self || !self->_dummy) - throw omni_thread_invalid(); - - omni_thread_dummy* dummy = (omni_thread_dummy*)self; - delete dummy; -} - - -#define INSIDE_THREAD_IMPL_CC -#include "threaddata.cc" -#undef INSIDE_THREAD_IMPL_CC diff --git a/omnithread/solaris.cc b/omnithread/solaris.cc deleted file mode 100644 index eedaaa99f..000000000 --- a/omnithread/solaris.cc +++ /dev/null @@ -1,615 +0,0 @@ -// Package : omnithread -// omnithread/solaris.cc Created : 7/94 tjr -// -// Copyright (C) 1994-1999 AT&T Laboratories Cambridge -// -// This file is part of the omnithread library -// -// The omnithread library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Boston, MA -// 02110-1301, USA -// -// -// Implementation of OMNI thread abstraction for solaris threads. -// - -#include <stdlib.h> -#include <errno.h> -#include <gnuradio/omnithread.h> - -#define DB(x) // x -// #include <iostream> or #include <iostream.h> if DB is on. - -#define THROW_ERRORS(x) { int rc = (x); \ - if (rc != 0) throw omni_thread_fatal(rc); } - - - -/////////////////////////////////////////////////////////////////////////// -// -// Mutex -// -/////////////////////////////////////////////////////////////////////////// - - -omni_mutex::omni_mutex(void) -{ - THROW_ERRORS(mutex_init(&sol_mutex, USYNC_THREAD, 0)); -} - -omni_mutex::~omni_mutex(void) -{ - THROW_ERRORS(mutex_destroy(&sol_mutex)); -} - -void -omni_mutex::lock(void) -{ - THROW_ERRORS(mutex_lock(&sol_mutex)); -} - -void -omni_mutex::unlock(void) -{ - THROW_ERRORS(mutex_unlock(&sol_mutex)); -} - - - -/////////////////////////////////////////////////////////////////////////// -// -// Condition variable -// -/////////////////////////////////////////////////////////////////////////// - - -omni_condition::omni_condition(omni_mutex* m) : mutex(m) -{ - THROW_ERRORS(cond_init(&sol_cond, USYNC_THREAD, 0)); -} - -omni_condition::~omni_condition(void) -{ - THROW_ERRORS(cond_destroy(&sol_cond)); -} - -void -omni_condition::wait(void) -{ - THROW_ERRORS(cond_wait(&sol_cond, &mutex->sol_mutex)); -} - -int -omni_condition::timedwait(unsigned long secs, unsigned long nanosecs) -{ - timespec rqts = { secs, nanosecs }; - - again: - int rc = cond_timedwait(&sol_cond, &mutex->sol_mutex, &rqts); - - if (rc == 0) - return 1; - - if (rc == EINTR) - goto again; - - if (rc == ETIME) - return 0; - - throw omni_thread_fatal(rc); -} - -void -omni_condition::signal(void) -{ - THROW_ERRORS(cond_signal(&sol_cond)); -} - -void -omni_condition::broadcast(void) -{ - THROW_ERRORS(cond_broadcast(&sol_cond)); -} - - - -/////////////////////////////////////////////////////////////////////////// -// -// Counting semaphore -// -/////////////////////////////////////////////////////////////////////////// - - -omni_semaphore::omni_semaphore(unsigned int initial) -{ - THROW_ERRORS(sema_init(&sol_sem, initial, USYNC_THREAD, NULL)); -} - -omni_semaphore::~omni_semaphore(void) -{ - THROW_ERRORS(sema_destroy(&sol_sem)); -} - -void -omni_semaphore::wait(void) -{ - THROW_ERRORS(sema_wait(&sol_sem)); -} - -void -omni_semaphore::post(void) -{ - THROW_ERRORS(sema_post(&sol_sem)); -} - - - -/////////////////////////////////////////////////////////////////////////// -// -// Thread -// -/////////////////////////////////////////////////////////////////////////// - - -// -// Static variables -// - -int omni_thread::init_t::count = 0; - -omni_mutex* omni_thread::next_id_mutex; -int omni_thread::next_id = 0; - -static thread_key_t self_key; - -static size_t stack_size = 0; - -// -// Initialisation function (gets called before any user code). -// - -omni_thread::init_t::init_t(void) -{ - if (count++ != 0) // only do it once however many objects get created. - return; - - DB(cerr << "omni_thread::init: solaris implementation initialising\n"); - - THROW_ERRORS(thr_keycreate(&self_key, NULL)); - - next_id_mutex = new omni_mutex; - - // - // Create object for this (i.e. initial) thread. - // - - omni_thread* t = new omni_thread; - - t->_state = STATE_RUNNING; - - t->sol_thread = thr_self(); - - DB(cerr << "initial thread " << t->id() << " sol_thread " << t->sol_thread - << endl); - - THROW_ERRORS(thr_setspecific(self_key, (void*)t)); - - THROW_ERRORS(thr_setprio(t->sol_thread, sol_priority(PRIORITY_NORMAL))); -} - - -// -// Wrapper for thread creation. -// - -extern "C" void* -omni_thread_wrapper(void* ptr) -{ - omni_thread* me = (omni_thread*)ptr; - - DB(cerr << "omni_thread::wrapper: thread " << me->id() - << " started\n"); - - THROW_ERRORS(thr_setspecific(self_key, me)); - - // - // Now invoke the thread function with the given argument. - // - - if (me->fn_void != NULL) { - (*me->fn_void)(me->thread_arg); - omni_thread::exit(); - } - - if (me->fn_ret != NULL) { - void* return_value = (*me->fn_ret)(me->thread_arg); - omni_thread::exit(return_value); - } - - if (me->detached) { - me->run(me->thread_arg); - omni_thread::exit(); - } else { - void* return_value = me->run_undetached(me->thread_arg); - omni_thread::exit(return_value); - } - - // should never get here. - - return NULL; -} - - -// -// Constructors for omni_thread - set up the thread object but don't -// start it running. -// - -// construct a detached thread running a given function. - -omni_thread::omni_thread(void (*fn)(void*), void* arg, priority_t pri) -{ - common_constructor(arg, pri, 1); - fn_void = fn; - fn_ret = NULL; -} - -// construct an undetached thread running a given function. - -omni_thread::omni_thread(void* (*fn)(void*), void* arg, priority_t pri) -{ - common_constructor(arg, pri, 0); - fn_void = NULL; - fn_ret = fn; -} - -// construct a thread which will run either run() or run_undetached(). - -omni_thread::omni_thread(void* arg, priority_t pri) -{ - common_constructor(arg, pri, 1); - fn_void = NULL; - fn_ret = NULL; -} - -// common part of all constructors. - -void -omni_thread::common_constructor(void* arg, priority_t pri, int det) -{ - _state = STATE_NEW; - _priority = pri; - - next_id_mutex->lock(); - _id = next_id++; - next_id_mutex->unlock(); - - thread_arg = arg; - detached = det; // may be altered in start_undetached() - - _dummy = 0; - _values = 0; - _value_alloc = 0; - // sol_thread is set up in initialisation routine or start(). -} - - -// -// Destructor for omni_thread. -// - -omni_thread::~omni_thread(void) -{ - DB(cerr << "destructor called for thread " << id() << endl); - if (_values) { - for (key_t i=0; i < _value_alloc; i++) { - if (_values[i]) { - delete _values[i]; - } - } - delete [] _values; - } -} - - -// -// Start the thread -// - -void -omni_thread::start(void) -{ - long flags = 0; - - if (detached) - flags |= THR_DETACHED; - - omni_mutex_lock l(mutex); - - if (_state != STATE_NEW) - throw omni_thread_invalid(); - - THROW_ERRORS(thr_create(0, stack_size, omni_thread_wrapper, (void*)this, flags, - &sol_thread)); - - _state = STATE_RUNNING; - - THROW_ERRORS(thr_setprio(sol_thread, sol_priority(_priority))); -} - - -// -// Start a thread which will run the member function run_undetached(). -// - -void -omni_thread::start_undetached(void) -{ - if ((fn_void != NULL) || (fn_ret != NULL)) - throw omni_thread_invalid(); - - detached = 0; - start(); -} - - -// -// join - simply check error conditions & call thr_join. -// - -void -omni_thread::join(void** status) -{ - mutex.lock(); - - if ((_state != STATE_RUNNING) && (_state != STATE_TERMINATED)) { - mutex.unlock(); - throw omni_thread_invalid(); - } - - mutex.unlock(); - - if (this == self()) - throw omni_thread_invalid(); - - if (detached) - throw omni_thread_invalid(); - - DB(cerr << "omni_thread::join: doing thr_join\n"); - - THROW_ERRORS(thr_join(sol_thread, (thread_t *)NULL, status)); - - DB(cerr << "omni_thread::join: thr_join succeeded\n"); - - delete this; -} - - -// -// Change this thread's priority. -// - -void -omni_thread::set_priority(priority_t pri) -{ - omni_mutex_lock l(mutex); - - if (_state != STATE_RUNNING) - throw omni_thread_invalid(); - - _priority = pri; - - THROW_ERRORS(thr_setprio(sol_thread, sol_priority(pri))); -} - - -// -// create - construct a new thread object and start it running. Returns thread -// object if successful, null pointer if not. -// - -// detached version - -omni_thread* -omni_thread::create(void (*fn)(void*), void* arg, priority_t pri) -{ - omni_thread* t = new omni_thread(fn, arg, pri); - - t->start(); - - return t; -} - -// undetached version - -omni_thread* -omni_thread::create(void* (*fn)(void*), void* arg, priority_t pri) -{ - omni_thread* t = new omni_thread(fn, arg, pri); - - t->start(); - - return t; -} - - -// -// exit() _must_ lock the mutex even in the case of a detached thread. This is -// because a thread may run to completion before the thread that created it has -// had a chance to get out of start(). By locking the mutex we ensure that the -// creating thread must have reached the end of start() before we delete the -// thread object. Of course, once the call to start() returns, the user can -// still incorrectly refer to the thread object, but that's their problem. -// - -void -omni_thread::exit(void* return_value) -{ - omni_thread* me = self(); - - if (me) - { - me->mutex.lock(); - - me->_state = STATE_TERMINATED; - - me->mutex.unlock(); - - DB(cerr << "omni_thread::exit: thread " << me->id() << " detached " - << me->detached << " return value " << return_value << endl); - - if (me->detached) - delete me; - } - else - { - DB(cerr << "omni_thread::exit: called with a non-omnithread. Exit quietly." << endl); - } - - thr_exit(return_value); -} - - -omni_thread* -omni_thread::self(void) -{ - omni_thread* me; - - THROW_ERRORS(thr_getspecific(self_key, (void**)&me)); - - if (!me) { - // This thread is not created by omni_thread::start because it - // doesn't has a class omni_thread instance attached to its key. - DB(cerr << "omni_thread::self: called with a non-ominthread. NULL is returned." << endl); - } - - return me; -} - - -void -omni_thread::yield(void) -{ - thr_yield(); -} - - -void -omni_thread::sleep(unsigned long secs, unsigned long nanosecs) -{ - timespec rqts = { secs, nanosecs }; - timespec remain; - while (nanosleep(&rqts, &remain)) { - if (errno == EINTR) { - rqts.tv_sec = remain.tv_sec; - rqts.tv_nsec = remain.tv_nsec; - continue; - } - else - throw omni_thread_fatal(errno); - } -} - - -void -omni_thread::get_time(unsigned long* abs_sec, unsigned long* abs_nsec, - unsigned long rel_sec, unsigned long rel_nsec) -{ - timespec abs; - clock_gettime(CLOCK_REALTIME, &abs); - abs.tv_nsec += rel_nsec; - abs.tv_sec += rel_sec + abs.tv_nsec / 1000000000; - abs.tv_nsec = abs.tv_nsec % 1000000000; - *abs_sec = abs.tv_sec; - *abs_nsec = abs.tv_nsec; -} - - -int -omni_thread::sol_priority(priority_t pri) -{ - switch (pri) { - - case PRIORITY_LOW: - return 0; - - case PRIORITY_NORMAL: - return 1; - - case PRIORITY_HIGH: - return 2; - } - - throw omni_thread_invalid(); -} - - -void -omni_thread::stacksize(unsigned long sz) -{ - stack_size = sz; -} - -unsigned long -omni_thread::stacksize() -{ - return stack_size; -} - - -// -// Dummy thread -// - -#error This dummy thread code is not tested. It might work if you're lucky. - -class omni_thread_dummy : public omni_thread { -public: - inline omni_thread_dummy() : omni_thread() - { - _dummy = 1; - _state = STATE_RUNNING; - sol_thread = thr_self(); - THROW_ERRORS(thr_setspecific(self_key, (void*)this)); - } - inline ~omni_thread_dummy() - { - THROW_ERRORS(thr_setspecific(self_key, 0)); - } -}; - -omni_thread* -omni_thread::create_dummy() -{ - if (omni_thread::self()) - throw omni_thread_invalid(); - - return new omni_thread_dummy; -} - -void -omni_thread::release_dummy() -{ - omni_thread* self = omni_thread::self(); - if (!self || !self->_dummy) - throw omni_thread_invalid(); - - omni_thread_dummy* dummy = (omni_thread_dummy*)self; - delete dummy; -} - - -#define INSIDE_THREAD_IMPL_CC -#include "threaddata.cc" -#undef INSIDE_THREAD_IMPL_CC diff --git a/omnithread/threaddata.cc b/omnithread/threaddata.cc deleted file mode 100644 index d54c43914..000000000 --- a/omnithread/threaddata.cc +++ /dev/null @@ -1,83 +0,0 @@ -// Package : omnithread -// omnithread/threaddata.cc Created : 10/2000 dpg1 -// -// Copyright (C) 2000 AT&T Laboratories Cambridge -// -// This file is part of the omnithread library -// -// The omnithread library is free software; you can redistribute it and/or -// modify it under the terms of the GNU Library General Public -// License as published by the Free Software Foundation; either -// version 2 of the License, or (at your option) any later version. -// -// This library 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 -// Library General Public License for more details. -// -// You should have received a copy of the GNU Library General Public -// License along with this library; if not, write to the Free -// Software Foundation, Inc., 51 Franklin Street, Boston, MA -// 02110-1301, USA -// - -// Implementation of per-thread data - -#ifndef INSIDE_THREAD_IMPL_CC -#error "threaddata.cc must be #included by a thread implementation." -#endif - - -static omni_thread::key_t allocated_keys = 0; - -omni_thread::key_t -omni_thread::allocate_key() -{ - omni_mutex_lock l(*next_id_mutex); - return ++allocated_keys; -} - -omni_thread::value_t* -omni_thread::set_value(key_t k, value_t* v) -{ - if (k == 0) return 0; - if (k > _value_alloc) { - next_id_mutex->lock(); - key_t alloc = allocated_keys; - next_id_mutex->unlock(); - - if (k > alloc) return 0; - - value_t** nv = new value_t*[alloc]; - key_t i = 0; - if (_values) { - for (; i < _value_alloc; i++) - nv[i] = _values[i]; - delete [] _values; - } - for (; i < alloc; i++) - nv[i] = 0; - - _values = nv; - _value_alloc = alloc; - } - if (_values[k-1]) delete _values[k-1]; - _values[k-1] = v; - return v; -} - -omni_thread::value_t* -omni_thread::get_value(key_t k) -{ - if (k > _value_alloc) return 0; - return _values[k-1]; -} - -omni_thread::value_t* -omni_thread::remove_value(key_t k) -{ - if (k > _value_alloc) return 0; - value_t* v = _values[k-1]; - _values[k-1] = 0; - return v; -} diff --git a/omnithread/vxWorks.cc b/omnithread/vxWorks.cc deleted file mode 100644 index aaff6cdb2..000000000 --- a/omnithread/vxWorks.cc +++ /dev/null @@ -1,1160 +0,0 @@ -////////////////////////////////////////////////////////////////////////////// -// Filename: vxWorks.cc -// Author: Tihomir Sokcevic -// Acterna, Eningen. -// Description: vxWorks adaptation of the omnithread wrapper classes -// Notes: Munching strategy is imperative -////////////////////////////////////////////////////////////////////////////// -// $Log$ -// Revision 1.1 2004/04/10 18:00:52 eb -// Initial revision -// -// Revision 1.1.1.1 2004/03/01 00:20:27 eb -// initial checkin -// -// Revision 1.1 2003/05/25 05:29:04 eb -// see ChangeLog -// -// Revision 1.1.2.1 2003/02/17 02:03:11 dgrisby -// vxWorks port. (Thanks Michael Sturm / Acterna Eningen GmbH). -// -// Revision 1.1.1.1 2002/11/19 14:58:04 sokcevti -// OmniOrb4.0.0 VxWorks port -// -// Revision 1.4 2002/10/15 07:54:09 kuttlest -// change semaphore from SEM_FIFO to SEM_PRIO -// --- -// -// Revision 1.3 2002/07/05 07:38:52 engeln -// made priority redefinable on load time by defining int variables -// omni_thread_prio_low = 220; -// omni_thread_prio_normal = 110; -// omni_thread_prio_high = 55; -// the default priority is prio_normal. -// The normal priority default has been increased from 200 to 110 and the -// high priority from 100 to 55. -// --- -// -// Revision 1.2 2002/06/14 12:44:57 engeln -// replaced possibly unsafe wakeup procedure in broadcast. -// --- -// -// Revision 1.1.1.1 2002/04/02 10:09:34 sokcevti -// omniORB4 initial realease -// -// Revision 1.0 2001/10/23 14:22:45 sokcevti -// Initial Version 4.00 -// --- -// -////////////////////////////////////////////////////////////////////////////// - - -////////////////////////////////////////////////////////////////////////////// -// Include files -////////////////////////////////////////////////////////////////////////////// -#include <stdlib.h> -#include <stdio.h> -#include <errno.h> -#include <time.h> -#include <gnuradio/omnithread.h> -#include <sysLib.h> - -#include <assert.h> // assert -#include <intLib.h> // intContext - - -////////////////////////////////////////////////////////////////////////////// -// Local defines -////////////////////////////////////////////////////////////////////////////// -#define ERRNO(x) (((x) != 0) ? (errno) : 0) -#define THROW_ERRORS(x) { if((x) != OK) throw omni_thread_fatal(errno); } -#define OMNI_THREAD_ID 0x7F7155AAl -#define OMNI_STACK_SIZE 32768l - -#ifdef _DEBUG - #include <fstream> - #define DBG_TRACE(X) X -#else // _DEBUG - #define DBG_TRACE(X) -#endif // _DEBUG - -#define DBG_ASSERT(X) - -#define DBG_THROW(X) X - -int omni_thread_prio_low = 220; -int omni_thread_prio_normal = 110; -int omni_thread_prio_high = 55; -/////////////////////////////////////////////////////////////////////////// -// -// Mutex -// -/////////////////////////////////////////////////////////////////////////// -omni_mutex::omni_mutex(void):m_bConstructed(false) -{ - mutexID = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE); - - DBG_ASSERT(assert(mutexID != NULL)); - - if(mutexID==NULL) - { - DBG_TRACE(cout<<"Exception: omni_mutex::omni_mutex() tid: "<<(int)taskIdSelf()<<endl); - DBG_THROW(throw omni_thread_fatal(-1)); - } - - m_bConstructed = true; -} - -omni_mutex::~omni_mutex(void) -{ - m_bConstructed = false; - - STATUS status = semDelete(mutexID); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_mutex::~omni_mutex() mutexID: "<<(int)mutexID<<" tid: "<<(int)taskIdSelf()<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } -} - -/* -void omni_mutex::lock(void) -{ - DBG_ASSERT(assert(!intContext())); // not in ISR context - DBG_ASSERT(assert(m_bConstructed)); - - STATUS status = semTake(mutexID, WAIT_FOREVER); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_mutex::lock() mutexID: "<<(int)mutexID<<" tid: "<<(int)taskIdSelf()<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } -} - -void omni_mutex::unlock(void) -{ - DBG_ASSERT(assert(m_bConstructed)); - - STATUS status = semGive(mutexID); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_mutex::unlock() mutexID: "<<(int)mutexID<<" tid: "<<(int)taskIdSelf()<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } -} -*/ - -/////////////////////////////////////////////////////////////////////////// -// -// Condition variable -// -/////////////////////////////////////////////////////////////////////////// -omni_condition::omni_condition(omni_mutex* m) : mutex(m) -{ - DBG_TRACE(cout<<"omni_condition::omni_condition mutexID: "<<(int)mutex->mutexID<<" tid:"<<(int)taskIdSelf()<<endl); - - waiters_ = 0; - - sema_ = semCCreate(SEM_Q_PRIORITY, 0); - if(sema_ == NULL) - { - DBG_TRACE(cout<<"Exception: omni_condition::omni_condition() tid: "<<(int)taskIdSelf()<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - waiters_lock_ = semMCreate(SEM_Q_PRIORITY | SEM_INVERSION_SAFE); - if(waiters_lock_ == NULL) - { - DBG_TRACE(cout<<"Exception: omni_condition::omni_condition() tid: "<<(int)taskIdSelf()<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - -} - -omni_condition::~omni_condition(void) -{ - STATUS status = semDelete(waiters_lock_); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::~omni_condition"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - status = semDelete(sema_); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::~omni_condition"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } -} - -void omni_condition::wait(void) -{ - DBG_TRACE(cout<<"omni_condition::wait mutexID: "<<(int)mutex->mutexID<<" tid:"<<(int)taskIdSelf()<<endl); - - // Prevent race conditions on the <waiters_> count. - - STATUS status = semTake(waiters_lock_,WAIT_FOREVER); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::wait"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - ++waiters_; - - status = semGive(waiters_lock_); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::wait"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - // disable task lock to have an atomic unlock+semTake - taskLock(); - - // We keep the lock held just long enough to increment the count of - // waiters by one. Note that we can't keep it held across the call - // to wait() since that will deadlock other calls to signal(). - mutex->unlock(); - - // Wait to be awakened by a cond_signal() or cond_broadcast(). - status = semTake(sema_,WAIT_FOREVER); - - // reenable task rescheduling - taskUnlock(); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::wait"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - // Reacquire lock to avoid race conditions on the <waiters_> count. - status = semTake(waiters_lock_,WAIT_FOREVER); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::wait"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - // We're ready to return, so there's one less waiter. - --waiters_; - - // Release the lock so that other collaborating threads can make - // progress. - status = semGive(waiters_lock_); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::wait"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - // Bad things happened, so let's just return below. - - // We must always regain the <external_mutex>, even when errors - // occur because that's the guarantee that we give to our callers. - mutex->lock(); -} - - -// The time given is absolute. Return 0 is timeout -int omni_condition::timedwait(unsigned long secs, unsigned long nanosecs) -{ - STATUS result = OK; - timespec now; - unsigned long timeout; - int ticks; - - // Prevent race conditions on the <waiters_> count. - STATUS status = semTake(waiters_lock_, WAIT_FOREVER); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::timedwait"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - ++waiters_; - - status = semGive(waiters_lock_); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::timedwait"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - clock_gettime(CLOCK_REALTIME, &now); - - if(((unsigned long)secs <= (unsigned long)now.tv_sec) && - (((unsigned long)secs < (unsigned long)now.tv_sec) || - (nanosecs < (unsigned long)now.tv_nsec))) - timeout = 0; - else - timeout = (secs-now.tv_sec) * 1000 + (nanosecs-now.tv_nsec) / 1000000l; - - // disable task lock to have an atomic unlock+semTake - taskLock(); - - // We keep the lock held just long enough to increment the count - // of waiters by one. - mutex->unlock(); - - // Wait to be awakened by a signal() or broadcast(). - ticks = (timeout * sysClkRateGet()) / 1000L; - result = semTake(sema_, ticks); - - // reenable task rescheduling - taskUnlock(); - - // Reacquire lock to avoid race conditions. - status = semTake(waiters_lock_, WAIT_FOREVER); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::timedwait"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - --waiters_; - - status = semGive(waiters_lock_); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::timedwait"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - // A timeout has occured - fires exception if the origin is other than timeout - if(result!=OK && !(errno == S_objLib_OBJ_TIMEOUT || errno == S_objLib_OBJ_UNAVAILABLE)) - { - DBG_TRACE(cout<<"omni_condition::timedwait! - thread:"<<omni_thread::self()->id()<<" SemID:"<<(int)sema_<<" errno:"<<errno<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - // We must always regain the <external_mutex>, even when errors - // occur because that's the guarantee that we give to our callers. - mutex->lock(); - - if(result!=OK) // timeout - return 0; - - return 1; -} - -void omni_condition::signal(void) -{ - DBG_TRACE(cout<<"omni_condition::signal mutexID: "<<(int)mutex->mutexID<<" tid:"<<(int)taskIdSelf()<<endl); - - STATUS status = semTake(waiters_lock_, WAIT_FOREVER); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::signal"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - int have_waiters = waiters_ > 0; - - status = semGive(waiters_lock_); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::signal"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - if(have_waiters != 0) - { - status = semGive(sema_); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::signal"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - } -} - -void omni_condition::broadcast(void) -{ - DBG_TRACE(cout<<"omni_condition::broadcast mutexID: "<<(int)mutex->mutexID<<" tid:"<<(int)taskIdSelf()<<endl); - - int have_waiters = 0; - - // The <external_mutex> must be locked before this call is made. - // This is needed to ensure that <waiters_> and <was_broadcast_> are - // consistent relative to each other. - STATUS status = semTake(waiters_lock_, WAIT_FOREVER); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::signal"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - if(waiters_ > 0) - { - // We are broadcasting, even if there is just one waiter... - // Record the fact that we are broadcasting. This helps the - // cond_wait() method know how to optimize itself. Be sure to - // set this with the <waiters_lock_> held. - have_waiters = 1; - } - - status = semGive(waiters_lock_); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_condition::signal"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - if(have_waiters) - { - // Wake up all the waiters. - status = semFlush(sema_); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"omni_condition::broadcast1! - thread:"<<omni_thread::self()->id()<<" SemID:"<<(int)sema_<<" errno:"<<errno<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - - } -} - - -/////////////////////////////////////////////////////////////////////////// -// -// Counting semaphore -// -/////////////////////////////////////////////////////////////////////////// -omni_semaphore::omni_semaphore(unsigned int initial) -{ - - DBG_ASSERT(assert(0 <= (int)initial)); // POSIX expects only unsigned init values - - semID = semCCreate(SEM_Q_PRIORITY, (int)initial); - - DBG_ASSERT(assert(semID!=NULL)); - - if(semID==NULL) - { - DBG_TRACE(cout<<"Exception: omni_semaphore::omni_semaphore"<<endl); - DBG_THROW(throw omni_thread_fatal(-1)); - } -} - -omni_semaphore::~omni_semaphore(void) -{ - STATUS status = semDelete(semID); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_semaphore::~omni_semaphore"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } -} - -void omni_semaphore::wait(void) -{ - DBG_ASSERT(assert(!intContext())); // no wait in ISR - - STATUS status = semTake(semID, WAIT_FOREVER); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_semaphore::wait"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } -} - -int omni_semaphore::trywait(void) -{ - STATUS status = semTake(semID, NO_WAIT); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - if(errno == S_objLib_OBJ_UNAVAILABLE) - { - return 0; - } - else - { - DBG_ASSERT(assert(false)); - - DBG_TRACE(cout<<"Exception: omni_semaphore::trywait"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } - } - - return 1; -} - -void omni_semaphore::post(void) -{ - STATUS status = semGive(semID); - - DBG_ASSERT(assert(status == OK)); - - if(status != OK) - { - DBG_TRACE(cout<<"Exception: omni_semaphore::post"<<endl); - DBG_THROW(throw omni_thread_fatal(errno)); - } -} - - - -/////////////////////////////////////////////////////////////////////////// -// -// Thread -// -/////////////////////////////////////////////////////////////////////////// - - -// -// static variables -// -omni_mutex* omni_thread::next_id_mutex = 0; -int omni_thread::next_id = 0; - -// omniORB requires a larger stack size than the default (21120) on OSF/1 -static size_t stack_size = OMNI_STACK_SIZE; - - -// -// Initialisation function (gets called before any user code). -// - -static int& count() { - static int the_count = 0; - return the_count; -} - -omni_thread::init_t::init_t(void) -{ - // Only do it once however many objects get created. - if(count()++ != 0) - return; - - attach(); -} - -omni_thread::init_t::~init_t(void) -{ - if (--count() != 0) return; - - omni_thread* self = omni_thread::self(); - if (!self) return; - - taskTcb(taskIdSelf())->spare1 = 0; - delete self; - - delete next_id_mutex; -} - - -// -// Wrapper for thread creation. -// -extern "C" void omni_thread_wrapper(void* ptr) -{ - omni_thread* me = (omni_thread*)ptr; - - DBG_TRACE(cout<<"omni_thread_wrapper: thread "<<me->id()<<" started\n"); - - // - // We can now tweaked the task info since the tcb exist now - // - me->mutex.lock(); // To ensure that start has had time to finish - taskTcb(me->tid)->spare1 = OMNI_THREAD_ID; - taskTcb(me->tid)->spare2 = (int)ptr; - me->mutex.unlock(); - - // - // Now invoke the thread function with the given argument. - // - if(me->fn_void != NULL) - { - (*me->fn_void)(me->thread_arg); - omni_thread::exit(); - } - - if(me->fn_ret != NULL) - { - void* return_value = (*me->fn_ret)(me->thread_arg); - omni_thread::exit(return_value); - } - - if(me->detached) - { - me->run(me->thread_arg); - omni_thread::exit(); - } - else - { - void* return_value = me->run_undetached(me->thread_arg); - omni_thread::exit(return_value); - } -} - - -// -// Special functions for VxWorks only -// -void omni_thread::attach(void) -{ - DBG_TRACE(cout<<"omni_thread_attach: VxWorks mapping thread initialising\n"); - - int _tid = taskIdSelf(); - - // Check the task is not already attached - if(taskTcb(_tid)->spare1 == OMNI_THREAD_ID) - return; - - // Create the mutex required to lock the threads debugging id (create before the thread!!!) - if(next_id_mutex == 0) - next_id_mutex = new omni_mutex; - - // Create a thread object for THIS running process - omni_thread* t = new omni_thread; - - // Lock its mutex straigh away! - omni_mutex_lock l(t->mutex); - - // Adjust data members of this instance - t->_state = STATE_RUNNING; - t->tid = taskIdSelf(); - - // Set the thread values so it can be recongnised as a omni_thread - // Set the id last can possibly prevent race condition - taskTcb(t->tid)->spare2 = (int)t; - taskTcb(t->tid)->spare1 = OMNI_THREAD_ID; - - // Create the running_mutex at this stage, but leave it empty. We are not running - // in the task context HERE, so taking it would be disastrous. - t->running_cond = new omni_condition(&t->mutex); -} - - -void omni_thread::detach(void) -{ - DBG_TRACE(cout<<"omni_thread_detach: VxWorks detaching thread mapping\n"); - - int _tid = taskIdSelf(); - - // Check the task has a OMNI_THREAD attached - if(taskTcb(_tid)->spare1 != OMNI_THREAD_ID) - return; - - // Invalidate the id NOW ! - taskTcb(_tid)->spare1 = 0; - - // Even if NULL, it is safe to delete the thread - omni_thread* t = (omni_thread*)taskTcb(_tid)->spare2; - // Fininsh cleaning the tcb structure - taskTcb(_tid)->spare2 = 0; - - delete t; -} - - -// -// Constructors for omni_thread - set up the thread object but don't -// start it running. -// - -// construct a detached thread running a given function. -omni_thread::omni_thread(void (*fn)(void*), void* arg, priority_t pri) -{ - common_constructor(arg, pri, 1); - fn_void = fn; - fn_ret = NULL; -} - -// construct an undetached thread running a given function. -omni_thread::omni_thread(void* (*fn)(void*), void* arg, priority_t pri) -{ - common_constructor(arg, pri, 0); - fn_void = NULL; - fn_ret = fn; -} - -// construct a thread which will run either run() or run_undetached(). - -omni_thread::omni_thread(void* arg, priority_t pri) -{ - common_constructor(arg, pri, 1); - fn_void = NULL; - fn_ret = NULL; -} - -// common part of all constructors. -void omni_thread::common_constructor(void* arg, priority_t pri, int det) -{ - _state = STATE_NEW; - _priority = pri; - - // Set the debugging id - next_id_mutex->lock(); - _id = next_id++; - next_id_mutex->unlock(); - - // Note : tid can only be setup when the task is up and running - tid = 0; - - thread_arg = arg; - detached = det; // may be altered in start_undetached() - - _dummy = 0; - _values = 0; - _value_alloc = 0; -} - -// -// Destructor for omni_thread. -// -omni_thread::~omni_thread(void) -{ - DBG_TRACE(cout<<"omni_thread::~omni_thread for thread "<<id()<<endl); - - if (_values) { - for (key_t i=0; i < _value_alloc; i++) { - if (_values[i]) { - delete _values[i]; - } - } - delete [] _values; - } - - delete running_cond; -} - - -// -// Start the thread -// -void omni_thread::start(void) -{ - omni_mutex_lock l(mutex); - - DBG_ASSERT(assert(_state == STATE_NEW)); - - if(_state != STATE_NEW) - DBG_THROW(throw omni_thread_invalid()); - - // Allocate memory for the task. (The returned id cannot be trusted by the task) - tid = taskSpawn( - NULL, // Task name - vxworks_priority(_priority), // Priority - 0, // Option - stack_size, // Stack size - (FUNCPTR)omni_thread_wrapper, // Priority - (int)this, // First argument is this - 0,0,0,0,0,0,0,0,0 // Remaining unused args - ); - - DBG_ASSERT(assert(tid!=ERROR)); - - if(tid==ERROR) - DBG_THROW(throw omni_thread_invalid()); - - _state = STATE_RUNNING; - - // Create the running_mutex at this stage, but leave it empty. We are not running - // in the task context HERE, so taking it would be disastrous. - running_cond = new omni_condition(&mutex); -} - - -// -// Start a thread which will run the member function run_undetached(). -// -void omni_thread::start_undetached(void) -{ - DBG_ASSERT(assert(!((fn_void != NULL) || (fn_ret != NULL)))); - - if((fn_void != NULL) || (fn_ret != NULL)) - DBG_THROW(throw omni_thread_invalid()); - - detached = 0; - - start(); -} - - -// -// join - Wait for the task to complete before returning to the calling process -// -void omni_thread::join(void** status) -{ - mutex.lock(); - - if((_state != STATE_RUNNING) && (_state != STATE_TERMINATED)) - { - mutex.unlock(); - - DBG_ASSERT(assert(false)); - - DBG_THROW(throw omni_thread_invalid()); - } - - mutex.unlock(); - - DBG_ASSERT(assert(this != self())); - - if(this == self()) - DBG_THROW(throw omni_thread_invalid()); - - DBG_ASSERT(assert(!detached)); - - if(detached) - DBG_THROW(throw omni_thread_invalid()); - - mutex.lock(); - running_cond->wait(); - mutex.unlock(); - - if(status) - *status = return_val; - - delete this; -} - - -// -// Change this thread's priority. -// -void omni_thread::set_priority(priority_t pri) -{ - omni_mutex_lock l(mutex); - - DBG_ASSERT(assert(_state == STATE_RUNNING)); - - if(_state != STATE_RUNNING) - { - DBG_THROW(throw omni_thread_invalid()); - } - - _priority = pri; - - if(taskPrioritySet(tid, vxworks_priority(pri))==ERROR) - { - DBG_ASSERT(assert(false)); - - DBG_THROW(throw omni_thread_fatal(errno)); - } -} - - -// -// create - construct a new thread object and start it running. Returns thread -// object if successful, null pointer if not. -// - -// detached version (the entry point is a void) -omni_thread* omni_thread::create(void (*fn)(void*), void* arg, priority_t pri) -{ - omni_thread* t = new omni_thread(fn, arg, pri); - - t->start(); - - return t; -} - -// undetached version (the entry point is a void*) -omni_thread* omni_thread::create(void* (*fn)(void*), void* arg, priority_t pri) -{ - omni_thread* t = new omni_thread(fn, arg, pri); - - t->start(); - - return t; -} - - -// -// exit() _must_ lock the mutex even in the case of a detached thread. This is -// because a thread may run to completion before the thread that created it has -// had a chance to get out of start(). By locking the mutex we ensure that the -// creating thread must have reached the end of start() before we delete the -// thread object. Of course, once the call to start() returns, the user can -// still incorrectly refer to the thread object, but that's their problem. -// -void omni_thread::exit(void* return_value) -{ - omni_thread* me = self(); - - if(me) - { - me->mutex.lock(); - - me->return_val = return_value; - me->_state = STATE_TERMINATED; - me->running_cond->signal(); - - me->mutex.unlock(); - - DBG_TRACE(cout<<"omni_thread::exit: thread "<<me->id()<<" detached "<<me->detached<<" return value "<<(int)return_value<<endl); - - if(me->detached) - delete me; - } - else - DBG_TRACE(cout<<"omni_thread::exit: called with a non-omnithread. Exit quietly."<<endl); - - taskDelete(taskIdSelf()); -} - - -omni_thread* omni_thread::self(void) -{ - if(taskTcb(taskIdSelf())->spare1 != OMNI_THREAD_ID) - return NULL; - - return (omni_thread*)taskTcb(taskIdSelf())->spare2; -} - - -void omni_thread::yield(void) -{ - taskDelay(NO_WAIT); -} - - -void omni_thread::sleep(unsigned long secs, unsigned long nanosecs) -{ - int tps = sysClkRateGet(); - - // Convert to us to avoid overflow in the multiplication - // tps should always be less than 1000 ! - nanosecs /= 1000; - - taskDelay(secs*tps + (nanosecs*tps)/1000000l); -} - - -void omni_thread::get_time( unsigned long* abs_sec, - unsigned long* abs_nsec, - unsigned long rel_sec, - unsigned long rel_nsec) -{ - timespec abs; - clock_gettime(CLOCK_REALTIME, &abs); - abs.tv_nsec += rel_nsec; - abs.tv_sec += rel_sec + abs.tv_nsec / 1000000000; - abs.tv_nsec = abs.tv_nsec % 1000000000; - *abs_sec = abs.tv_sec; - *abs_nsec = abs.tv_nsec; -} - - -int omni_thread::vxworks_priority(priority_t pri) -{ - switch (pri) - { - case PRIORITY_LOW: - return omni_thread_prio_low; - - case PRIORITY_NORMAL: - return omni_thread_prio_normal; - - case PRIORITY_HIGH: - return omni_thread_prio_high; - } - - DBG_ASSERT(assert(false)); - - DBG_THROW(throw omni_thread_invalid()); -} - - -void omni_thread::stacksize(unsigned long sz) -{ - stack_size = sz; -} - - -unsigned long omni_thread::stacksize() -{ - return stack_size; -} - - -void omni_thread::show(void) -{ - omni_thread *pThread; - int s1, s2; - int tid = taskIdSelf(); - - printf("TaskId is %.8x\n", tid); - - s1 = taskTcb(tid)->spare1; - - if(s1 != OMNI_THREAD_ID) - { - printf("Spare 1 is %.8x, and not recongnized\n", s1); - - return; - } - else - { - printf("Spare 1 indicate an omni_thread.\n"); - } - - s2 = taskTcb(tid)->spare2; - - if(s2 == 0) - { - printf("Spare 2 is NULL! - No thread object attached !!\n"); - - return; - } - else - { - printf("Thread object at %.8x\n", s2); - } - - pThread = (omni_thread *)s2; - - state_t status = pThread->_state; - - printf(" | Thread status is "); - - switch (status) - { - case STATE_NEW: - printf("NEW\n"); break; - case STATE_RUNNING: - printf("STATE_RUNNING\n"); break; - case STATE_TERMINATED: - printf("TERMINATED\n"); break; - default: - printf("Illegal (=%.8x)\n", (unsigned int)status); - - return; - } - - if(pThread->tid != tid) - { - printf(" | Task ID in thread object is different!! (=%.8x)\n", pThread->tid); - - return; - } - else - { - printf(" | Task ID in thread consistent\n"); - } - - printf("\n"); -} - - -// -// Dummy thread -// - -class omni_thread_dummy : public omni_thread { -public: - inline omni_thread_dummy() : omni_thread() - { - _dummy = 1; - _state = STATE_RUNNING; - - // Adjust data members of this instance - tid = taskIdSelf(); - - // Set the thread values so it can be recongnised as a omni_thread - // Set the id last can possibly prevent race condition - taskTcb(tid)->spare2 = (int)this; - taskTcb(tid)->spare1 = OMNI_THREAD_ID; - } - inline ~omni_thread_dummy() - { - taskTcb(taskIdSelf())->spare1 = 0; - } -}; - -omni_thread* -omni_thread::create_dummy() -{ - if (omni_thread::self()) - throw omni_thread_invalid(); - - return new omni_thread_dummy; -} - -void -omni_thread::release_dummy() -{ - omni_thread* self = omni_thread::self(); - if (!self || !self->_dummy) - throw omni_thread_invalid(); - - omni_thread_dummy* dummy = (omni_thread_dummy*)self; - delete dummy; -} - - -#define INSIDE_THREAD_IMPL_CC -#include "threaddata.cc" -#undef INSIDE_THREAD_IMPL_CC diff --git a/run_tests.sh.in b/run_tests.sh.in index ce0d90978..1cb8e170a 100644 --- a/run_tests.sh.in +++ b/run_tests.sh.in @@ -56,9 +56,6 @@ fi PYTHONPATH="$mylibdir:$mysrcdir:$mypydir:$PYTHONPATH" export PYTHONPATH -# Where to find omnithread library files -gromnidir=@omnithread_LIBDIRPATH@ - # Where to find gruel library files grueldir=@gruel_LIBDIRPATH@ @@ -68,7 +65,7 @@ grcoredir=@gnuradio_core_LIBDIRPATH@ # Construct search path for python modules # Check each one to make sure it's not "" before adding grlibdir="" -for dir in $gromnidir $grcoredir $grueldir +for dir in $grcoredir $grueldir do if [ "$dir" != "" ] then diff --git a/usrp/firmware/include/usrp_ids.h b/usrp/firmware/include/usrp_ids.h index 4152600bd..46a069434 100644 --- a/usrp/firmware/include/usrp_ids.h +++ b/usrp/firmware/include/usrp_ids.h @@ -56,6 +56,7 @@ #define USB_PID_FSF_BDALE_9 0x0013 // Bdale Garbee <bdale@gag.com> #define USB_PID_FSF_HPSDR_HERMES 0x0014 // HPSDR Hermes #define USB_PID_FSF_THINKRF 0x0015 // Catalin Patulea <catalin.patulea@thinkrf.com> +#define USB_PID_FSF_MSA 0x0016 // Hans de Bok <hdbok@dionaea.demon.nl> Scotty's Modular Spectrum Analyzer #define USB_PID_FSF_LBNL_UXO 0x0018 // http://recycle.lbl.gov/~ldoolitt/uxo/ diff --git a/usrp/firmware/src/common/build_eeprom.py b/usrp/firmware/src/common/build_eeprom.py index d73cbbc4f..00c2e3414 100755 --- a/usrp/firmware/src/common/build_eeprom.py +++ b/usrp/firmware/src/common/build_eeprom.py @@ -182,10 +182,6 @@ if __name__ == '__main__': sys.stderr.write ( "You must specify the install prefix with -p PREFIX\n") sys.exit (1) - if not os.path.isdir(options.prefix): - sys.stderr.write ( - "PREFIX dir (" + options.prefix + "), does not exist\n") - sys.exit (1) ihx_filename = args[0] diff --git a/usrp/host/apps/burn-db-eeprom b/usrp/host/apps/burn-db-eeprom index 7ff1e9736..0c908e3d5 100755 --- a/usrp/host/apps/burn-db-eeprom +++ b/usrp/host/apps/burn-db-eeprom @@ -65,12 +65,14 @@ 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)), 'wbx_lo' : ((WBX_LO_TX, 0x0000), (WBX_LO_RX, 0x0000)), 'wbx_ng' : ((WBX_NG_TX, 0x0000), (WBX_NG_RX, 0x0000)), 'xcvr2450' : ((XCVR2450_TX, 0x0000), (XCVR2450_RX, 0x0000)), + 'bitshark_rx' : (None, (BITSHARK_RX, 0x0000)), 'experimental_tx' : ((EXPERIMENTAL_TX, 0x0000), None), 'experimental_rx' : (None, (EXPERIMENTAL_RX, 0x0000)), } diff --git a/usrp/host/include/usrp/Makefile.am b/usrp/host/include/usrp/Makefile.am index cfce51443..2aaf66a53 100644 --- a/usrp/host/include/usrp/Makefile.am +++ b/usrp/host/include/usrp/Makefile.am @@ -26,6 +26,7 @@ usrpincludedir = $(includedir)/usrp usrpinclude_HEADERS = \ db_base.h \ db_basic.h \ + db_bitshark_rx.h \ db_dbs_rx.h \ db_dtt754.h \ db_dtt768.h \ diff --git a/usrp/host/include/usrp/db_bitshark_rx.h b/usrp/host/include/usrp/db_bitshark_rx.h new file mode 100644 index 000000000..f81877d28 --- /dev/null +++ b/usrp/host/include/usrp/db_bitshark_rx.h @@ -0,0 +1,56 @@ +/* -*- 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 asversion 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 DB_BITSHARK_RX_H +#define DB_BITSHARK_RX_H + +#include <usrp/db_base.h> +#include <vector> +#include <stdint.h> + +class db_bitshark_rx : public db_base +{ +private: + int d_i2c_addr; + // Internal function for interfacing to the card + void _set_pga(int pga_gain); + +protected: + void shutdown(); + +public: + db_bitshark_rx(usrp_basic_sptr usrp, int which); + ~db_bitshark_rx(); + + float gain_min(); + float gain_max(); + float gain_db_per_step(); + double freq_min(); + double freq_max(); + struct freq_result_t set_freq(double freq); + bool set_gain(float gain); + bool set_bw(float bw); + bool set_clock_scheme(uint8_t clock_scheme, uint32_t ref_clock_freq); + bool is_quadrature(); + bool i_and_q_swapped(); +}; + +#endif diff --git a/usrp/host/include/usrp/db_flexrf.h b/usrp/host/include/usrp/db_flexrf.h index 0c834402d..70a55514e 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/include/usrp/db_wbxng.h b/usrp/host/include/usrp/db_wbxng.h index 8611d4787..9a7829278 100644 --- a/usrp/host/include/usrp/db_wbxng.h +++ b/usrp/host/include/usrp/db_wbxng.h @@ -30,7 +30,7 @@ class adf4350; class wbxng_base : public db_base { public: - wbxng_base(usrp_basic_sptr usrp, int which, int _power_on=0); + wbxng_base(usrp_basic_sptr usrp, int which); ~wbxng_base(); struct freq_result_t set_freq(double freq); @@ -40,31 +40,30 @@ public: double freq_max(); protected: - bool _lock_detect(); + void _write_spi(std::string data); + int _refclk_divisor(); + bool _get_locked(); bool _set_pga(float pga_gain); - int power_on() { return d_power_on; } - int power_off() { return 0; } - bool d_first; int d_spi_format; int d_spi_enable; int d_power_on; int d_PD; - adf4350 *d_common; + boost::shared_ptr<adf4350> d_common; }; // ---------------------------------------------------------------- -class wbxng_base_tx : public wbxng_base +class db_wbxng_tx : public wbxng_base { protected: void shutdown(); public: - wbxng_base_tx(usrp_basic_sptr usrp, int which, int _power_on=0); - ~wbxng_base_tx(); + db_wbxng_tx(usrp_basic_sptr usrp, int which); + ~db_wbxng_tx(); float gain_min(); float gain_max(); @@ -75,36 +74,20 @@ public: bool set_gain(float gain); }; -class wbxng_base_rx : public wbxng_base +class db_wbxng_rx : public wbxng_base { protected: void shutdown(); bool _set_attn(float attn); public: - wbxng_base_rx(usrp_basic_sptr usrp, int which, int _power_on=0); - ~wbxng_base_rx(); + db_wbxng_rx(usrp_basic_sptr usrp, int which); + ~db_wbxng_rx(); bool set_auto_tr(bool on); bool select_rx_antenna(int which_antenna); bool select_rx_antenna(const std::string &which_antenna); bool set_gain(float gain); -}; - -// ---------------------------------------------------------------- - -class db_wbxng_tx : public wbxng_base_tx -{ - public: - db_wbxng_tx(usrp_basic_sptr usrp, int which); - ~db_wbxng_tx(); -}; - -class db_wbxng_rx : public wbxng_base_rx -{ -public: - db_wbxng_rx(usrp_basic_sptr usrp, int which); - ~db_wbxng_rx(); float gain_min(); float gain_max(); diff --git a/usrp/host/lib/Makefile.am b/usrp/host/lib/Makefile.am index 5848412c9..23889fc85 100644 --- a/usrp/host/lib/Makefile.am +++ b/usrp/host/lib/Makefile.am @@ -24,7 +24,7 @@ common_INCLUDES = $(USRP_INCLUDES) $(USB_INCLUDES) lib_LTLIBRARIES = libusrp.la -libusrp_la_common_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 $(BOOST_LDFLAGS) +libusrp_la_common_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS) $(BOOST_LDFLAGS) libusrp_la_common_LIBADD = \ $(USB_LIBS) \ @@ -120,6 +120,7 @@ libusrp_la_common_SOURCES = \ db_boards.cc \ db_base.cc \ db_basic.cc \ + db_bitshark_rx.cc \ db_tv_rx.cc \ db_tv_rx_mimo.cc \ db_flexrf.cc \ diff --git a/usrp/host/lib/db_base.cc b/usrp/host/lib/db_base.cc index 1cb463429..b4fb45c51 100644 --- a/usrp/host/lib/db_base.cc +++ b/usrp/host/lib/db_base.cc @@ -238,7 +238,7 @@ int db_base::_refclk_divisor() { // Return value to stick in REFCLK_DIVISOR register - throw std::runtime_error("_reflck_divisor() called from base class\n");; + throw std::runtime_error("_refclk_divisor() called from base class\n");; } bool diff --git a/usrp/host/lib/db_bitshark_rx.cc b/usrp/host/lib/db_bitshark_rx.cc new file mode 100644 index 000000000..5368866d8 --- /dev/null +++ b/usrp/host/lib/db_bitshark_rx.cc @@ -0,0 +1,417 @@ +// +// 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 asversion 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 <usrp/db_bitshark_rx.h> +#include <db_base_impl.h> +#include <cmath> +#include <cstdio> +#include <string.h> +#include <stdint.h> + +/* Note: Thie general structure of this file is based on the db_dbsrx.cc + codebase for the dbsrx daughterboard. */ + +/* The following defines specify the address map provided by the + Bitshark card. These registers are all accessed over I2C. */ +#define RF_CENTER_FREQ_REG 0x00 +#define RF_CHAN_FILTER_BW_REG 0x01 +#define RF_GAIN_REG 0x02 +#define BB_GAIN_REG 0x03 +#define ADF4350_REG 0x10 +#define SKY73202_REG 0x11 +#define CLOCK_SCHEME_REG 0x20 + +/* The following table lists the registers provided by the BURX board that + are accessible over I2C: + -------------------------------------------------------- + |RegAddr: 0x00-RF Center Freq register | + |4-bytes 0x00| + |4-byte unsigned RF center freq (in KHz)| + |RegAddr: 0x01-RF channel filter bandwidth register | + |4-bytes 0x00| + |4-byte unsigned RF channel filter bw (in KHz)| + |RegAddr: 0x02-RF gain register | + |7-bytes 0x00| + |1-byte signed RF gain (in dB)| + |RegAddr: 0x03-Baseband gain register | + |4-bytes 0x00| + |4-byte signed baseband filter gain (in dB)| + |RegAddr: 0x10-ADF4350 register | + |4-bytes 0x00| + |4-byte ADF4350 register value (actual ADF4350 reg addr embedded + within 4-byte value)| + |RegAddr: 0x11-SKY73202 register | + |5-bytes 0x00| + |1-byte reg 0 of SKY73202 | + |1-byte reg 1 of SKY73202 | + |1-byte reg 2 of SKY73202 | + |RegAddr: 0x20-Clock Scheme | + |3-bytes 0x00| + |1-byte indicating clocking scheme: + -0x00 -> BURX local TCXO off, BURX accepts ref clock from + USRP (freq of USRP's ref clock specified in bytes 2-5) + -0x01 -> BURX local TCXO on, BURX uses its local TCXO as its ref + clock, TCXO signal output for use by USRP | + |4-byte USRP ref clock freq in hz (only needed if byte 1 set to 0x00) | + + --------------------------------------------------------------------------- + + As an example, lets say the client wants to set an RF center freq of + 1000 MHz. In KHz, this translates to 1000000 (resolution is only down to + steps of 1 KHz), which is 0x000F4240 in hex. So the complete 9-byte I2C + sequence that the client should send is as follows: + byte 0: 0x00-register 0x00 is the target of the write operation + bytes 1-4: 0x00 (padding) + byte 5: 0x40 (LSB of the 1000000 KHz value, in hex) + byte 6: 0x42 + byte 7: 0x0F + byte 8: 0x00 (MSB of the 1000000 KHz value, in hex) + + If using the usrper cmd-line application on a PC, this sequence would + be sent as follows (assuming that the BURX is in slot A): + + # usrper i2c_write 0x47 000000000040420F00 + + How about another example...lets say the client wants to setup the clock + scheme to use scheme #1 where the 26 MHz TCXO on the BURX board is enabled, + and is provided to the USRP. 26 MHz (i.e. 26 million), in hex, is 0x18CBA80. + So the complete 9-byte I2C sequence that the client should send is as follows: + byte 0: 0x20-register 0x20 is the target of the write operation + bytes 1-3: 0x00 (padding) + byte 4: 0x01 (indicating that clock scheme #1 is wanted) + byte 5: 0x80 (LSB of the BURX ref clk freq) + byte 6: 0xBA + byte 7: 0x8C + byte 8: 0x01 (MSB of the BURX ref clk freq) + + To enable the BURX local ref clk, which will also make it available on the + on-board U.FL connector as a source for the USRP, a user can also use + the usrper cmd-line application on a PC. The following sequence would + be sent (assuming that the BURX is in slot A): + + # usrper i2c_write 0x47 200000000180BA8C01 + +*/ + +#define NUM_BYTES_IN_I2C_CMD 9 + +/*****************************************************************************/ + +db_bitshark_rx::db_bitshark_rx(usrp_basic_sptr _usrp, int which) + : db_base(_usrp, which) +{ + // Control Bitshark receiver USRP daughterboard. + // + // @param usrp: instance of usrp.source_c + // @param which: which side: 0, 1 corresponding to RX_A or RX_B respectively + + // turn off all outputs + usrp()->_write_oe(d_which, 0, 0xffff); + + if (which == 0) + { + d_i2c_addr = 0x47; + } + else + { + d_i2c_addr = 0x45; + } + + // initialize gain + set_gain((gain_min() + gain_max()) / 2.0); + + // by default, assume we're using the USRPs clock as the ref clk, + // so setup the clock scheme and frequency. If the user wants + // to use the Bitshark's TCXO, the clock scheme should be set + // to 1, the freq should be set to 26000000, and a top-level + // 'make' and 'make install' needs to be executed. In addition, + // a U.FL to SMA cable needs to connect J6 on the Bitshark to + // the external clk input on the USRP + set_clock_scheme(0,64000000); + + set_bw(8e6); // Default IF bandwidth to match USRP1 max host bandwidth + + bypass_adc_buffers(true); +} + +db_bitshark_rx::~db_bitshark_rx() +{ + shutdown(); +} + +/************ Private Functions **********************/ + +void +db_bitshark_rx::_set_pga(int pga_gain) +{ + assert(pga_gain>=0 && pga_gain<=20); + if(d_which == 0) + { + usrp()->set_pga (0, pga_gain); + usrp()->set_pga (1, pga_gain); + } + else + { + usrp()->set_pga (2, pga_gain); + usrp()->set_pga (3, pga_gain); + } +} + +/************ Public Functions **********************/ +void +db_bitshark_rx::shutdown() +{ + if (!d_is_shutdown) + { + d_is_shutdown = true; + } +} + +bool +db_bitshark_rx::set_bw (float bw) +{ + std::vector<int> args(NUM_BYTES_IN_I2C_CMD,0); + uint16_t rf_bw_in_khz = (uint16_t)(bw/1000.0); + char val[4]; + bool result = false; + uint8_t try_count = 0; + + memset(val,0x00,4); + if (rf_bw_in_khz < 660 || rf_bw_in_khz > 56000) + { + fprintf(stderr, "db_bitshark_rx::set_bw: bw (=%d) must be between 660 KHz and 56 MHz inclusive\n", rf_bw_in_khz); + return false; + } + //fprintf(stdout,"Setting bw: requested bw in khz is %d\r\n",rf_bw_in_khz); + memcpy(val,&rf_bw_in_khz,4); + args[0] = RF_CHAN_FILTER_BW_REG; + args[5] = val[0]; + args[6] = val[1]; + args[7] = val[2]; + args[8] = val[3]; + while ((result != true) && (try_count < 3)) + { + result=usrp()->write_i2c (d_i2c_addr, int_seq_to_str (args)); + try_count++; + } + + if (result == false) + { + fprintf(stderr, "db_bitshark_rx:set_bw: giving up after 3 tries without success\n"); + } + + return result; +} + +/* The gain referenced below is RF gain only. There are two independent + gain settings at RF: a digital step attenuator (providing 0, -6, -12, and + -18 dB of attenuation), and a second LNA (LNA2) that provides ~25 dB of + gain (roughly...it actually depends on the RF freq). So combining these + two stages can provide an overall gain range from 0 (which is mapped + to -18 dB on the step attenuator + LNA2 turned off) to 42 (which is + mapped to 0 dB on the step attenuator + LNA2 turned on). + + There could be better ways to map these, but this is sufficient for + now. */ +float +db_bitshark_rx::gain_min() +{ + return 0; +} + +float +db_bitshark_rx::gain_max() +{ + return 42; +} + +float +db_bitshark_rx::gain_db_per_step() +{ + return 6; +} + +bool +db_bitshark_rx::set_gain(float gain) +{ + // Set the gain. + // + // @param gain: RF gain in decibels, range of 0-42 + // @returns True/False + + std::vector<int> args(NUM_BYTES_IN_I2C_CMD,0); + bool result = false; + uint8_t try_count = 0; + + if (gain < gain_min() || gain > gain_max()) + { + fprintf(stderr,"db_bitshark_rx::set_gain: gain (=%f) must be between %f and %f inclusive\n", gain,gain_min(),gain_max()); + return false; + } + //fprintf(stdout,"db_bitshark_rx::set_gain: requested gain of %f\r\n",gain); + args[0] = RF_GAIN_REG; + args[5] = (int)gain; + + while ((result != true) && (try_count < 3)) + { + result=usrp()->write_i2c (d_i2c_addr, int_seq_to_str (args)); + try_count++; + } + + if (result == false) + { + fprintf(stderr, "db_bitshark_rx:set_gain: giving up after 3 tries without success\n"); + } + + return result; +} + + +bool +db_bitshark_rx::set_clock_scheme(uint8_t clock_scheme, uint32_t ref_clk_freq) +{ + // Set the clock scheme for determining how the BURX + // dboard receives its clock. Note: Ideally, the constructor for the + // BURX board could simply call this method to set how it wants the + // clock scheme configured. However, depending on the application + // using the daughterboard, the constructor may run _after_ some + // other portion of the application needs the FPGA. And if the + // the clock source for the FPGA was the BURX's 26 MHz TCXO, we're in + // a chicken-before-the-egg dilemna. So the solution is to leave + // this function here for reference in case an app wants to use it, + // and also give the user the ability to set the clock scheme through + // the usrper cmd-line application (see example at the top of this + // file). + // + // @param clock_scheme + // @param ref_clk_freq in Hz + // @returns True/False + + std::vector<int> args(NUM_BYTES_IN_I2C_CMD,0); + bool result = false; + uint8_t try_count = 0; + char val[4]; + + if (clock_scheme > 1) + { + fprintf(stderr,"db_bitshark_rx::set_clock_scheme: invalid scheme %d\n",clock_scheme); + return false; + } + //fprintf(stdout,"db_bitshark_rx::set_clock_scheme: requested clock schem of %d with freq %d Hz \n",clock_scheme,ref_clk_freq); + memcpy(val,&ref_clk_freq,4); + args[0] = CLOCK_SCHEME_REG; + args[4] = (int)clock_scheme; + args[5] = val[0]; + args[6] = val[1]; + args[7] = val[2]; + args[8] = val[3]; + + while ((result != true) && (try_count < 3)) + { + result=usrp()->write_i2c (d_i2c_addr, int_seq_to_str (args)); + try_count++; + } + + if (result == false) + { + fprintf(stderr, "db_bitshark_rx:set_clock_scheme: giving up after 3 tries without success\n"); + } + return result; +} + +double +db_bitshark_rx::freq_min() +{ + return 300e6; +} + +double +db_bitshark_rx::freq_max() +{ + return 4e9; +} + +struct freq_result_t +db_bitshark_rx::set_freq(double freq) +{ + // Set the frequency. + // + // @param freq: target RF frequency in Hz + // @type freq: double + // + // @returns (ok, actual_baseband_freq) where: + // ok is True or False and indicates success or failure, + // actual_baseband_freq is RF frequency that corresponds to DC in the IF. + + std::vector<int> args(NUM_BYTES_IN_I2C_CMD,0); + std::vector<int> bytes(2); + char val[4]; + freq_result_t act_freq = {false, 0}; + uint32_t freq_in_khz = (uint32_t)(freq/1000.0); + bool result = false; + uint8_t try_count = 0; + + memset(val,0x00,4); + if(!(freq>=freq_min() && freq<=freq_max())) + { + return act_freq; + } + + //fprintf(stdout,"db_bitshark_rx::set_freq: requested freq is %d KHz\n",freq_in_khz); + memcpy(val,&freq_in_khz,4); + args[0] = RF_CENTER_FREQ_REG; + args[5] = val[0]; + args[6] = val[1]; + args[7] = val[2]; + args[8] = val[3]; + + while ((result != true) && (try_count < 3)) + { + result=usrp()->write_i2c (d_i2c_addr, int_seq_to_str (args)); + try_count++; + } + + if (result == false) + { + fprintf(stderr, "db_bitshark_rx:set_freq: giving up after 3 tries without success\n"); + } + + act_freq.ok = result; + act_freq.baseband_freq = (double)freq; + return act_freq; +} + +bool +db_bitshark_rx::is_quadrature() +{ + // Return True if this board requires both I & Q analog channels. + return true; +} + +bool +db_bitshark_rx::i_and_q_swapped() +{ + // Returns True since our I and Q channels are swapped + return true; +} diff --git a/usrp/host/lib/db_boards.cc b/usrp/host/lib/db_boards.cc index 590d8132d..9324d58ee 100644 --- a/usrp/host/lib/db_boards.cc +++ b/usrp/host/lib/db_boards.cc @@ -36,6 +36,7 @@ #include <usrp/db_xcvr2450.h> #include <usrp/db_dtt754.h> #include <usrp/db_dtt768.h> +#include <usrp/db_bitshark_rx.h> #include <cstdio> std::vector<db_base_sptr> @@ -209,6 +210,10 @@ instantiate_dbs(int dbid, usrp_basic_sptr usrp, int which_side) db.push_back(db_base_sptr(new db_dtt768(usrp, which_side))); break; + case(USRP_DBID_BITSHARK_RX): + db.push_back(db_base_sptr(new db_bitshark_rx(usrp, which_side))); + break; + case(-1): if (boost::dynamic_pointer_cast<usrp_basic_tx>(usrp)){ db.push_back(db_base_sptr(new db_basic_tx(usrp, which_side))); diff --git a/usrp/host/lib/db_flexrf.cc b/usrp/host/lib/db_flexrf.cc index 07ac2be3b..2819c19bd 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/db_wbxng.cc b/usrp/host/lib/db_wbxng.cc index bd836dfe3..89200653e 100644 --- a/usrp/host/lib/db_wbxng.cc +++ b/usrp/host/lib/db_wbxng.cc @@ -46,8 +46,8 @@ #define ATTN_SHIFT 8 #define ATTN_MASK (63 << ATTN_SHIFT) -wbxng_base::wbxng_base(usrp_basic_sptr _usrp, int which, int _power_on) - : db_base(_usrp, which), d_power_on(_power_on) +wbxng_base::wbxng_base(usrp_basic_sptr _usrp, int which) + : db_base(_usrp, which) { /* @param usrp: instance of usrp.source_c @@ -67,8 +67,12 @@ wbxng_base::wbxng_base(usrp_basic_sptr _usrp, int which, int _power_on) wbxng_base::~wbxng_base() { - if (d_common) - delete d_common; +} + +int +wbxng_base::_refclk_divisor() +{ + return 1; } struct freq_result_t @@ -83,8 +87,19 @@ wbxng_base::set_freq(double freq) // clamp freq freq_t int_freq = freq_t(std::max(freq_min(), std::min(freq, freq_max()))); - bool ok = d_common->_set_freq(int_freq*2); - double freq_result = (double) d_common->_get_freq()/2.0; + bool ok = d_common->_set_freq(int_freq*2, _refclk_freq()); + + _write_spi(d_common->compute_register(5)); + _write_spi(d_common->compute_register(4)); + _write_spi(d_common->compute_register(3)); + /* load involved registers */ + _write_spi(d_common->compute_register(2)); + _write_spi(d_common->compute_register(1)); + _write_spi(d_common->compute_register(0)); + + double freq_result = (double) d_common->_get_freq(_refclk_freq())/2.0; + + //ok &= _get_locked(); struct freq_result_t args = {ok, freq_result}; /* Wait before reading Lock Detect*/ @@ -144,10 +159,22 @@ wbxng_base::freq_max() return (double) d_common->_get_max_freq()/2.0; } +bool +wbxng_base::_get_locked(void) +{ + return usrp()->read_io(d_which) & PLL_LOCK_DETECT; +} + +void +wbxng_base::_write_spi(std::string data) +{ + usrp()->_write_spi(0, d_spi_enable, d_spi_format, data); +} + // ---------------------------------------------------------------- -wbxng_base_tx::wbxng_base_tx(usrp_basic_sptr _usrp, int which, int _power_on) - : wbxng_base(_usrp, which, _power_on) +db_wbxng_tx::db_wbxng_tx(usrp_basic_sptr _usrp, int which) + : wbxng_base(_usrp, which) { /* @param usrp: instance of usrp.sink_c @@ -161,40 +188,48 @@ wbxng_base_tx::wbxng_base_tx(usrp_basic_sptr _usrp, int which, int _power_on) d_spi_enable = SPI_ENABLE_TX_B; } - d_common = new adf4350(_usrp, d_which, d_spi_enable); + d_common = boost::shared_ptr<adf4350> (new adf4350()); + + /* Initialize the registers. */ + _write_spi(d_common->compute_register(5)); + _write_spi(d_common->compute_register(4)); + _write_spi(d_common->compute_register(3)); + _write_spi(d_common->compute_register(2)); + _write_spi(d_common->compute_register(1)); + _write_spi(d_common->compute_register(0)); // power up the transmit side, but don't enable the mixer - usrp()->_write_oe(d_which,(RX_TXN|TXMOD_EN|ENABLE_33|ENABLE_5), (RX_TXN|TXMOD_EN|ENABLE_33|ENABLE_5)); - usrp()->write_io(d_which, (power_on()|RX_TXN|ENABLE_33|ENABLE_5), (RX_TXN|ENABLE_33|ENABLE_5)); + usrp()->_write_oe(d_which,(PLL_CE|PLL_PDBRF|RX_TXN|TXMOD_EN|ENABLE_33|ENABLE_5), (PLL_CE|PLL_PDBRF|RX_TXN|TXMOD_EN|ENABLE_33|ENABLE_5)); + usrp()->write_io(d_which, (PLL_CE|RX_TXN|ENABLE_33|ENABLE_5), (PLL_CE|PLL_PDBRF|RX_TXN|ENABLE_33|ENABLE_5)); //set_lo_offset(4e6); // Disable VCO/PLL - d_common->_enable(true); + //d_common->_enable(true); + usrp()->write_io(d_which, (PLL_PDBRF), (PLL_PDBRF)); - set_gain((gain_min() + gain_max()) / 2.0); // initialize gain + set_gain(gain_min()); // initialize gain } -wbxng_base_tx::~wbxng_base_tx() +db_wbxng_tx::~db_wbxng_tx() { shutdown(); } - void -wbxng_base_tx::shutdown() +db_wbxng_tx::shutdown() { - // fprintf(stderr, "wbxng_base_tx::shutdown d_is_shutdown = %d\n", d_is_shutdown); + // fprintf(stderr, "db_wbxng_tx::shutdown d_is_shutdown = %d\n", d_is_shutdown); if (!d_is_shutdown){ d_is_shutdown = true; // do whatever there is to do to shutdown // Disable VCO/PLL - d_common->_enable(false); + //d_common->_enable(false); + usrp()->write_io(d_which, 0, (PLL_PDBRF)); // Power down and leave the T/R switch in the R position - usrp()->write_io(d_which, (power_off()|RX_TXN), (RX_TXN|ENABLE_33|ENABLE_5)); - + usrp()->write_io(d_which, (RX_TXN), (PLL_CE|PLL_PDBRF|RX_TXN|ENABLE_33|ENABLE_5)); /* _write_control(_compute_control_reg()); @@ -205,7 +240,7 @@ wbxng_base_tx::shutdown() } bool -wbxng_base_tx::set_auto_tr(bool on) +db_wbxng_tx::set_auto_tr(bool on) { bool ok = true; if(on) { @@ -222,7 +257,7 @@ wbxng_base_tx::set_auto_tr(bool on) } bool -wbxng_base_tx::set_enable(bool on) +db_wbxng_tx::set_enable(bool on) { /* Enable transmitter if on is true @@ -244,25 +279,25 @@ wbxng_base_tx::set_enable(bool on) } float -wbxng_base_tx::gain_min() +db_wbxng_tx::gain_min() { return 0.0; } float -wbxng_base_tx::gain_max() +db_wbxng_tx::gain_max() { return 25.0; } float -wbxng_base_tx::gain_db_per_step() +db_wbxng_tx::gain_db_per_step() { return gain_max()/(1+(1.4-0.5)*4096/3.3); } bool -wbxng_base_tx::set_gain(float gain) +db_wbxng_tx::set_gain(float gain) { /* Set the gain. @@ -299,8 +334,8 @@ wbxng_base_tx::set_gain(float gain) /**************************************************************************/ -wbxng_base_rx::wbxng_base_rx(usrp_basic_sptr _usrp, int which, int _power_on) - : wbxng_base(_usrp, which, _power_on) +db_wbxng_rx::db_wbxng_rx(usrp_basic_sptr _usrp, int which) + : wbxng_base(_usrp, which) { /* @param usrp: instance of usrp.source_c @@ -314,15 +349,24 @@ wbxng_base_rx::wbxng_base_rx(usrp_basic_sptr _usrp, int which, int _power_on) d_spi_enable = SPI_ENABLE_RX_B; } - d_common = new adf4350(_usrp, d_which, d_spi_enable); - - // Disable VCO/PLL - d_common->_enable(true); + d_common = boost::shared_ptr<adf4350> (new adf4350()); - usrp()->_write_oe(d_which, (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5), (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5)); - usrp()->write_io(d_which, (power_on()|RX2_RX1N|RXBB_EN|ENABLE_33|ENABLE_5), (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5)); + /* Initialize the registers. */ + _write_spi(d_common->compute_register(5)); + _write_spi(d_common->compute_register(4)); + _write_spi(d_common->compute_register(3)); + _write_spi(d_common->compute_register(2)); + _write_spi(d_common->compute_register(1)); + _write_spi(d_common->compute_register(0)); + + usrp()->_write_oe(d_which, (PLL_CE|PLL_PDBRF|RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5), (PLL_CE|PLL_PDBRF|RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5)); + usrp()->write_io(d_which, (PLL_CE|RX2_RX1N|RXBB_EN|ENABLE_33|ENABLE_5), (PLL_CE|PLL_PDBRF|RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5)); //fprintf(stderr,"Setting WBXNG RXBB on"); + // Enable VCO/PLL + //d_common->_enable(true); + usrp()->write_io(d_which, (PLL_PDBRF), (PLL_PDBRF)); + // set up for RX on TX/RX port select_rx_antenna("TX/RX"); @@ -331,43 +375,46 @@ wbxng_base_rx::wbxng_base_rx(usrp_basic_sptr _usrp, int which, int _power_on) /* set_lo_offset(-4e6); */ + + set_gain(gain_min()); // initialize gain } -wbxng_base_rx::~wbxng_base_rx() +db_wbxng_rx::~db_wbxng_rx() { shutdown(); } void -wbxng_base_rx::shutdown() +db_wbxng_rx::shutdown() { - // fprintf(stderr, "wbxng_base_rx::shutdown d_is_shutdown = %d\n", d_is_shutdown); + // fprintf(stderr, "db_wbxng_rx::shutdown d_is_shutdown = %d\n", d_is_shutdown); if (!d_is_shutdown){ d_is_shutdown = true; // do whatever there is to do to shutdown // Power down VCO/PLL - d_common->_enable(false); + //d_common->_enable(false); + usrp()->write_io(d_which, 0, (PLL_PDBRF)); - // fprintf(stderr, "wbxng_base_rx::shutdown before _write_control\n"); + // fprintf(stderr, "db_wbxng_rx::shutdown before _write_control\n"); //_write_control(_compute_control_reg()); - // fprintf(stderr, "wbxng_base_rx::shutdown before _enable_refclk\n"); + // fprintf(stderr, "db_wbxng_rx::shutdown before _enable_refclk\n"); _enable_refclk(false); // turn off refclk - // fprintf(stderr, "wbxng_base_rx::shutdown before set_auto_tr\n"); + // fprintf(stderr, "db_wbxng_rx::shutdown before set_auto_tr\n"); set_auto_tr(false); // Power down - usrp()->write_io(d_which, power_off(), (RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5)); + usrp()->write_io(d_which, 0, (PLL_CE|PLL_PDBRF|RX2_RX1N|RXBB_EN|ATTN_MASK|ENABLE_33|ENABLE_5)); - // fprintf(stderr, "wbxng_base_rx::shutdown after set_auto_tr\n"); + // fprintf(stderr, "db_wbxng_rx::shutdown after set_auto_tr\n"); } } bool -wbxng_base_rx::set_auto_tr(bool on) +db_wbxng_rx::set_auto_tr(bool on) { bool ok = true; if(on) { @@ -384,7 +431,7 @@ wbxng_base_rx::set_auto_tr(bool on) } bool -wbxng_base_rx::select_rx_antenna(int which_antenna) +db_wbxng_rx::select_rx_antenna(int which_antenna) { /* Specify which antenna port to use for reception. @@ -404,7 +451,7 @@ wbxng_base_rx::select_rx_antenna(int which_antenna) } bool -wbxng_base_rx::select_rx_antenna(const std::string &which_antenna) +db_wbxng_rx::select_rx_antenna(const std::string &which_antenna) { /* Specify which antenna port to use for reception. @@ -426,7 +473,7 @@ wbxng_base_rx::select_rx_antenna(const std::string &which_antenna) } bool -wbxng_base_rx::set_gain(float gain) +db_wbxng_rx::set_gain(float gain) { /* Set the gain. @@ -441,7 +488,6 @@ wbxng_base_rx::set_gain(float gain) float pga_gain, agc_gain; float maxgain = gain_max() - usrp()->pga_max(); - float mingain = gain_min(); if(gain > maxgain) { pga_gain = gain-maxgain; assert(pga_gain <= usrp()->pga_max()); @@ -456,7 +502,7 @@ wbxng_base_rx::set_gain(float gain) } bool -wbxng_base_rx::_set_attn(float attn) +db_wbxng_rx::_set_attn(float attn) { int attn_code = int(floor(attn/0.5)); unsigned int iobits = (~attn_code) << ATTN_SHIFT; @@ -464,27 +510,6 @@ wbxng_base_rx::_set_attn(float attn) return usrp()->write_io(d_which, iobits, ATTN_MASK); } -// ---------------------------------------------------------------- - -db_wbxng_tx::db_wbxng_tx(usrp_basic_sptr usrp, int which) - : wbxng_base_tx(usrp, which) -{ -} - -db_wbxng_tx::~db_wbxng_tx() -{ -} - -db_wbxng_rx::db_wbxng_rx(usrp_basic_sptr usrp, int which) - : wbxng_base_rx(usrp, which) -{ - set_gain((gain_min() + gain_max()) / 2.0); // initialize gain -} - -db_wbxng_rx::~db_wbxng_rx() -{ -} - float db_wbxng_rx::gain_min() { @@ -503,7 +528,6 @@ db_wbxng_rx::gain_db_per_step() return 0.05; } - bool db_wbxng_rx::i_and_q_swapped() { diff --git a/usrp/host/lib/db_wbxng_adf4350.cc b/usrp/host/lib/db_wbxng_adf4350.cc index c17e8d670..f1ab63d82 100644 --- a/usrp/host/lib/db_wbxng_adf4350.cc +++ b/usrp/host/lib/db_wbxng_adf4350.cc @@ -27,9 +27,7 @@ #include <stdio.h> #define FREQ_C(freq) uint64_t(freq) -#define INPUT_REF_FREQ FREQ_C(64e6) #define DIV_ROUND(num, denom) (((num) + ((denom)/2))/(denom)) -#define INPUT_REF_FREQ_2X (2*INPUT_REF_FREQ) /* input ref freq with doubler turned on */ #define MIN_INT_DIV uint16_t(23) /* minimum int divider, prescaler 4/5 only */ #define MAX_RF_DIV uint8_t(16) /* max rf divider, divides rf output */ #define MIN_VCO_FREQ FREQ_C(2.2e9) /* minimum vco freq */ @@ -42,95 +40,46 @@ #define MUX_PIN (1 << 1) #define LD_PIN (1 << 0) -adf4350::adf4350(usrp_basic_sptr _usrp, int _which, int _spi_enable) +adf4350::adf4350() { - /* Initialize the pin directions. */ - - d_usrp = _usrp; - d_which = _which; - d_spi_enable = _spi_enable; - d_spi_format = SPI_FMT_MSB | SPI_FMT_HDR_0; - - d_regs = new adf4350_regs(this); - - /* Outputs */ - d_usrp->_write_oe(d_which, (CE_PIN | PDB_RF_PIN), (CE_PIN | PDB_RF_PIN)); - d_usrp->write_io(d_which, (CE_PIN), (CE_PIN | PDB_RF_PIN)); - - /* Initialize the pin levels. */ - _enable(true); - /* Initialize the registers. */ - d_regs->_load_register(5); - d_regs->_load_register(4); - d_regs->_load_register(3); - d_regs->_load_register(2); - d_regs->_load_register(1); - d_regs->_load_register(0); + d_regs = new adf4350_regs(); } adf4350::~adf4350() { - d_usrp->write_io(d_which, (0), (CE_PIN | PDB_RF_PIN)); delete d_regs; } -freq_t -adf4350::_get_max_freq(void) -{ - return MAX_FREQ; -} - -freq_t -adf4350::_get_min_freq(void) -{ - return MIN_FREQ; -} - -bool -adf4350::_get_locked(void) -{ - return d_usrp->read_io(d_which) & LD_PIN; -} - -void -adf4350::_enable(bool enable) +std::string +adf4350::compute_register(uint8_t addr) { - if (enable){ /* chip enable */ - d_usrp->write_io(d_which, (PDB_RF_PIN), (PDB_RF_PIN)); - }else{ - d_usrp->write_io(d_which, 0, (PDB_RF_PIN)); - } -} + uint32_t data = d_regs->compute_register(addr); -void -adf4350::_write(uint8_t addr, uint32_t data) -{ data |= addr; - // create str from data here + // create std::string from data here char s[4]; s[0] = (char)((data >> 24) & 0xff); s[1] = (char)((data >> 16) & 0xff); s[2] = (char)((data >> 8) & 0xff); s[3] = (char)(data & 0xff); - std::string str(s, 4); - - timespec t; - t.tv_sec = 0; - t.tv_nsec = 5e6; + return std::string(s, 4); +} - nanosleep(&t, NULL); - d_usrp->_write_spi(0, d_spi_enable, d_spi_format, str); - nanosleep(&t, NULL); +freq_t +adf4350::_get_max_freq(void) +{ + return MAX_FREQ; +} - //fprintf(stderr, "Wrote to WBXNG SPI address %d with data %8x\n", addr, data); - /* pulse latch */ - //d_usrp->write_io(d_which, 1, LE_PIN); - //d_usrp->write_io(d_which, 0, LE_PIN); +freq_t +adf4350::_get_min_freq(void) +{ + return MIN_FREQ; } bool -adf4350::_set_freq(freq_t freq) +adf4350::_set_freq(freq_t freq, freq_t refclock_freq) { /* Set the frequency by setting int, frac, mod, r, div */ if (freq > MAX_FREQ || freq < MIN_FREQ) return false; @@ -147,7 +96,7 @@ adf4350::_set_freq(freq_t freq) d_regs->d_divider_select++; //double the divider } /* Ramp up the R divider until the N divider is at least the minimum. */ - //d_regs->d_10_bit_r_counter = INPUT_REF_FREQ*MIN_INT_DIV/freq; + //d_regs->d_10_bit_r_counter = refclock_freq*MIN_INT_DIV/freq; d_regs->d_10_bit_r_counter = 2; uint64_t n_mod; do{ @@ -155,7 +104,7 @@ adf4350::_set_freq(freq_t freq) n_mod = freq; n_mod *= d_regs->d_10_bit_r_counter; n_mod *= d_regs->d_mod; - n_mod /= INPUT_REF_FREQ; + n_mod /= refclock_freq; /* calculate int and frac */ d_regs->d_int = n_mod/d_regs->d_mod; d_regs->d_frac = (n_mod - (freq_t)d_regs->d_int*d_regs->d_mod) & uint16_t(0xfff); @@ -169,38 +118,31 @@ adf4350::_set_freq(freq_t freq) }while(d_regs->d_int < min_int_div); /* calculate the band select so PFD is under 125 KHz */ d_regs->d_8_bit_band_select_clock_divider_value = \ - INPUT_REF_FREQ/(FREQ_C(30e3)*d_regs->d_10_bit_r_counter) + 1; + refclock_freq/(FREQ_C(30e3)*d_regs->d_10_bit_r_counter) + 1; /* fprintf(stderr, "Band Selection: Div %u, Freq %lu\n", d_regs->d_8_bit_band_select_clock_divider_value, - INPUT_REF_FREQ/(d_regs->d_8_bit_band_select_clock_divider_value * d_regs->d_10_bit_r_counter) + 1 + refclock_freq/(d_regs->d_8_bit_band_select_clock_divider_value * d_regs->d_10_bit_r_counter) + 1 ); */ - d_regs->_load_register(5); - d_regs->_load_register(3); - d_regs->_load_register(1); - /* load involved registers */ - d_regs->_load_register(2); - d_regs->_load_register(4); - d_regs->_load_register(0); /* register 0 must be last */ return true; } freq_t -adf4350::_get_freq(void) +adf4350::_get_freq(freq_t refclock_freq) { /* Calculate the freq from int, frac, mod, ref, r, div: * freq = (int + frac/mod) * (ref/r) * Keep precision by doing multiplies first: * freq = (((((((int)*mod) + frac)*ref)/mod)/r)/div) */ - uint64_t temp; - temp = d_regs->d_int; - temp *= d_regs->d_mod; - temp += d_regs->d_frac; - temp *= INPUT_REF_FREQ; - temp /= d_regs->d_mod; - temp /= d_regs->d_10_bit_r_counter; - temp /= (1 << d_regs->d_divider_select); - return temp; + uint64_t freq; + freq = d_regs->d_int; + freq *= d_regs->d_mod; + freq += d_regs->d_frac; + freq *= refclock_freq; + freq /= d_regs->d_mod; + freq /= d_regs->d_10_bit_r_counter; + freq /= (1 << d_regs->d_divider_select); + return freq; } diff --git a/usrp/host/lib/db_wbxng_adf4350.h b/usrp/host/lib/db_wbxng_adf4350.h index 2b0783c20..ce8cbf4b1 100644 --- a/usrp/host/lib/db_wbxng_adf4350.h +++ b/usrp/host/lib/db_wbxng_adf4350.h @@ -31,22 +31,16 @@ class adf4350_regs; class adf4350 { public: - adf4350(usrp_basic_sptr _usrp, int _which, int _spi_enable); + adf4350(); ~adf4350(); void _update(); - bool _get_locked(); - void _enable(bool enable); - void _write(uint8_t addr, uint32_t data); - bool _set_freq(freq_t freq); - freq_t _get_freq(); + std::string compute_register(uint8_t addr); + bool _set_freq(freq_t freq, freq_t refclock_freq); + freq_t _get_freq(freq_t refclock_freq); freq_t _get_max_freq(); freq_t _get_min_freq(); protected: - usrp_basic_sptr d_usrp; - int d_which; - int d_spi_enable; - int d_spi_format; adf4350_regs *d_regs; }; diff --git a/usrp/host/lib/db_wbxng_adf4350_regs.cc b/usrp/host/lib/db_wbxng_adf4350_regs.cc index 21d77dcce..c9707c3c6 100644 --- a/usrp/host/lib/db_wbxng_adf4350_regs.cc +++ b/usrp/host/lib/db_wbxng_adf4350_regs.cc @@ -55,8 +55,7 @@ const uint8_t adf4350_regs::s_output_power = 3; /* reg 5 */ const uint8_t adf4350_regs::s_ld_pin_mode = 1; -adf4350_regs::adf4350_regs(adf4350* _adf4350){ - d_adf4350 = _adf4350; +adf4350_regs::adf4350_regs(){ /* reg 0 */ d_int = uint16_t(100); @@ -79,19 +78,21 @@ adf4350_regs::~adf4350_regs(void){ uint32_t adf4350_regs::_reg_shift(uint32_t data, uint32_t shift){ return data << shift; - } +} -void -adf4350_regs::_load_register(uint8_t addr){ - uint32_t data; +uint32_t +adf4350_regs::compute_register(uint8_t addr){ + uint32_t data = 0; switch (addr){ case 0: data = ( _reg_shift(d_int, 15) | - _reg_shift(d_frac, 3)); break; + _reg_shift(d_frac, 3)); + break; case 1: data = ( _reg_shift(d_prescaler, 27) | _reg_shift(s_phase, 15) | - _reg_shift(d_mod, 3)); break; + _reg_shift(d_mod, 3)); + break; case 2: data = ( _reg_shift(s_low_noise_and_low_spur_modes, 29) | _reg_shift(s_muxout, 26) | @@ -105,11 +106,13 @@ adf4350_regs::_load_register(uint8_t addr){ _reg_shift(s_pd_polarity, 6) | _reg_shift(s_power_down, 5) | _reg_shift(s_cp_three_state, 4) | - _reg_shift(s_counter_reset, 3)); break; + _reg_shift(s_counter_reset, 3)); + break; case 3: data = ( _reg_shift(s_csr, 18) | _reg_shift(s_clk_div_mode, 15) | - _reg_shift(s_12_bit_clock_divider_value, 3)); break; + _reg_shift(s_12_bit_clock_divider_value, 3)); + break; case 4: data = ( _reg_shift(s_feedback_select, 23) | _reg_shift(d_divider_select, 20) | @@ -120,11 +123,14 @@ adf4350_regs::_load_register(uint8_t addr){ _reg_shift(s_aux_output_enable, 8) | _reg_shift(s_aux_output_power, 6) | _reg_shift(s_rf_output_enable, 5) | - _reg_shift(s_output_power, 3)); break; + _reg_shift(s_output_power, 3)); + break; case 5: data = ( - _reg_shift(s_ld_pin_mode, 22)); break; - default: return; + _reg_shift(s_ld_pin_mode, 22)); + break; + default: return data; } - /* write the data out to spi */ - d_adf4350->_write(addr, data); + /* return the data to write out to spi */ + return data; } + diff --git a/usrp/host/lib/db_wbxng_adf4350_regs.h b/usrp/host/lib/db_wbxng_adf4350_regs.h index 0018aa07f..33a548e85 100644 --- a/usrp/host/lib/db_wbxng_adf4350_regs.h +++ b/usrp/host/lib/db_wbxng_adf4350_regs.h @@ -29,13 +29,11 @@ class adf4350; class adf4350_regs { public: - adf4350_regs(adf4350* _adf4350); + adf4350_regs(); ~adf4350_regs(); - adf4350* d_adf4350; - uint32_t _reg_shift(uint32_t data, uint32_t shift); - void _load_register(uint8_t addr); + uint32_t compute_register(uint8_t addr); /* reg 0 */ uint16_t d_int; @@ -75,6 +73,11 @@ public: static const uint8_t s_output_power; /* reg 5 */ static const uint8_t s_ld_pin_mode; + +protected: + usrp_basic_sptr d_usrp; + int d_spi_enable; + int d_spi_format; }; #endif /* ADF4350_REGS_H */ diff --git a/usrp/host/lib/usrp_dbid.dat b/usrp/host/lib/usrp_dbid.dat index 7d1e18714..2548d737e 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 @@ -84,5 +87,7 @@ "XCVR2450 Tx" 0x0060 "XCVR2450 Rx" 0x0061 +"Bitshark Rx" 0x0070 + "Experimental Tx" 0xfffe "Experimental Rx" 0xffff diff --git a/usrp/limbo/apps-inband/.gitignore b/usrp/limbo/apps-inband/.gitignore deleted file mode 100644 index f62d9e1de..000000000 --- a/usrp/limbo/apps-inband/.gitignore +++ /dev/null @@ -1,35 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/*.dat -/.*.swp -/usrper -/usrper2 -/test_input -/test_fusb -/test_usrp -/test_usrp0 -/test_usrp_standard_rx -/test_usrp_standard_tx -/test_usrp_standard_2tx -/test_usrp_inband_timestamps -/test_usrp_inband_registers -/test_usrp_inband_rx -/test_usrp_inband_2rx -/test_usrp_inband_tx -/test_usrp_inband_2tx -/test_usrp_basic_rx -/check_order_quickly -/usrp_cal_dc_offset -/test_usrp_inband_cs -/read_packets -/test_usrp_inband_ping -/test_usrp_inband_underrun -/test_usrp_inband_overrun -/gmac_mbh.cc -/test_gmac_tx diff --git a/usrp/limbo/apps-inband/Makefile.am b/usrp/limbo/apps-inband/Makefile.am deleted file mode 100644 index 0a44d8112..000000000 --- a/usrp/limbo/apps-inband/Makefile.am +++ /dev/null @@ -1,77 +0,0 @@ -# -# Copyright 2003,2006,2008 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -AM_CPPFLAGS = \ - $(DEFINES) $(OMNITHREAD_INCLUDES) $(PMT_INCLUDES) $(MBLOCK_INCLUDES) \ - $(USRP_INCLUDES) $(USRP_INBAND_INCLUDES) $(BOOST_CPPFLAGS) \ - $(CPPUNIT_INCLUDES) $(WITH_INCLUDES) -I$(top_srcdir)/mblock/src/lib - - -bin_PROGRAMS = - -noinst_PROGRAMS = \ - test_usrp_inband_ping \ - test_usrp_inband_registers \ - test_usrp_inband_rx \ - test_usrp_inband_2rx \ - test_usrp_inband_tx \ - test_usrp_inband_2tx \ - test_usrp_inband_timestamps \ - test_usrp_inband_overrun \ - test_usrp_inband_underrun \ - read_packets - -noinst_HEADERS = \ - ui_nco.h \ - ui_sincos.h - - -test_usrp_inband_ping_SOURCES = test_usrp_inband_ping.cc -test_usrp_inband_ping_LDADD = $(USRP_LA) $(USRP_INBAND_LA) - -test_usrp_inband_tx_SOURCES = test_usrp_inband_tx.cc ui_sincos.c -test_usrp_inband_tx_LDADD = $(USRP_LA) $(USRP_INBAND_LA) - -test_usrp_inband_2tx_SOURCES = test_usrp_inband_2tx.cc ui_sincos.c -test_usrp_inband_2tx_LDADD = $(USRP_LA) $(USRP_INBAND_LA) - -test_usrp_inband_timestamps_SOURCES = test_usrp_inband_timestamps.cc ui_sincos.c -test_usrp_inband_timestamps_LDADD = $(USRP_LA) $(USRP_INBAND_LA) - -test_usrp_inband_registers_SOURCES = test_usrp_inband_registers.cc ui_sincos.c -test_usrp_inband_registers_LDADD = $(USRP_LA) $(USRP_INBAND_LA) - -test_usrp_inband_overrun_SOURCES = test_usrp_inband_overrun.cc -test_usrp_inband_overrun_LDADD = $(USRP_LA) $(USRP_INBAND_LA) - -test_usrp_inband_underrun_SOURCES = test_usrp_inband_underrun.cc -test_usrp_inband_underrun_LDADD = $(USRP_LA) $(USRP_INBAND_LA) - -test_usrp_inband_rx_SOURCES = test_usrp_inband_rx.cc ui_sincos.c -test_usrp_inband_rx_LDADD = $(USRP_LA) $(USRP_INBAND_LA) - -test_usrp_inband_2rx_SOURCES = test_usrp_inband_2rx.cc ui_sincos.c -test_usrp_inband_2rx_LDADD = $(USRP_LA) $(USRP_INBAND_LA) - -read_packets_SOURCES = read_packets.cc -read_packets_LDADD = $(USRP_LA) $(USRP_INBAND_LA) diff --git a/usrp/limbo/apps-inband/read_packets.cc b/usrp/limbo/apps-inband/read_packets.cc deleted file mode 100644 index 24a1e88b5..000000000 --- a/usrp/limbo/apps-inband/read_packets.cc +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <iostream> -#include <usrp_inband_usb_packet.h> -#include <mblock/class_registry.h> -#include <vector> -#include <usrp_usb_interface.h> -#include <fstream> - -typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit easy - -int main(int argc, char *argv[]) { - - if(argc !=2) { - std::cout << "Usage: ./read_packets <data_file>\n"; - return -1; - } - - std::ifstream infile; - std::ofstream outfile; - - unsigned int pkt_size = transport_pkt::max_pkt_size(); - unsigned int pkt_num=0; - - transport_pkt *pkt; - char pkt_data[pkt_size]; // allocate the number of bytes for a single packet - - pkt = (transport_pkt *)pkt_data; // makes operations cleaner to read - - // Open the file and read the packets, dumping information - infile.open(argv[1], std::ios::binary|std::ios::in); - if(!infile.is_open()) - exit(-1); - - //outfile.open("dump.dat",std::ios::out|std::ios::binary); - - // read 1 packet in to the memory - infile.read(pkt_data, pkt_size); - - while(!infile.eof()) { - - printf("Packet %u\n", pkt_num); - - if(pkt->start_of_burst()) - printf("\tstart of burst\n"); - - if(pkt->end_of_burst()) - printf("\tend of burst\n"); - -// if(pkt->carrier_sense()) -// printf("\tcarrier sense\n"); - - if(pkt->underrun()) - printf("\tunderrun\n"); - - if(pkt->overrun()) - printf("\toverrun\n"); - - printf("\tchannel: \t0x%x\n", pkt->chan()); - printf("\ttimestamp: \t0x%x\n", pkt->timestamp()); - //printf("\ttimestamp: \t%u\n", pkt->timestamp()); - printf("\tlength: \t%u\n", pkt->payload_len()); - printf("\trssi: \t%u\n", pkt->rssi()); - - printf("\tpayload: \n"); - for(int i=0; i < pkt->payload_len(); i++) - //for(int i=0; i < pkt->max_payload(); i++) - { - printf("\t%d\t0x%x\n", i, *(pkt->payload()+i)); - //outfile.write((const char*)(pkt->payload()+i),1); - //printf("\t\t0x%x\n", pkt->payload()+i); - - } - printf("\n\n"); - - pkt_num++; - - // read 1 packet in to the memory - infile.read(pkt_data, pkt_size); - - } - - infile.close(); - //outfile.close(); - -} diff --git a/usrp/limbo/apps-inband/test_usrp_inband_2rx.cc b/usrp/limbo/apps-inband/test_usrp_inband_2rx.cc deleted file mode 100644 index c210f196a..000000000 --- a/usrp/limbo/apps-inband/test_usrp_inband_2rx.cc +++ /dev/null @@ -1,371 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/mblock.h> -#include <mblock/runtime.h> -#include <mb_runtime_nop.h> // QA only -#include <mblock/protocol_class.h> -#include <mblock/exception.h> -#include <mblock/msg_queue.h> -#include <mblock/message.h> -#include <mb_mblock_impl.h> -#include <mblock/msg_accepter.h> -#include <mblock/class_registry.h> -#include <pmt.h> -#include <stdio.h> -#include <string.h> -#include <iostream> -#include <fstream> - -// Include the symbols needed for communication with USRP server -#include <symbols_usrp_server_cs.h> -#include <symbols_usrp_channel.h> -#include <symbols_usrp_low_level_cs.h> -#include <symbols_usrp_rx.h> - -static bool verbose = true; - -class test_usrp_rx : public mb_mblock -{ - mb_port_sptr d_rx; - mb_port_sptr d_cs; - pmt_t d_rx_chan0, d_rx_chan1; - - enum state_t { - INIT, - OPENING_USRP, - ALLOCATING_CHANNEL, - RECEIVING, - CLOSING_CHANNEL, - CLOSING_USRP, - }; - - state_t d_state; - - std::ofstream d_ofile; - - long d_samples_recvd; - long d_samples_to_recv; - - public: - test_usrp_rx(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~test_usrp_rx(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void open_usrp(); - void close_usrp(); - void allocate_channel(); - void send_packets(); - void enter_receiving(); - void build_and_send_next_frame(); - void handle_response_recv_raw_samples(pmt_t invocation_handle); - void enter_closing_channel(); -}; - -test_usrp_rx::test_usrp_rx(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_rx_chan0(PMT_NIL), d_rx_chan1(PMT_NIL), - d_samples_recvd(0), - d_samples_to_recv(20e6) -{ - d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - // Pass a dictionary to usrp_server which specifies which interface to use, the stub or USRP - pmt_t usrp_dict = pmt_make_dict(); - - // To test the application without a USRP - bool fake_usrp_p = false; - if(fake_usrp_p) { - pmt_dict_set(usrp_dict, - pmt_intern("fake-usrp"), - PMT_T); - } - - // Specify the RBF to use - pmt_dict_set(usrp_dict, - pmt_intern("rbf"), - pmt_intern("inband_2rxhb_2tx.rbf")); - - pmt_dict_set(usrp_dict, - pmt_intern("decim-rx"), - pmt_from_long(64)); - - define_component("server", "usrp_server", usrp_dict); - - connect("self", "rx0", "server", "rx0"); - connect("self", "cs", "server", "cs"); - -} - -test_usrp_rx::~test_usrp_rx() -{ -} - -void -test_usrp_rx::initial_transition() -{ - open_usrp(); -} - -void -test_usrp_rx::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); - pmt_t data = msg->data(); - - pmt_t handle = PMT_F; - pmt_t status = PMT_F; - std::string error_msg; - - switch(d_state){ - - //----------------------------- OPENING_USRP ----------------------------// - // We only expect a response from opening the USRP which should be succesful - // or failed. - case OPENING_USRP: - if (pmt_eq(event, s_response_open)){ - status = pmt_nth(1, data); - if (pmt_eq(status, PMT_T)){ - allocate_channel(); - return; - } - else { - error_msg = "failed to open usrp:"; - goto bail; - } - } - goto unhandled; - - //----------------------- ALLOCATING CHANNELS --------------------// - // Allocate an RX channel to perform the overrun test. - case ALLOCATING_CHANNEL: - if (pmt_eq(event, s_response_allocate_channel)){ - status = pmt_nth(1, data); - if(pmt_eqv(d_rx_chan0, PMT_NIL)) - d_rx_chan0 = pmt_nth(2, data); - else - d_rx_chan1 = pmt_nth(2, data); - - if (pmt_eq(status, PMT_T) && !pmt_eqv(d_rx_chan1, PMT_NIL)){ - enter_receiving(); - return; - } - else if(pmt_eq(status, PMT_F)){ - error_msg = "failed to allocate channel:"; - goto bail; - } - return; - } - goto unhandled; - - //--------------------------- RECEIVING ------------------------------// - // In the receiving state, we receive samples until the specified amount - // while counting the number of overruns. - case RECEIVING: - if (pmt_eq(event, s_response_recv_raw_samples)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - handle_response_recv_raw_samples(data); - return; - } - else { - error_msg = "bad response-xmit-raw-frame:"; - goto bail; - } - } - goto unhandled; - - //------------------------- CLOSING CHANNEL ----------------------------// - // Check deallocation response for the RX channel - case CLOSING_CHANNEL: - if (pmt_eq(event, s_response_deallocate_channel)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - close_usrp(); - return; - } - else { - error_msg = "failed to deallocate channel:"; - goto bail; - } - } - - // Alternately, we ignore all response recv samples while waiting for the - // channel to actually close - if (pmt_eq(event, s_response_recv_raw_samples)) - return; - - goto unhandled; - - //--------------------------- CLOSING USRP ------------------------------// - // Once we have received a successful USRP close response, we shutdown all - // mblocks and exit. - case CLOSING_USRP: - if (pmt_eq(event, s_response_close)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - fflush(stdout); - shutdown_all(PMT_T); - return; - } - else { - error_msg = "failed to close USRP:"; - goto bail; - } - } - goto unhandled; - - default: - goto unhandled; - } - return; - - // An error occured, print it, and shutdown all m-blocks - bail: - std::cerr << error_msg << data - << "status = " << status << std::endl; - shutdown_all(PMT_F); - return; - - // Received an unhandled message for a specific state - unhandled: - if(verbose && !pmt_eq(event, pmt_intern("%shutdown"))) - std::cout << "test_usrp_inband_tx: unhandled msg: " << msg - << "in state "<< d_state << std::endl; -} - - -void -test_usrp_rx::open_usrp() -{ - pmt_t which_usrp = pmt_from_long(0); - - d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, which_usrp)); - d_state = OPENING_USRP; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_RX] Opening the USRP\n"; -} - -void -test_usrp_rx::close_usrp() -{ - - d_cs->send(s_cmd_close, pmt_list1(PMT_NIL)); - d_state = CLOSING_USRP; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_RX] Closing the USRP\n"; -} - -void -test_usrp_rx::allocate_channel() -{ - long capacity = (long) 16e6; - d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); - d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); - d_state = ALLOCATING_CHANNEL; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_RX] Requesting RX channel allocation\n"; -} - -void -test_usrp_rx::enter_receiving() -{ - d_state = RECEIVING; - - d_rx->send(s_cmd_start_recv_raw_samples, - pmt_list2(PMT_F, - d_rx_chan0)); - - d_rx->send(s_cmd_start_recv_raw_samples, - pmt_list2(PMT_F, - d_rx_chan1)); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_RX] Receiving...\n"; -} - -void -test_usrp_rx::handle_response_recv_raw_samples(pmt_t data) -{ - pmt_t invocation_handle = pmt_nth(0, data); - pmt_t status = pmt_nth(1, data); - pmt_t v_samples = pmt_nth(2, data); - pmt_t timestamp = pmt_nth(3, data); - pmt_t channel = pmt_nth(4, data); - pmt_t properties = pmt_nth(5, data); - - d_samples_recvd += pmt_length(v_samples) / 4; - - // Check for overrun - if(!pmt_is_dict(properties)) { - std::cout << "[TEST_USRP_INBAND_RX] Recv samples dictionary is improper\n"; - return; - } - - // Check if the number samples we have received meets the test - if(d_samples_recvd >= d_samples_to_recv) { - d_rx->send(s_cmd_stop_recv_raw_samples, pmt_list2(PMT_NIL, d_rx_chan0)); - d_rx->send(s_cmd_stop_recv_raw_samples, pmt_list2(PMT_NIL, d_rx_chan1)); - enter_closing_channel(); - return; - } - -} - -void -test_usrp_rx::enter_closing_channel() -{ - d_state = CLOSING_CHANNEL; - - d_rx->send(s_cmd_deallocate_channel, pmt_list2(PMT_NIL, d_rx_chan0)); - d_rx->send(s_cmd_deallocate_channel, pmt_list2(PMT_NIL, d_rx_chan1)); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_RX] Deallocating RX channel\n"; -} - -REGISTER_MBLOCK_CLASS(test_usrp_rx); - - -// ---------------------------------------------------------------- - -int -main (int argc, char **argv) -{ - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - rt->run("top", "test_usrp_rx", PMT_F, &result); - -} diff --git a/usrp/limbo/apps-inband/test_usrp_inband_2tx.cc b/usrp/limbo/apps-inband/test_usrp_inband_2tx.cc deleted file mode 100644 index 11a1a491c..000000000 --- a/usrp/limbo/apps-inband/test_usrp_inband_2tx.cc +++ /dev/null @@ -1,430 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/mblock.h> -#include <mblock/runtime.h> -#include <mb_runtime_nop.h> // QA only -#include <mblock/protocol_class.h> -#include <mblock/exception.h> -#include <mblock/msg_queue.h> -#include <mblock/message.h> -#include <mb_mblock_impl.h> -#include <mblock/msg_accepter.h> -#include <mblock/class_registry.h> -#include <pmt.h> -#include <stdio.h> -#include <string.h> -#include <iostream> - -#include <ui_nco.h> -#include <symbols_usrp_server_cs.h> -#include <symbols_usrp_channel.h> -#include <symbols_usrp_low_level_cs.h> -#include <symbols_usrp_tx.h> - -static bool verbose = true; - -class test_usrp_tx : public mb_mblock -{ - mb_port_sptr d_tx; - mb_port_sptr d_cs; - pmt_t d_tx_chan0, d_tx_chan1; - - enum state_t { - INIT, - OPENING_USRP, - ALLOCATING_CHANNEL, - TRANSMITTING, - CLOSING_CHANNEL, - CLOSING_USRP, - }; - - state_t d_state; - long d_nsamples_to_send; - long d_nsamples_xmitted; - long d_nframes_xmitted; - long d_samples_per_frame; - bool d_done_sending; - - // for generating sine wave output - ui_nco<float,float> d_nco; - double d_amplitude; - - public: - test_usrp_tx(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~test_usrp_tx(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void open_usrp(); - void close_usrp(); - void allocate_channel(); - void send_packets(); - void enter_transmitting(); - void build_and_send_next_frame(); - void handle_xmit_response(pmt_t invocation_handle); - void enter_closing_channel(); -}; - -test_usrp_tx::test_usrp_tx(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_tx_chan0(PMT_NIL), d_tx_chan1(PMT_NIL), - d_state(INIT), d_nsamples_to_send((long) 80e6), - d_nsamples_xmitted(0), - d_nframes_xmitted(0), - d_samples_per_frame((long)(126 * 4)), // full packet - d_done_sending(false), - d_amplitude(16384) -{ - // std::cout << "[TEST_USRP_TX] Initializing...\n"; - - d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - //bool fake_usrp_p = true; - bool fake_usrp_p = false; - - // Test the TX side - - pmt_t usrp_dict = pmt_make_dict(); - - if(fake_usrp_p) { - pmt_dict_set(usrp_dict, - pmt_intern("fake-usrp"), - PMT_T); - } - - // Specify the RBF to use - pmt_dict_set(usrp_dict, - pmt_intern("rbf"), - pmt_intern("inband_2rxhb_2tx.rbf")); - - // Set TX and RX interpolations - pmt_dict_set(usrp_dict, - pmt_intern("interp-tx"), - pmt_from_long(128)); - -// pmt_dict_set(usrp_dict, -// pmt_intern("rf-freq"), -// pmt_from_long(10e6)); - - define_component("server", "usrp_server", usrp_dict); - - connect("self", "tx0", "server", "tx0"); - connect("self", "cs", "server", "cs"); - - // initialize NCO - double freq = 100e3; - int interp = 32; // 32 -> 4MS/s - double sample_rate = 128e6 / interp; - d_nco.set_freq(2*M_PI * freq/sample_rate); - - // FIXME need to somehow set the interp rate in the USRP. - // for now, we'll have the low-level code hardwire it. -} - -test_usrp_tx::~test_usrp_tx() -{ -} - -void -test_usrp_tx::initial_transition() -{ - open_usrp(); -} - -void -test_usrp_tx::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); - pmt_t data = msg->data(); - - pmt_t handle = PMT_F; - pmt_t status = PMT_F; - std::string error_msg; - - //std::cout << msg << std::endl; - - switch(d_state){ - case OPENING_USRP: - if (pmt_eq(event, s_response_open)){ - status = pmt_nth(1, data); - if (pmt_eq(status, PMT_T)){ - allocate_channel(); - return; - } - else { - error_msg = "failed to open usrp:"; - goto bail; - } - } - goto unhandled; - - case ALLOCATING_CHANNEL: - if (pmt_eq(event, s_response_allocate_channel)){ - status = pmt_nth(1, data); - if(pmt_eqv(d_tx_chan0, PMT_NIL)) - d_tx_chan0 = pmt_nth(2, data); - else - d_tx_chan1 = pmt_nth(2, data); - - if (pmt_eq(status, PMT_T) && !pmt_eqv(d_tx_chan1, PMT_NIL)){ - enter_transmitting(); - return; - } - else if(pmt_eq(status, PMT_F)){ - error_msg = "failed to allocate channel:"; - goto bail; - } - return; - } - goto unhandled; - - case TRANSMITTING: - if (pmt_eq(event, s_response_xmit_raw_frame)){ - handle = pmt_nth(0, data); - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - handle_xmit_response(handle); - return; - } - else { - error_msg = "bad response-xmit-raw-frame:"; - goto bail; - } - } - goto unhandled; - - case CLOSING_CHANNEL: - if (pmt_eq(event, s_response_deallocate_channel)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - close_usrp(); - return; - } - else { - error_msg = "failed to deallocate channel:"; - goto bail; - } - } - goto unhandled; - - case CLOSING_USRP: - if (pmt_eq(event, s_response_close)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - shutdown_all(PMT_T); - return; - } - else { - error_msg = "failed to close USRP:"; - goto bail; - } - } - goto unhandled; - - default: - goto unhandled; - } - return; - - bail: - std::cerr << error_msg << data - << "status = " << status << std::endl; - shutdown_all(PMT_F); - return; - - unhandled: - std::cout << "test_usrp_inband_tx: unhandled msg: " << msg - << "in state "<< d_state << std::endl; -} - - -void -test_usrp_tx::open_usrp() -{ - pmt_t which_usrp = pmt_from_long(0); - - d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, which_usrp)); - d_state = OPENING_USRP; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TX] Opening the USRP\n"; -} - -void -test_usrp_tx::close_usrp() -{ - d_cs->send(s_cmd_close, pmt_list1(PMT_NIL)); - d_state = CLOSING_USRP; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TX] Closing the USRP\n"; -} - -void -test_usrp_tx::allocate_channel() -{ - long capacity = (long) 16e6; - - // Send two capacity requests, which will allocate us two channels - d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); - d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); - d_state = ALLOCATING_CHANNEL; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TX] Requesting TX channel allocation\n"; -} - -void -test_usrp_tx::enter_transmitting() -{ - d_state = TRANSMITTING; - d_nsamples_xmitted = 0; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TX] Transmitting...\n"; - - build_and_send_next_frame(); // fire off 4 to start pipeline - build_and_send_next_frame(); - build_and_send_next_frame(); - build_and_send_next_frame(); -} - -void -test_usrp_tx::build_and_send_next_frame() -{ - // allocate the uniform vector for the samples - // FIXME perhaps hold on to this between calls - -#if 1 - long nsamples_this_frame = - std::min(d_nsamples_to_send - d_nsamples_xmitted, - d_samples_per_frame); -#else - long nsamples_this_frame = d_samples_per_frame; -#endif - - if (nsamples_this_frame == 0){ - d_done_sending = true; - return; - } - - - size_t nshorts = 2 * nsamples_this_frame; // 16-bit I & Q - pmt_t uvec = pmt_make_s16vector(nshorts, 0); - size_t ignore; - int16_t *samples = pmt_s16vector_writable_elements(uvec, ignore); - - // fill in the complex sinusoid - - for (int i = 0; i < nsamples_this_frame; i++){ - - if (1){ - gr_complex s; - d_nco.sincos(&s, 1, d_amplitude); - // write 16-bit i & q - samples[2*i] = (int16_t) s.real(); - samples[2*i+1] = (int16_t) s.imag(); - } - else { - gr_complex s(d_amplitude, d_amplitude); - - // write 16-bit i & q - samples[2*i] = (int16_t) s.real(); - samples[2*i+1] = (int16_t) s.imag(); - } - } - - pmt_t tx_properties = pmt_make_dict(); - - pmt_t timestamp = pmt_from_long(0xffffffff); // NOW - d_tx->send(s_cmd_xmit_raw_frame, - pmt_list5(pmt_from_long(d_nframes_xmitted), // invocation-handle - d_tx_chan0, // channel - uvec, // the samples - timestamp, - tx_properties)); - - // Resend on channel 1 - d_tx->send(s_cmd_xmit_raw_frame, - pmt_list5(pmt_from_long(d_nframes_xmitted), // invocation-handle - d_tx_chan1, // channel - uvec, // the samples - timestamp, - tx_properties)); - - d_nsamples_xmitted += nsamples_this_frame; - d_nframes_xmitted++; - - if(verbose && 0) - std::cout << "[TEST_USRP_INBAND_TX] Transmitted frame\n"; -} - - -void -test_usrp_tx::handle_xmit_response(pmt_t handle) -{ - if (d_done_sending && - pmt_to_long(handle) == (d_nframes_xmitted - 1)){ - // We're done sending and have received all responses - enter_closing_channel(); - } - - build_and_send_next_frame(); -} - -void -test_usrp_tx::enter_closing_channel() -{ - d_state = CLOSING_CHANNEL; - - // Deallocate both channels - d_tx->send(s_cmd_deallocate_channel, pmt_list2(PMT_NIL, d_tx_chan0)); - d_tx->send(s_cmd_deallocate_channel, pmt_list2(PMT_NIL, d_tx_chan1)); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_tX] Deallocating TX channel\n"; -} - -REGISTER_MBLOCK_CLASS(test_usrp_tx); - - -// ---------------------------------------------------------------- - -int -main (int argc, char **argv) -{ - // handle any command line args here - - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - rt->run("top", "test_usrp_tx", PMT_F, &result); -} diff --git a/usrp/limbo/apps-inband/test_usrp_inband_overrun.cc b/usrp/limbo/apps-inband/test_usrp_inband_overrun.cc deleted file mode 100644 index cd0fa525a..000000000 --- a/usrp/limbo/apps-inband/test_usrp_inband_overrun.cc +++ /dev/null @@ -1,375 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/mblock.h> -#include <mblock/runtime.h> -#include <mblock/protocol_class.h> -#include <mblock/exception.h> -#include <mblock/msg_queue.h> -#include <mblock/message.h> -#include <mblock/msg_accepter.h> -#include <mblock/class_registry.h> -#include <pmt.h> -#include <stdio.h> -#include <string.h> -#include <iostream> -#include <fstream> - -// Include the symbols needed for communication with USRP server -#include <symbols_usrp_server_cs.h> -#include <symbols_usrp_channel.h> -#include <symbols_usrp_low_level_cs.h> -#include <symbols_usrp_rx.h> - -static bool verbose = true; - -class test_usrp_rx : public mb_mblock -{ - mb_port_sptr d_rx; - mb_port_sptr d_cs; - pmt_t d_rx_chan; // returned tx channel handle - - enum state_t { - INIT, - OPENING_USRP, - ALLOCATING_CHANNEL, - RECEIVING, - CLOSING_CHANNEL, - CLOSING_USRP, - }; - - state_t d_state; - - std::ofstream d_ofile; - - long d_n_overruns; - - long d_samples_recvd; - long d_samples_to_recv; - - public: - test_usrp_rx(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~test_usrp_rx(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void open_usrp(); - void close_usrp(); - void allocate_channel(); - void send_packets(); - void enter_receiving(); - void build_and_send_next_frame(); - void handle_response_recv_raw_samples(pmt_t invocation_handle); - void enter_closing_channel(); -}; - -test_usrp_rx::test_usrp_rx(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_n_overruns(0), - d_samples_recvd(0), - d_samples_to_recv(10e6) -{ - - d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - // Pass a dictionary to usrp_server which specifies which interface to use, the stub or USRP - pmt_t usrp_dict = pmt_make_dict(); - - // Specify the RBF to use - pmt_dict_set(usrp_dict, - pmt_intern("rbf"), - pmt_intern("inband_1rxhb_1tx.rbf")); - - pmt_dict_set(usrp_dict, - pmt_intern("decim-rx"), - pmt_from_long(128)); - - define_component("server", "usrp_server", usrp_dict); - - connect("self", "rx0", "server", "rx0"); - connect("self", "cs", "server", "cs"); - -} - -test_usrp_rx::~test_usrp_rx() -{ -} - -void -test_usrp_rx::initial_transition() -{ - open_usrp(); -} - -void -test_usrp_rx::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); - pmt_t data = msg->data(); - - pmt_t handle = PMT_F; - pmt_t status = PMT_F; - std::string error_msg; - - switch(d_state){ - - //----------------------------- OPENING_USRP ----------------------------// - // We only expect a response from opening the USRP which should be succesful - // or failed. - case OPENING_USRP: - if (pmt_eq(event, s_response_open)){ - status = pmt_nth(1, data); - if (pmt_eq(status, PMT_T)){ - allocate_channel(); - return; - } - else { - error_msg = "failed to open usrp:"; - goto bail; - } - } - goto unhandled; - - //----------------------- ALLOCATING CHANNELS --------------------// - // Allocate an RX channel to perform the overrun test. - case ALLOCATING_CHANNEL: - if (pmt_eq(event, s_response_allocate_channel)){ - status = pmt_nth(1, data); - d_rx_chan = pmt_nth(2, data); - - if (pmt_eq(status, PMT_T)){ - enter_receiving(); - return; - } - else { - error_msg = "failed to allocate channel:"; - goto bail; - } - } - goto unhandled; - - //--------------------------- RECEIVING ------------------------------// - // In the receiving state, we receive samples until the specified amount - // while counting the number of overruns. - case RECEIVING: - if (pmt_eq(event, s_response_recv_raw_samples)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - handle_response_recv_raw_samples(data); - return; - } - else { - error_msg = "bad response-xmit-raw-frame:"; - goto bail; - } - } - goto unhandled; - - //------------------------- CLOSING CHANNEL ----------------------------// - // Check deallocation response for the RX channel - case CLOSING_CHANNEL: - if (pmt_eq(event, s_response_deallocate_channel)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - close_usrp(); - return; - } - else { - error_msg = "failed to deallocate channel:"; - goto bail; - } - } - - // Alternately, we ignore all response recv samples while waiting for the - // channel to actually close - if (pmt_eq(event, s_response_recv_raw_samples)) - return; - - goto unhandled; - - //--------------------------- CLOSING USRP ------------------------------// - // Once we have received a successful USRP close response, we shutdown all - // mblocks and exit. - case CLOSING_USRP: - if (pmt_eq(event, s_response_close)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - std::cout << "\nOverruns: " << d_n_overruns << std::endl; - fflush(stdout); - shutdown_all(PMT_T); - return; - } - else { - error_msg = "failed to close USRP:"; - goto bail; - } - } - goto unhandled; - - default: - goto unhandled; - } - return; - - // An error occured, print it, and shutdown all m-blocks - bail: - std::cerr << error_msg << data - << "status = " << status << std::endl; - shutdown_all(PMT_F); - return; - - // Received an unhandled message for a specific state - unhandled: - if(verbose && !pmt_eq(event, pmt_intern("%shutdown"))) - std::cout << "test_usrp_inband_tx: unhandled msg: " << msg - << "in state "<< d_state << std::endl; -} - - -void -test_usrp_rx::open_usrp() -{ - pmt_t which_usrp = pmt_from_long(0); - - d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, which_usrp)); - d_state = OPENING_USRP; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_OVERRUN] Opening the USRP\n"; -} - -void -test_usrp_rx::close_usrp() -{ - d_cs->send(s_cmd_close, pmt_list1(PMT_NIL)); - d_state = CLOSING_USRP; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_OVERRUN] Closing the USRP\n"; -} - -void -test_usrp_rx::allocate_channel() -{ - long capacity = (long) 16e6; - d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); - d_state = ALLOCATING_CHANNEL; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_OVERRUN] Requesting RX channel allocation\n"; -} - -void -test_usrp_rx::enter_receiving() -{ - d_state = RECEIVING; - - d_rx->send(s_cmd_start_recv_raw_samples, - pmt_list2(PMT_F, - d_rx_chan)); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_OVERRUN] Receiving...\n"; -} - -void -test_usrp_rx::handle_response_recv_raw_samples(pmt_t data) -{ - pmt_t invocation_handle = pmt_nth(0, data); - pmt_t status = pmt_nth(1, data); - pmt_t v_samples = pmt_nth(2, data); - pmt_t timestamp = pmt_nth(3, data); - pmt_t channel = pmt_nth(4, data); - pmt_t properties = pmt_nth(5, data); - - d_samples_recvd += pmt_length(v_samples) / 4; - - // Check for overrun - if(!pmt_is_dict(properties)) { - std::cout << "[TEST_USRP_INBAND_OVERRUN] Recv samples dictionary is improper\n"; - return; - } - - if(pmt_t overrun = pmt_dict_ref(properties, - pmt_intern("overrun"), - PMT_NIL)) { - if(pmt_eqv(overrun, PMT_T)) { - d_n_overruns++; - - if(verbose && 0) - std::cout << "[TEST_USRP_INBAND_OVERRUN] Underrun\n"; - } - else { - if(verbose && 0) - std::cout << "[TEST_USRP_INBAND_OVERRUN] No overrun\n" << overrun <<std::endl; - } - } else { - - if(verbose && 0) - std::cout << "[TEST_USRP_INBAND_OVERRUN] No overrun\n"; - } - - // Check if the number samples we have received meets the test - if(d_samples_recvd >= d_samples_to_recv) { - d_rx->send(s_cmd_stop_recv_raw_samples, pmt_list2(PMT_NIL, d_rx_chan)); - enter_closing_channel(); - return; - } - -} - -void -test_usrp_rx::enter_closing_channel() -{ - d_state = CLOSING_CHANNEL; - - sleep(2); - - d_rx->send(s_cmd_deallocate_channel, pmt_list2(PMT_NIL, d_rx_chan)); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_OVERRUN] Deallocating RX channel\n"; -} - -REGISTER_MBLOCK_CLASS(test_usrp_rx); - - -// ---------------------------------------------------------------- - -int -main (int argc, char **argv) -{ - // handle any command line args here - - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - rt->run("top", "test_usrp_rx", PMT_F, &result); -} diff --git a/usrp/limbo/apps-inband/test_usrp_inband_ping.cc b/usrp/limbo/apps-inband/test_usrp_inband_ping.cc deleted file mode 100644 index d779c9a64..000000000 --- a/usrp/limbo/apps-inband/test_usrp_inband_ping.cc +++ /dev/null @@ -1,374 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/mblock.h> -#include <mblock/runtime.h> -#include <mblock/protocol_class.h> -#include <mblock/exception.h> -#include <mblock/msg_queue.h> -#include <mblock/message.h> -#include <mblock/msg_accepter.h> -#include <mblock/class_registry.h> -#include <pmt.h> -#include <stdio.h> -#include <string.h> -#include <sys/time.h> -#include <iostream> - -// Include the symbols needed for communication with USRP server -#include <symbols_usrp_server_cs.h> -#include <symbols_usrp_channel.h> -#include <symbols_usrp_low_level_cs.h> -#include <symbols_usrp_tx.h> -#include <symbols_usrp_rx.h> - -static bool verbose = false; - -class test_usrp_inband_ping : public mb_mblock -{ - - mb_port_sptr d_tx; // Ports connected to the USRP server - mb_port_sptr d_rx; - mb_port_sptr d_cs; - - pmt_t d_tx_chan; // Returned channel from TX allocation - pmt_t d_rx_chan; // Returned channel from RX allocation - - pmt_t d_which_usrp; // The USRP to use for the test - - long d_warm_msgs; // The number of messages to 'warm' the USRP - long d_warm_recvd; // The number of msgs received in the 'warm' state - - // Keep track of current state - enum state_t { - INIT, - OPENING_USRP, - ALLOCATING_CHANNELS, - WARMING_USRP, - PINGING, - CLOSING_CHANNELS, - CLOSING_USRP, - }; - state_t d_state; - - public: - test_usrp_inband_ping(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~test_usrp_inband_ping(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void opening_usrp(); - void allocating_channels(); - void enter_warming_usrp(); - void enter_pinging(); - void build_and_send_ping(); - void closing_channels(); - void closing_usrp(); -}; - - -int -main (int argc, char **argv) -{ - // handle any command line args here - - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - rt->run("top", "test_usrp_inband_ping", PMT_F, &result); -} - - -test_usrp_inband_ping::test_usrp_inband_ping(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_tx_chan(PMT_NIL), - d_rx_chan(PMT_NIL), - d_which_usrp(pmt_from_long(0)), - d_state(INIT) -{ - - // A dictionary is used to pass parameters to the USRP - pmt_t usrp_dict = pmt_make_dict(); - - // Specify the RBF to use - pmt_dict_set(usrp_dict, - pmt_intern("rbf"), - pmt_intern("fixed1.rbf")); - - // Set TX and RX interpolations - pmt_dict_set(usrp_dict, - pmt_intern("interp-tx"), - pmt_from_long(128)); - - pmt_dict_set(usrp_dict, - pmt_intern("decim-rx"), - pmt_from_long(16)); - - d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL); - d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - // Create an instance of USRP server and connect ports - define_component("server", "usrp_server", usrp_dict); - connect("self", "tx0", "server", "tx0"); - connect("self", "rx0", "server", "rx0"); - connect("self", "cs", "server", "cs"); - -} - -test_usrp_inband_ping::~test_usrp_inband_ping() -{ -} - -void -test_usrp_inband_ping::initial_transition() -{ - opening_usrp(); -} - -// Handle message reads all incoming messages from USRP server which will be -// initialization and ping responses. We perform actions based on the current -// state and the event (ie, ping response) -void -test_usrp_inband_ping::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); - pmt_t data = msg->data(); - pmt_t port_id = msg->port_id(); - - pmt_t handle = PMT_F; - pmt_t status = PMT_F; - std::string error_msg; - - // Dispatch based on state - switch(d_state) { - - //----------------------------- OPENING_USRP ----------------------------// - // We only expect a response from opening the USRP which should be succesful - // or failed. - case OPENING_USRP: - - if(pmt_eq(event, s_response_open)) { - - status = pmt_nth(1, data); // failed/succes - - if(pmt_eq(status, PMT_T)) { - allocating_channels(); - return; - } - else { - error_msg = "failed to open usrp:"; - goto bail; - } - - } - - goto unhandled; // all other messages not handled in this state - - - //----------------------- ALLOCATING CHANNELS --------------------// - // When allocating channels, we need to wait for 2 responses from - // USRP server: one for TX and one for RX. Both are initialized to - // NIL so we know to continue to the next state once both are set. - case ALLOCATING_CHANNELS: - - // A TX allocation response - if(pmt_eq(event, s_response_allocate_channel) - && pmt_eq(d_tx->port_symbol(), port_id)) - { - status = pmt_nth(1, data); - - // If successful response, extract the channel - if(pmt_eq(status, PMT_T)) { - - d_tx_chan = pmt_nth(2, data); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_PING] Received TX allocation" - << " on channel " << d_tx_chan << std::endl; - - // If the RX has also been allocated already, we can continue - if(!pmt_eqv(d_rx_chan, PMT_NIL)) - enter_warming_usrp(); - - return; - } - else { // TX allocation failed - error_msg = "failed to allocate TX channel:"; - goto bail; - } - } - - // A RX allocation response - if(pmt_eq(event, s_response_allocate_channel) - && pmt_eq(d_rx->port_symbol(), port_id)) - { - status = pmt_nth(1, data); - - // If successful response, extract the channel - if(pmt_eq(status, PMT_T)) { - - d_rx_chan = pmt_nth(2, data); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_PING] Received RX allocation" - << " on channel " << d_rx_chan << std::endl; - - // If the TX has also been allocated already, we can continue - if(!pmt_eqv(d_tx_chan, PMT_NIL)) - enter_warming_usrp(); - - return; - } - else { // RX allocation failed - error_msg = "failed to allocate RX channel:"; - goto bail; - } - } - - goto unhandled; - - //----------------------- WARMING USRP --------------------// - // The FX2 seems to need some amount of data to be buffered - // before it begins reading. We use this state to simply - // warm up the USRP before benchmarking pings. - case WARMING_USRP: - - // We really don't care about the responses from the - // control channel in the warming stage, but once we receive - // the proper number of responses we switch states. - if(pmt_eq(event, s_response_from_control_channel) - && pmt_eq(d_rx->port_symbol(), port_id)) - { - d_warm_recvd++; - - if(d_warm_recvd > d_warm_msgs) - enter_pinging(); - - return; - } - - goto unhandled; - - case PINGING: - goto unhandled; - - case CLOSING_CHANNELS: - goto unhandled; - - case CLOSING_USRP: - goto unhandled; - - case INIT: - goto unhandled; - - } - - // An error occured, print it, and shutdown all m-blocks - bail: - std::cerr << error_msg << data - << "status = " << status << std::endl; - shutdown_all(PMT_F); - return; - - // Received an unhandled message for a specific state - unhandled: - if(verbose) - std::cout << "test_usrp_inband_tx: unhandled msg: " << msg - << "in state "<< d_state << std::endl; - -} - - -// Sends a command to USRP server to open up a connection to the -// specified USRP, which is defaulted to USRP 0 on the system -void -test_usrp_inband_ping::opening_usrp() -{ - - if(verbose) - std::cout << "[TEST_USRP_INBAND_PING] Opening USRP " - << d_which_usrp << std::endl; - - d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, d_which_usrp)); - d_state = OPENING_USRP; -} - -// RX and TX channels must be allocated so that the USRP server can -// properly share bandwidth across multiple USRPs. No commands will be -// successful to the USRP through the USRP server on the TX or RX channels until -// a bandwidth allocation has been received. -void -test_usrp_inband_ping::allocating_channels() -{ - d_state = ALLOCATING_CHANNELS; - - long capacity = (long) 16e6; - d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); - d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); -} - -// The USRP needs some amount of initial data to pass a buffering point such -// that it begins to pull and read data from the FX2. We send an arbitrary -// amount of data to start the pipeline, which are just pings. -void -test_usrp_inband_ping::enter_warming_usrp() -{ - d_state = WARMING_USRP; - - for(int i=0; i < d_warm_msgs; i++) - build_and_send_ping(); -} - -void -test_usrp_inband_ping::enter_pinging() -{ - d_state = PINGING; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_PING] Running ping tests\n"; - -} - -// Pings are sent over the TX channel using the signal 'cmd-to-control-channel' -// to the USRP server. Within this message there can be infinite subpackets -// stored as a list (the second parameter) and sent. The only subpacket we send -// is a ping, interpreted by the 'op-ping-fixed' signal. -void -test_usrp_inband_ping::build_and_send_ping() -{ - - d_tx->send(s_cmd_to_control_channel, // USRP server signal - pmt_list2(PMT_NIL, // invocation handle - pmt_list1(pmt_list3(s_op_ping_fixed, - pmt_from_long(0), - pmt_from_long(0))))); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_PING] Ping!!" << std::endl; -} - -REGISTER_MBLOCK_CLASS(test_usrp_inband_ping); diff --git a/usrp/limbo/apps-inband/test_usrp_inband_registers.cc b/usrp/limbo/apps-inband/test_usrp_inband_registers.cc deleted file mode 100644 index d9bd2db17..000000000 --- a/usrp/limbo/apps-inband/test_usrp_inband_registers.cc +++ /dev/null @@ -1,435 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/mblock.h> -#include <mblock/runtime.h> -#include <mblock/protocol_class.h> -#include <mblock/exception.h> -#include <mblock/msg_queue.h> -#include <mblock/message.h> -//#include <mb_mblock_impl.h> -#include <mblock/msg_accepter.h> -#include <mblock/class_registry.h> -#include <pmt.h> -#include <stdio.h> -#include <string.h> -#include <sys/time.h> -#include <iostream> - -// Include the symbols needed for communication with USRP server -#include <symbols_usrp_server_cs.h> -#include <symbols_usrp_channel.h> -#include <symbols_usrp_low_level_cs.h> -#include <symbols_usrp_tx.h> -#include <symbols_usrp_rx.h> - -static bool verbose = true; - -class test_usrp_inband_registers : public mb_mblock -{ - - mb_port_sptr d_tx; // Ports connected to the USRP server - mb_port_sptr d_rx; - mb_port_sptr d_cs; - - pmt_t d_tx_chan; // Returned channel from TX allocation - pmt_t d_rx_chan; // Returned channel from RX allocation - - pmt_t d_which_usrp; // The USRP to use for the test - - long d_warm_msgs; // The number of messages to 'warm' the USRP - long d_warm_recvd; // The number of msgs received in the 'warm' state - - // Keep track of current state - enum state_t { - INIT, - OPENING_USRP, - ALLOCATING_CHANNELS, - WRITE_REGISTER, - READ_REGISTER, - CLOSING_CHANNELS, - CLOSING_USRP, - }; - state_t d_state; - - public: - test_usrp_inband_registers(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~test_usrp_inband_registers(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void opening_usrp(); - void allocating_channels(); - void write_register(); - void read_register(); - void closing_channels(); - void closing_usrp(); - void enter_receiving(); - void build_and_send_ping(); -}; - - -int -main (int argc, char **argv) -{ - // handle any command line args here - - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - rt->run("top", "test_usrp_inband_registers", PMT_F, &result); -} - - -test_usrp_inband_registers::test_usrp_inband_registers(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_tx_chan(PMT_NIL), - d_rx_chan(PMT_NIL), - d_which_usrp(pmt_from_long(0)), - d_state(INIT) -{ - - // A dictionary is used to pass parameters to the USRP - pmt_t usrp_dict = pmt_make_dict(); - - // Specify the RBF to use - pmt_dict_set(usrp_dict, - pmt_intern("rbf"), - pmt_intern("inband_1rxhb_1tx.rbf")); - - // Set TX and RX interpolations - pmt_dict_set(usrp_dict, - pmt_intern("interp-tx"), - pmt_from_long(128)); - - pmt_dict_set(usrp_dict, - pmt_intern("decim-rx"), - pmt_from_long(16)); - - d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL); - d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - // Create an instance of USRP server and connect ports - define_component("server", "usrp_server", usrp_dict); - connect("self", "tx0", "server", "tx0"); - connect("self", "rx0", "server", "rx0"); - connect("self", "cs", "server", "cs"); - -} - -test_usrp_inband_registers::~test_usrp_inband_registers() -{ -} - -void -test_usrp_inband_registers::initial_transition() -{ - opening_usrp(); -} - -// Handle message reads all incoming messages from USRP server which will be -// initialization and ping responses. We perform actions based on the current -// state and the event (ie, ping response) -void -test_usrp_inband_registers::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); - pmt_t data = msg->data(); - pmt_t port_id = msg->port_id(); - - pmt_t handle = PMT_F; - pmt_t status = PMT_F; - std::string error_msg; - - // Dispatch based on state - switch(d_state) { - - //----------------------------- OPENING_USRP ----------------------------// - // We only expect a response from opening the USRP which should be succesful - // or failed. - case OPENING_USRP: - - if(pmt_eq(event, s_response_open)) { - - status = pmt_nth(1, data); // failed/succes - - if(pmt_eq(status, PMT_T)) { - allocating_channels(); - return; - } - else { - error_msg = "failed to open usrp:"; - goto bail; - } - - } - - goto unhandled; // all other messages not handled in this state - - - //----------------------- ALLOCATING CHANNELS --------------------// - // When allocating channels, we need to wait for 2 responses from - // USRP server: one for TX and one for RX. Both are initialized to - // NIL so we know to continue to the next state once both are set. - case ALLOCATING_CHANNELS: - - // A TX allocation response - if(pmt_eq(event, s_response_allocate_channel) - && pmt_eq(d_tx->port_symbol(), port_id)) - { - status = pmt_nth(1, data); - - // If successful response, extract the channel - if(pmt_eq(status, PMT_T)) { - - d_tx_chan = pmt_nth(2, data); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_PING] Received TX allocation" - << " on channel " << d_tx_chan << std::endl; - - // If the RX has also been allocated already, we can continue - if(!pmt_eqv(d_rx_chan, PMT_NIL)) { - enter_receiving(); - write_register(); - } - - return; - } - else { // TX allocation failed - error_msg = "failed to allocate TX channel:"; - goto bail; - } - } - - // A RX allocation response - if(pmt_eq(event, s_response_allocate_channel) - && pmt_eq(d_rx->port_symbol(), port_id)) - { - status = pmt_nth(1, data); - - // If successful response, extract the channel - if(pmt_eq(status, PMT_T)) { - - d_rx_chan = pmt_nth(2, data); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_PING] Received RX allocation" - << " on channel " << d_rx_chan << std::endl; - - // If the TX has also been allocated already, we can continue - if(!pmt_eqv(d_tx_chan, PMT_NIL)) { - enter_receiving(); - write_register(); - } - - return; - } - else { // RX allocation failed - error_msg = "failed to allocate RX channel:"; - goto bail; - } - } - - goto unhandled; - - //-------------------------- WRITE REGISTER ----------------------------// - // In the write register state, we do not expect to receive any messages - // since the write does not directly generate a response until the USRP - // responds. - case WRITE_REGISTER: - goto unhandled; - - //-------------------------- READ REGISTER ----------------------------// - // In the read register state, we only expect a read register response back - // that has the value we expect to have in it. We read the response, ensure - // that the read was successful and display the register value. - case READ_REGISTER: - - if(pmt_eq(event, s_response_from_control_channel) - && pmt_eq(d_tx->port_symbol(), port_id)) - { - status = pmt_nth(1, data); - - // If the read was successful, we extract the subpacket information - if(pmt_eq(status, PMT_T)) { - - pmt_t subp = pmt_nth(2, data); // subpacket should be the read reg reply - - pmt_t subp_sig = pmt_nth(0, subp); - pmt_t subp_data = pmt_nth(1, subp); - - if(!pmt_eqv(subp_sig, s_op_read_reg_reply)) { - error_msg = "received improper subpacket when expecting reg reply."; - goto bail; - } - - pmt_t rid = pmt_nth(0, subp_data); - pmt_t reg_num = pmt_nth(1, subp_data); - pmt_t reg_val = pmt_nth(2, subp_data); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_REGISTERS] Received read reg reply " - << "(" - << "RID: " << rid << ", " - << "Reg: " << reg_num << ", " - << "Val: " << reg_val - << ")\n"; - - // read_register(); FIX ME STATE TRANSITION - return; - - } else { // bail on unsuccessful write - error_msg = "failed to write to register."; - goto bail; - } - } - goto unhandled; - - case CLOSING_CHANNELS: - goto unhandled; - - case CLOSING_USRP: - goto unhandled; - - case INIT: - goto unhandled; - - } - - // An error occured, print it, and shutdown all m-blocks - bail: - std::cerr << error_msg << data - << "status = " << status << std::endl; - shutdown_all(PMT_F); - return; - - // Received an unhandled message for a specific state - unhandled: - if(verbose && !pmt_eq(event, s_response_recv_raw_samples)) - std::cout << "test_usrp_inband_tx: unhandled msg: " << msg - << "in state "<< d_state << std::endl; - -} - - -// Sends a command to USRP server to open up a connection to the -// specified USRP, which is defaulted to USRP 0 on the system -void -test_usrp_inband_registers::opening_usrp() -{ - - if(verbose) - std::cout << "[TEST_USRP_INBAND_PING] Opening USRP " - << d_which_usrp << std::endl; - - d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, d_which_usrp)); - d_state = OPENING_USRP; -} - -// RX and TX channels must be allocated so that the USRP server can -// properly share bandwidth across multiple USRPs. No commands will be -// successful to the USRP through the USRP server on the TX or RX channels until -// a bandwidth allocation has been received. -void -test_usrp_inband_registers::allocating_channels() -{ - d_state = ALLOCATING_CHANNELS; - - long capacity = (long) 16e6; - d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); - d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); -} - -// After allocating the channels, a write register command will be sent to the -// USRP. -void -test_usrp_inband_registers::write_register() -{ - d_state = WRITE_REGISTER; - - long reg = 0; - - d_tx->send(s_cmd_to_control_channel, // C/S packet - pmt_list2(PMT_NIL, // invoc handle - pmt_list1( - pmt_list2(s_op_write_reg, - pmt_list2( - pmt_from_long(reg), - pmt_from_long(0xbeef)))))); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_REGISTERS] Writing 0xbeef to " - << reg << std::endl; - - read_register(); // immediately transition to read the register -} - -// Temporary: for testing pings -void -test_usrp_inband_registers::build_and_send_ping() -{ - - d_tx->send(s_cmd_to_control_channel, - pmt_list2(PMT_NIL, pmt_list1(pmt_list2(s_op_ping_fixed, - pmt_list2(pmt_from_long(0), - pmt_from_long(0)))))); - - std::cout << "[TEST_USRP_INBAND_CS] Ping sent" << std::endl; -} - -// After writing to the register, we want to read the value back and ensure that -// it is the same value that we wrote. -void -test_usrp_inband_registers::read_register() -{ - d_state = READ_REGISTER; - - long reg = 9; - - d_tx->send(s_cmd_to_control_channel, // C/S packet - pmt_list2(PMT_NIL, // invoc handle - pmt_list1( - pmt_list2(s_op_read_reg, - pmt_list2( - pmt_from_long(0), // rid - pmt_from_long(reg)))))); - if(verbose) - std::cout << "[TEST_USRP_INBAND_REGISTERS] Reading from register " - << reg << std::endl; -} - -// Used to enter the receiving state -void -test_usrp_inband_registers::enter_receiving() -{ - d_rx->send(s_cmd_start_recv_raw_samples, - pmt_list2(PMT_F, - d_rx_chan)); -} - -REGISTER_MBLOCK_CLASS(test_usrp_inband_registers); diff --git a/usrp/limbo/apps-inband/test_usrp_inband_rx.cc b/usrp/limbo/apps-inband/test_usrp_inband_rx.cc deleted file mode 100644 index 4f21e4afc..000000000 --- a/usrp/limbo/apps-inband/test_usrp_inband_rx.cc +++ /dev/null @@ -1,362 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/mblock.h> -#include <mblock/runtime.h> -#include <mblock/protocol_class.h> -#include <mblock/exception.h> -#include <mblock/msg_queue.h> -#include <mblock/message.h> -#include <mblock/msg_accepter.h> -#include <mblock/class_registry.h> -#include <pmt.h> -#include <stdio.h> -#include <string.h> -#include <iostream> -#include <fstream> - -// Include the symbols needed for communication with USRP server -#include <symbols_usrp_server_cs.h> -#include <symbols_usrp_channel.h> -#include <symbols_usrp_low_level_cs.h> -#include <symbols_usrp_rx.h> - -static bool verbose = true; - -class test_usrp_rx : public mb_mblock -{ - mb_port_sptr d_rx; - mb_port_sptr d_cs; - pmt_t d_rx_chan; // returned tx channel handle - - enum state_t { - INIT, - OPENING_USRP, - ALLOCATING_CHANNEL, - RECEIVING, - CLOSING_CHANNEL, - CLOSING_USRP, - }; - - state_t d_state; - - std::ofstream d_ofile; - - long d_samples_recvd; - long d_samples_to_recv; - - public: - test_usrp_rx(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~test_usrp_rx(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void open_usrp(); - void close_usrp(); - void allocate_channel(); - void send_packets(); - void enter_receiving(); - void build_and_send_next_frame(); - void handle_response_recv_raw_samples(pmt_t invocation_handle); - void enter_closing_channel(); -}; - -test_usrp_rx::test_usrp_rx(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_samples_recvd(0), - d_samples_to_recv(20e6) -{ - d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - // Pass a dictionary to usrp_server which specifies which interface to use, the stub or USRP - pmt_t usrp_dict = pmt_make_dict(); - - // To test the application without a USRP - bool fake_usrp_p = false; - if(fake_usrp_p) { - pmt_dict_set(usrp_dict, - pmt_intern("fake-usrp"), - PMT_T); - } - - // Specify the RBF to use - pmt_dict_set(usrp_dict, - pmt_intern("rbf"), - pmt_intern("inband_1rxhb_1tx.rbf")); - - pmt_dict_set(usrp_dict, - pmt_intern("decim-rx"), - pmt_from_long(64)); - -// If unspecified, chooses center frequency from range -// pmt_dict_set(usrp_dict, -// pmt_intern("rf-freq"), -// pmt_from_long(10e6)); - - define_component("server", "usrp_server", usrp_dict); - - connect("self", "rx0", "server", "rx0"); - connect("self", "cs", "server", "cs"); - -} - -test_usrp_rx::~test_usrp_rx() -{ -} - -void -test_usrp_rx::initial_transition() -{ - open_usrp(); -} - -void -test_usrp_rx::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); - pmt_t data = msg->data(); - - pmt_t handle = PMT_F; - pmt_t status = PMT_F; - std::string error_msg; - - switch(d_state){ - - //----------------------------- OPENING_USRP ----------------------------// - // We only expect a response from opening the USRP which should be succesful - // or failed. - case OPENING_USRP: - if (pmt_eq(event, s_response_open)){ - status = pmt_nth(1, data); - if (pmt_eq(status, PMT_T)){ - allocate_channel(); - return; - } - else { - error_msg = "failed to open usrp:"; - goto bail; - } - } - goto unhandled; - - //----------------------- ALLOCATING CHANNELS --------------------// - // Allocate an RX channel to perform the overrun test. - case ALLOCATING_CHANNEL: - if (pmt_eq(event, s_response_allocate_channel)){ - status = pmt_nth(1, data); - d_rx_chan = pmt_nth(2, data); - - if (pmt_eq(status, PMT_T)){ - enter_receiving(); - return; - } - else { - error_msg = "failed to allocate channel:"; - goto bail; - } - } - goto unhandled; - - //--------------------------- RECEIVING ------------------------------// - // In the receiving state, we receive samples until the specified amount - // while counting the number of overruns. - case RECEIVING: - if (pmt_eq(event, s_response_recv_raw_samples)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - handle_response_recv_raw_samples(data); - return; - } - else { - error_msg = "bad response-xmit-raw-frame:"; - goto bail; - } - } - goto unhandled; - - //------------------------- CLOSING CHANNEL ----------------------------// - // Check deallocation response for the RX channel - case CLOSING_CHANNEL: - if (pmt_eq(event, s_response_deallocate_channel)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - close_usrp(); - return; - } - else { - error_msg = "failed to deallocate channel:"; - goto bail; - } - } - - // Alternately, we ignore all response recv samples while waiting for the - // channel to actually close - if (pmt_eq(event, s_response_recv_raw_samples)) - return; - - goto unhandled; - - //--------------------------- CLOSING USRP ------------------------------// - // Once we have received a successful USRP close response, we shutdown all - // mblocks and exit. - case CLOSING_USRP: - if (pmt_eq(event, s_response_close)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - fflush(stdout); - shutdown_all(PMT_T); - return; - } - else { - error_msg = "failed to close USRP:"; - goto bail; - } - } - goto unhandled; - - default: - goto unhandled; - } - return; - - // An error occured, print it, and shutdown all m-blocks - bail: - std::cerr << error_msg << data - << "status = " << status << std::endl; - shutdown_all(PMT_F); - return; - - // Received an unhandled message for a specific state - unhandled: - if(verbose && !pmt_eq(event, pmt_intern("%shutdown"))) - std::cout << "test_usrp_inband_tx: unhandled msg: " << msg - << "in state "<< d_state << std::endl; -} - - -void -test_usrp_rx::open_usrp() -{ - pmt_t which_usrp = pmt_from_long(0); - - d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, which_usrp)); - d_state = OPENING_USRP; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_RX] Opening the USRP\n"; -} - -void -test_usrp_rx::close_usrp() -{ - - d_cs->send(s_cmd_close, pmt_list1(PMT_NIL)); - d_state = CLOSING_USRP; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_RX] Closing the USRP\n"; -} - -void -test_usrp_rx::allocate_channel() -{ - long capacity = (long) 16e6; - d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); - d_state = ALLOCATING_CHANNEL; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_RX] Requesting RX channel allocation\n"; -} - -void -test_usrp_rx::enter_receiving() -{ - d_state = RECEIVING; - - d_rx->send(s_cmd_start_recv_raw_samples, - pmt_list2(PMT_F, - d_rx_chan)); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_RX] Receiving...\n"; -} - -void -test_usrp_rx::handle_response_recv_raw_samples(pmt_t data) -{ - pmt_t invocation_handle = pmt_nth(0, data); - pmt_t status = pmt_nth(1, data); - pmt_t v_samples = pmt_nth(2, data); - pmt_t timestamp = pmt_nth(3, data); - pmt_t channel = pmt_nth(4, data); - pmt_t properties = pmt_nth(5, data); - - d_samples_recvd += pmt_length(v_samples) / 4; - - // Check for overrun - if(!pmt_is_dict(properties)) { - std::cout << "[TEST_USRP_INBAND_RX] Recv samples dictionary is improper\n"; - return; - } - - // Check if the number samples we have received meets the test - if(d_samples_recvd >= d_samples_to_recv) { - d_rx->send(s_cmd_stop_recv_raw_samples, pmt_list2(PMT_NIL, d_rx_chan)); - enter_closing_channel(); - return; - } - -} - -void -test_usrp_rx::enter_closing_channel() -{ - d_state = CLOSING_CHANNEL; - - d_rx->send(s_cmd_deallocate_channel, pmt_list2(PMT_NIL, d_rx_chan)); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_RX] Deallocating RX channel\n"; -} - -REGISTER_MBLOCK_CLASS(test_usrp_rx); - - -// ---------------------------------------------------------------- - -int -main (int argc, char **argv) -{ - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - rt->run("top", "test_usrp_rx", PMT_F, &result); - -} diff --git a/usrp/limbo/apps-inband/test_usrp_inband_timestamps.cc b/usrp/limbo/apps-inband/test_usrp_inband_timestamps.cc deleted file mode 100644 index 3b874d1a5..000000000 --- a/usrp/limbo/apps-inband/test_usrp_inband_timestamps.cc +++ /dev/null @@ -1,506 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/mblock.h> -#include <mblock/runtime.h> -#include <mblock/protocol_class.h> -#include <mblock/exception.h> -#include <mblock/msg_queue.h> -#include <mblock/message.h> -#include <mblock/msg_accepter.h> -#include <mblock/class_registry.h> -#include <pmt.h> -#include <stdio.h> -#include <string.h> -#include <sys/time.h> -#include <iostream> - -#include <ui_nco.h> -#include <symbols_usrp_server_cs.h> -#include <symbols_usrp_channel.h> -#include <symbols_usrp_low_level_cs.h> -#include <symbols_usrp_tx.h> -#include <symbols_usrp_rx.h> - -#define NBPING 10 - -static bool verbose = true; -bool bskip = false; -long bstep = 10000; -long bcurr = 0; -long incr = 0x500; -long ptime = 0x000; - -class test_usrp_inband_timestamps : public mb_mblock -{ - mb_port_sptr d_tx; - mb_port_sptr d_rx; - mb_port_sptr d_cs; - pmt_t d_tx_chan; // returned tx channel handle - pmt_t d_rx_chan; // returned tx channel handle - - struct timeval times[NBPING]; - - enum state_t { - INIT, - OPENING_USRP, - ALLOCATING_CHANNEL, - TRANSMITTING, - CLOSING_CHANNEL, - CLOSING_USRP, - }; - - state_t d_state; - long d_nsamples_to_send; - long d_nsamples_xmitted; - long d_nframes_xmitted; - long d_samples_per_frame; - bool d_done_sending; - - // for generating sine wave output - ui_nco<float,float> d_nco; - double d_amplitude; - - public: - test_usrp_inband_timestamps(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~test_usrp_inband_timestamps(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void open_usrp(); - void close_usrp(); - void allocate_channel(); - void send_packets(); - void enter_receiving(); - void enter_transmitting(); - void build_and_send_ping(); - void build_and_send_next_frame(); - void handle_xmit_response(pmt_t invocation_handle); - void enter_closing_channel(); -}; - -test_usrp_inband_timestamps::test_usrp_inband_timestamps(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_tx_chan(PMT_NIL), - d_rx_chan(PMT_NIL), - d_state(INIT), d_nsamples_to_send((long) 40e6), - d_nsamples_xmitted(0), - d_nframes_xmitted(0), - //d_samples_per_frame((long)(126)), - d_samples_per_frame((long)(126 * 2)), // non-full packet - //d_samples_per_frame((long)(126 * 3.5)), // non-full packet - //d_samples_per_frame((long)(126 * 4)), // full packet - d_done_sending(false), - d_amplitude(16384) -{ - if(verbose) - std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Initializing...\n"; - - d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL); - d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - bool fake_usrp_p = false; - - // Test the TX side - - pmt_t usrp_dict = pmt_make_dict(); - - if(fake_usrp_p) { - pmt_dict_set(usrp_dict, - pmt_intern("fake-usrp"), - PMT_T); - } - - // Set TX and RX interpolations - pmt_dict_set(usrp_dict, - pmt_intern("interp-tx"), - pmt_from_long(128)); - - pmt_dict_set(usrp_dict, - pmt_intern("decim-rx"), - pmt_from_long(16)); - - // Specify the RBF to use - pmt_dict_set(usrp_dict, - pmt_intern("rbf"), - pmt_intern("inband_1rxhb_1tx.rbf")); - - define_component("server", "usrp_server", usrp_dict); - - connect("self", "tx0", "server", "tx0"); - connect("self", "rx0", "server", "rx0"); - connect("self", "cs", "server", "cs"); - - // initialize NCO - double freq = 100e3; - int interp = 32; // 32 -> 4MS/s - double sample_rate = 128e6 / interp; - d_nco.set_freq(2*M_PI * freq/sample_rate); - -} - -test_usrp_inband_timestamps::~test_usrp_inband_timestamps() -{ -} - -void -test_usrp_inband_timestamps::initial_transition() -{ - open_usrp(); -} - -void -test_usrp_inband_timestamps::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); - pmt_t data = msg->data(); - pmt_t port_id = msg->port_id(); - - pmt_t handle = PMT_F; - pmt_t status = PMT_F; - std::string error_msg; - - //std::cout << msg << std::endl; - - switch(d_state){ - case OPENING_USRP: - if (pmt_eq(event, s_response_open)){ - status = pmt_nth(1, data); - if (pmt_eq(status, PMT_T)){ - allocate_channel(); - return; - } - else { - error_msg = "failed to open usrp:"; - goto bail; - } - } - goto unhandled; - - case ALLOCATING_CHANNEL: - if (pmt_eq(event, s_response_allocate_channel)){ - - if(pmt_eq(d_tx->port_symbol(), port_id)) { - status = pmt_nth(1, data); - d_tx_chan = pmt_nth(2, data); - - if (pmt_eq(status, PMT_T)){ - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Received allocation for TX\n"; - - if(!pmt_eqv(d_rx_chan, PMT_NIL)) { - enter_receiving(); - enter_transmitting(); - } - return; - } - else { - error_msg = "failed to allocate channel:"; - goto bail; - } - } - - if(pmt_eq(d_rx->port_symbol(), port_id)) { - status = pmt_nth(1, data); - d_rx_chan = pmt_nth(2, data); - - if (pmt_eq(status, PMT_T)){ - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Received allocation for TX\n"; - - if(!pmt_eqv(d_tx_chan, PMT_NIL)) { - enter_receiving(); - enter_transmitting(); - } - return; - } - else { - error_msg = "failed to allocate channel:"; - goto bail; - } - } - } - goto unhandled; - - case TRANSMITTING: - if (pmt_eq(event, s_response_xmit_raw_frame)){ - handle = pmt_nth(0, data); - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - handle_xmit_response(handle); - return; - } - else { - error_msg = "bad response-xmit-raw-frame:"; - goto bail; - } - } - - if (pmt_eq(event, s_response_from_control_channel)) { - std::cout << "ping response!\n"; - } - goto unhandled; - - case CLOSING_CHANNEL: - if (pmt_eq(event, s_response_deallocate_channel)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - close_usrp(); - return; - } - else { - error_msg = "failed to deallocate channel:"; - goto bail; - } - } - goto unhandled; - - case CLOSING_USRP: - if (pmt_eq(event, s_response_close)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - shutdown_all(PMT_T); - return; - } - else { - error_msg = "failed to close USRP:"; - goto bail; - } - } - goto unhandled; - - default: - goto unhandled; - } - return; - - bail: - std::cerr << error_msg << data - << "status = " << status << std::endl; - shutdown_all(PMT_F); - return; - - unhandled: - if(verbose && 0) - std::cout << "test_usrp_inband_tx: unhandled msg: " << msg - << "in state "<< d_state << std::endl; -} - - -void -test_usrp_inband_timestamps::open_usrp() -{ - pmt_t which_usrp = pmt_from_long(0); - - d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, which_usrp)); - d_state = OPENING_USRP; -} - -void -test_usrp_inband_timestamps::close_usrp() -{ - d_cs->send(s_cmd_close, pmt_list1(PMT_NIL)); - d_state = CLOSING_USRP; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Closing USRP\n"; -} - -void -test_usrp_inband_timestamps::allocate_channel() -{ - long capacity = (long) 16e6; - d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); - d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); - d_state = ALLOCATING_CHANNEL; -} - -void -test_usrp_inband_timestamps::enter_receiving() -{ - d_rx->send(s_cmd_start_recv_raw_samples, - pmt_list2(PMT_F, - d_rx_chan)); -} - -void -test_usrp_inband_timestamps::enter_transmitting() -{ - d_state = TRANSMITTING; - d_nsamples_xmitted = 0; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Beginning transmission\n"; - - sleep(1); - - build_and_send_next_frame(); - build_and_send_next_frame(); - build_and_send_next_frame(); - build_and_send_next_frame(); - -} - -void -test_usrp_inband_timestamps::build_and_send_ping() -{ - - d_tx->send(s_cmd_to_control_channel, - pmt_list2(PMT_NIL, pmt_list1(pmt_list2(s_op_ping_fixed, - pmt_list2(pmt_from_long(0), - pmt_from_long(0)))))); - if(verbose && 0) - std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Ping sent" << std::endl; -} - -void -test_usrp_inband_timestamps::build_and_send_next_frame() -{ - // allocate the uniform vector for the samples - // FIXME perhaps hold on to this between calls - -#if 0 - long nsamples_this_frame = - std::min(d_nsamples_to_send - d_nsamples_xmitted, - d_samples_per_frame); -#else - long nsamples_this_frame = d_samples_per_frame; -#endif - - if (nsamples_this_frame == 0){ - d_done_sending = true; - return; - } - - - size_t nshorts = 2 * nsamples_this_frame; // 16-bit I & Q - pmt_t uvec = pmt_make_s16vector(nshorts, 0); - size_t ignore; - int16_t *samples = pmt_s16vector_writable_elements(uvec, ignore); - - // fill in the complex sinusoid - - for (int i = 0; i < nsamples_this_frame; i++){ - - if (1){ - gr_complex s; - d_nco.sincos(&s, 1, d_amplitude); - // write 16-bit i & q - samples[2*i] = (int16_t) s.real(); - samples[2*i+1] = (int16_t) s.imag(); - } - else { - gr_complex s(d_amplitude, d_amplitude); - - // write 16-bit i & q - samples[2*i] = (int16_t) s.real(); - samples[2*i+1] = (int16_t) s.imag(); - } - } - - pmt_t timestamp; - - if(bskip) { - timestamp = pmt_from_long(0x0); // throw away - bcurr++; - if(bcurr == bstep) { - bskip = false; - bcurr = 0; - } - } else { - timestamp = pmt_from_long(0xffffffff); // NOW - timestamp = pmt_from_long(ptime); - ptime += incr; - bcurr++; - if(bcurr == bstep) { - //bskip = true; - bcurr = 0; - } - } - - std::cout << bskip << " -- " << bcurr << std::endl; - - d_tx->send(s_cmd_xmit_raw_frame, - pmt_list4(pmt_from_long(d_nframes_xmitted), // invocation-handle - d_tx_chan, // channel - uvec, // the samples - timestamp)); - - d_nsamples_xmitted += nsamples_this_frame; - d_nframes_xmitted++; - - if(verbose && 0) - std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Transmitted frame\n"; - - //build_and_send_next_frame(); -} - - -void -test_usrp_inband_timestamps::handle_xmit_response(pmt_t handle) -{ - if (d_done_sending && - pmt_to_long(handle) == (d_nframes_xmitted - 1)){ - // We're done sending and have received all responses - enter_closing_channel(); - } - - build_and_send_next_frame(); - //build_and_send_ping(); -} - -void -test_usrp_inband_timestamps::enter_closing_channel() -{ - d_state = CLOSING_CHANNEL; - - d_tx->send(s_cmd_deallocate_channel, pmt_list2(PMT_NIL, d_tx_chan)); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TIMESTAMPS] Closing channel\n"; -} - -REGISTER_MBLOCK_CLASS(test_usrp_inband_timestamps); - - -// ---------------------------------------------------------------- - -int -main (int argc, char **argv) -{ - // handle any command line args here - - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - rt->run("top", "test_usrp_inband_timestamps", PMT_F, &result); -} diff --git a/usrp/limbo/apps-inband/test_usrp_inband_tx.cc b/usrp/limbo/apps-inband/test_usrp_inband_tx.cc deleted file mode 100644 index 9f294e770..000000000 --- a/usrp/limbo/apps-inband/test_usrp_inband_tx.cc +++ /dev/null @@ -1,411 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/mblock.h> -#include <mblock/runtime.h> -#include <mblock/protocol_class.h> -#include <mblock/exception.h> -#include <mblock/msg_queue.h> -#include <mblock/message.h> -#include <mblock/msg_accepter.h> -#include <mblock/class_registry.h> -#include <pmt.h> -#include <stdio.h> -#include <string.h> -#include <iostream> - -#include <ui_nco.h> -#include <symbols_usrp_server_cs.h> -#include <symbols_usrp_channel.h> -#include <symbols_usrp_low_level_cs.h> -#include <symbols_usrp_tx.h> - -static bool verbose = true; - -class test_usrp_tx : public mb_mblock -{ - mb_port_sptr d_tx; - mb_port_sptr d_cs; - pmt_t d_tx_chan; // returned tx channel handle - - enum state_t { - INIT, - OPENING_USRP, - ALLOCATING_CHANNEL, - TRANSMITTING, - CLOSING_CHANNEL, - CLOSING_USRP, - }; - - state_t d_state; - long d_nsamples_to_send; - long d_nsamples_xmitted; - long d_nframes_xmitted; - long d_samples_per_frame; - bool d_done_sending; - - // for generating sine wave output - ui_nco<float,float> d_nco; - double d_amplitude; - - public: - test_usrp_tx(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~test_usrp_tx(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void open_usrp(); - void close_usrp(); - void allocate_channel(); - void send_packets(); - void enter_transmitting(); - void build_and_send_next_frame(); - void handle_xmit_response(pmt_t invocation_handle); - void enter_closing_channel(); -}; - -test_usrp_tx::test_usrp_tx(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_state(INIT), d_nsamples_to_send((long) 80e6), - d_nsamples_xmitted(0), - d_nframes_xmitted(0), - d_samples_per_frame((long)(126 * 4)), // full packet - d_done_sending(false), - d_amplitude(16384) -{ - // std::cout << "[TEST_USRP_TX] Initializing...\n"; - - d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - //bool fake_usrp_p = true; - bool fake_usrp_p = false; - - // Test the TX side - - pmt_t usrp_dict = pmt_make_dict(); - - if(fake_usrp_p) { - pmt_dict_set(usrp_dict, - pmt_intern("fake-usrp"), - PMT_T); - } - - // Specify the RBF to use - pmt_dict_set(usrp_dict, - pmt_intern("rbf"), - pmt_intern("inband_1rxhb_1tx.rbf")); - - // Set TX and RX interpolations - pmt_dict_set(usrp_dict, - pmt_intern("interp-tx"), - pmt_from_long(64)); - -// If unspecified, chooses center frequency from range -// pmt_dict_set(usrp_dict, -// pmt_intern("rf-freq"), -// pmt_from_long(10e6)); - - define_component("server", "usrp_server", usrp_dict); - - connect("self", "tx0", "server", "tx0"); - connect("self", "cs", "server", "cs"); - - // initialize NCO - double freq = 100e3; - int interp = 32; // 32 -> 4MS/s - double sample_rate = 128e6 / interp; - d_nco.set_freq(2*M_PI * freq/sample_rate); - - // FIXME need to somehow set the interp rate in the USRP. - // for now, we'll have the low-level code hardwire it. -} - -test_usrp_tx::~test_usrp_tx() -{ -} - -void -test_usrp_tx::initial_transition() -{ - open_usrp(); -} - -void -test_usrp_tx::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); - pmt_t data = msg->data(); - - pmt_t handle = PMT_F; - pmt_t status = PMT_F; - std::string error_msg; - - //std::cout << msg << std::endl; - - switch(d_state){ - case OPENING_USRP: - if (pmt_eq(event, s_response_open)){ - status = pmt_nth(1, data); - if (pmt_eq(status, PMT_T)){ - allocate_channel(); - return; - } - else { - error_msg = "failed to open usrp:"; - goto bail; - } - } - goto unhandled; - - case ALLOCATING_CHANNEL: - if (pmt_eq(event, s_response_allocate_channel)){ - status = pmt_nth(1, data); - d_tx_chan = pmt_nth(2, data); - - if (pmt_eq(status, PMT_T)){ - enter_transmitting(); - return; - } - else { - error_msg = "failed to allocate channel:"; - goto bail; - } - } - goto unhandled; - - case TRANSMITTING: - if (pmt_eq(event, s_response_xmit_raw_frame)){ - handle = pmt_nth(0, data); - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - handle_xmit_response(handle); - return; - } - else { - error_msg = "bad response-xmit-raw-frame:"; - goto bail; - } - } - goto unhandled; - - case CLOSING_CHANNEL: - if (pmt_eq(event, s_response_deallocate_channel)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - close_usrp(); - return; - } - else { - error_msg = "failed to deallocate channel:"; - goto bail; - } - } - goto unhandled; - - case CLOSING_USRP: - if (pmt_eq(event, s_response_close)){ - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - shutdown_all(PMT_T); - return; - } - else { - error_msg = "failed to close USRP:"; - goto bail; - } - } - goto unhandled; - - default: - goto unhandled; - } - return; - - bail: - std::cerr << error_msg << data - << "status = " << status << std::endl; - shutdown_all(PMT_F); - return; - - unhandled: - std::cout << "test_usrp_inband_tx: unhandled msg: " << msg - << "in state "<< d_state << std::endl; -} - - -void -test_usrp_tx::open_usrp() -{ - pmt_t which_usrp = pmt_from_long(0); - - d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, which_usrp)); - d_state = OPENING_USRP; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TX] Opening the USRP\n"; -} - -void -test_usrp_tx::close_usrp() -{ - d_cs->send(s_cmd_close, pmt_list1(PMT_NIL)); - d_state = CLOSING_USRP; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TX] Closing the USRP\n"; -} - -void -test_usrp_tx::allocate_channel() -{ - long capacity = (long) 16e6; - d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); - d_state = ALLOCATING_CHANNEL; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TX] Requesting TX channel allocation\n"; -} - -void -test_usrp_tx::enter_transmitting() -{ - d_state = TRANSMITTING; - d_nsamples_xmitted = 0; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TX] Transmitting...\n"; - - build_and_send_next_frame(); // fire off 4 to start pipeline - build_and_send_next_frame(); - build_and_send_next_frame(); - build_and_send_next_frame(); -} - -void -test_usrp_tx::build_and_send_next_frame() -{ - // allocate the uniform vector for the samples - // FIXME perhaps hold on to this between calls - -#if 1 - long nsamples_this_frame = - std::min(d_nsamples_to_send - d_nsamples_xmitted, - d_samples_per_frame); -#else - long nsamples_this_frame = d_samples_per_frame; -#endif - - if (nsamples_this_frame == 0){ - d_done_sending = true; - return; - } - - - size_t nshorts = 2 * nsamples_this_frame; // 16-bit I & Q - pmt_t uvec = pmt_make_s16vector(nshorts, 0); - size_t ignore; - int16_t *samples = pmt_s16vector_writable_elements(uvec, ignore); - - // fill in the complex sinusoid - - for (int i = 0; i < nsamples_this_frame; i++){ - - if (1){ - gr_complex s; - d_nco.sincos(&s, 1, d_amplitude); - // write 16-bit i & q - samples[2*i] = (int16_t) s.real(); - samples[2*i+1] = (int16_t) s.imag(); - } - else { - gr_complex s(d_amplitude, d_amplitude); - - // write 16-bit i & q - samples[2*i] = (int16_t) s.real(); - samples[2*i+1] = (int16_t) s.imag(); - } - } - - pmt_t tx_properties = pmt_make_dict(); - - pmt_t timestamp = pmt_from_long(0xffffffff); // NOW - d_tx->send(s_cmd_xmit_raw_frame, - pmt_list5(pmt_from_long(d_nframes_xmitted), // invocation-handle - d_tx_chan, // channel - uvec, // the samples - timestamp, - tx_properties)); - - d_nsamples_xmitted += nsamples_this_frame; - d_nframes_xmitted++; - - if(verbose && 0) - std::cout << "[TEST_USRP_INBAND_TX] Transmitted frame\n"; -} - - -void -test_usrp_tx::handle_xmit_response(pmt_t handle) -{ - if (d_done_sending && - pmt_to_long(handle) == (d_nframes_xmitted - 1)){ - // We're done sending and have received all responses - enter_closing_channel(); - } - - build_and_send_next_frame(); -} - -void -test_usrp_tx::enter_closing_channel() -{ - d_state = CLOSING_CHANNEL; - - d_tx->send(s_cmd_deallocate_channel, pmt_list2(PMT_NIL, d_tx_chan)); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_tX] Deallocating TX channel\n"; -} - -REGISTER_MBLOCK_CLASS(test_usrp_tx); - - -// ---------------------------------------------------------------- - -int -main (int argc, char **argv) -{ - // handle any command line args here - - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - rt->run("top", "test_usrp_tx", PMT_F, &result); -} diff --git a/usrp/limbo/apps-inband/test_usrp_inband_underrun.cc b/usrp/limbo/apps-inband/test_usrp_inband_underrun.cc deleted file mode 100644 index 11babb048..000000000 --- a/usrp/limbo/apps-inband/test_usrp_inband_underrun.cc +++ /dev/null @@ -1,674 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <mblock/mblock.h> -#include <mblock/runtime.h> -#include <mblock/protocol_class.h> -#include <mblock/exception.h> -#include <mblock/msg_queue.h> -#include <mblock/message.h> -#include <mblock/msg_accepter.h> -#include <mblock/class_registry.h> -#include <pmt.h> -#include <stdio.h> -#include <string.h> -#include <sys/time.h> -#include <iostream> -#include <ui_nco.h> - -// Include the symbols needed for communication with USRP server -#include <symbols_usrp_server_cs.h> -#include <symbols_usrp_channel.h> -#include <symbols_usrp_low_level_cs.h> -#include <symbols_usrp_tx.h> -#include <symbols_usrp_rx.h> - -static bool verbose = true; - -class test_usrp_inband_underrun : public mb_mblock -{ - - mb_port_sptr d_tx; // Ports connected to the USRP server - mb_port_sptr d_rx; - mb_port_sptr d_cs; - - pmt_t d_tx_chan; // Returned channel from TX allocation - pmt_t d_rx_chan; // Returned channel from RX allocation - - pmt_t d_which_usrp; // The USRP to use for the test - - long d_warm_msgs; // The number of messages to 'warm' the USRP - long d_warm_recvd; // The number of msgs received in the 'warm' state - - // Keep track of current state - enum state_t { - INIT, - OPENING_USRP, - ALLOCATING_CHANNELS, - WRITE_REGISTER, - READ_REGISTER, - TRANSMITTING, - CLOSING_CHANNELS, - CLOSING_USRP, - }; - state_t d_state; - - long d_nsamples_to_send; - long d_nsamples_xmitted; - long d_nframes_xmitted; - long d_samples_per_frame; - bool d_done_sending; - - // for generating sine wave output - ui_nco<float,float> d_nco; - double d_amplitude; - - long d_n_underruns; - - public: - test_usrp_inband_underrun(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~test_usrp_inband_underrun(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void opening_usrp(); - void allocating_channels(); - void write_register(); - void read_register(); - void closing_channels(); - void closing_usrp(); - void enter_receiving(); - void enter_transmitting(); - void build_and_send_ping(); - void build_and_send_next_frame(); - void handle_xmit_response(pmt_t handle); - void handle_recv_response(pmt_t dict); -}; - - -int -main (int argc, char **argv) -{ - // handle any command line args here - - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_NIL; - - rt->run("top", "test_usrp_inband_underrun", PMT_F, &result); -} - - -test_usrp_inband_underrun::test_usrp_inband_underrun(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_tx_chan(PMT_NIL), - d_rx_chan(PMT_NIL), - d_which_usrp(pmt_from_long(0)), - d_state(INIT), - d_nsamples_to_send((long) 27e6), - d_nsamples_xmitted(0), - d_nframes_xmitted(0), - d_samples_per_frame(d_nsamples_to_send), // full packet - - d_done_sending(false), - d_amplitude(16384), - d_n_underruns(0) -{ - - // A dictionary is used to pass parameters to the USRP - pmt_t usrp_dict = pmt_make_dict(); - - // Specify the RBF to use - pmt_dict_set(usrp_dict, - pmt_intern("rbf"), - pmt_intern("inband_1rxhb_1tx.rbf")); - - // Set TX and RX interpolations - pmt_dict_set(usrp_dict, - pmt_intern("interp-tx"), - pmt_from_long(64)); - - pmt_dict_set(usrp_dict, - pmt_intern("decim-rx"), - pmt_from_long(128)); - - d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL); - d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - // Create an instance of USRP server and connect ports - define_component("server", "usrp_server", usrp_dict); - connect("self", "tx0", "server", "tx0"); - connect("self", "rx0", "server", "rx0"); - connect("self", "cs", "server", "cs"); - - // initialize NCO - double freq = 100e3; - int interp = 32; // 32 -> 4MS/s - double sample_rate = 128e6 / interp; - d_nco.set_freq(2*M_PI * freq/sample_rate); -} - -test_usrp_inband_underrun::~test_usrp_inband_underrun() -{ -} - -void -test_usrp_inband_underrun::initial_transition() -{ - opening_usrp(); -} - -// Handle message reads all incoming messages from USRP server which will be -// initialization and ping responses. We perform actions based on the current -// state and the event (ie, ping response) -void -test_usrp_inband_underrun::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); - pmt_t data = msg->data(); - pmt_t port_id = msg->port_id(); - - pmt_t handle = PMT_F; - pmt_t status = PMT_F; - pmt_t dict = PMT_NIL; - std::string error_msg; - - // Check the recv sample responses for underruns and count - if(pmt_eq(event, s_response_recv_raw_samples)) { - handle = pmt_nth(0, data); - status = pmt_nth(1, data); - dict = pmt_nth(4, data); - - if(pmt_eq(status, PMT_T)) { - handle_recv_response(dict); - return; - } - else { - error_msg = "error while receiving samples:"; - goto bail; - } - } - - - // Dispatch based on state - switch(d_state) { - - //----------------------------- OPENING_USRP ----------------------------// - // We only expect a response from opening the USRP which should be succesful - // or failed. - case OPENING_USRP: - - if(pmt_eq(event, s_response_open)) { - - status = pmt_nth(1, data); // failed/succes - - if(pmt_eq(status, PMT_T)) { - allocating_channels(); - return; - } - else { - error_msg = "failed to open usrp:"; - goto bail; - } - - } - - goto unhandled; // all other messages not handled in this state - - - //----------------------- ALLOCATING CHANNELS --------------------// - // When allocating channels, we need to wait for 2 responses from - // USRP server: one for TX and one for RX. Both are initialized to - // NIL so we know to continue to the next state once both are set. - case ALLOCATING_CHANNELS: - - // A TX allocation response - if(pmt_eq(event, s_response_allocate_channel) - && pmt_eq(d_tx->port_symbol(), port_id)) - { - status = pmt_nth(1, data); - - // If successful response, extract the channel - if(pmt_eq(status, PMT_T)) { - - d_tx_chan = pmt_nth(2, data); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_UNDERRUN] Received TX allocation" - << " on channel " << d_tx_chan << std::endl; - - // If the RX has also been allocated already, we can continue - if(!pmt_eqv(d_rx_chan, PMT_NIL)) { - enter_receiving(); - enter_transmitting(); - } - - return; - } - else { // TX allocation failed - error_msg = "failed to allocate TX channel:"; - goto bail; - } - } - - // A RX allocation response - if(pmt_eq(event, s_response_allocate_channel) - && pmt_eq(d_rx->port_symbol(), port_id)) - { - status = pmt_nth(1, data); - - // If successful response, extract the channel - if(pmt_eq(status, PMT_T)) { - - d_rx_chan = pmt_nth(2, data); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_UNDERRUN] Received RX allocation" - << " on channel " << d_rx_chan << std::endl; - - // If the TX has also been allocated already, we can continue - if(!pmt_eqv(d_tx_chan, PMT_NIL)) { - enter_receiving(); - enter_transmitting(); - } - - return; - } - else { // RX allocation failed - error_msg = "failed to allocate RX channel:"; - goto bail; - } - } - - goto unhandled; - - case WRITE_REGISTER: - goto unhandled; - - case READ_REGISTER: - goto unhandled; - - //-------------------------- TRANSMITTING ----------------------------// - // In the transmit state we count the number of underruns received and - // ballpark the number with an expected count (something >1 for starters) - case TRANSMITTING: - - // Check that the transmits are OK - if (pmt_eq(event, s_response_xmit_raw_frame)){ - handle = pmt_nth(0, data); - status = pmt_nth(1, data); - - if (pmt_eq(status, PMT_T)){ - handle_xmit_response(handle); - return; - } - else { - error_msg = "bad response-xmit-raw-frame:"; - goto bail; - } - } - - goto unhandled; - - //------------------------- CLOSING CHANNELS ----------------------------// - // Check deallocation responses, once the TX and RX channels are both - // deallocated then we close the USRP. - case CLOSING_CHANNELS: - - if (pmt_eq(event, s_response_deallocate_channel) - && pmt_eq(d_tx->port_symbol(), port_id)) - { - status = pmt_nth(1, data); - - // If successful, set the port to NIL - if(pmt_eq(status, PMT_T)) { - d_tx_chan = PMT_NIL; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_UNDERRUN] Received TX deallocation\n"; - - // If the RX is also deallocated, we can close the USRP - if(pmt_eq(d_rx_chan, PMT_NIL)) - closing_usrp(); - - return; - - } else { - - error_msg = "failed to deallocate TX channel:"; - goto bail; - - } - } - - if (pmt_eq(event, s_response_deallocate_channel) - && pmt_eq(d_rx->port_symbol(), port_id)) - { - status = pmt_nth(1, data); - - // If successful, set the port to NIL - if(pmt_eq(status, PMT_T)) { - d_rx_chan = PMT_NIL; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_UNDERRUN] Received RX deallocation\n"; - - // If the TX is also deallocated, we can close the USRP - if(pmt_eq(d_tx_chan, PMT_NIL)) - closing_usrp(); - - return; - - } else { - - error_msg = "failed to deallocate RX channel:"; - goto bail; - - } - } - - goto unhandled; - - //--------------------------- CLOSING USRP ------------------------------// - // Once we have received a successful USRP close response, we shutdown all - // mblocks and exit. - case CLOSING_USRP: - - if (pmt_eq(event, s_response_close)) { - - status = pmt_nth(1, data); - - if(pmt_eq(status, PMT_T)) { - - if(verbose) - std::cout << "[TEST_USRP_INBAND_UNDERRUN] Successfully closed USRP\n"; - - std::cout << "\nUnderruns: " << d_n_underruns << std::endl; - fflush(stdout); - - shutdown_all(PMT_T); - return; - - } else { - - error_msg = "failed to close USRP:"; - goto bail; - } - } - - goto unhandled; - - case INIT: - goto unhandled; - - } - - // An error occured, print it, and shutdown all m-blocks - bail: - std::cerr << error_msg << data - << "status = " << status << std::endl; - shutdown_all(PMT_F); - return; - - // Received an unhandled message for a specific state - unhandled: - if(verbose && !pmt_eq(event, pmt_intern("%shutdown"))) - std::cout << "test_usrp_inband_tx: unhandled msg: " << msg - << "in state "<< d_state << std::endl; - -} - - -// Sends a command to USRP server to open up a connection to the -// specified USRP, which is defaulted to USRP 0 on the system -void -test_usrp_inband_underrun::opening_usrp() -{ - - if(verbose) - std::cout << "[TEST_USRP_INBAND_UNDERRUN] Opening USRP " - << d_which_usrp << std::endl; - - d_cs->send(s_cmd_open, pmt_list2(PMT_NIL, d_which_usrp)); - d_state = OPENING_USRP; -} - -// RX and TX channels must be allocated so that the USRP server can -// properly share bandwidth across multiple USRPs. No commands will be -// successful to the USRP through the USRP server on the TX or RX channels until -// a bandwidth allocation has been received. -void -test_usrp_inband_underrun::allocating_channels() -{ - d_state = ALLOCATING_CHANNELS; - - long capacity = (long) 16e6; - d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); - d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(capacity))); -} - -// After allocating the channels, a write register command will be sent to the -// USRP. -void -test_usrp_inband_underrun::write_register() -{ - d_state = WRITE_REGISTER; - - long reg = 0; - - d_tx->send(s_cmd_to_control_channel, // C/S packet - pmt_list2(PMT_NIL, // invoc handle - pmt_list1( - pmt_list2(s_op_write_reg, - pmt_list2( - pmt_from_long(reg), - pmt_from_long(0xbeef)))))); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_REGISTERS] Writing 0xbeef to " - << reg << std::endl; - - read_register(); // immediately transition to read the register -} - -// Temporary: for testing pings -void -test_usrp_inband_underrun::build_and_send_ping() -{ - - d_tx->send(s_cmd_to_control_channel, - pmt_list2(PMT_NIL, pmt_list1(pmt_list2(s_op_ping_fixed, - pmt_list2(pmt_from_long(0), - pmt_from_long(0)))))); - - std::cout << "[TEST_USRP_INBAND_UNDERRUN] Ping sent" << std::endl; -} - -// After writing to the register, we want to read the value back and ensure that -// it is the same value that we wrote. -void -test_usrp_inband_underrun::read_register() -{ - d_state = READ_REGISTER; - - long reg = 9; - - d_tx->send(s_cmd_to_control_channel, // C/S packet - pmt_list2(PMT_NIL, // invoc handle - pmt_list1( - pmt_list2(s_op_read_reg, - pmt_list2( - pmt_from_long(0), // rid - pmt_from_long(reg)))))); - if(verbose) - std::cout << "[TEST_USRP_INBAND_UNDERRUN] Reading from register " - << reg << std::endl; -} - -// Used to enter the receiving state -void -test_usrp_inband_underrun::enter_receiving() -{ - d_rx->send(s_cmd_start_recv_raw_samples, - pmt_list2(PMT_F, - d_rx_chan)); - - if(verbose) - std::cout << "[TEST_USRP_INBAND_UNDERRUN] Started RX sample stream\n"; -} - -void -test_usrp_inband_underrun::enter_transmitting() -{ - d_state = TRANSMITTING; - d_nsamples_xmitted = 0; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_UNDERRUN] Entering transmit state...\n"; - - build_and_send_next_frame(); // fire off 4 to start pipeline - build_and_send_next_frame(); - build_and_send_next_frame(); - build_and_send_next_frame(); -} - -void -test_usrp_inband_underrun::build_and_send_next_frame() -{ - - long nsamples_this_frame = - std::min(d_nsamples_to_send - d_nsamples_xmitted, - d_samples_per_frame); - - if (nsamples_this_frame == 0){ - d_done_sending = true; - return; - } - - size_t nshorts = 2 * nsamples_this_frame; // 16-bit I & Q - pmt_t uvec = pmt_make_s16vector(nshorts, 0); - size_t ignore; - int16_t *samples = pmt_s16vector_writable_elements(uvec, ignore); - - // fill in the complex sinusoid - - for (int i = 0; i < nsamples_this_frame; i++){ - - if (1){ - gr_complex s; - d_nco.sincos(&s, 1, d_amplitude); - // write 16-bit i & q - samples[2*i] = (int16_t) s.real(); - samples[2*i+1] = (int16_t) s.imag(); - } - else { - gr_complex s(d_amplitude, d_amplitude); - - // write 16-bit i & q - samples[2*i] = (int16_t) s.real(); - samples[2*i+1] = (int16_t) s.imag(); - } - } - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TX] Transmitting frame...\n"; - - pmt_t timestamp = pmt_from_long(0xffffffff); // NOW - d_tx->send(s_cmd_xmit_raw_frame, - pmt_list4(pmt_from_long(d_nframes_xmitted), // invocation-handle - d_tx_chan, // channel - uvec, // the samples - timestamp)); - - d_nsamples_xmitted += nsamples_this_frame; - d_nframes_xmitted++; - - if(verbose) - std::cout << "[TEST_USRP_INBAND_TX] Transmitted frame\n"; - -} - -void -test_usrp_inband_underrun::handle_xmit_response(pmt_t handle) -{ - if (d_done_sending && - pmt_to_long(handle) == (d_nframes_xmitted - 1)){ - // We're done sending and have received all responses - closing_channels(); - return; - } - - build_and_send_next_frame(); -} - -void -test_usrp_inband_underrun::handle_recv_response(pmt_t dict) -{ - if(!pmt_is_dict(dict)) { - std::cout << "[TEST_USRP_INBAND_UNDERRUN] Recv samples dictionary is improper\n"; - return; - } - - // Read the TX interpolations - if(pmt_t underrun = pmt_dict_ref(dict, - pmt_intern("underrun"), - PMT_NIL)) { - if(pmt_eqv(underrun, PMT_T)) { - d_n_underruns++; - - if(verbose && 0) - std::cout << "[TEST_USRP_INBAND_UNDERRUN] Underrun\n"; - } - else { - if(verbose && 0) - std::cout << "[TEST_USRP_INBAND_UNDERRUN] No underrun\n" << underrun <<std::endl; - } - } else { - - if(verbose && 0) - std::cout << "[TEST_USRP_INBAND_UNDERRUN] No underrun\n"; - } - -} - -void -test_usrp_inband_underrun::closing_channels() -{ - d_state = CLOSING_CHANNELS; - - d_tx->send(s_cmd_deallocate_channel, pmt_list2(PMT_NIL, d_tx_chan)); - d_rx->send(s_cmd_deallocate_channel, pmt_list2(PMT_NIL, d_rx_chan)); -} - -void -test_usrp_inband_underrun::closing_usrp() -{ - d_state = CLOSING_USRP; - - d_cs->send(s_cmd_close, pmt_list1(PMT_NIL)); -} - -REGISTER_MBLOCK_CLASS(test_usrp_inband_underrun); diff --git a/usrp/limbo/apps-inband/ui_nco.h b/usrp/limbo/apps-inband/ui_nco.h deleted file mode 100644 index e6d7814ab..000000000 --- a/usrp/limbo/apps-inband/ui_nco.h +++ /dev/null @@ -1,202 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002 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_UI_NCO_H -#define INCLUDED_UI_NCO_H - - -#include <vector> -#include <ui_sincos.h> -#include <cmath> - -#include <complex> -typedef std::complex<float> gr_complex; - - -/*! - * \brief base class template for Numerically Controlled Oscillator (NCO) - */ - - -//FIXME Eventually generalize this to fixed point - -template<class o_type, class i_type> -class ui_nco { -public: - ui_nco () : phase (0), phase_inc(0) {} - - virtual ~ui_nco () {} - - // radians - void set_phase (double angle) { - phase = angle; - } - - void adjust_phase (double delta_phase) { - phase += delta_phase; - } - - - // angle_rate is in radians / step - void set_freq (double angle_rate){ - phase_inc = angle_rate; - } - - // angle_rate is a delta in radians / step - void adjust_freq (double delta_angle_rate) - { - phase_inc += delta_angle_rate; - } - - // increment current phase angle - - void step () - { - phase += phase_inc; - if (fabs (phase) > M_PI){ - - while (phase > M_PI) - phase -= 2*M_PI; - - while (phase < -M_PI) - phase += 2*M_PI; - } - } - - void step (int n) - { - phase += phase_inc * n; - if (fabs (phase) > M_PI){ - - while (phase > M_PI) - phase -= 2*M_PI; - - while (phase < -M_PI) - phase += 2*M_PI; - } - } - - // units are radians / step - double get_phase () const { return phase; } - double get_freq () const { return phase_inc; } - - // compute sin and cos for current phase angle - void sincos (float *sinx, float *cosx) const; - - // compute cos or sin for current phase angle - float cos () const { return std::cos (phase); } - float sin () const { return std::sin (phase); } - - // compute a block at a time - void sin (float *output, int noutput_items, double ampl = 1.0); - void cos (float *output, int noutput_items, double ampl = 1.0); - void sincos (gr_complex *output, int noutput_items, double ampl = 1.0); - void sin (short *output, int noutput_items, double ampl = 1.0); - void cos (short *output, int noutput_items, double ampl = 1.0); - void sin (int *output, int noutput_items, double ampl = 1.0); - void cos (int *output, int noutput_items, double ampl = 1.0); - -protected: - double phase; - double phase_inc; -}; - -template<class o_type, class i_type> -void -ui_nco<o_type,i_type>::sincos (float *sinx, float *cosx) const -{ - ui_sincosf (phase, sinx, cosx); -} - -template<class o_type, class i_type> -void -ui_nco<o_type,i_type>::sin (float *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (float)(sin () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -ui_nco<o_type,i_type>::cos (float *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (float)(cos () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -ui_nco<o_type,i_type>::sin (short *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (short)(sin() * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -ui_nco<o_type,i_type>::cos (short *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (short)(cos () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -ui_nco<o_type,i_type>::sin (int *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (int)(sin () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -ui_nco<o_type,i_type>::cos (int *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - output[i] = (int)(cos () * ampl); - step (); - } -} - -template<class o_type, class i_type> -void -ui_nco<o_type,i_type>::sincos (gr_complex *output, int noutput_items, double ampl) -{ - for (int i = 0; i < noutput_items; i++){ - float cosx, sinx; - sincos (&sinx, &cosx); - output[i] = gr_complex(cosx * ampl, sinx * ampl); - step (); - } -} - -#endif /* INCLUDED_UI_NCO_H */ - diff --git a/usrp/limbo/apps-inband/ui_sincos.c b/usrp/limbo/apps-inband/ui_sincos.c deleted file mode 100644 index 27841f010..000000000 --- a/usrp/limbo/apps-inband/ui_sincos.c +++ /dev/null @@ -1,81 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004 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 - -#define _GNU_SOURCE // ask for GNU extensions if available - -#include "ui_sincos.h" -#include <math.h> - -// ---------------------------------------------------------------- - -#if defined (HAVE_SINCOS) - -void -ui_sincos (double x, double *sinx, double *cosx) -{ - sincos (x, sinx, cosx); -} - -#else - -void -ui_sincos (double x, double *sinx, double *cosx) -{ - *sinx = sin (x); - *cosx = cos (x); -} - -#endif - -// ---------------------------------------------------------------- - -#if defined (HAVE_SINCOSF) - -void -ui_sincosf (float x, float *sinx, float *cosx) -{ - sincosf (x, sinx, cosx); -} - -#elif defined (HAVE_SINF) && defined (HAVE_COSF) - -void -ui_sincosf (float x, float *sinx, float *cosx) -{ - *sinx = sinf (x); - *cosx = cosf (x); -} - -#else - -void -ui_sincosf (float x, float *sinx, float *cosx) -{ - *sinx = sin (x); - *cosx = cos (x); -} - -#endif diff --git a/usrp/limbo/apps-inband/ui_sincos.h b/usrp/limbo/apps-inband/ui_sincos.h deleted file mode 100644 index d2d6e4b76..000000000 --- a/usrp/limbo/apps-inband/ui_sincos.h +++ /dev/null @@ -1,39 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2002,2004 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_UI_SINCOS_H -#define INCLUDED_UI_SINCOS_H - -#ifdef __cplusplus -extern "C" { -#endif - -// compute sine and cosine at the same time - -void ui_sincos (double x, double *sin, double *cos); -void ui_sincosf (float x, float *sin, float *cos); - -#ifdef __cplusplus -}; -#endif - -#endif /* INCLUDED_UI_SINCOS_H */ diff --git a/usrp/limbo/inband/.gitignore b/usrp/limbo/inband/.gitignore deleted file mode 100644 index a228dcdc1..000000000 --- a/usrp/limbo/inband/.gitignore +++ /dev/null @@ -1,20 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/*.swp -/*.dat -/test_fusb -/std_paths.h -/usrp_dbid.py -/usrp_dbid.h -/usrp_dbid.cc -/usrp_server_mbh.cc -/test_inband -/test_usrp_inband -/test_usrp_tx -/*_mbh.cc diff --git a/usrp/limbo/inband/Makefile.am b/usrp/limbo/inband/Makefile.am deleted file mode 100644 index 650a25ff9..000000000 --- a/usrp/limbo/inband/Makefile.am +++ /dev/null @@ -1,114 +0,0 @@ -# -# Copyright 2007,2008 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -include $(top_srcdir)/Makefile.common - -AM_CPPFLAGS = \ - $(DEFINES) $(OMNITHREAD_INCLUDES) $(PMT_INCLUDES) $(MBLOCK_INCLUDES) \ - $(USRP_INCLUDES) $(BOOST_CPPFLAGS) $(CPPUNIT_INCLUDES) \ - -I$(srcdir)/../../apps-inband $(WITH_INCLUDES) - -TESTS = test_inband - -EXTRA_DIST = \ - usrp_server.mbh \ - usrp_interface.mbh - -lib_LTLIBRARIES = \ - libusrp-inband.la \ - libusrp-inband-qa.la - -# ------------------------------------------------------------------------ -# Build the inband library - -BUILT_SOURCES = \ - usrp_server_mbh.cc \ - usrp_interface_mbh.cc - -usrp_server_mbh.cc : usrp_server.mbh - $(COMPILE_MBH) $(srcdir)/usrp_server.mbh usrp_server_mbh.cc - -usrp_interface_mbh.cc : usrp_interface.mbh - $(COMPILE_MBH) $(srcdir)/usrp_interface.mbh usrp_interface_mbh.cc - -libusrp_inband_la_SOURCES = \ - $(BUILT_SOURCES) \ - $(srcdir)/../../apps-inband/ui_sincos.c \ - usrp_inband_usb_packet.cc \ - usrp_rx.cc \ - usrp_rx_stub.cc \ - usrp_server.cc \ - usrp_tx.cc \ - usrp_tx_stub.cc \ - usrp_usb_interface.cc - -libusrp_inband_la_LDFLAGS = $(NO_UNDEFINED) -version-info 0:0:0 - -libusrp_inband_la_LIBADD = \ - $(MBLOCK_LA) \ - $(USRP_LA) \ - -lstdc++ - -include_HEADERS = \ - usrp_inband_usb_packet.h \ - usrp_rx.h \ - usrp_rx_stub.h \ - usrp_server.h \ - usrp_tx.h \ - usrp_tx_stub.h \ - usrp_usb_interface.h - -noinst_HEADERS = \ - qa_inband.h \ - qa_inband_packet_prims.h \ - qa_inband_usrp_server.h \ - symbols_usrp_channel.h \ - symbols_usrp_interface_cs.h \ - symbols_usrp_low_level_cs.h \ - symbols_usrp_rx.h \ - symbols_usrp_rx_cs.h \ - symbols_usrp_server_cs.h \ - symbols_usrp_tx.h \ - symbols_usrp_tx_cs.h - -# ------------------------------------------------------------------------ -# Build the qa code in its own library - -libusrp_inband_qa_la_SOURCES = \ - qa_inband.cc \ - qa_inband_packet_prims.cc \ - qa_inband_usrp_server.cc - -# magic flags -libusrp_inband_qa_la_LDFLAGS = $(NO_UNDEFINED) -avoid-version - -libusrp_inband_qa_la_LIBADD = \ - libusrp-inband.la \ - $(PMT_LA) \ - $(CPPUNIT_LIBS) \ - -lstdc++ - -# ------------------------------------------------------------------------ - -noinst_PROGRAMS = \ - test_inband - -test_inband_SOURCES = test_inband.cc -test_inband_LDADD = libusrp-inband-qa.la diff --git a/usrp/limbo/inband/dump_packets.py b/usrp/limbo/inband/dump_packets.py deleted file mode 100755 index 237362406..000000000 --- a/usrp/limbo/inband/dump_packets.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -import sys -import struct -from optparse import OptionParser - -from usb_packet import * - -def dump_packet(raw_pkt, outfile, dump_payload): - pkt = usb_packet(raw_pkt) - outfile.write(pkt.decoded_flags()) - outfile.write(' chan= %2d len= %3d timestamp= 0x%08x rssi= % 2d tag= %2d\n' % ( - pkt.chan(), pkt.payload_len(), pkt.timestamp(), pkt.rssi(), pkt.tag())) - if dump_payload: - assert pkt.payload_len() % 4 == 0 - shorts = struct.unpack('<%dh' % (pkt.payload_len() // 2), pkt.payload()) - for i in range(0, len(shorts), 2): - outfile.write(' %6d, %6d\n' % (shorts[i], shorts[i+1])) - - -def dump_packets(infile, outfile, dump_payload): - raw_pkt = infile.read(512) - while raw_pkt: - if len(raw_pkt) != 512: - sys.stderr.write("File length is not a multiple of 512 bytes") - raise SystemExit, 1 - - dump_packet(raw_pkt, outfile, dump_payload) - raw_pkt = infile.read(512) - - -def main(): - parser = OptionParser() - parser.add_option('-p', '--dump-payload', action='store_true', default=False, - help='dump payload in decimal and hex') - - (options, files) = parser.parse_args() - if len(files) == 0: - dump_packets(sys.stdin, sys.stdout, options.dump_payload) - else: - for f in files: - dump_packets(open(f, "r"), sys.stdout, options.dump_payload) - - -if __name__ == '__main__': - main() diff --git a/usrp/limbo/inband/gen_test_packets.py b/usrp/limbo/inband/gen_test_packets.py deleted file mode 100755 index 2ee646384..000000000 --- a/usrp/limbo/inband/gen_test_packets.py +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/env python - -import random -import struct -from pprint import pprint -from usb_packet import * - -MAX_PAYLOAD = 504 -TIME_NOW = 0xffffffff - - -class sequence_generator(object): - def __init__(self): - self.i = 0 - - def __call__(self): - t = self.i - self.i += 1 - return t - -def gen_shuffled_lengths(): - valid_lengths = range(0, MAX_PAYLOAD+1, 4) # [0, 4, 8, ... 504] - random.shuffle(valid_lengths) - return valid_lengths - - -class packet_sequence_generator(object): - def __init__(self, channel, lengths): - self.next = sequence_generator() - self.channel = channel - self.lengths = lengths - - def __call__(self, output_file): - gen_packet(output_file, self.channel, self.next, self.lengths[0]) - del self.lengths[0] - - -def gen_packet(output_file, channel, content_generator, payload_len): - assert (payload_len % 4) == 0 - payload = [] - n_iq = payload_len // 4 - for n in range(n_iq): - payload.append(content_generator()) # I - payload.append(content_generator()) # Q - for n in range(MAX_PAYLOAD // 4 - n_iq): - payload.append(0x0000) - payload.append(0xffff) - - assert (len(payload) == MAX_PAYLOAD // 2) - - #print "\npayload_len =", payload_len - #pprint(payload) - - output_file.write(make_header(FL_START_OF_BURST|FL_END_OF_BURST, - channel, payload_len, TIME_NOW)) - output_file.write(struct.pack('<252h', *payload)) - - -def gen_all_valid_packet_lengths_1_channel(output_file): - lengths = gen_shuffled_lengths() - npkts = len(lengths) # number of packets we'll generator on each stream - pkt_gen_0 = packet_sequence_generator(0, lengths) - for i in range(npkts): - pkt_gen_0(output_file) - - assert pkt_gen_0.next() == 16002 # 2*sum(1, 2, ..., 126) == 126 * 127 - - -def gen_all_valid_packet_lengths_2_channels(output_file): - lengths = gen_shuffled_lengths() - npkts = len(lengths) # number of packets we'll generator on each stream - pkt_gen_0 = packet_sequence_generator(0, lengths) - pkt_gen_1 = packet_sequence_generator(0x1f, gen_shuffled_lengths()) - pkt_gen = (pkt_gen_0, pkt_gen_1) - - which_gen = (npkts * [0]) + (npkts * [1]) - random.shuffle(which_gen) - - for i in which_gen: - pkt_gen[i](output_file) - - assert pkt_gen_0.next() == 16002 # 2*sum(1, 2, ..., 126) == 126 * 127 - assert pkt_gen_1.next() == 16002 # 2*sum(1, 2, ..., 126) == 126 * 127 - -if __name__ == '__main__': - random.seed(0) - gen_all_valid_packet_lengths_1_channel(open("all_valid_packet_lengths_1_channel.dat", "w")) - gen_all_valid_packet_lengths_2_channels(open("all_valid_packet_lengths_2_channels.dat", "w")) diff --git a/usrp/limbo/inband/qa_inband.cc b/usrp/limbo/inband/qa_inband.cc deleted file mode 100644 index 6f33a6ead..000000000 --- a/usrp/limbo/inband/qa_inband.cc +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <qa_inband.h> -#include <qa_inband_packet_prims.h> -#include <qa_inband_usrp_server.h> - -CppUnit::TestSuite * -qa_inband::suite() -{ - CppUnit::TestSuite *s = new CppUnit::TestSuite("inband"); - - s->addTest (qa_inband_packet_prims::suite()); - s->addTest (qa_inband_usrp_server::suite()); - - return s; -} diff --git a/usrp/limbo/inband/qa_inband.h b/usrp/limbo/inband/qa_inband.h deleted file mode 100644 index ab8f7f250..000000000 --- a/usrp/limbo/inband/qa_inband.h +++ /dev/null @@ -1,35 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef INCLUDED_QA_INBAND_H -#define INCLUDED_QA_INBAND_H - -#include <cppunit/TestSuite.h> - -//! collect all the tests for the user server - -class qa_inband { - public: - //! return suite of tests for all of usrp server - static CppUnit::TestSuite *suite(); -}; - -#endif /* INCLUDED_QA_INBAND_H */ diff --git a/usrp/limbo/inband/qa_inband_packet_prims.cc b/usrp/limbo/inband/qa_inband_packet_prims.cc deleted file mode 100644 index d9bbbec22..000000000 --- a/usrp/limbo/inband/qa_inband_packet_prims.cc +++ /dev/null @@ -1,162 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <qa_inband_packet_prims.h> -#include <cppunit/TestAssert.h> -#include <stdio.h> -#include <string.h> -#include <usrp_inband_usb_packet.h> // will change on gigabit crossover - -typedef usrp_inband_usb_packet transport_pkt; - -void -qa_inband_packet_prims::test_flags() -{ - transport_pkt pkt; - - // Test each one of the flags while ensuring no other fields become set in the process - pkt.set_header(pkt.FL_START_OF_BURST,0,0,0); - CPPUNIT_ASSERT_EQUAL(1, pkt.start_of_burst()); - CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst()); - CPPUNIT_ASSERT_EQUAL(0, pkt.overrun()); - CPPUNIT_ASSERT_EQUAL(0, pkt.underrun()); - CPPUNIT_ASSERT_EQUAL(0, pkt.dropped()); - CPPUNIT_ASSERT_EQUAL(0, pkt.chan()); - CPPUNIT_ASSERT_EQUAL(0, pkt.tag()); - CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len()); - - pkt.set_header(pkt.FL_END_OF_BURST,0,0,0); - CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst()); - CPPUNIT_ASSERT_EQUAL(1, pkt.end_of_burst()); - CPPUNIT_ASSERT_EQUAL(0, pkt.overrun()); - CPPUNIT_ASSERT_EQUAL(0, pkt.underrun()); - CPPUNIT_ASSERT_EQUAL(0, pkt.dropped()); - CPPUNIT_ASSERT_EQUAL(0, pkt.chan()); - CPPUNIT_ASSERT_EQUAL(0, pkt.tag()); - CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len()); - - pkt.set_header(pkt.FL_OVERRUN,0,0,0); - CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst()); - CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst()); - CPPUNIT_ASSERT_EQUAL(1, pkt.overrun()); - CPPUNIT_ASSERT_EQUAL(0, pkt.underrun()); - CPPUNIT_ASSERT_EQUAL(0, pkt.dropped()); - CPPUNIT_ASSERT_EQUAL(0, pkt.chan()); - CPPUNIT_ASSERT_EQUAL(0, pkt.tag()); - CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len()); - - pkt.set_header(pkt.FL_UNDERRUN,0,0,0); - CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst()); - CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst()); - CPPUNIT_ASSERT_EQUAL(0, pkt.overrun()); - CPPUNIT_ASSERT_EQUAL(1, pkt.underrun()); - CPPUNIT_ASSERT_EQUAL(0, pkt.dropped()); - CPPUNIT_ASSERT_EQUAL(0, pkt.chan()); - CPPUNIT_ASSERT_EQUAL(0, pkt.tag()); - CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len()); - - pkt.set_header(pkt.FL_DROPPED,0,0,0); - CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst()); - CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst()); - CPPUNIT_ASSERT_EQUAL(0, pkt.overrun()); - CPPUNIT_ASSERT_EQUAL(0, pkt.underrun()); - CPPUNIT_ASSERT_EQUAL(1, pkt.dropped()); - CPPUNIT_ASSERT_EQUAL(0, pkt.chan()); - CPPUNIT_ASSERT_EQUAL(0, pkt.tag()); - CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len()); - - // test of all fields set - pkt.set_header( - pkt.FL_START_OF_BURST | - pkt.FL_END_OF_BURST | - pkt.FL_UNDERRUN | - pkt.FL_OVERRUN | - pkt.FL_DROPPED - ,0,0,0); - CPPUNIT_ASSERT_EQUAL(1, pkt.start_of_burst()); - CPPUNIT_ASSERT_EQUAL(1, pkt.end_of_burst()); - CPPUNIT_ASSERT_EQUAL(1, pkt.overrun()); - CPPUNIT_ASSERT_EQUAL(1, pkt.underrun()); - CPPUNIT_ASSERT_EQUAL(1, pkt.dropped()); - CPPUNIT_ASSERT_EQUAL(0, pkt.chan()); - CPPUNIT_ASSERT_EQUAL(0, pkt.tag()); - CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len()); - - -} -////////////////////////////////////////////////////////////////////// - -void -qa_inband_packet_prims::test_fields() -{ - transport_pkt pkt; - void * payload; - - // test word0 field exclusiveness - // - // I want to test max values of each field to ensure field boundaries - // but these max values could change based on technology? The - // max payload is returned by a private method so the code is not - // technology dependent - pkt.set_header(0,16,0,0); - CPPUNIT_ASSERT_EQUAL(16, pkt.chan()); - CPPUNIT_ASSERT_EQUAL(0, pkt.tag()); - CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len()); - - pkt.set_header(0,0,8,0); - CPPUNIT_ASSERT_EQUAL(0, pkt.chan()); - CPPUNIT_ASSERT_EQUAL(8, pkt.tag()); - CPPUNIT_ASSERT_EQUAL(0,pkt.payload_len()); - - pkt.set_header(0,0,0,pkt.max_payload()); - CPPUNIT_ASSERT_EQUAL(0, pkt.chan()); - CPPUNIT_ASSERT_EQUAL(0, pkt.tag()); - CPPUNIT_ASSERT_EQUAL(pkt.max_payload(), pkt.payload_len()); - - // test timestamp, shouldn't have to test other fields since - // setting the timestamp only has the ability to affect one word - pkt.set_timestamp(54); - CPPUNIT_ASSERT_EQUAL(uint32_t(54), pkt.timestamp()); - - // test the payload, ensure no other fields overwritten - // - // is there a better test for this? - pkt.set_header(0,0,0,0); - payload = malloc(pkt.payload_len()); - memset(payload, 'f', pkt.payload_len()); - memcpy(pkt.payload(), payload, pkt.payload_len()); - CPPUNIT_ASSERT_EQUAL(0, memcmp(pkt.payload(), payload, pkt.payload_len())); - CPPUNIT_ASSERT_EQUAL(0, pkt.start_of_burst()); - CPPUNIT_ASSERT_EQUAL(0, pkt.end_of_burst()); - CPPUNIT_ASSERT_EQUAL(0, pkt.overrun()); - CPPUNIT_ASSERT_EQUAL(0, pkt.underrun()); - CPPUNIT_ASSERT_EQUAL(0, pkt.dropped()); - CPPUNIT_ASSERT_EQUAL(0, pkt.chan()); - CPPUNIT_ASSERT_EQUAL(0, pkt.tag()); - CPPUNIT_ASSERT_EQUAL(0, pkt.payload_len()); - free(payload); - -} -////////////////////////////////////////////////////////////////////// diff --git a/usrp/limbo/inband/qa_inband_packet_prims.h b/usrp/limbo/inband/qa_inband_packet_prims.h deleted file mode 100644 index 71c0d737d..000000000 --- a/usrp/limbo/inband/qa_inband_packet_prims.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef QA_INBAND_PACKET_PRIMS_H -#define QA_INBAND_PACKET_PRIMS_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_inband_packet_prims : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE(qa_inband_packet_prims); - CPPUNIT_TEST(test_flags); - CPPUNIT_TEST(test_fields); - CPPUNIT_TEST_SUITE_END(); - - private: - void test_flags(); - void test_fields(); - -}; - -#endif /* INCLUDED_QA_INBAND_PACKET_PRIMS_H */ diff --git a/usrp/limbo/inband/qa_inband_usrp_server.cc b/usrp/limbo/inband/qa_inband_usrp_server.cc deleted file mode 100644 index 6049a8a87..000000000 --- a/usrp/limbo/inband/qa_inband_usrp_server.cc +++ /dev/null @@ -1,1575 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <usrp_inband_usb_packet.h> -#include <qa_inband_usrp_server.h> -#include <cppunit/TestAssert.h> -#include <stdio.h> -#include <usrp_server.h> -#include <mblock/mblock.h> -#include <mblock/runtime.h> -#include <mblock/protocol_class.h> -#include <mblock/class_registry.h> -#include <vector> -#include <iostream> -#include <pmt.h> - -#include <symbols_usrp_server_cs.h> -#include <symbols_usrp_tx.h> -#include <symbols_usrp_rx.h> -#include <symbols_usrp_channel.h> -#include <symbols_usrp_low_level_cs.h> - -typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit easy - -static bool verbose = false; - -static pmt_t s_timeout = pmt_intern("%timeout"); - -// ---------------------------------------------------------------------------------------------- - -class qa_alloc_top : public mb_mblock -{ - mb_port_sptr d_tx; - mb_port_sptr d_rx; - mb_port_sptr d_cs; - - long d_nmsgs_to_recv; - long d_nrecvd; - - long d_max_capacity; - long d_ntx_chan, d_nrx_chan; - - long d_nstatus; - long d_nstatus_to_recv; - - public: - qa_alloc_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~qa_alloc_top(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void check_message(mb_message_sptr msg); - void run_tests(); -}; - -qa_alloc_top::qa_alloc_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - d_nrecvd=0; - d_nmsgs_to_recv = 6; - d_nstatus=0; - d_nstatus_to_recv = 50; - - d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL); - d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - // Use the stub with the usrp_server - pmt_t usrp_server_dict = pmt_make_dict(); - pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T); - - // Test the TX side - define_component("server", "usrp_server", usrp_server_dict); - connect("self", "tx0", "server", "tx0"); - connect("self", "rx0", "server", "rx0"); - connect("self", "cs", "server", "cs"); - -} - -qa_alloc_top::~qa_alloc_top(){} - -void -qa_alloc_top::initial_transition() -{ - // Allocations should fail before open - d_tx->send(s_cmd_allocate_channel, - pmt_list2(pmt_list2(s_response_allocate_channel, - s_err_usrp_not_opened), - pmt_from_long(1))); - - d_rx->send(s_cmd_allocate_channel, - pmt_list2(pmt_list2(s_response_allocate_channel, - s_err_usrp_not_opened), - pmt_from_long(1))); - - // Retrieve information about the USRP, then run tests - d_cs->send(s_cmd_open, - pmt_list2(pmt_list2(s_response_open, PMT_T), - pmt_from_long(0))); - - d_cs->send(s_cmd_max_capacity, - pmt_list1(pmt_list2(s_response_max_capacity, PMT_T))); - - d_cs->send(s_cmd_ntx_chan, - pmt_list1(pmt_list2(s_response_ntx_chan, PMT_T))); - - d_cs->send(s_cmd_nrx_chan, - pmt_list1(pmt_list2(s_response_nrx_chan,PMT_T))); -} - -void -qa_alloc_top::run_tests() -{ - if(verbose) - std::cout << "[qa_alloc_top] Starting tests...\n"; - - // should be able to allocate 1 byte - d_tx->send(s_cmd_allocate_channel, - pmt_list2(PMT_T, pmt_from_long(1))); - - // should not be able to allocate max capacity after 100 bytes were allocated - d_tx->send(s_cmd_allocate_channel, - pmt_list2(s_err_requested_capacity_unavailable, - pmt_from_long(d_max_capacity))); - - // keep allocating a little more until all of the channels are used and test - // the error response we start at 1 since we've already allocated 1 channel - for(int i=1; i < d_ntx_chan; i++) { - - if(verbose) - std::cout << "[qa_alloc_top] Sent allocation request...\n"; - - d_tx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1))); - - d_nmsgs_to_recv++; - } - - // No more channels after allocating all of them is expected - d_tx->send(s_cmd_allocate_channel, - pmt_list2(s_err_channel_unavailable, - pmt_from_long(1))); - - // test out the same on the RX side - d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1))); - - d_rx->send(s_cmd_allocate_channel, - pmt_list2(s_err_requested_capacity_unavailable, - pmt_from_long(d_max_capacity))); - - for(int i=1; i < d_nrx_chan; i++) { - - d_rx->send(s_cmd_allocate_channel, pmt_list2(PMT_T, pmt_from_long(1))); - - d_nmsgs_to_recv++; - } - - d_rx->send(s_cmd_allocate_channel, - pmt_list2(s_err_channel_unavailable, - pmt_from_long(1))); - - // when all is said and done, there should be d_ntx_chan+d_ntx_chan bytes - // allocated - d_cs->send(s_cmd_current_capacity_allocation, - pmt_list1(pmt_from_long(d_ntx_chan+d_nrx_chan))); -} - -void -qa_alloc_top::handle_message(mb_message_sptr msg) -{ - pmt_t data = msg->data(); - - if ((pmt_eq(msg->port_id(), d_tx->port_symbol()) - || pmt_eq(msg->port_id(), d_rx->port_symbol())) - && pmt_eq(msg->signal(), s_response_allocate_channel)) - check_message(msg); - - if (pmt_eq(msg->port_id(), d_cs->port_symbol())) { - - if(pmt_eq(msg->signal(), s_response_max_capacity)) { - d_max_capacity = pmt_to_long(pmt_nth(2, data)); - if(verbose) - std::cout << "[qa_alloc_top] USRP has max capacity of " - << d_max_capacity << "\n"; - } - else if(pmt_eq(msg->signal(), s_response_ntx_chan)) { - d_ntx_chan = pmt_to_long(pmt_nth(2, data)); - if(verbose) - std::cout << "[qa_alloc_top] USRP tx channels: " - << d_ntx_chan << "\n"; - } - else if(pmt_eq(msg->signal(), s_response_nrx_chan)) { - d_nrx_chan = pmt_to_long(pmt_nth(2, data)); - if(verbose) - std::cout << "[qa_alloc_top] USRP rx channels: " - << d_nrx_chan << "\n"; - } - else if(pmt_eq(msg->signal(), s_response_current_capacity_allocation)) { - check_message(msg); - } - - d_nstatus++; - - check_message(msg); - - if(d_nstatus==d_nstatus_to_recv) - run_tests(); - } -} - -void -qa_alloc_top::check_message(mb_message_sptr msg) -{ - pmt_t data = msg->data(); - pmt_t event = msg->signal(); - - pmt_t expected = pmt_nth(0, data); - pmt_t status = pmt_nth(1, data); - - pmt_t e_event = pmt_nth(0, expected); - pmt_t e_status = pmt_nth(1, expected); - - d_nrecvd++; - - - if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) { - if(verbose) - std::cout << "Got: " << status << " Expected: " << e_status << "\n"; - shutdown_all(PMT_F); - return; - } else { - if(verbose) - std::cout << "[qa_alloc_top] Received expected response for message " - << d_nrecvd << " (" << event << ")\n"; - } - - if(d_nrecvd == d_nmsgs_to_recv) - shutdown_all(PMT_T); -} - -REGISTER_MBLOCK_CLASS(qa_alloc_top); - -// ---------------------------------------------------------------------------------------------- - -class qa_dealloc_top : public mb_mblock -{ - mb_port_sptr d_tx; - mb_port_sptr d_rx; - mb_port_sptr d_cs; - - long d_max_capacity; - long d_ntx_chan, d_nrx_chan; - - long d_nstatus; - long d_nstatus_to_recv; - - long d_nalloc_to_recv; - long d_nalloc_recvd; - - long d_ndealloc_to_recv; - long d_ndealloc_recvd; - - std::vector<long> d_tx_chans; - std::vector<long> d_rx_chans; - - public: - qa_dealloc_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~qa_dealloc_top(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void check_allocation(mb_message_sptr msg); - void check_deallocation(mb_message_sptr msg); - void allocate_max(); - void deallocate_all(); -}; - -qa_dealloc_top::qa_dealloc_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - d_ndealloc_recvd=0; - d_ndealloc_to_recv = 0; - d_nalloc_recvd=0; - d_nalloc_to_recv = 0; // auto-set - d_nstatus=0; - d_nstatus_to_recv = 4; - - d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL); - d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - // Use the stub with the usrp_server - pmt_t usrp_server_dict = pmt_make_dict(); - pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T); - - // Test the TX side - define_component("server", "usrp_server", usrp_server_dict); - connect("self", "tx0", "server", "tx0"); - connect("self", "rx0", "server", "rx0"); - connect("self", "cs", "server", "cs"); -} - -qa_dealloc_top::~qa_dealloc_top(){} - -void -qa_dealloc_top::initial_transition() -{ - - if(verbose) - std::cout << "[qa_dealloc_top] Initializing...\n"; - - // Retrieve information about the USRP, then run tests - d_cs->send(s_cmd_open, - pmt_list2(pmt_list2(s_response_open,PMT_T), - pmt_from_long(0))); - - d_cs->send(s_cmd_max_capacity, - pmt_list1(pmt_list2(s_response_max_capacity,PMT_T))); - - d_cs->send(s_cmd_ntx_chan, - pmt_list1(pmt_list2(s_response_ntx_chan,PMT_T))); - - d_cs->send(s_cmd_nrx_chan, - pmt_list1(pmt_list2(s_response_nrx_chan,PMT_T))); -} - -void -qa_dealloc_top::allocate_max() -{ - - // Keep allocating until we hit the maximum number of channels - for(int i=0; i < d_ntx_chan; i++) { - d_tx->send(s_cmd_allocate_channel, - pmt_list2(pmt_list2(s_response_allocate_channel,PMT_T), - pmt_from_long(1))); // 1 byte is good enough - - d_nalloc_to_recv++; - } - - for(int i=0; i < d_nrx_chan; i++) { - d_rx->send(s_cmd_allocate_channel, - pmt_list2(pmt_list2(s_response_allocate_channel,PMT_T), - pmt_from_long(1))); - - d_nalloc_to_recv++; - } - -} - -void -qa_dealloc_top::deallocate_all() { - - // Deallocate all of the channels that were allocated from allocate_max() - for(int i=0; i < (int)d_tx_chans.size(); i++) { - - if(verbose) - std::cout << "[qa_dealloc_top] Trying to dealloc TX " - << d_tx_chans[i] << std::endl; - - d_tx->send(s_cmd_deallocate_channel, - pmt_list2(pmt_list2(s_response_deallocate_channel,PMT_T), - pmt_from_long(d_tx_chans[i]))); - - d_ndealloc_to_recv++; - } - - // Deallocate the RX side now - for(int i=0; i < (int)d_rx_chans.size(); i++) { - - if(verbose) - std::cout << "[qa_dealloc_top] Trying to dealloc RX " - << d_tx_chans[i] << std::endl; - - d_rx->send(s_cmd_deallocate_channel, - pmt_list2(pmt_list2(s_response_deallocate_channel,PMT_T), - pmt_from_long(d_rx_chans[i]))); - - d_ndealloc_to_recv++; - } - - // Should get permission denied errors trying to re-dealloc the channels, as - // we no longer have permission to them after deallocating - for(int i=0; i < (int)d_tx_chans.size(); i++) { - - d_tx->send(s_cmd_deallocate_channel, - pmt_list2(pmt_list2(s_response_deallocate_channel, - s_err_channel_permission_denied), - pmt_from_long(d_tx_chans[i]))); - - d_ndealloc_to_recv++; - } - - // Same for RX - for(int i=0; i < (int)d_rx_chans.size(); i++) { - - d_rx->send(s_cmd_deallocate_channel, - pmt_list2(pmt_list2(s_response_deallocate_channel, - s_err_channel_permission_denied), - pmt_from_long(d_rx_chans[i]))); - - d_ndealloc_to_recv++; - } - - // Try to deallocate a channel that doesn't exist on both sides, the last - // element in the vectors is the highest channel number, so we take that plus - // 1 - d_ndealloc_to_recv+=2; - d_tx->send(s_cmd_deallocate_channel, - pmt_list2(pmt_list2(s_response_deallocate_channel, - s_err_channel_invalid), - pmt_from_long(d_rx_chans.back()+1))); - - d_rx->send(s_cmd_deallocate_channel, - pmt_list2(pmt_list2(s_response_deallocate_channel, - s_err_channel_invalid), - pmt_from_long(d_rx_chans.back()+1))); - - - // The used capacity should be back to 0 now that we've deallocated everything - d_cs->send(s_cmd_current_capacity_allocation, - pmt_list1(pmt_list2(s_response_current_capacity_allocation, - PMT_T))); -} - -void -qa_dealloc_top::handle_message(mb_message_sptr msg) -{ - pmt_t data = msg->data(); - pmt_t event = msg->signal(); - - if(pmt_eq(event, pmt_intern("%shutdown"))) - return; - - pmt_t expected = pmt_nth(0, data); - pmt_t status = pmt_nth(1, data); - - pmt_t e_event = pmt_nth(0, expected); - pmt_t e_status = pmt_nth(1, expected); - - if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) { - if(verbose) - std::cout << "Got: " << status << " Expected: " << e_status << "\n"; - shutdown_all(PMT_F); - return; - } else { - if(verbose) - std::cout << "[qa_alloc_top] Received expected response for message " - << d_ndealloc_recvd - << " (" << event << ")\n"; - } - - if (pmt_eq(msg->port_id(), d_tx->port_symbol()) - || pmt_eq(msg->port_id(), d_rx->port_symbol())) { - - if(pmt_eq(msg->signal(), s_response_allocate_channel)) { - check_allocation(msg); - } - - } - - if (pmt_eq(msg->port_id(), d_cs->port_symbol())) { - - if(pmt_eq(msg->signal(), s_response_max_capacity)) { - d_max_capacity = pmt_to_long(pmt_nth(2, data)); - } - else if(pmt_eq(msg->signal(), s_response_ntx_chan)) { - d_ntx_chan = pmt_to_long(pmt_nth(2, data)); - } - else if(pmt_eq(msg->signal(), s_response_nrx_chan)) { - d_nrx_chan = pmt_to_long(pmt_nth(2, data)); - } - else if(pmt_eq(msg->signal(), s_response_current_capacity_allocation)) { - // the final command is a capacity check which should be 0, then we - // shutdown - pmt_t expected_result = pmt_from_long(0); - pmt_t result = pmt_nth(2, data); - - if(pmt_eqv(expected_result, result)) { - shutdown_all(PMT_T); - return; - } else { - shutdown_all(PMT_F); - return; - } - } - - d_nstatus++; - - if(d_nstatus==d_nstatus_to_recv) - allocate_max(); - } -} - - -void -qa_dealloc_top::check_allocation(mb_message_sptr msg) -{ - pmt_t data = msg->data(); - pmt_t event = msg->signal(); - - pmt_t expected = pmt_nth(0, data); - pmt_t status = pmt_nth(1, data); - pmt_t channel = pmt_nth(2, data); - - d_nalloc_recvd++; - - if(!pmt_eqv(status, PMT_T)) { - shutdown_all(PMT_F); - return; - } else { - // store all of the allocate channel numbers - if(pmt_eq(msg->port_id(), d_tx->port_symbol())) - d_tx_chans.push_back(pmt_to_long(channel)); - if(pmt_eq(msg->port_id(), d_rx->port_symbol())) - d_rx_chans.push_back(pmt_to_long(channel)); - } - - if(d_nalloc_recvd == d_nalloc_to_recv) { - - if(verbose) { - std::cout << "[qa_dealloc_top] Allocated TX channels: "; - for(int i=0; i < (int)d_tx_chans.size(); i++) - std::cout << d_tx_chans[i] << " "; - - std::cout << "\n[qa_dealloc_top] Allocated RX channels: "; - for(int i=0; i < (int)d_rx_chans.size(); i++) - std::cout << d_rx_chans[i] << " "; - std::cout << "\n"; - } - - deallocate_all(); // once we've allocated all of our channels, try to - // dealloc them - } -} - -REGISTER_MBLOCK_CLASS(qa_dealloc_top); - -// ---------------------------------------------------------------------------------------------- - -class qa_open_close_top : public mb_mblock -{ - mb_port_sptr d_cs; - - long d_max_capacity; - - long d_nmsg_to_recv; - long d_nmsg_recvd; - - public: - qa_open_close_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~qa_open_close_top(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void check_cs(mb_message_sptr msg); - void run_tests(); -}; - -qa_open_close_top::qa_open_close_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - - d_nmsg_to_recv=7; - d_nmsg_recvd=0; - - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - // Use the stub with the usrp_server - pmt_t usrp_server_dict = pmt_make_dict(); - pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T); - - // Test the TX side - define_component("server", "usrp_server", usrp_server_dict); - connect("self", "cs", "server", "cs"); -} - -qa_open_close_top::~qa_open_close_top(){} - -void -qa_open_close_top::initial_transition() -{ - run_tests(); -} - -void -qa_open_close_top::run_tests() -{ - // std::cout << "[qa_open_close_top] Starting tests\n"; - - // A close before an open should fail - d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close, - s_err_usrp_already_closed))); - - // Perform an open, and a second open which should fail - d_cs->send(s_cmd_open, - pmt_list2(pmt_list2(s_response_open,PMT_T), - pmt_from_long(0))); - - d_cs->send(s_cmd_open, - pmt_list2(pmt_list2(s_response_open, - s_err_usrp_already_opened), - pmt_from_long(0))); - - // A close should now be successful since the interface is open - d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_T))); - - // But, a second close should fail - d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close, - s_err_usrp_already_closed))); - - // Just to be thorough, try an open and close again - d_cs->send(s_cmd_open, - pmt_list2(pmt_list2(s_response_open,PMT_T), - pmt_from_long(0))); - - d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_T))); - -} - - -void -qa_open_close_top::handle_message(mb_message_sptr msg) -{ - pmt_t data = msg->data(); - - if (pmt_eq(msg->port_id(), d_cs->port_symbol())) { - check_cs(msg); - } - - d_nmsg_recvd++; - - if(d_nmsg_to_recv == d_nmsg_recvd) - shutdown_all(PMT_T); -} - -void -qa_open_close_top::check_cs(mb_message_sptr msg) -{ - pmt_t data = msg->data(); - pmt_t event = msg->signal(); - - pmt_t expected = pmt_nth(0, data); - pmt_t status = pmt_nth(1, data); - - pmt_t e_event = pmt_nth(0, expected); - pmt_t e_status = pmt_nth(1, expected); - - if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) { - - if(verbose) - std::cout << "[qa_open_close_top] FAILED check_cs... Got: " << status - << " Expected: " << e_status - << " for event " << event << "\n"; - - shutdown_all(PMT_F); - } else { - if(verbose) - std::cout << "[qa_open_close_top] Received expected CS response (" - << event << ")\n"; - } - -} - -REGISTER_MBLOCK_CLASS(qa_open_close_top); - -// ---------------------------------------------------------------------------------------------- - -class qa_tx_top : public mb_mblock -{ - mb_port_sptr d_tx; - mb_port_sptr d_rx; - mb_port_sptr d_cs; - - long d_max_capacity; - long d_ntx_chan, d_nrx_chan; - - long d_tx_chan; - long d_rx_chan; - - long d_nmsg_to_recv; - long d_nmsg_recvd; - - public: - qa_tx_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~qa_tx_top(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void check_allocation(mb_message_sptr msg); - void check_deallocation(mb_message_sptr msg); - void check_xmit(mb_message_sptr msg); - void check_cs(mb_message_sptr msg); - void run_tests(); -}; - -qa_tx_top::qa_tx_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - - d_nmsg_to_recv=10; - d_nmsg_recvd=0; - - d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL); - d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - // Use the stub with the usrp_server - pmt_t usrp_server_dict = pmt_make_dict(); - pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T); - - // Test the TX side - define_component("server", "usrp_server", usrp_server_dict); - connect("self", "tx0", "server", "tx0"); - connect("self", "rx0", "server", "rx0"); - connect("self", "cs", "server", "cs"); -} - -qa_tx_top::~qa_tx_top(){} - -void -qa_tx_top::initial_transition() -{ - run_tests(); -} - -void -qa_tx_top::run_tests() -{ - if(verbose) - std::cout << "[qa_tx_top] Starting tests\n"; - - // A transmit before an open should fail - d_tx->send(s_cmd_xmit_raw_frame, - pmt_list4(pmt_list2(s_response_xmit_raw_frame, - s_err_usrp_not_opened), - pmt_from_long(0), - pmt_make_u32vector(transport_pkt::max_payload()/4, 0), - pmt_from_long(0))); - - // Now open - d_cs->send(s_cmd_open, - pmt_list2(pmt_list2(s_response_open,PMT_T), - pmt_from_long(0))); - - // Try to transmit on a channel that we have no allocation for - d_tx->send(s_cmd_xmit_raw_frame, - pmt_list4(pmt_list2(s_response_xmit_raw_frame, - s_err_channel_permission_denied), - pmt_from_long(0), - pmt_make_u32vector(transport_pkt::max_payload()/4, 0), - pmt_from_long(0))); - - // Get a channel allocation and send on it, we assume 0 (FIXME) until 'defer' - // is implemented for simplicity - d_tx->send(s_cmd_allocate_channel, - pmt_list2(pmt_list2(s_response_allocate_channel, PMT_T), - pmt_from_long(1))); - - d_tx->send(s_cmd_xmit_raw_frame, - pmt_list4(pmt_list2(s_response_xmit_raw_frame, PMT_T), - pmt_from_long(0), - pmt_make_u32vector(transport_pkt::max_payload()/4, 0), - pmt_from_long(0))); - - // Close should be successful - d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_T))); - - // After closing, a new transmit raw frame should fail again - d_tx->send(s_cmd_xmit_raw_frame, - pmt_list4(pmt_list2(s_response_xmit_raw_frame, - s_err_usrp_not_opened), - pmt_from_long(0), - pmt_make_u32vector(transport_pkt::max_payload()/4, 0), - pmt_from_long(0))); - - // Reopen and retry before getting an allocation, the first xmit should fail, - // after we allocate it should work again - d_cs->send(s_cmd_open, - pmt_list2(pmt_list2(s_response_open, PMT_T), - pmt_from_long(0))); - - d_tx->send(s_cmd_xmit_raw_frame, - pmt_list4(pmt_list2(s_response_xmit_raw_frame, - s_err_channel_permission_denied), - pmt_from_long(0), - pmt_make_u32vector(transport_pkt::max_payload()/4, 0), - pmt_from_long(0))); - - d_tx->send(s_cmd_allocate_channel, - pmt_list2(pmt_list2(s_response_allocate_channel, PMT_T), - pmt_from_long(1))); - - d_tx->send(s_cmd_xmit_raw_frame, - pmt_list4(pmt_list2(s_response_xmit_raw_frame,PMT_T), - pmt_from_long(0), - pmt_make_u32vector(transport_pkt::max_payload()/4, 0), - pmt_from_long(0))); - - // A final close which should be successful - d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_T))); - -} - - -void -qa_tx_top::handle_message(mb_message_sptr msg) -{ - pmt_t data = msg->data(); - pmt_t event = msg->signal(); - - if(pmt_eq(event, pmt_intern("%shutdown"))) - return; - - pmt_t expected = pmt_nth(0, data); - pmt_t status = pmt_nth(1, data); - - pmt_t e_event = pmt_nth(0, expected); - pmt_t e_status = pmt_nth(1, expected); - - if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) { - if(verbose) - std::cout << "[qa_xmit_top] Got: " << status - << " Expected: " << e_status - << "For signal: " << event << "\n"; - shutdown_all(PMT_F); - return; - } else { - if(verbose) - std::cout << "[qa_xmit_top] Received expected response for message " - << d_nmsg_recvd - << " (" << event << ")\n"; - } - - if (pmt_eq(msg->port_id(), d_tx->port_symbol()) - || pmt_eq(msg->port_id(), d_rx->port_symbol())) { - - if(pmt_eq(msg->signal(), s_response_allocate_channel)) - check_allocation(msg); - - } - - d_nmsg_recvd++; - - if(d_nmsg_to_recv == d_nmsg_recvd){ - shutdown_all(PMT_T); - return; - } -} - -void -qa_tx_top::check_allocation(mb_message_sptr msg) -{ - pmt_t data = msg->data(); - pmt_t event = msg->signal(); - - pmt_t expected = pmt_nth(0, data); - pmt_t status = pmt_nth(1, data); - pmt_t channel = pmt_nth(2, data); - - if(pmt_eqv(status, PMT_T)) { - // store all of the allocate channel numbers - if(pmt_eq(msg->port_id(), d_tx->port_symbol())) - d_tx_chan = pmt_to_long(channel); - if(pmt_eq(msg->port_id(), d_rx->port_symbol())) - d_rx_chan = pmt_to_long(channel); - } -} - -REGISTER_MBLOCK_CLASS(qa_tx_top); - -// ---------------------------------------------------------------------------------------------- - -class qa_rx_top : public mb_mblock -{ - mb_port_sptr d_rx; - mb_port_sptr d_cs; - - long d_max_capacity; - long d_ntx_chan, d_nrx_chan; - - long d_rx_chan; - - bool d_got_response_recv; - - mb_time d_t0; - double d_delta_t; - - public: - qa_rx_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~qa_rx_top(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void check_allocation(mb_message_sptr msg); - void check_deallocation(mb_message_sptr msg); - void check_xmit(mb_message_sptr msg); - void check_cs(mb_message_sptr msg); - void run_tests(); -}; - -qa_rx_top::qa_rx_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg), - d_got_response_recv(false) -{ - - d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - // Use the stub with the usrp_server - pmt_t usrp_dict = pmt_make_dict(); - // Set TX and RX interpolations - pmt_dict_set(usrp_dict, - pmt_intern("decim-rx"), - pmt_from_long(128)); - pmt_dict_set(usrp_dict, pmt_intern("fake-usrp"), PMT_T); - - // Test the TX side - define_component("server", "usrp_server", usrp_dict); - connect("self", "rx0", "server", "rx0"); - connect("self", "cs", "server", "cs"); -} - -qa_rx_top::~qa_rx_top(){} - -void -qa_rx_top::initial_transition() -{ - run_tests(); -} - -void -qa_rx_top::run_tests() -{ - if(verbose) - std::cout << "[qa_rx_top] Starting tests\n"; - - d_cs->send(s_cmd_open, pmt_list2(pmt_list2(s_response_open,PMT_T), pmt_from_long(0))); - - d_rx->send(s_cmd_allocate_channel, - pmt_list2(pmt_list2(s_response_allocate_channel,PMT_T), - pmt_from_long(1))); - - d_rx->send(s_cmd_start_recv_raw_samples, - pmt_list2(PMT_NIL, - pmt_from_long(0))); - - // Schedule a small timeout in which we expect to have received at least one - // packet worth of samples from the stub - d_t0 = mb_time::time(); - schedule_one_shot_timeout(d_t0 + 0.01, PMT_NIL); -} - - -void -qa_rx_top::handle_message(mb_message_sptr msg) -{ - pmt_t data = msg->data(); - pmt_t event = msg->signal(); - - if(pmt_eq(event, pmt_intern("%shutdown"))) - return; - - pmt_t expected = pmt_nth(0, data); - pmt_t status = pmt_nth(1, data); - - // If we get a timeout we shutdown - if(pmt_eq(event, s_timeout)) { - if(verbose) - std::cout << "[qa_rx_top] Got timeout\n"; - d_rx->send(s_cmd_stop_recv_raw_samples, - pmt_list2(PMT_NIL, - pmt_from_long(0))); - - d_cs->send(s_cmd_close, pmt_list1(pmt_list2(s_response_close,PMT_T))); - return; - } - - // For testing RX, an invocation handle is not generated by the stub, - // therefore the same approach for testing is not used. We simply - // expect all responses to be true. - if(pmt_eq(event, s_response_recv_raw_samples)) { - if(pmt_eqv(status, PMT_T)) { - - if(verbose) - std::cout << "[qa_rx_top] Received expected response for message " - << " (" << event << ")\n"; - - // All we want is 1 response receive! Can't guarantee exact numbers - d_got_response_recv = true; - } - else { - if(verbose) - std::cout << "Got: " << status << " Expected: " << PMT_T << "\n"; - shutdown_all(PMT_F); - } - return; - } - - pmt_t e_event = pmt_nth(0, expected); - pmt_t e_status = pmt_nth(1, expected); - - if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) { - if(verbose) - std::cout << "Got: " << status << " Expected: " << e_status << "\n"; - shutdown_all(PMT_F); - return; - } else { - if(verbose) - std::cout << "[qa_rx_top] Received expected response for message " - << " (" << event << ")\n"; - } - - if (pmt_eq(msg->port_id(), d_rx->port_symbol())) { - - if(pmt_eq(msg->signal(), s_response_allocate_channel)) - check_allocation(msg); - - } - - // We stop when we get a close, we are successful if we - // got a response from recv, fail if we never got a recv response - if(pmt_eq(msg->signal(), s_response_close)) { - - if(d_got_response_recv) { - shutdown_all(PMT_T); - return; - } - else { - shutdown_all(PMT_F); - if(verbose) - std::cout << "[qa_rx_top] No response message before close\n"; - return; - } - } -} - - -void -qa_rx_top::check_allocation(mb_message_sptr msg) -{ - pmt_t data = msg->data(); - pmt_t event = msg->signal(); - - pmt_t expected = pmt_nth(0, data); - pmt_t status = pmt_nth(1, data); - pmt_t channel = pmt_nth(2, data); - - if(pmt_eqv(status, PMT_T)) { - // store all of the allocate channel numbers - if(pmt_eq(msg->port_id(), d_rx->port_symbol())) - d_rx_chan = pmt_to_long(channel); - } -} - -REGISTER_MBLOCK_CLASS(qa_rx_top); - -// ---------------------------------------------------------------------------------------------- - -class qa_rid_top : public mb_mblock -{ - mb_port_sptr d_tx; - mb_port_sptr d_rx; - mb_port_sptr d_cs; - - long d_npongs; - long d_tcycles; - long d_cycles; - long d_max_rid; - - mb_time d_t0; - double d_delta_t; - - public: - qa_rid_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~qa_rid_top(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void run_tests(); - void send_max_pings(); -}; - -qa_rid_top::qa_rid_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - d_npongs = 0; - d_tcycles = 3; - d_cycles = d_tcycles; - d_max_rid = usrp_server::D_MAX_RID; - d_delta_t = 0.1; - - - d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL); - d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - // Use the stub with the usrp_server - pmt_t usrp_server_dict = pmt_make_dict(); - pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T); - - // Test the TX side - define_component("server", "usrp_server", usrp_server_dict); - connect("self", "tx0", "server", "tx0"); - connect("self", "rx0", "server", "rx0"); - connect("self", "cs", "server", "cs"); - -} - -qa_rid_top::~qa_rid_top(){} - -void -qa_rid_top::initial_transition() -{ - run_tests(); -} - -void -qa_rid_top::run_tests() -{ - if(verbose) - std::cout << "[qa_rid_top] Starting tests...\n"; - - // Retrieve information about the USRP, then run tests - d_cs->send(s_cmd_open, - pmt_list2(pmt_list2(s_response_open, PMT_T), - pmt_from_long(0))); - - // should be able to allocate 1 byte - d_tx->send(s_cmd_allocate_channel, - pmt_list2(pmt_list2(s_response_allocate_channel, PMT_T), - pmt_from_long(1))); - - d_rx->send(s_cmd_allocate_channel, - pmt_list2(pmt_list2(s_response_allocate_channel, PMT_T), - pmt_from_long(1))); - - // Need to start receiving to read from the USRP to get C/S responses - d_rx->send(s_cmd_start_recv_raw_samples, - pmt_list2(PMT_NIL, - pmt_from_long(0))); - - // Build a subpacket of MAX_RID pings and wait a small amount for all of the - // responses and fire off another MAX_RID. If MAX_RID*2 responses are - // received, the RID recycling is working correctly. - // Schedule a timer in which we expect to have received all of the responses, - // which will send off another MAX_RID worth. - send_max_pings(); - d_t0 = mb_time::time(); - schedule_one_shot_timeout(d_t0 + d_delta_t, PMT_NIL); -} - -void -qa_rid_top::send_max_pings() -{ - pmt_t ping = pmt_list2(s_op_ping_fixed, - pmt_list2(pmt_from_long(0), - pmt_from_long(0))); - - pmt_t sub_packets = PMT_NIL; - - for(int i=0; i<d_max_rid; i++) - sub_packets = pmt_list_add(sub_packets, ping); - - d_tx->send(s_cmd_to_control_channel, - pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T), - sub_packets)); -} - -void -qa_rid_top::handle_message(mb_message_sptr msg) -{ - pmt_t data = msg->data(); - pmt_t event = msg->signal(); - - // If we get a timeout we ensure we got a maximum RID number of responses. - if(pmt_eq(event, s_timeout)) { - if(verbose) - std::cout << "[qa_rid_top] Got timeout, received so far: " - << d_npongs << "\n"; - - d_cycles--; - - if(d_cycles==0 && d_npongs == d_max_rid*d_tcycles) { - shutdown_all(PMT_T); - } - else if(d_cycles==0) { - - std::cout << "[qa_rid_top] d_npongs: " << d_npongs - << " expected: " << d_max_rid*d_tcycles - << std::endl; - - shutdown_all(PMT_F); - } - else { - send_max_pings(); - d_t0 = mb_time::time(); - schedule_one_shot_timeout(d_t0 + d_delta_t, PMT_NIL); - } - - } - else if(pmt_eq(event, s_response_from_control_channel)) - { - d_npongs++; - } - -} - -REGISTER_MBLOCK_CLASS(qa_rid_top); - - -// ---------------------------------------------------------------------------------------------- - -class qa_cs_top : public mb_mblock -{ - mb_port_sptr d_tx; - mb_port_sptr d_rx; - mb_port_sptr d_cs; - - long d_nmsgs_to_recv; - long d_nrecvd; - - long d_max_capacity; - long d_ntx_chan, d_nrx_chan; - - long d_nstatus; - long d_nstatus_to_recv; - - public: - qa_cs_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg); - ~qa_cs_top(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - protected: - void check_message(mb_message_sptr msg); - void run_tests(); -}; - -qa_cs_top::qa_cs_top(mb_runtime *runtime, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(runtime, instance_name, user_arg) -{ - d_nrecvd=0; - d_nmsgs_to_recv = 8; - d_nstatus=0; - d_nstatus_to_recv = 50; - - d_rx = define_port("rx0", "usrp-rx", false, mb_port::INTERNAL); - d_tx = define_port("tx0", "usrp-tx", false, mb_port::INTERNAL); - d_cs = define_port("cs", "usrp-server-cs", false, mb_port::INTERNAL); - - // Use the stub with the usrp_server - pmt_t usrp_server_dict = pmt_make_dict(); - pmt_dict_set(usrp_server_dict, pmt_intern("fake-usrp"),PMT_T); - - // Test the TX side - define_component("server", "usrp_server", usrp_server_dict); - connect("self", "tx0", "server", "tx0"); - connect("self", "rx0", "server", "rx0"); - connect("self", "cs", "server", "cs"); - -} - -qa_cs_top::~qa_cs_top(){} - -void -qa_cs_top::initial_transition() -{ - run_tests(); -} - -void -qa_cs_top::run_tests() -{ - if(verbose) - std::cout << "[qa_cs_top] Starting tests...\n"; - - // Retrieve information about the USRP, then run tests - d_cs->send(s_cmd_open, - pmt_list2(pmt_list2(s_response_open, PMT_T), - pmt_from_long(0))); - - // should be able to allocate 1 byte - d_tx->send(s_cmd_allocate_channel, - pmt_list2(pmt_list2(s_response_allocate_channel, PMT_T), - pmt_from_long(1))); - - d_rx->send(s_cmd_allocate_channel, - pmt_list2(pmt_list2(s_response_allocate_channel, PMT_T), - pmt_from_long(1))); - - // Need to start receiving to read from the USRP to get C/S responses - d_rx->send(s_cmd_start_recv_raw_samples, - pmt_list2(PMT_NIL, - pmt_from_long(0))); - - d_tx->send(s_cmd_to_control_channel, - pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T), - pmt_list1( - pmt_list2(s_op_ping_fixed, - pmt_list2(pmt_from_long(3), - pmt_from_long(0)))))); - - d_tx->send(s_cmd_to_control_channel, - pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T), - pmt_list1( - pmt_list2(s_op_write_reg, - pmt_list2( - pmt_from_long(0x3), - pmt_from_long(0x4)))))); - - d_tx->send(s_cmd_to_control_channel, - pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T), - pmt_list1( - pmt_list2(s_op_write_reg_masked, - pmt_list3( - pmt_from_long(0x3), - pmt_from_long(0x4), - pmt_from_long(0x5)))))); - - d_tx->send(s_cmd_to_control_channel, - pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T), - pmt_list1( - pmt_list2(s_op_read_reg, - pmt_list2(pmt_from_long(0), - pmt_from_long(0x6)))))); - - d_tx->send(s_cmd_to_control_channel, - pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T), - pmt_list1( - pmt_list2(s_op_delay, - pmt_list1(pmt_from_long(0x7)))))); - - pmt_t subpackets = pmt_list5( - pmt_list2(s_op_ping_fixed, pmt_list2(pmt_from_long(0), pmt_from_long(0))), - pmt_list2(s_op_delay, pmt_list1(pmt_from_long(0x7))), - pmt_list2(s_op_write_reg_masked, pmt_list3(pmt_from_long(3), - pmt_from_long(4), - pmt_from_long(5))), - pmt_list2(s_op_write_reg, pmt_list2(pmt_from_long(3), - pmt_from_long(4))), - pmt_list2(s_op_read_reg, pmt_list2(pmt_from_long(0), - pmt_from_long(6))) - ); - - d_tx->send(s_cmd_to_control_channel, - pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T), - subpackets)); - - pmt_t i2c_data = pmt_make_u8vector(8, 0xff); - - subpackets = pmt_list2( - pmt_list2(s_op_i2c_write, - pmt_list2(pmt_from_long(8), i2c_data)), - pmt_list2(s_op_i2c_read, - pmt_list3(pmt_from_long(0), pmt_from_long(9), pmt_from_long(1))) - - ); - - d_tx->send(s_cmd_to_control_channel, - pmt_list2(pmt_list2(s_response_from_control_channel, PMT_T), - subpackets)); - -} - -void -qa_cs_top::handle_message(mb_message_sptr msg) -{ - pmt_t data = msg->data(); - - if ((pmt_eq(msg->port_id(), d_tx->port_symbol()) - || pmt_eq(msg->port_id(), d_rx->port_symbol())) - && pmt_eq(msg->signal(), s_response_allocate_channel)) - check_message(msg); - - if (pmt_eq(msg->port_id(), d_tx->port_symbol()) - && pmt_eq(msg->signal(), s_response_from_control_channel)) - check_message(msg); - - if (pmt_eq(msg->port_id(), d_cs->port_symbol())) { - - if(pmt_eq(msg->signal(), s_response_max_capacity)) { - d_max_capacity = pmt_to_long(pmt_nth(2, data)); - if(verbose) - std::cout << "[qa_cs_top] USRP has max capacity of " - << d_max_capacity << "\n"; - } - else if(pmt_eq(msg->signal(), s_response_ntx_chan)) { - d_ntx_chan = pmt_to_long(pmt_nth(2, data)); - if(verbose) - std::cout << "[qa_cs_top] USRP tx channels: " - << d_ntx_chan << "\n"; - } - else if(pmt_eq(msg->signal(), s_response_nrx_chan)) { - d_nrx_chan = pmt_to_long(pmt_nth(2, data)); - if(verbose) - std::cout << "[qa_cs_top] USRP rx channels: " - << d_nrx_chan << "\n"; - } - else if(pmt_eq(msg->signal(), s_response_current_capacity_allocation)) { - check_message(msg); - } - - d_nstatus++; - - check_message(msg); - - if(d_nstatus==d_nstatus_to_recv) - run_tests(); - } -} - -void -qa_cs_top::check_message(mb_message_sptr msg) -{ - pmt_t data = msg->data(); - pmt_t event = msg->signal(); - - pmt_t expected = pmt_nth(0, data); - pmt_t status = pmt_nth(1, data); - - pmt_t e_event = pmt_nth(0, expected); - pmt_t e_status = pmt_nth(1, expected); - - d_nrecvd++; - - - if(!pmt_eqv(e_status, status) || !pmt_eqv(e_event, event)) { - if(verbose) - std::cout << "[qa_cs_top] Got: " << status << " Expected: " << e_status << "\n"; - shutdown_all(PMT_F); - return; - } else { - if(verbose) - std::cout << "[qa_cs_top] Received expected response for message " - << d_nrecvd << " (" << event << ")\n"; - } - - if(d_nrecvd == d_nmsgs_to_recv) - shutdown_all(PMT_T); -} - -REGISTER_MBLOCK_CLASS(qa_cs_top); - -// ---------------------------------------------------------------------------------------------- - -void -qa_inband_usrp_server::test_open_close() -{ - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_T; - - // std::cout << "\n\n----------------------------\n"; - // std::cout << " RUNNING OPEN/CLOSE TESTS \n"; - - rt->run("top", "qa_open_close_top", PMT_F, &result); - - CPPUNIT_ASSERT(pmt_equal(PMT_T, result)); -} - -void -qa_inband_usrp_server::test_chan_allocation() -{ - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_T; - - // std::cout << "\n\n----------------------------\n"; - // std::cout << " RUNNING ALLOCATION TESTS \n"; - - rt->run("qa_alloc_top", "qa_alloc_top", PMT_F, &result); - - CPPUNIT_ASSERT(pmt_equal(PMT_T, result)); -} - -void -qa_inband_usrp_server::test_chan_deallocation() -{ - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_T; - - // std::cout << "\n\n----------------------------\n"; - // std::cout << " RUNNING DEALLOCATION TESTS \n"; - - rt->run("qa_dealloc_top", "qa_dealloc_top", PMT_F, &result); - - CPPUNIT_ASSERT(pmt_equal(PMT_T, result)); -} - -void -qa_inband_usrp_server::test_tx() -{ - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_T; - - // std::cout << "\n\n-----------------\n"; - // std::cout << " RUNNING TX TESTS \n"; - - rt->run("top", "qa_tx_top", PMT_F, &result); - - CPPUNIT_ASSERT(pmt_equal(PMT_T, result)); -} - -void -qa_inband_usrp_server::test_rx() -{ - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_T; - - // std::cout << "\n\n-----------------\n"; - // std::cout << " RUNNING RX TESTS \n"; - - rt->run("top", "qa_rx_top", PMT_F, &result); - - CPPUNIT_ASSERT(pmt_equal(PMT_T, result)); -} - -void -qa_inband_usrp_server::test_cs() -{ - // FIXME This test is disabled because it hangs with the change to use usrp_standard_*_sptr's - return; - - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_T; - - // std::cout << "\n\n-----------------\n"; - // std::cout << " RUNNING CS TESTS \n"; - - rt->run("top", "qa_cs_top", PMT_F, &result); - - CPPUNIT_ASSERT(pmt_equal(PMT_T, result)); -} - -void -qa_inband_usrp_server::test_rid() -{ - // FIXME This test is disabled because it hangs with the change to use usrp_standard_*_sptr's - return; - - mb_runtime_sptr rt = mb_make_runtime(); - pmt_t result = PMT_T; - - // std::cout << "\n\n-----------------\n"; - // std::cout << " RUNNING RID TESTS \n"; - - rt->run("top", "qa_rid_top", PMT_F, &result); - - CPPUNIT_ASSERT(pmt_equal(PMT_T, result)); -} diff --git a/usrp/limbo/inband/qa_inband_usrp_server.h b/usrp/limbo/inband/qa_inband_usrp_server.h deleted file mode 100644 index 52a4a0b06..000000000 --- a/usrp/limbo/inband/qa_inband_usrp_server.h +++ /dev/null @@ -1,50 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef QA_INBAND_USRP_SERVER_H -#define QA_INBAND_USRP_SERVER_H - -#include <cppunit/extensions/HelperMacros.h> -#include <cppunit/TestCase.h> - -class qa_inband_usrp_server : public CppUnit::TestCase { - - CPPUNIT_TEST_SUITE(qa_inband_usrp_server); - CPPUNIT_TEST(test_open_close); - CPPUNIT_TEST(test_chan_allocation); - CPPUNIT_TEST(test_chan_deallocation); - CPPUNIT_TEST(test_tx); - CPPUNIT_TEST(test_rx); - CPPUNIT_TEST(test_cs); - CPPUNIT_TEST(test_rid); - CPPUNIT_TEST_SUITE_END(); - - private: - void test_chan_allocation(); - void test_chan_deallocation(); - void test_open_close(); - void test_tx(); - void test_rx(); - void test_cs(); - void test_rid(); -}; - -#endif /* INCLUDED_QA_INBAND_USRP_SERVER_H */ diff --git a/usrp/limbo/inband/symbols_usrp_channel.h b/usrp/limbo/inband/symbols_usrp_channel.h deleted file mode 100644 index a0114cf3c..000000000 --- a/usrp/limbo/inband/symbols_usrp_channel.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_SYMBOLS_USRP_CHANNEL_H -#define INCLUDED_SYMBOLS_USRP_CHANNEL_H - -#include <pmt.h> - -// Outgoing -static pmt_t s_cmd_allocate_channel = pmt_intern("cmd-allocate-channel"); -static pmt_t s_cmd_deallocate_channel = pmt_intern("cmd-deallocate-channel"); - -// Incoming -static pmt_t s_response_allocate_channel = pmt_intern("response-allocate-channel"); -static pmt_t s_response_deallocate_channel = pmt_intern("response-deallocate-channel"); - -// Errors -static pmt_t s_err_requested_capacity_unavailable = pmt_intern("err-requested-capacity-unavailable"); -static pmt_t s_err_channel_unavailable = pmt_intern("err-channel-unavailable"); -static pmt_t s_err_channel_invalid = pmt_intern("err-channel-invalid"); -static pmt_t s_err_channel_permission_denied = pmt_intern("err-channel-permission-denied"); - -#endif /* INCLUDED_SYMBOLS_USRP_CHANNEL_H */ diff --git a/usrp/limbo/inband/symbols_usrp_interface_cs.h b/usrp/limbo/inband/symbols_usrp_interface_cs.h deleted file mode 100644 index 72c8fcc91..000000000 --- a/usrp/limbo/inband/symbols_usrp_interface_cs.h +++ /dev/null @@ -1,43 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_SYMBOLS_USRP_INTERFACE_CS_H -#define INCLUDED_SYMBOLS_USRP_INTERFACE_CS_H - -#include <pmt.h> - -// Outgoing -static pmt_t s_cmd_usrp_open = pmt_intern("cmd-usrp-open"); -static pmt_t s_cmd_usrp_close = pmt_intern("cmd-usrp-close"); -static pmt_t s_cmd_usrp_ntx_chan = pmt_intern("cmd-usrp-ntx-chan"); -static pmt_t s_cmd_usrp_nrx_chan = pmt_intern("cmd-usrp-nrx-chan"); -static pmt_t s_cmd_usrp_write = pmt_intern("cmd-usrp-write"); -static pmt_t s_cmd_usrp_start_reading = pmt_intern("cmd-usrp-start-reading"); -static pmt_t s_cmd_usrp_stop_reading = pmt_intern("cmd-usrp-stop-reading"); - -// Incoming -static pmt_t s_response_usrp_open = pmt_intern("response-usrp-open"); -static pmt_t s_response_usrp_close = pmt_intern("response-usrp-close"); -static pmt_t s_response_usrp_ntx_chan = pmt_intern("response-usrp-ntx-chan"); -static pmt_t s_response_usrp_nrx_chan = pmt_intern("response-usrp-nrx-chan"); -static pmt_t s_response_usrp_write = pmt_intern("response-usrp-write"); -static pmt_t s_response_usrp_read = pmt_intern("response-usrp-read"); - -#endif /* INCLUDED_SYMBOLS_USRP_INTERFACE_CS_H */ diff --git a/usrp/limbo/inband/symbols_usrp_low_level_cs.h b/usrp/limbo/inband/symbols_usrp_low_level_cs.h deleted file mode 100644 index a7260603a..000000000 --- a/usrp/limbo/inband/symbols_usrp_low_level_cs.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_SYMBOLS_USRP_LOW_LEVEL_CS_H -#define INCLUDED_SYMBOLS_USRP_LOW_LEVEL_CS_H - -#include <pmt.h> - -// Outgoing -static pmt_t s_cmd_to_control_channel = pmt_intern("cmd-to-control-channel"); - -// Incoming -static pmt_t s_response_from_control_channel = pmt_intern("response-from-control-channel"); - -// Subpackets -static pmt_t s_op_ping_fixed = pmt_intern("op-ping-fixed"); -static pmt_t s_op_ping_fixed_reply = pmt_intern("op-ping-fixed-reply"); -static pmt_t s_op_write_reg = pmt_intern("op-write-reg"); -static pmt_t s_op_write_reg_masked = pmt_intern("op-write-reg-masked"); -static pmt_t s_op_read_reg = pmt_intern("op-read-reg"); -static pmt_t s_op_read_reg_reply = pmt_intern("op-read-reg-reply"); -static pmt_t s_op_i2c_write = pmt_intern("op-i2c-write"); -static pmt_t s_op_i2c_read = pmt_intern("op-i2c-read"); -static pmt_t s_op_i2c_read_reply = pmt_intern("op-i2c-read-reply"); -static pmt_t s_op_spi_write = pmt_intern("op-spi-write"); -static pmt_t s_op_spi_read = pmt_intern("op-spi-read"); -static pmt_t s_op_spi_read_reply = pmt_intern("op-spi-read-reply"); -static pmt_t s_op_delay = pmt_intern("op-delay"); - -#endif /* INCLUDED_SYMBOLS_USRP_LOW_LEVEL_CS_H */ diff --git a/usrp/limbo/inband/symbols_usrp_rx.h b/usrp/limbo/inband/symbols_usrp_rx.h deleted file mode 100644 index 07d58a3f5..000000000 --- a/usrp/limbo/inband/symbols_usrp_rx.h +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_SYMBOLS_USRP_RX_H -#define INCLUDED_SYMBOLS_USRP_RX_H - -#include <pmt.h> - -// Outgoing -static pmt_t s_cmd_start_recv_raw_samples = pmt_intern("cmd-start-recv-raw-samples"); -static pmt_t s_cmd_stop_recv_raw_samples = pmt_intern("cmd-stop-recv-raw-samples"); - -// Incoming -static pmt_t s_response_recv_raw_samples = pmt_intern("response-recv-raw-samples"); - -// Errors -static pmt_t s_err_already_receiving = pmt_intern("err-already-receiving"); - -#endif /* INCLUDED_SYMBOLS_USRP_RX_H */ diff --git a/usrp/limbo/inband/symbols_usrp_rx_cs.h b/usrp/limbo/inband/symbols_usrp_rx_cs.h deleted file mode 100644 index bf4f0338b..000000000 --- a/usrp/limbo/inband/symbols_usrp_rx_cs.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_SYMBOLS_USRP_RX_CS_H -#define INCLUDED_SYMBOLS_USRP_RX_CS_H - -#include <pmt.h> - -// Outgoing -static pmt_t s_cmd_usrp_rx_start_reading = pmt_intern("cmd-usrp-rx-start-reading"); - -// Incoming -static pmt_t s_response_usrp_rx_read = pmt_intern("response-usrp-rx-read"); - -#endif /* INCLUDED_SYMBOLS_USRP_RX_CS_H */ diff --git a/usrp/limbo/inband/symbols_usrp_server_cs.h b/usrp/limbo/inband/symbols_usrp_server_cs.h deleted file mode 100644 index e612e24ea..000000000 --- a/usrp/limbo/inband/symbols_usrp_server_cs.h +++ /dev/null @@ -1,47 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_SYMBOLS_USRP_SERVER_CS_H -#define INCLUDED_SYMBOLS_USRP_SERVER_CS_H - -#include <pmt.h> - -// Outgoing -static pmt_t s_cmd_open = pmt_intern("cmd-open"); -static pmt_t s_cmd_close = pmt_intern("cmd-close"); -static pmt_t s_cmd_max_capacity = pmt_intern("cmd-max-capacity"); -static pmt_t s_cmd_ntx_chan = pmt_intern("cmd-ntx-chan"); -static pmt_t s_cmd_nrx_chan = pmt_intern("cmd-nrx-chan"); -static pmt_t s_cmd_current_capacity_allocation = pmt_intern("cmd-current-capacity-allocation"); - -// Incoming -static pmt_t s_response_open = pmt_intern("response-open"); -static pmt_t s_response_close = pmt_intern("response-close"); -static pmt_t s_response_max_capacity = pmt_intern("response-max-capacity"); -static pmt_t s_response_ntx_chan = pmt_intern("response-ntx-chan"); -static pmt_t s_response_nrx_chan = pmt_intern("response-nrx-chan"); -static pmt_t s_response_current_capacity_allocation = pmt_intern("response-current-capacity-allocation"); - -// Errors -static pmt_t s_err_usrp_not_opened = pmt_intern("err-usrp-not-opened"); -static pmt_t s_err_usrp_already_opened = pmt_intern("err-usrp-already-opened"); -static pmt_t s_err_usrp_already_closed = pmt_intern("err-usrp-already-closed"); - -#endif /* INCLUDED_SYMBOLS_USRP_SERVER_CS_H */ diff --git a/usrp/limbo/inband/symbols_usrp_tx.h b/usrp/limbo/inband/symbols_usrp_tx.h deleted file mode 100644 index 4e58e2cf9..000000000 --- a/usrp/limbo/inband/symbols_usrp_tx.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_SYMBOLS_USRP_TX_H -#define INCLUDED_SYMBOLS_USRP_TX_H - -#include <pmt.h> - -// Outgoing -static pmt_t s_cmd_xmit_raw_frame = pmt_intern("cmd-xmit-raw-frame"); - -// Incoming -static pmt_t s_response_xmit_raw_frame = pmt_intern("response-xmit-raw-frame"); - -#endif /* INCLUDED_SYMBOLS_USRP_TX_H */ diff --git a/usrp/limbo/inband/symbols_usrp_tx_cs.h b/usrp/limbo/inband/symbols_usrp_tx_cs.h deleted file mode 100644 index d02ef1d26..000000000 --- a/usrp/limbo/inband/symbols_usrp_tx_cs.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_SYMBOLS_USRP_TX_CS_H -#define INCLUDED_SYMBOLS_USRP_TX_CS_H - -#include <pmt.h> - -// Outgoing -static pmt_t s_cmd_usrp_tx_write = pmt_intern("cmd-usrp-tx-write"); - -// Incoming -static pmt_t s_response_usrp_tx_write = pmt_intern("response-usrp-tx-write"); - -#endif /* INCLUDED_SYMBOLS_USRP_TX_CS_H */ diff --git a/usrp/limbo/inband/test_inband.cc b/usrp/limbo/inband/test_inband.cc deleted file mode 100644 index 77cdca556..000000000 --- a/usrp/limbo/inband/test_inband.cc +++ /dev/null @@ -1,36 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include <cppunit/TextTestRunner.h> -#include <qa_inband.h> - -int -main(int argc, char **argv) -{ - - CppUnit::TextTestRunner runner; - - runner.addTest(qa_inband::suite ()); - - bool was_successful = runner.run("", false); - - return was_successful ? 0 : 1; -} diff --git a/usrp/limbo/inband/usb_packet.py b/usrp/limbo/inband/usb_packet.py deleted file mode 100644 index 6dfcf8638..000000000 --- a/usrp/limbo/inband/usb_packet.py +++ /dev/null @@ -1,115 +0,0 @@ -# -# Copyright 2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -import struct - - -FL_OVERRUN = 0x80000000 -FL_UNDERRUN = 0x40000000 -FL_DROPPED = 0x20000000 -FL_END_OF_BURST = 0x10000000 -FL_START_OF_BURST = 0x08000000 - -FL_ALL_FLAGS = 0xf8000000 - -FL_OVERRUN_SHIFT = 31 -FL_UNDERRUN_SHIFT = 30 -FL_DROPPED_SHIFT = 29 -FL_END_OF_BURST_SHIFT = 28 -FL_START_OF_BURST_SHIFT = 27 - -RSSI_MASK = 0x3f -RSSI_SHIFT = 21 - -CHAN_MASK = 0x1f -CHAN_SHIFT = 16 - -TAG_MASK = 0xf -TAG_SHIFT = 9 - -PAYLOAD_LEN_MASK = 0x1ff -PAYLOAD_LEN_SHIFT = 0 - -def make_header(flags, chan, payload_len, timestamp, rssi=0, tag=0): - word0 = ((flags & FL_ALL_FLAGS) - | ((rssi & RSSI_MASK) << RSSI_SHIFT) - | ((chan & CHAN_MASK) << CHAN_SHIFT) - | ((tag & TAG_MASK) << TAG_SHIFT) - | ((payload_len & PAYLOAD_LEN_MASK) << PAYLOAD_LEN_SHIFT)) - word1 = timestamp - return struct.pack('<2I', word0, word1) - - -def _decode(pred, indicator): - if pred: - return indicator - else: - return '-' - - -class usb_packet(object): - def __init__(self, raw_pkt): - assert isinstance(raw_pkt, str) and len(raw_pkt) == 512 - self._raw_pkt = raw_pkt; - (self._word0, self._word1) = struct.unpack('<2I', self._raw_pkt[0:8]) - - def timestamp(self): - return self._word1 - - def rssi(self): - return (self._word0 >> RSSI_SHIFT) & RSSI_MASK - - def chan(self): - return (self._word0 >> CHAN_SHIFT) & CHAN_MASK - - def tag(self): - return (self._word0 >> TAG_SHIFT) & TAG_MASK - - def payload_len(self): - return (self._word0 >> PAYLOAD_LEN_SHIFT) & PAYLOAD_LEN_MASK - - def flags(self): - return self._word0 & FL_ALL_FLAGS - - def overrun(self): - return (self._word0 >> FL_OVERRUN_SHIFT) & 0x1 - - def underrun(self): - return (self._word0 >> FL_UNDERRUN_SHIFT) & 0x1 - - def start_of_burst(self): - return (self._word0 >> FL_START_OF_BURST_SHIFT) & 0x1 - - def end_of_burst(self): - return (self._word0 >> FL_END_OF_BURST_SHIFT) & 0x1 - - def dropped(self): - return (self._word0 >> FL_DROPPED_SHIFT) & 0x1 - - def payload(self): - return self._raw_pkt[8:8+self.payload_len()] - - def decoded_flags(self): - s = (_decode(self.overrun(), 'O') - + _decode(self.underrun(), 'U') - + _decode(self.dropped(), 'D') - + _decode(self.end_of_burst(), 'E') - + _decode(self.start_of_burst(), 'S')) - return s diff --git a/usrp/limbo/inband/usrp_inband_usb_packet.cc b/usrp/limbo/inband/usrp_inband_usb_packet.cc deleted file mode 100644 index 72bc45ccb..000000000 --- a/usrp/limbo/inband/usrp_inband_usb_packet.cc +++ /dev/null @@ -1,793 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <usrp_inband_usb_packet.h> - -#include <usrp_bytesex.h> -#include <iostream> -#include <stdio.h> -#include <string.h> - -/*! - * \brief Aligns the packet payload on a 32 bit boundary. This is essential to - * all control/status packets so that the inband FPGA code can parse them - * easily. - * - * \returns true if successful or if the packet was already aligned; false if it - * cannot be aligned. - */ -bool usrp_inband_usb_packet::align32() -{ - int p_len = payload_len(); - - int bytes_needed = 4 - (p_len % 4); - - if(bytes_needed == 4) - return true; - - // If the room left in the packet is less than the number of bytes - // needed, return false to indicate no room to align - if((MAX_PAYLOAD - p_len) < bytes_needed) - return false; - - incr_header_len(bytes_needed); - - return true; -} - -/*! - * \brief Adds a ping command to the current control packet. - * - * The \p rid is the rid to be associated with the ping response and \p ping_val - * is currently unused. - * - * \returns true if adding the ping command was successful, false otherwise - * (i.e. no space in the current packet). - */ -bool usrp_inband_usb_packet::cs_ping(long rid, long ping_val) -{ - if(!align32()) - return false; - - int p_len = payload_len(); - - if((MAX_PAYLOAD - p_len) < (CS_PING_LEN + CS_FIXED_LEN)) - return false; - - uint32_t ping = ( - ((OP_PING_FIXED & CS_OPCODE_MASK) << CS_OPCODE_SHIFT) - | ((CS_PING_LEN & CS_LEN_MASK) << CS_LEN_SHIFT) - | ((rid & CS_RID_MASK) << CS_RID_SHIFT) - | (ping_val & CS_PINGVAL_MASK) - - ); - - uint32_t *payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(ping); - - // Update payload length - incr_header_len(CS_FIXED_LEN + CS_PING_LEN); - - return true; -} - -/*! - * \brief Adds a ping response to the packet. This is used by the fake USRP - * code to generate fake responses for pings. - * - * The \p rid is the RID to be associated with the response and \p ping_val is - * currently unused. - * - * \returns true if the ping reply was added successfully, false otherwise. - */ -bool usrp_inband_usb_packet::cs_ping_reply(long rid, long ping_val) -{ - if(!align32()) - return false; - - int p_len = payload_len(); - - if((MAX_PAYLOAD - p_len) < (CS_PING_LEN + CS_FIXED_LEN)) - return false; - - uint32_t ping = ( - ((OP_PING_FIXED_REPLY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT) - | ((CS_PING_LEN & CS_LEN_MASK) << CS_LEN_SHIFT) - | ((rid & CS_RID_MASK) << CS_RID_SHIFT) - | ((ping_val & CS_PINGVAL_MASK) << CS_PINGVAL_SHIFT) - - ); - - uint32_t *payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(ping); - - // Update payload length - incr_header_len(CS_FIXED_LEN + CS_PING_LEN); - - return true; -} - -/*! - * \brief Adds a write register command to the packet. - * - * The \p reg_num is the register number for which the value \p val will be - * written to. - * - * \returns true if the command was added to the packet successfully, false - * otherwise. - */ -bool usrp_inband_usb_packet::cs_write_reg(long reg_num, long val) -{ - if(!align32()) - return false; - - int p_len = payload_len(); - - if((MAX_PAYLOAD - p_len) < (CS_WRITEREG_LEN + CS_FIXED_LEN)) - return false; - - uint32_t word0 = 0; - - // Build the first word which includes the register number - word0 = ( - ((OP_WRITE_REG & CS_OPCODE_MASK) << CS_OPCODE_SHIFT) - | ((CS_WRITEREG_LEN & CS_LEN_MASK) << CS_LEN_SHIFT) - | ((reg_num & CS_REGNUM_MASK) << CS_REGNUM_SHIFT) - ); - - uint32_t *payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(word0); - - // The second word is solely the register value to be written - // FIXME: should this be unsigned? - payload += 1; - *payload = host_to_usrp_u32((uint32_t) val); - - // Rebuild the header to update the payload length - incr_header_len(CS_FIXED_LEN + CS_WRITEREG_LEN); - - return true; -} - -/*! - * \brief Adds a write register masked command to the packet. - * - * The \p reg_num is the register number for which the value \p val will be - * written, masked by \p mask - * - * \returns true if the command was added to the packet, false otherwise. - */ -bool usrp_inband_usb_packet::cs_write_reg_masked(long reg_num, long val, long mask) -{ - if(!align32()) - return false; - - int p_len = payload_len(); - - if((MAX_PAYLOAD - p_len) < (CS_WRITEREGMASKED_LEN + CS_FIXED_LEN)) - return false; - - uint32_t word0 = 0; - - // Build the first word which includes the register number - word0 = ( - ((OP_WRITE_REG_MASKED & CS_OPCODE_MASK) << CS_OPCODE_SHIFT) - | ((CS_WRITEREGMASKED_LEN & CS_LEN_MASK) << CS_LEN_SHIFT) - | ((reg_num & CS_REGNUM_MASK) << CS_REGNUM_SHIFT) - ); - - uint32_t *payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(word0); - - // Skip over the first word and write the register value - payload += 1; - *payload = host_to_usrp_u32((uint32_t) val); - - // Skip over the register value and write the mask - payload += 1; - *payload = host_to_usrp_u32((uint32_t) mask); - - // Rebuild the header to update the payload length - incr_header_len(CS_FIXED_LEN + CS_WRITEREGMASKED_LEN); - - return true; -} - -/*! - * \brief Adds a read register message to the packet. - * - * The \p rid will be the associated RID returned with the response, and \p - * reg_num is the register to be read. - * - * \returns true if the command was added to the packet, false otherwise. - */ -bool usrp_inband_usb_packet::cs_read_reg(long rid, long reg_num) -{ - if(!align32()) - return false; - - int p_len = payload_len(); - - if((MAX_PAYLOAD - p_len) < (CS_READREG_LEN + CS_FIXED_LEN)) - return false; - - uint32_t read_reg = ( - ((OP_READ_REG & CS_OPCODE_MASK) << CS_OPCODE_SHIFT) - | ((CS_READREG_LEN & CS_LEN_MASK) << CS_LEN_SHIFT) - | ((rid & CS_RID_MASK) << CS_RID_SHIFT) - | ((reg_num & CS_REGNUM_MASK) << CS_REGNUM_SHIFT) - - ); - - uint32_t *payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(read_reg); - - // Update payload length - incr_header_len(CS_FIXED_LEN + CS_READREG_LEN); - - return true; -} - -/*! - * \brief Adds a read register reply response to the current packet. This is - * used by the fake USRP code to generate fake register read responses for - * testing. - * - * The \p rid is the associated RID to be included in the response, \p reg_num - * is the register the read is coming from, and \p reg_val is the value of the - * read. - * - * \returns true if the command was added to the packet, false otherwise. - */ -bool usrp_inband_usb_packet::cs_read_reg_reply(long rid, long reg_num, long reg_val) -{ - if(!align32()) - return false; - - int p_len = payload_len(); - - if((MAX_PAYLOAD - p_len) < (CS_READREGREPLY_LEN + CS_FIXED_LEN)) - return false; - - uint32_t word0 = ( - ((OP_READ_REG_REPLY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT) - | ((CS_READREGREPLY_LEN & CS_LEN_MASK) << CS_LEN_SHIFT) - | ((rid & CS_RID_MASK) << CS_RID_SHIFT) - | ((reg_num & CS_REGNUM_MASK) << CS_REGNUM_SHIFT) - - ); - - uint32_t *payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(word0); - - // Hop to the next word and write the reg value - payload += 1; - *payload = host_to_usrp_u32((uint32_t) reg_val); - - // Update payload length - incr_header_len(CS_FIXED_LEN + CS_READREGREPLY_LEN); - - return true; -} - -/*! - * \brief Adds a delay command to the current packet. - * - * The \p ticks parameter is the number of clock ticks the FPGA should delay - * parsing for, which is added to the packet. - * - * \returns true if the command was added to the packet, false otherwise. - */ -bool usrp_inband_usb_packet::cs_delay(long ticks) -{ - if(!align32()) - return false; - - int p_len = payload_len(); - - if((MAX_PAYLOAD - p_len) < (CS_DELAY_LEN + CS_FIXED_LEN)) - return false; - - uint32_t delay = ( - ((OP_DELAY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT) - | ((CS_DELAY_LEN & CS_LEN_MASK) << CS_LEN_SHIFT) - | ((ticks & CS_DELAY_MASK) << CS_DELAY_SHIFT) - - ); - - uint32_t *payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(delay); - - // Update payload length - incr_header_len(CS_FIXED_LEN + CS_DELAY_LEN); - - return true; -} - -/*! - * \brief - * - * \returns true if the command was added to the packet, false otherwise. - */ -bool usrp_inband_usb_packet::cs_i2c_write(long i2c_addr, uint8_t *i2c_data, size_t data_len) -{ - if(!align32()) - return false; - - int p_len = payload_len(); - - int i2c_len = data_len + 2; // 2 bytes between mbz and addr - - if((MAX_PAYLOAD - p_len) < (i2c_len + CS_FIXED_LEN)) - return false; - - uint32_t word0 = 0; - - word0 = ( - ((OP_I2C_WRITE & CS_OPCODE_MASK) << CS_OPCODE_SHIFT) - | ((i2c_len & CS_LEN_MASK) << CS_LEN_SHIFT) - | ((i2c_addr & CS_I2CADDR_MASK) << CS_I2CADDR_SHIFT) - ); - - uint32_t *payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(word0); - - // Jump over the first word and write the data - // FIXME: Should the data be changed to usrp byte order? - payload += 1; - memcpy(payload, i2c_data, data_len); - - // Update payload length - incr_header_len(CS_FIXED_LEN + i2c_len); - - return true; -} - -/*! - * \brief Adds an I2C read command to the current packet. - * - * The \p rid is the associated RID to return with the read response, \p - * i2c_addr is the address to read from on the I2C bus, and \p n_bytes is the - * number of bytes to be read from the bus. - * - * \returns true if the command was added to the packet, false otherwise. - */ -bool usrp_inband_usb_packet::cs_i2c_read(long rid, long i2c_addr, long n_bytes) -{ - if(!align32()) - return false; - - int p_len = payload_len(); - - if((MAX_PAYLOAD - p_len) < (CS_I2CREAD_LEN + CS_FIXED_LEN)) - return false; - - uint32_t word0 = 0; - - word0 = ( - ((OP_I2C_READ & CS_OPCODE_MASK) << CS_OPCODE_SHIFT) - | ((CS_I2CREAD_LEN & CS_LEN_MASK) << CS_LEN_SHIFT) - | ((rid & CS_RID_MASK) << CS_RID_SHIFT) - | ((i2c_addr & CS_I2CADDR_MASK) << CS_I2CADDR_SHIFT) - ); - - uint32_t *payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(word0); - - // Jump a word and write the number of bytes to read - payload += 1; - uint32_t word1 = - (n_bytes & CS_I2CREADBYTES_MASK) << CS_I2CREADBYTES_SHIFT; - *payload = host_to_usrp_u32(word1); - - // Update payload length - incr_header_len(CS_FIXED_LEN + CS_I2CREAD_LEN); - - return true; -} - -/*! - * \brief Adds an I2C read reply response to the current packet. This is used - * by the fake USRP code to generate fake I2C responses. - * - * The \p rid is the RID to be associated with the response, \p i2c_addr is the - * address on the I2C bus that the \p i2c_data of \p i2c_data_len was read from. - * - * \returns true if the command was added to the packet, false otherwise. - */ -bool usrp_inband_usb_packet::cs_i2c_read_reply(long rid, long i2c_addr, uint8_t *i2c_data, long i2c_data_len) -{ - if(!align32()) - return false; - - int p_len = payload_len(); - - int i2c_len = i2c_data_len + 2; - - if((MAX_PAYLOAD - p_len) < (i2c_len + CS_FIXED_LEN)) - return false; - - uint32_t word0 = 0; - - word0 = ( - ((OP_I2C_READ_REPLY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT) - | ((i2c_len & CS_LEN_MASK) << CS_LEN_SHIFT) - | ((rid & CS_RID_MASK) << CS_RID_SHIFT) - | ((i2c_addr & CS_I2CADDR_MASK) << CS_I2CADDR_SHIFT) - ); - - uint32_t *payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(word0); - - // Jump a word and write the actual data - payload += 1; - memcpy(payload, i2c_data, i2c_data_len); - - // Update payload length - incr_header_len(CS_FIXED_LEN + i2c_len); - - return true; -} - -/*! - * \brief Adds a SPI write command to the current packet. - * - * \returns true if the command was added to the packet, false otherwise. - */ -bool usrp_inband_usb_packet::cs_spi_write(long enables, long format, long opt_header_bytes, uint8_t *spi_data, long spi_data_len) -{ - if(!align32()) - return false; - - int p_len = payload_len(); - - int spi_len = spi_data_len + 6; - - if((MAX_PAYLOAD - p_len) < (spi_len + CS_FIXED_LEN)) - return false; - - uint32_t word = 0; - - // First word contains the opcode and length, then mbz - word = ( - ((OP_SPI_WRITE & CS_OPCODE_MASK) << CS_OPCODE_SHIFT) - | ((spi_len & CS_LEN_MASK) << CS_LEN_SHIFT) - ); - uint32_t *payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(word); - - payload += 1; - - // Second word contains the enables, format, and optional tx bytes - word = 0; - word = ( - ((enables & CS_SPIENABLES_MASK) << CS_SPIENABLES_SHIFT) - | ((format & CS_SPIFORMAT_MASK) << CS_SPIFORMAT_SHIFT) - | ((opt_header_bytes & CS_SPIOPT_MASK) << CS_SPIOPT_SHIFT) - ); - payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(word); - - payload += 1; - memcpy(payload, spi_data, spi_data_len); - - // Update payload length - incr_header_len(CS_FIXED_LEN + spi_len); - - return true; -} - -/*! - * \brief Adds a SPI bus read command to the packet. - * - * \returns true if the command was added to the packet, false otherwise. - */ -bool usrp_inband_usb_packet::cs_spi_read(long rid, long enables, long format, long opt_header_bytes, long n_bytes) -{ - if(!align32()) - return false; - - int p_len = payload_len(); - - if((MAX_PAYLOAD - p_len) < (CS_SPIREAD_LEN + CS_FIXED_LEN)) - return false; - - uint32_t word = 0; - - // First word contains the opcode, length, and RID - word = ( - ((OP_SPI_READ & CS_OPCODE_MASK) << CS_OPCODE_SHIFT) - | ((CS_SPIREAD_LEN & CS_LEN_MASK) << CS_LEN_SHIFT) - | ((rid & CS_RID_MASK) << CS_RID_SHIFT) - ); - uint32_t *payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(word); - - payload += 1; - - // Second word contains the enables, format, and optional tx bytes - word = 0; - word = ( - ((enables & CS_SPIENABLES_MASK) << CS_SPIENABLES_SHIFT) - | ((format & CS_SPIFORMAT_MASK) << CS_SPIFORMAT_SHIFT) - | ((opt_header_bytes & CS_SPIOPT_MASK) << CS_SPIOPT_SHIFT) - ); - payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(word); - - payload += 1; - - // The third word contains the number of bytes - word = 0; - word = ( - ((n_bytes & CS_SPINBYTES_MASK) << CS_SPINBYTES_SHIFT) - ); - payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(word); - - // Update payload length - incr_header_len(CS_FIXED_LEN + CS_SPIREAD_LEN); - - return true; -} - -/*! - * \brief Adds an SPI read reply to the current packet. This is used by the - * fake USRP code to generate fake responses for SPI reads. - * - * \returns true if the command was added to the packet, false otherwise. - */ -bool usrp_inband_usb_packet::cs_spi_read_reply(long rid, uint8_t *spi_data, long spi_data_len) -{ - if(!align32()) - return false; - - int p_len = payload_len(); - - int spi_len = spi_data_len + 2; - - if((MAX_PAYLOAD - p_len) < (spi_len + CS_FIXED_LEN)) - return false; - - uint32_t word = 0; - - // First word contains the opcode, length, and RID - word = ( - ((OP_SPI_READ_REPLY & CS_OPCODE_MASK) << CS_OPCODE_SHIFT) - | ((spi_len & CS_LEN_MASK) << CS_LEN_SHIFT) - | ((rid & CS_RID_MASK) << CS_RID_SHIFT) - ); - uint32_t *payload = (uint32_t *) (d_payload + p_len); - *payload = host_to_usrp_u32(word); - - // Jump a word and write the actual data - payload += 1; - memcpy(payload, spi_data, spi_data_len); - - // Update payload length - incr_header_len(CS_FIXED_LEN + spi_len); - - return true; -} - -/*! - * \brief Since all control packets contain subpackets which have the length of - * the subpacket at a uniform location in the subpacket, this will return the - * subpacket length given a byte offset of the start of the subpacket from the beginning of the packet. - * - * \returns the length of the subpacket - */ -int usrp_inband_usb_packet::cs_len(int payload_offset) { - uint32_t subpkt = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset))); - return (subpkt >> CS_LEN_SHIFT) & CS_LEN_MASK; -} - -/*! - * \brief The following method takes an offset within the packet payload to - * extract a control/status subpacket and constructs a pmt response which - * includes the proper signal and arguments specified by usrp-low-level-cs. The - * USRP server could therefore use this to read subpackets and pass them - * responses back up to the application. It's arguable that only reply packets - * should be parsed here, however we parse others for use in debugging or - * failure reporting on the transmit side of packets. - */ -pmt_t usrp_inband_usb_packet::read_subpacket(int payload_offset) { - - uint32_t subpkt = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset))); - uint32_t opcode = (subpkt >> CS_OPCODE_SHIFT) & CS_OPCODE_MASK; - uint32_t len = (subpkt >> CS_LEN_SHIFT) & CS_LEN_MASK; - - switch(opcode) { - - case OP_PING_FIXED_REPLY: - { - pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK); - pmt_t pingval = pmt_from_long((subpkt >> CS_PINGVAL_SHIFT) & CS_PINGVAL_MASK); - return pmt_list3(s_op_ping_fixed_reply, rid, pingval); - } - - case OP_READ_REG_REPLY: - { - pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK); - pmt_t reg_num = pmt_from_long((subpkt >> CS_REGNUM_SHIFT) & CS_REGNUM_MASK); - - // To get the register value we just read the next 32 bits - uint32_t val = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 4))); - pmt_t reg_val = pmt_from_long(val); - - return pmt_list4(s_op_read_reg_reply, rid, reg_num, reg_val); - } - - case OP_I2C_READ_REPLY: - { - pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK); - pmt_t i2c_addr = pmt_from_long((subpkt >> CS_I2CADDR_SHIFT) & CS_I2CADDR_MASK); - - // Make a u8 vector to dump the data from the packet into - size_t i2c_data_len; - pmt_t i2c_data = pmt_make_u8vector(len - 2, 0); // skip rid+mbz+addr = 2 bytes - uint8_t *w_data = - (uint8_t *) pmt_u8vector_writable_elements(i2c_data, i2c_data_len); - - memcpy(w_data, d_payload + payload_offset + 4, i2c_data_len); // skip first word - - return pmt_list4(s_op_i2c_read_reply, rid, i2c_addr, i2c_data); - } - - case OP_SPI_READ_REPLY: - { - pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK); - - // Make a u8 vector to dump the data from the packet into - size_t spi_data_len; - pmt_t spi_data = pmt_make_u8vector(len - 2, 0); // skip rid+mbz+addr = 2 bytes - uint8_t *w_data = - (uint8_t *) pmt_u8vector_writable_elements(spi_data, spi_data_len); - - memcpy(w_data, d_payload + payload_offset + 4, spi_data_len); // skip first word - - return pmt_list3(s_op_spi_read_reply, rid, spi_data); - } - - case OP_PING_FIXED: - { - pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK); - pmt_t pingval = pmt_from_long((subpkt >> CS_PINGVAL_SHIFT) & CS_PINGVAL_MASK); - return pmt_list3(s_op_ping_fixed, rid, pingval); - } - - case OP_WRITE_REG: - { - pmt_t reg_num = pmt_from_long((subpkt >> CS_REGNUM_SHIFT) & CS_REGNUM_MASK); - - // To get the register value we just read the next 32 bits - uint32_t val = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 4))); - pmt_t reg_val = pmt_from_long(val); - - return pmt_list3(s_op_write_reg, reg_num, reg_val); - } - - case OP_WRITE_REG_MASKED: - { - pmt_t reg_num = pmt_from_long((subpkt >> CS_REGNUM_SHIFT) & CS_REGNUM_MASK); - - // To get the register value we just read the next 32 bits - uint32_t val = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 4))); - pmt_t reg_val = pmt_from_long(val); - - // The mask is the next 32 bits - uint32_t mask = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 8))); - pmt_t reg_mask = pmt_from_long(mask); - - return pmt_list4(s_op_write_reg_masked, reg_num, reg_val, reg_mask); - } - - case OP_READ_REG: - { - pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK); - pmt_t reg_num = pmt_from_long((subpkt >> CS_REGNUM_SHIFT) & CS_REGNUM_MASK); - - return pmt_list3(s_op_read_reg, rid, reg_num); - } - - case OP_I2C_WRITE: - { - pmt_t i2c_addr = pmt_from_long((subpkt >> CS_I2CADDR_SHIFT) & CS_I2CADDR_MASK); - - // The length includes an extra 2 bytes for storing the mbz and addr - pmt_t i2c_data = pmt_make_u8vector(len-2, 0); - - // Get a writable address to copy the data from the packet - size_t ignore; - uint8_t *w_data = (uint8_t *) pmt_u8vector_writable_elements(i2c_data, ignore); - memcpy(w_data, d_payload + payload_offset + 4, len-2); - - - return pmt_list3(s_op_i2c_write, i2c_addr, i2c_data); - } - - case OP_I2C_READ: - { - pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK); - pmt_t i2c_addr = pmt_from_long((subpkt >> CS_I2CADDR_SHIFT) & CS_I2CADDR_MASK); - - // The number of bytes is in the next word - uint32_t bytes = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 4))); - bytes = (bytes >> CS_I2CREADBYTES_SHIFT) & CS_I2CREADBYTES_MASK; - pmt_t i2c_bytes = pmt_from_long(bytes); - - return pmt_list4(s_op_i2c_read, rid, i2c_addr, i2c_bytes); - } - - case OP_SPI_WRITE: - { - // Nothing interesting in the first word, skip to the next - uint32_t word = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 4))); - pmt_t enables = pmt_from_long((word >> CS_SPIENABLES_SHIFT) & CS_SPIENABLES_MASK); - pmt_t format = pmt_from_long((word >> CS_SPIFORMAT_SHIFT) & CS_SPIFORMAT_MASK); - pmt_t opt = pmt_from_long((word >> CS_SPIOPT_SHIFT) & CS_SPIOPT_MASK); - - // From the next word and on is data - size_t spi_data_len; - pmt_t spi_data = pmt_make_u8vector(len - 6, 0); // skip rid+mbz+addr = 2 bytes - uint8_t *w_data = - (uint8_t *) pmt_u8vector_writable_elements(spi_data, spi_data_len); - - memcpy(w_data, d_payload + payload_offset + 8, spi_data_len); // skip first 2 words - - return pmt_list5(s_op_spi_write, enables, format, opt, spi_data); - } - - case OP_SPI_READ: - { - // Read the RID from the first word, the rest is mbz - pmt_t rid = pmt_from_long((subpkt >> CS_RID_SHIFT) & CS_RID_MASK); - - // Continue at the next word... - uint32_t word = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 4))); - pmt_t enables = pmt_from_long((word >> CS_SPIENABLES_SHIFT) & CS_SPIENABLES_MASK); - pmt_t format = pmt_from_long((word >> CS_SPIFORMAT_SHIFT) & CS_SPIFORMAT_MASK); - pmt_t opt = pmt_from_long((word >> CS_SPIOPT_SHIFT) & CS_SPIOPT_MASK); - - // The number of bytes is the only thing to read in the next word - word = usrp_to_host_u32(*((uint32_t *)(d_payload + payload_offset + 8))); - pmt_t n_bytes = pmt_from_long((word >> CS_SPINBYTES_SHIFT) & CS_SPINBYTES_MASK); - - return pmt_list6(s_op_spi_read, rid, enables, format, opt, n_bytes); - } - - case OP_DELAY: - { - pmt_t ticks = pmt_from_long((subpkt >> CS_DELAY_SHIFT) & CS_DELAY_MASK); - - return pmt_list2(s_op_delay, ticks); - } - - default: - return PMT_NIL; - - } -} - diff --git a/usrp/limbo/inband/usrp_inband_usb_packet.h b/usrp/limbo/inband/usrp_inband_usb_packet.h deleted file mode 100644 index 6f1a3feb3..000000000 --- a/usrp/limbo/inband/usrp_inband_usb_packet.h +++ /dev/null @@ -1,240 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef INCLUDED_USRP_INBAND_USB_PACKET_H_ -#define INCLUDED_USRP_INBAND_USB_PACKET_H_ - -#include <usrp_bytesex.h> -#include <mblock/mblock.h> -#include <pmt.h> -#include <iostream> - -#include <symbols_usrp_low_level_cs.h> - -static const int USB_PKT_SIZE = 512; // bytes -static const int MAX_PAYLOAD = USB_PKT_SIZE-2*sizeof(uint32_t); -static const int CONTROL_CHAN = 0x1f; - -class usrp_inband_usb_packet { - // - // keep raw packet in USRP-endian order - // - uint32_t d_word0; - uint32_t d_timestamp; - unsigned char d_payload[MAX_PAYLOAD]; - -public: - - enum opcodes { - OP_PING_FIXED = 0x00, - OP_PING_FIXED_REPLY = 0x01, - OP_WRITE_REG = 0x02, - OP_WRITE_REG_MASKED = 0x03, - OP_READ_REG = 0x04, - OP_READ_REG_REPLY = 0x05, - OP_I2C_WRITE = 0x06, - OP_I2C_READ = 0x07, - OP_I2C_READ_REPLY = 0x08, - OP_SPI_WRITE = 0x09, - OP_SPI_READ = 0x0a, - OP_SPI_READ_REPLY = 0x0b, - OP_DELAY = 0x0c - }; - - enum flags { - FL_OVERRUN = 0x80000000, - FL_UNDERRUN = 0x40000000, - FL_DROPPED = 0x20000000, - FL_START_OF_BURST = 0x10000000, - FL_END_OF_BURST = 0x08000000, - FL_CARRIER_SENSE = 0x04000000, - - FL_ALL_FLAGS = 0xfc000000 - }; - - static const int FL_OVERRUN_SHIFT = 31; - static const int FL_UNDERRUN_SHIFT = 30; - static const int FL_DROPPED_SHIFT = 29; - static const int FL_END_OF_BURST_SHIFT = 27; - static const int FL_START_OF_BURST_SHIFT = 28; - - static const int RSSI_MASK = 0x3f; - static const int RSSI_SHIFT = 21; - - static const int CHAN_MASK = 0x1f; - static const int CHAN_SHIFT = 16; - - static const int TAG_MASK = 0xf; - static const int TAG_SHIFT = 9; - - static const int PAYLOAD_LEN_MASK = 0x1ff; - static const int PAYLOAD_LEN_SHIFT = 0; - - // Fixed size for opcode and length fields - static const int CS_FIXED_LEN = 2; - - static const int CS_OPCODE_MASK = 0xff; - static const int CS_OPCODE_SHIFT = 24; - - static const int CS_LEN_MASK = 0xff; - static const int CS_LEN_SHIFT = 16; - - static const int CS_RID_MASK = 0x3f; - static const int CS_RID_SHIFT = 10; - - static const int CS_PING_LEN = 2; - static const int CS_PINGVAL_MASK = 0x3ff; - static const int CS_PINGVAL_SHIFT = 0; - - static const int CS_WRITEREG_LEN = 6; - static const int CS_WRITEREGMASKED_LEN = 10; - static const int CS_READREG_LEN = 2; - static const int CS_READREGREPLY_LEN = 6; - static const int CS_REGNUM_MASK = 0x3ff; - static const int CS_REGNUM_SHIFT = 0; - - static const int CS_DELAY_LEN = 2; - static const int CS_DELAY_MASK = 0xffff; - static const int CS_DELAY_SHIFT = 0; - - static const int CS_I2CADDR_MASK = 0x7f; - static const int CS_I2CADDR_SHIFT = 0; - - static const int CS_I2CREAD_LEN = 3; - static const int CS_I2CREADBYTES_MASK = 0x7f; - static const int CS_I2CREADBYTES_SHIFT = 24; - - static const int CS_SPIOPT_MASK = 0xffff; - static const int CS_SPIOPT_SHIFT = 0; - static const int CS_SPIFORMAT_MASK = 0xff; - static const int CS_SPIFORMAT_SHIFT = 16; - static const int CS_SPIENABLES_MASK = 0xff; - static const int CS_SPIENABLES_SHIFT = 24; - static const int CS_SPIREAD_LEN = 7; - static const int CS_SPINBYTES_MASK = 0xff; - static const int CS_SPINBYTES_SHIFT = 24; - -public: - - void set_timestamp(uint32_t timestamp){ - d_timestamp = host_to_usrp_u32(timestamp); - } - - void set_end_of_burst() { - uint32_t word0 = usrp_to_host_u32(d_word0); - word0 |= 1<<FL_END_OF_BURST_SHIFT; - d_word0 = host_to_usrp_u32(word0); - } - - void set_header(int flags, int chan, int tag, int payload_len){ - uint32_t word0 = ((flags & FL_ALL_FLAGS) - | ((chan & CHAN_MASK) << CHAN_SHIFT) - | ((tag & TAG_MASK) << TAG_SHIFT) - | ((payload_len & PAYLOAD_LEN_MASK) << PAYLOAD_LEN_SHIFT)); - d_word0 = host_to_usrp_u32(word0); - } - - void incr_header_len(int val) { - set_header(flags(), chan(), tag(), payload_len() + val); - } - - uint32_t timestamp() const { - return usrp_to_host_u32(d_timestamp); - } - - int rssi() const { - uint32_t word0 = usrp_to_host_u32(d_word0); - return (word0 >> RSSI_SHIFT) & RSSI_MASK; - } - - int chan() const { - uint32_t word0 = usrp_to_host_u32(d_word0); - return (word0 >> CHAN_SHIFT) & CHAN_MASK; - } - - int tag() const { - uint32_t word0 = usrp_to_host_u32(d_word0); - return (word0 >> TAG_SHIFT) & TAG_MASK; - } - - int payload_len() const { - uint32_t word0 = usrp_to_host_u32(d_word0); - return (word0 >> PAYLOAD_LEN_SHIFT) & PAYLOAD_LEN_MASK; - } - - int flags() const { - return usrp_to_host_u32(d_word0) & FL_ALL_FLAGS; - } - - int overrun() const { - return (usrp_to_host_u32(d_word0) & FL_OVERRUN) >> FL_OVERRUN_SHIFT; - } - - - int underrun() const { - return (usrp_to_host_u32(d_word0) & FL_UNDERRUN) >> FL_UNDERRUN_SHIFT; - } - - - int start_of_burst() const { - return (usrp_to_host_u32(d_word0) & FL_START_OF_BURST) >> FL_START_OF_BURST_SHIFT; - } - - int end_of_burst() const { - return (usrp_to_host_u32(d_word0) & FL_END_OF_BURST) >> FL_END_OF_BURST_SHIFT; - } - - int dropped() const { - return (usrp_to_host_u32(d_word0) & FL_DROPPED) >> FL_DROPPED_SHIFT; - } - - unsigned char *payload() { - return d_payload; - } - - static int max_payload() { - return MAX_PAYLOAD; - } - - static int max_pkt_size() { - return USB_PKT_SIZE; - } - - // C/S methods - bool align32(); - bool cs_ping(long rid, long ping_val); - bool cs_ping_reply(long rid, long ping_val); - bool cs_write_reg(long reg_num, long val); - bool cs_write_reg_masked(long reg_num, long val, long mask); - bool cs_read_reg(long rid, long reg_num); - bool cs_read_reg_reply(long rid, long reg_num, long reg_val); - bool cs_delay(long ticks); - bool cs_i2c_write(long i2c_addr, uint8_t *i2c_data, size_t data_len); - bool cs_i2c_read(long rid, long i2c_addr, long n_bytes); - bool cs_i2c_read_reply(long rid, long i2c_addr, uint8_t *i2c_data, long i2c_data_len); - bool cs_spi_write(long enables, long format, long opt_header_bytes, uint8_t *spi_data, long spi_data_len); - bool cs_spi_read(long rid, long enables, long format, long opt_header_bytes, long n_bytes); - bool cs_spi_read_reply(long rid, uint8_t *spi_data, long spi_data_len); - int cs_len(int payload_offset); - pmt_t read_subpacket(int payload_offset); -}; - -#endif diff --git a/usrp/limbo/inband/usrp_interface.mbh b/usrp/limbo/inband/usrp_interface.mbh deleted file mode 100644 index ad0f78b4e..000000000 --- a/usrp/limbo/inband/usrp_interface.mbh +++ /dev/null @@ -1,88 +0,0 @@ -;; -*- scheme -*- ; not really, but tells emacs how to format this -;; -;; Copyright 2007 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 2, or (at your option) -;; any later version. -;; -;; GNU Radio is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License along -;; with this program; if not, write to the Free Software Foundation, Inc., -;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -;; - -;; ---------------------------------------------------------------- -;; This is an mblock header file -;; -;; The format is very much a work-in-progress. -;; It'll be compiled to C++. -;; ---------------------------------------------------------------- - -;; ---------------------------------------------------------------- -;; usrp-interface-cs -;; -;; Handles interaction between the usrp_sever and the USB interface - -(define-protocol-class usrp-interface-cs - - (:outgoing - (cmd-usrp-open invocation-handle which-usrp) - (cmd-usrp-close invocation-handle) - (cmd-usrp-ntx-chan invocation-handle) - (cmd-usrp-nrx-chan invocation-handle) - (cmd-usrp-write invocation-handle channel data) - (cmd-usrp-start-reading invocation-handle channel) - ) - - (:incoming - (response-usrp-open invocation-handle status) - (response-usrp-close invocation-handle status) - (response-usrp-ntx-chan invocation-handle ntx-chan) - (response-usrp-nrx-chan invocation-handle nrx-chan) - (response-usrp-write invocation-handle status channel) - (response-usrp-read invocation-handle status data) - ) - ) - -;; ---------------------------------------------------------------- -;; usrp-tx-cs -;; -;; Handles interaction between the USB interface and TX interface - -(define-protocol-class usrp-tx-cs - - (:outgoing - (cmd-usrp-tx-write invocation-handle channel data tx-handle) - ) - - (:incoming - (response-usrp-tx-write invocation-handle status channel) - ) - ) - -;; ---------------------------------------------------------------- -;; usrp-rx-cs -;; -;; Handles interaction between the USB interface and RX interface - -(define-protocol-class usrp-rx-cs - - (:outgoing - (cmd-usrp-rx-start-reading invocation-handle rx-handle) - (cmd-usrp-rx-stop-reading invocation-handle) - ) - - (:incoming - (response-usrp-rx-read invocation-handle status data) - - ;; There is currently no response to a stop reading - ) - ) diff --git a/usrp/limbo/inband/usrp_rx.cc b/usrp/limbo/inband/usrp_rx.cc deleted file mode 100644 index fe9486cf6..000000000 --- a/usrp/limbo/inband/usrp_rx.cc +++ /dev/null @@ -1,184 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <usrp_rx.h> - -#include <usrp_standard.h> -#include <iostream> -#include <vector> -#include <usb.h> -#include <mblock/class_registry.h> -#include <usrp_inband_usb_packet.h> -#include <fpga_regs_common.h> -#include <stdio.h> - -#include <symbols_usrp_rx_cs.h> - -typedef usrp_inband_usb_packet transport_pkt; - -static const bool verbose = false; - -bool usrp_rx_stop; - -usrp_rx::usrp_rx(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(rt, instance_name, user_arg), - d_disk_write(false), - d_disk_write_pkt(false) // if true, writes full packet, else just the payload -{ - d_cs = define_port("cs", "usrp-rx-cs", true, mb_port::EXTERNAL); - - if(d_disk_write) { - d_ofile0.open("rx_data_chan0.dat",std::ios::binary|std::ios::out); - d_ofile1.open("rx_data_chan1.dat",std::ios::binary|std::ios::out); - d_cs_ofile.open("rx_cs.dat",std::ios::binary|std::ios::out); - } - - usrp_rx_stop = false; - -} - -usrp_rx::~usrp_rx() -{ - if(d_disk_write) { - d_ofile0.close(); - d_ofile1.close(); - d_cs_ofile.close(); - } -} - -void -usrp_rx::initial_transition() -{ - -} - -/*! - * \brief Handles incoming signals to to the m-block, wihch should only ever be - * a single message: cmd-usrrp-rx-start-reading. There is no signal to stop - * reading as the m-block goes in to a forever loop to read inband packets from - * the bus. - */ -void -usrp_rx::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); - pmt_t port_id = msg->port_id(); - pmt_t data = msg->data(); - - // Theoretically only have 1 message to ever expect, but - // want to make sure its at least what we want - if(pmt_eq(port_id, d_cs->port_symbol())) { - - if(pmt_eqv(event, s_cmd_usrp_rx_start_reading)) - read_and_respond(data); - } -} - -/*! - * \brief Performs the actual reading of data from the USB bus, called by - * handle_message() when a cmd-usrp-rx-start-reading signal is received. - * - * The method enters a forever loop where it continues to read data from the bus - * and generate read responses to the higher layer. Currently, shared memory is - * used to exit this loop. - * - * The \p data parameter is a PMT list which contains only a single element, an - * invocation handle which will be returned with all read respones. - */ -void -usrp_rx::read_and_respond(pmt_t data) -{ - size_t ignore; - bool underrun; - unsigned int n_read; - unsigned int pkt_size = sizeof(transport_pkt); - - pmt_t invocation_handle = pmt_nth(0, data); - - // Need the handle to the RX port to send responses, this is passed - // by the USRP interface m-block - pmt_t handle = pmt_nth(1, data); - d_urx = - boost::any_cast<usrp_standard_rx_sptr>(pmt_any_ref(handle)); - - if(verbose) - std::cout << "[usrp_rx] Waiting for packets..\n"; - - // Read by 512 which is packet size and send them back up - while(!usrp_rx_stop) { - - pmt_t v_pkt = pmt_make_u8vector(pkt_size, 0); - transport_pkt *pkt = - (transport_pkt *) pmt_u8vector_writable_elements(v_pkt, ignore); - - n_read = d_urx->read(pkt, pkt_size, &underrun); - - if(n_read != pkt_size) { - std::cerr << "[usrp_rx] Error reading packet, shutting down\n"; - d_cs->send(s_response_usrp_rx_read, - pmt_list3(PMT_NIL, PMT_F, PMT_NIL)); - return; - } - - if(underrun && verbose && 0) - std::cout << "[usrp_rx] Underrun\n"; - - d_cs->send(s_response_usrp_rx_read, - pmt_list3(PMT_NIL, PMT_T, v_pkt)); - if(verbose && 0) - std::cout << "[usrp_rx] Read 1 packet\n"; - - if(d_disk_write) { - if(pkt->chan() == CONTROL_CHAN) - d_cs_ofile.write((const char *)pkt, transport_pkt::max_pkt_size()); - else { - if(d_disk_write_pkt) { - if(pkt->chan() == 0) - d_ofile0.write((const char *)pkt, transport_pkt::max_pkt_size()); - else if(pkt->chan() == 1) - d_ofile1.write((const char *)pkt, transport_pkt::max_pkt_size()); - } else { - if(pkt->chan() == 0) - d_ofile0.write((const char *)pkt->payload(), transport_pkt::max_payload()); - else if(pkt->chan() == 1) - d_ofile1.write((const char *)pkt->payload(), transport_pkt::max_payload()); - } - } - - d_cs_ofile.flush(); - d_ofile0.flush(); - d_ofile1.flush(); - } - } - - usrp_rx_stop = false; - - if(verbose) { - std::cout << "[USRP_RX] Stopping...\n"; - fflush(stdout); - } -} - -REGISTER_MBLOCK_CLASS(usrp_rx); diff --git a/usrp/limbo/inband/usrp_rx.h b/usrp/limbo/inband/usrp_rx.h deleted file mode 100644 index 1006235bf..000000000 --- a/usrp/limbo/inband/usrp_rx.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_USRP_RX_H -#define INCLUDED_USRP_RX_H - -#include <mblock/mblock.h> -#include <fstream> -#include "usrp_standard.h" - -extern bool usrp_rx_stop; // used to communicate a 'stop' to the RX stub - -/*! - * \brief Implements the low level usb interface to the USRP - */ -class usrp_rx : public mb_mblock -{ - mb_port_sptr d_cs; - usrp_standard_rx_sptr d_urx; - - bool d_disk_write; - bool d_disk_write_pkt; - std::ofstream d_ofile0; - std::ofstream d_ofile1; - std::ofstream d_cs_ofile; - - public: - usrp_rx(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg); - ~usrp_rx(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - private: - void read_and_respond(pmt_t data); - void read_data(); - -}; - - -#endif /* INCLUDED_USRP_RX_H */ - diff --git a/usrp/limbo/inband/usrp_rx_stub.cc b/usrp/limbo/inband/usrp_rx_stub.cc deleted file mode 100644 index e5c454d24..000000000 --- a/usrp/limbo/inband/usrp_rx_stub.cc +++ /dev/null @@ -1,227 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <usrp_rx_stub.h> - -#include <iostream> -#include <vector> -#include <usb.h> -#include <mblock/class_registry.h> -#include <usrp_inband_usb_packet.h> -#include <fpga_regs_common.h> -#include "usrp_standard.h" -#include <stdio.h> -#include <string.h> -#include <ui_nco.h> -#include <fstream> - -#include <symbols_usrp_rx_cs.h> - -typedef usrp_inband_usb_packet transport_pkt; - -static const bool verbose = false; - -bool usrp_rx_stop_stub; - -// Used for the fake control packet response code to send the responses back up -// the RX. The TX stub dumps responses in to this queue. -std::queue<pmt_t> d_cs_queue; - -usrp_rx_stub::usrp_rx_stub(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(rt, instance_name, user_arg), - d_samples_per_frame((long)(126)), - d_decim_rx(128), - d_amplitude(16384), - d_disk_write(false) -{ - - // Information about the rates are passed all the way from the app in the form - // of a dictionary. We use this to read the RX decimation rate and compute - // the approximate number of MS/s as a form of flow control for the stub. - pmt_t usrp_dict = user_arg; - - if (pmt_is_dict(usrp_dict)) { - // Read the RX decimation rate - if(pmt_t decim_rx = pmt_dict_ref(usrp_dict, - pmt_intern("decim-rx"), - PMT_NIL)) { - if(!pmt_eqv(decim_rx, PMT_NIL)) - d_decim_rx = pmt_to_long(decim_rx); - } - } - - d_cs = define_port("cs", "usrp-rx-cs", true, mb_port::EXTERNAL); - - // initialize NCO - double freq = 100e3; - int interp = 32; // 32 -> 4MS/s - double sample_rate = 64e6 / interp; - d_nco.set_freq(2*M_PI * freq/sample_rate); - - //d_disk_write = true; - - if(d_disk_write) - d_ofile.open("raw_rx.dat",std::ios::binary|std::ios::out); - - usrp_rx_stop_stub = false; -} - -usrp_rx_stub::~usrp_rx_stub() -{ - if(d_disk_write) - d_ofile.close(); -} - -void -usrp_rx_stub::initial_transition() -{ -} - -void -usrp_rx_stub::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); - pmt_t port_id = msg->port_id(); - pmt_t data = msg->data(); - - if (pmt_eq(msg->signal(), s_timeout) - && !pmt_eq(msg->data(), s_done)) { - - if(!usrp_rx_stop_stub) - read_and_respond(); - else { // requested to stop - cancel_timeout(msg->metadata()); - usrp_rx_stop_stub=false; - if(verbose) - std::cout << "[USRP_RX_STUB] Stopping RX stub\n"; - } - - } - - // Theoretically only have 1 message to ever expect, but - // want to make sure its at least what we want - if(pmt_eq(port_id, d_cs->port_symbol()) - && pmt_eqv(event, s_cmd_usrp_rx_start_reading)) { - - if(verbose) - std::cout << "[USRP_RX_STUB] Starting with decim @ " - << d_decim_rx << std::endl; - - start_packet_timer(); - } -} - -// Setup a periodic timer which will drive packet generation -void -usrp_rx_stub::start_packet_timer() -{ - d_t0 = mb_time::time(); // current time - - // Calculate the inter-packet arrival time. - double samples_per_sec = (64.0/(double)d_decim_rx)*1000000.0; - double frames_per_sec = samples_per_sec / (double)d_samples_per_frame; - double frame_rate = 1.0 / frames_per_sec; - - if(verbose) { - std::cout << "[USRP_RX_STUB] Scheduling periodic packet generator\n"; - std::cout << "\tsamples_per_sec: " << samples_per_sec << std::endl; - std::cout << "\tframes_per_sec: " << frames_per_sec << std::endl; - std::cout << "\tframe_rate: " << frame_rate << std::endl; - } - - schedule_periodic_timeout(d_t0 + frame_rate, mb_time(frame_rate), PMT_T); -} - -void -usrp_rx_stub::read_and_respond() -{ - - long nsamples_this_frame = d_samples_per_frame; - - size_t nshorts = 2 * nsamples_this_frame; // 16-bit I & Q - long channel = 0; - long n_bytes = nshorts*2; - pmt_t uvec = pmt_make_s16vector(nshorts, 0); - size_t ignore; - int16_t *samples = pmt_s16vector_writable_elements(uvec, ignore); - - // fill in the complex sinusoid - - for (int i = 0; i < nsamples_this_frame; i++){ - - if (1){ - gr_complex s; - d_nco.sincos(&s, 1, d_amplitude); - // write 16-bit i & q - samples[2*i] = (int16_t) s.real(); - samples[2*i+1] = (int16_t) s.imag(); - } - else { - gr_complex s(d_amplitude, d_amplitude); - - // write 16-bit i & q - samples[2*i] = (int16_t) s.real(); - samples[2*i+1] = (int16_t) s.imag(); - } - } - - if(d_disk_write) - d_ofile.write((const char *)samples, n_bytes); - - pmt_t v_pkt = pmt_make_u8vector(sizeof(transport_pkt), 0); - transport_pkt *pkt = - (transport_pkt *) pmt_u8vector_writable_elements(v_pkt, ignore); - - pkt->set_header(0, channel, 0, n_bytes); - pkt->set_timestamp(0xffffffff); - memcpy(pkt->payload(), samples, n_bytes); - - d_cs->send(s_response_usrp_rx_read, pmt_list3(PMT_NIL, PMT_T, v_pkt)); - - // Now lets check the shared CS queue between the TX and RX stub. Each - // element in a queue is a list where the first element is an invocation - // handle and the second element is a PMT u8 vect representation of the - // CS packet response which can just be passed transparently. - while(!d_cs_queue.empty()) { - - pmt_t cs_pkt = d_cs_queue.front(); - d_cs_queue.pop(); - - pmt_t invocation_handle = pmt_nth(0, cs_pkt); - pmt_t v_pkt = pmt_nth(1, cs_pkt); - - d_cs->send(s_response_usrp_rx_read, - pmt_list3(invocation_handle, - PMT_T, - v_pkt)); // Take the front CS pkt - - - if(verbose) - std::cout << "[USRP_RX_STUB] Received CS response from TX stub\n"; - } - -} - -REGISTER_MBLOCK_CLASS(usrp_rx_stub); diff --git a/usrp/limbo/inband/usrp_rx_stub.h b/usrp/limbo/inband/usrp_rx_stub.h deleted file mode 100644 index 238b4568f..000000000 --- a/usrp/limbo/inband/usrp_rx_stub.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_USRP_RX_STUB_H -#define INCLUDED_USRP_RX_STUB_H - -#include <mblock/mblock.h> -#include <vector> -#include "usrp_standard.h" -#include <ui_nco.h> -#include <fstream> -#include <queue> -#include <usrp_inband_usb_packet.h> - -typedef usrp_inband_usb_packet transport_pkt; - -extern bool usrp_rx_stop_stub; // used to communicate a 'stop' to the RX stub -extern std::queue<pmt_t> d_cs_queue; - -static pmt_t s_timeout = pmt_intern("%timeout"); -static pmt_t s_done = pmt_intern("done"); - -/*! - * \brief Implements the low level usb interface to the USRP - */ -class usrp_rx_stub : public mb_mblock -{ - public: - - mb_port_sptr d_cs; - usrp_standard_rx* d_urx; - - long d_samples_per_frame; - long d_decim_rx; - - mb_time d_t0; - double d_delta_t; - - // for generating sine wave output - ui_nco<float,float> d_nco; - double d_amplitude; - - bool d_disk_write; - - std::ofstream d_ofile; - - public: - usrp_rx_stub(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg); - ~usrp_rx_stub(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - private: - void read_and_respond(); - void read_data(); - void start_packet_timer(); - -}; - - -#endif /* INCLUDED_USRP_RX_H */ - diff --git a/usrp/limbo/inband/usrp_server.cc b/usrp/limbo/inband/usrp_server.cc deleted file mode 100644 index 4f5f396b4..000000000 --- a/usrp/limbo/inband/usrp_server.cc +++ /dev/null @@ -1,1861 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <usrp_server.h> -#include <iostream> -#include <usrp_inband_usb_packet.h> -#include <mblock/class_registry.h> -#include <vector> -#include <usrp_usb_interface.h> -#include <string.h> -#include <fpga_regs_common.h> -#include <fpga_regs_standard.h> - -#include <symbols_usrp_server_cs.h> -#include <symbols_usrp_channel.h> -#include <symbols_usrp_tx.h> -#include <symbols_usrp_rx.h> -#include <symbols_usrp_low_level_cs.h> -#include <symbols_usrp_interface_cs.h> - -static pmt_t s_shutdown = pmt_intern("%shutdown"); - -typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit easy - -const static bool verbose = false; - -static std::string -str(long x) -{ - std::ostringstream s; - s << x; - return s.str(); -} - -usrp_server::usrp_server(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(rt, instance_name, user_arg), - d_fpga_debug(false), - d_interp_tx(128), // these should match the lower level defaults (rx also) - d_decim_rx(128), - d_fake_rx(false) -{ - if(verbose) - std::cout << "[USRP_SERVER] Initializing...\n"; - - // Dictionary for arguments to all of the components - d_usrp_dict = user_arg; - - if (pmt_is_dict(d_usrp_dict)) { - - if(pmt_t fpga_debug = pmt_dict_ref(d_usrp_dict, - pmt_intern("fpga-debug"), - PMT_NIL)) { - if(pmt_eqv(fpga_debug, PMT_T)) - d_fpga_debug=true; - } - - // Read the TX interpolations - if(pmt_t interp_tx = pmt_dict_ref(d_usrp_dict, - pmt_intern("interp-tx"), - PMT_NIL)) { - if(!pmt_eqv(interp_tx, PMT_NIL)) - d_interp_tx = pmt_to_long(interp_tx); - } - - // Read the RX decimation rate - if(pmt_t decim_rx = pmt_dict_ref(d_usrp_dict, - pmt_intern("decim-rx"), - PMT_NIL)) { - if(!pmt_eqv(decim_rx, PMT_NIL)) - d_decim_rx = pmt_to_long(decim_rx); - } - } - - // control & status port - d_cs = define_port("cs", "usrp-server-cs", true, mb_port::EXTERNAL); - d_cs_usrp = define_port("cs_usrp", "usrp-interface-cs", false, mb_port::INTERNAL); - - // ports - // - // (if/when we do replicated ports, these will be replaced by a - // single replicated port) - for(int port=0; port < N_PORTS; port++) { - - d_tx.push_back(define_port("tx"+str(port), - "usrp-tx", - true, - mb_port::EXTERNAL)); - - d_rx.push_back(define_port("rx"+str(port), - "usrp-rx", - true, - mb_port::EXTERNAL)); - } - - define_component("usrp", "usrp_usb_interface", d_usrp_dict); - connect("self", "cs_usrp", "usrp", "cs"); - - d_defer=false; - d_opened=false; - - // FIXME: needs to be returned from open, if we want to use this - d_nrx_chan = 2; - d_ntx_chan = 2; - - // Initialize capacity on each channel to 0 and to no owner - // Also initialize the USRP standard tx/rx pointers to NULL - for(int chan=0; chan < d_ntx_chan; chan++) - d_chaninfo_tx.push_back(channel_info()); - - for(int chan=0; chan < d_nrx_chan; chan++) - d_chaninfo_rx.push_back(channel_info()); - - d_rx_chan_mask = 0; - - for(int i=0; i < D_MAX_RID; i++) - d_rids.push_back(rid_info()); - - //d_fake_rx=true; -} - -/*! - * \brief resets the assigned capacity and owners of each RX and TX channel from - * allocations. - */ -void -usrp_server::reset_channels() -{ - - for(int chan=0; chan < d_ntx_chan; chan++) { - d_chaninfo_tx[chan].assigned_capacity = 0; - d_chaninfo_tx[chan].owner = PMT_NIL; - } - - for(int chan=0; chan < d_nrx_chan; chan++) { - d_chaninfo_rx[chan].assigned_capacity = 0; - d_chaninfo_rx[chan].owner = PMT_NIL; - } - - d_rx_chan_mask = 0; -} - -usrp_server::~usrp_server() -{ -} - - -void -usrp_server::initial_transition() -{ - // the initial transition -} - -/*! - * \brief Reads all incoming messages to USRP server from the TX, RX, and the CS - * ports. This drives the state of USRP server and dispatches based on the - * message. - */ -void -usrp_server::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); // the "name" of the message - pmt_t port_id = msg->port_id(); // which port it came in on - pmt_t data = msg->data(); - pmt_t invocation_handle; - pmt_t metadata = msg->metadata(); - pmt_t status; - - long port; - - if (pmt_eq(event, s_shutdown)) // ignore (for now) - return; - - invocation_handle = pmt_nth(0, data); - - if (0){ - std::cout << "[USRP_SERVER] event: " << event << std::endl; - std::cout << "[USRP_SERVER] port_id: " << port_id << std::endl; - } - - // It would be nice if this were all table driven, and we could compute our - // state transition as f(current_state, port_id, signal) - - // A message from the USRP CS, which should *only* be responses - // - // It is important that this set come before checking messages of any other - // components. This is since we always want to listen to the low level USRP - // server, even if we aren't initialized we are waiting for responses to - // become initialized. Likewise, after the usrp_server is "closed", we still - // want to pass responses back from the low level. - - //---------------- USRP RESPONSE ---------------// - if (pmt_eq(port_id, d_cs_usrp->port_symbol())) { - - //-------------- USRP OPEN ------------------// - if(pmt_eq(event, s_response_usrp_open)) { - // pass the response back over the regular CS port - pmt_t status = pmt_nth(1, data); - d_cs->send(s_response_open, pmt_list2(invocation_handle, status)); - - //reset_all_registers(); - //initialize_registers(); - - if(pmt_eqv(status,PMT_T)) { - d_opened = true; - d_defer = false; - recall_defer_queue(); - } - - return; - } - //------------- USRP CLOSE -------------------// - else if (pmt_eq(event, s_response_usrp_close)) { - pmt_t status = pmt_nth(1, data); - d_cs->send(s_response_close, pmt_list2(invocation_handle, status)); - - if(pmt_eqv(status,PMT_T)) { - d_opened = false; - d_defer = false; - reset_channels(); - recall_defer_queue(); - } - - return; - } - //--------------- USRP WRITE --------------// - else if (pmt_eq(event, s_response_usrp_write)) { - - pmt_t status = pmt_nth(1, data); - long channel = pmt_to_long(pmt_nth(2, data)); - long port; - - // Do not report back responses if they were generated from a - // command packet - if(channel == CONTROL_CHAN) - return; - - // Find the port through the owner of the channel - if((port = tx_port_index(d_chaninfo_tx[channel].owner)) !=-1 ){ - d_tx[port]->send(s_response_xmit_raw_frame, - pmt_list2(invocation_handle, status)); - return; - } - } - //--------------- USRP READ ---------------// - else if (pmt_eq(event, s_response_usrp_read)) { - - pmt_t status = pmt_nth(1, data); - - if(!pmt_eqv(status, PMT_T)) { - std::cerr << "[USRP_SERVER] Error receiving packet\n"; - return; - } - else { - handle_response_usrp_read(data); - return; - } - } - - goto unhandled; - } - - // Checking for defer on all other messages - if(d_defer) { - if (verbose) - std::cout << "[USRP_SERVER] Received msg while deferring (" - << msg->signal() << ")\n"; - d_defer_queue.push(msg); - return; - } - - //--------- CONTROL / STATUS ------------// - if (pmt_eq(port_id, d_cs->port_symbol())){ - - //----------- OPEN -----------// - if (pmt_eq(event, s_cmd_open)){ - - // Reject if already open - if(d_opened) { - d_cs->send(s_response_open, pmt_list2(invocation_handle, s_err_usrp_already_opened)); - return; - } - - // the parameters are the same to the low level interface, so we just pass 'data' along - d_cs_usrp->send(s_cmd_usrp_open, data); - - d_defer = true; - - return; - } - //---------- CLOSE -----------// - else if (pmt_eq(event, s_cmd_close)){ - - if(!d_opened) { - d_cs->send(s_response_close, pmt_list2(invocation_handle, s_err_usrp_already_closed)); - return; - } - - d_defer = true; - d_cs_usrp->send(s_cmd_usrp_close, pmt_list1(invocation_handle)); - - return; - } - //---------- MAX CAPACITY ----------// - else if (pmt_eq(event, s_cmd_max_capacity)) { - - if(!d_opened) { - d_cs->send(s_response_max_capacity, - pmt_list3(invocation_handle, s_err_usrp_not_opened, pmt_from_long(0))); - return; - } - - d_cs->send(s_response_max_capacity, - pmt_list3(invocation_handle, - PMT_T, - pmt_from_long(max_capacity()))); - return; - } - //---------- NTX CHAN --------------// - else if (pmt_eq(event, s_cmd_ntx_chan)) { - - if(!d_opened) { - d_cs->send(s_response_ntx_chan, - pmt_list3(invocation_handle, s_err_usrp_not_opened, pmt_from_long(0))); - return; - } - - d_cs->send(s_response_ntx_chan, - pmt_list3(invocation_handle, - PMT_T, - pmt_from_long(d_ntx_chan))); - return; - } - //---------- NRX CHAN -----------// - else if (pmt_eq(event, s_cmd_nrx_chan)) { - - if(!d_opened) { - d_cs->send(s_response_nrx_chan, - pmt_list3(invocation_handle, s_err_usrp_not_opened, pmt_from_long(0))); - return; - } - - d_cs->send(s_response_nrx_chan, - pmt_list3(invocation_handle, - PMT_T, - pmt_from_long(d_nrx_chan))); - return; - } - //--------- ALLOCATION? -----------// - else if (pmt_eq(event, s_cmd_current_capacity_allocation)) { - - if(!d_opened) { - d_cs->send(s_response_current_capacity_allocation, - pmt_list3(invocation_handle, - s_err_usrp_not_opened, - pmt_from_long(0))); - return; - } - - d_cs->send(s_response_current_capacity_allocation, - pmt_list3(invocation_handle, - PMT_T, - pmt_from_long(current_capacity_allocation()))); - return; - } - goto unhandled; - } - - //-------------- TX ---------------// - if ((port = tx_port_index(port_id)) != -1) { - - //------------ ALLOCATE (TX) ----------------// - if (pmt_eq(event, s_cmd_allocate_channel)){ - - if(!d_opened) { - d_tx[port]->send(s_response_allocate_channel, - pmt_list3(invocation_handle, - s_err_usrp_not_opened, - pmt_from_long(0))); - return; - } - - handle_cmd_allocate_channel(d_tx[port], d_chaninfo_tx, data); - return; - } - - //----------- DEALLOCATE (TX) ---------------// - if (pmt_eq(event, s_cmd_deallocate_channel)) { - - if(!d_opened) { - d_tx[port]->send(s_response_deallocate_channel, - pmt_list3(invocation_handle, - s_err_usrp_not_opened, - pmt_from_long(0))); - return; - } - - handle_cmd_deallocate_channel(d_tx[port], d_chaninfo_tx, data); - return; - } - - //-------------- XMIT RAW FRAME -----------------/ - if (pmt_eq(event, s_cmd_xmit_raw_frame)){ - - if(!d_opened) { - d_tx[port]->send(s_response_xmit_raw_frame, - pmt_list2(invocation_handle, s_err_usrp_not_opened)); - return; - } - - handle_cmd_xmit_raw_frame(d_tx[port], d_chaninfo_tx, data); - return; - } - - //-------------- CONTROL PACKET -----------------/ - if (pmt_eq(event, s_cmd_to_control_channel)) { - - if(!d_opened) { - d_tx[port]->send(s_response_xmit_raw_frame, - pmt_list2(invocation_handle, s_err_usrp_not_opened)); - return; - } - - handle_cmd_to_control_channel(d_tx[port], d_chaninfo_tx, data); - return; - - } - - goto unhandled; - } - - //-------------- RX ---------------// - if ((port = rx_port_index(port_id)) != -1) { - - //------------ ALLOCATE (RX) ----------------// - if (pmt_eq(event, s_cmd_allocate_channel)) { - - if(!d_opened) { - d_rx[port]->send(s_response_allocate_channel, - pmt_list3(invocation_handle, - s_err_usrp_not_opened, - pmt_from_long(0))); - return; - } - - handle_cmd_allocate_channel(d_rx[port], d_chaninfo_rx, data); - return; - } - - //----------- DEALLOCATE (RX) ---------------// - if (pmt_eq(event, s_cmd_deallocate_channel)) { - - if(!d_opened) { - d_rx[port]->send(s_response_deallocate_channel, - pmt_list3(invocation_handle, - s_err_usrp_not_opened, - pmt_from_long(0))); - return; - } - - handle_cmd_deallocate_channel(d_rx[port], d_chaninfo_rx, data); - return; - } - - //-------------- START RECV ----------------// - if (pmt_eq(event, s_cmd_start_recv_raw_samples)) { - - if(!d_opened) { - d_rx[port]->send(s_response_recv_raw_samples, - pmt_list2(invocation_handle, s_err_usrp_not_opened)); - return; - } - - handle_cmd_start_recv_raw_samples(d_rx[port], d_chaninfo_rx, data); - return; - } - - //-------------- STOP RECV ----------------// - if (pmt_eq(event, s_cmd_stop_recv_raw_samples)) { - - if(!d_opened) - return; - - // FIX ME : no response for stopping? even if error? (permissions) - handle_cmd_stop_recv_raw_samples(d_rx[port], d_chaninfo_rx, data); - - return; - } - - goto unhandled; - } - - unhandled: - std::cout << "[USRP_SERVER] unhandled msg: " << msg << std::endl; -} - -/*! - * \brief Takes a port_symbol() as parameter \p port_id and is used to determine - * if the port is a TX port, or to find an index in the d_tx vector which stores - * the port. - * - * \returns -1 if \p port_id is not in the d_tx vector (i.e., it's not a TX - * port), otherwise returns an index in the d_tx vector which stores the port. - */ -int usrp_server::tx_port_index(pmt_t port_id) { - - for(int i=0; i < (int) d_tx.size(); i++) - if(pmt_eq(d_tx[i]->port_symbol(), port_id)) - return i; - - return -1; -} - -/*! - * \brief Takes a port_symbol() as parameter \p port_id and is used to determine - * if the port is an RX port, or to find an index in the d_rx vector which - * stores the port. - * - * \returns -1 if \p port_id is not in the d_rx vector (i.e., it's not an RX - * port), otherwise returns an index in the d_rx vector which stores the port. - */ -int usrp_server::rx_port_index(pmt_t port_id) { - - for(int i=0; i < (int) d_rx.size(); i++) - if(pmt_eq(d_rx[i]->port_symbol(), port_id)) - return i; - - return -1; -} - -/*! - * \brief Determines the current total capacity allocated by all RX and TX - * channels. - * - * \returns the total allocated capacity - */ -long usrp_server::current_capacity_allocation() { - long capacity = 0; - - for(int chan=0; chan < d_ntx_chan; chan++) - capacity += d_chaninfo_tx[chan].assigned_capacity; - - for(int chan=0; chan < d_nrx_chan; chan++) - capacity += d_chaninfo_rx[chan].assigned_capacity; - - return capacity; -} - - -/*! - * \brief Called by the handle_message() method if the incoming message to - * usrp_server is to allocate a channel (cmd-allocate-channel). The method - * checks if the requested capacity exists and if so it will reserve it for the - * caller on the channel that is returned via a response-allocate-channel - * signal. - */ -void -usrp_server::handle_cmd_allocate_channel( - mb_port_sptr port, - std::vector<struct channel_info> &chan_info, - pmt_t data) -{ - pmt_t invocation_handle = pmt_nth(0, data); - long rqstd_capacity = pmt_to_long(pmt_nth(1, data)); - long chan; - - // Check capacity exists - if((D_USB_CAPACITY - current_capacity_allocation()) < rqstd_capacity) { - - // no capacity available - port->send(s_response_allocate_channel, - pmt_list3(invocation_handle, - s_err_requested_capacity_unavailable, - PMT_NIL)); - return; - } - - // Find a free channel, assign the capacity and respond - for(chan=0; chan < (long)chan_info.size(); chan++) { - - if(verbose) - std::cout << "[USRP_SERVER] Checking chan: " << chan - << " owner " << chan_info[chan].owner - << " size " << chan_info.size() - << std::endl; - - if(chan_info[chan].owner == PMT_NIL) { - - chan_info[chan].owner = port->port_symbol(); - chan_info[chan].assigned_capacity = rqstd_capacity; - - port->send(s_response_allocate_channel, - pmt_list3(invocation_handle, - PMT_T, - pmt_from_long(chan))); - - if(verbose) - std::cout << "[USRP_SERVER] Assigning channel: " << chan - << " to " << chan_info[chan].owner - << std::endl; - return; - } - - } - - if (verbose) - std::cout << "[USRP_SERVER] Couldnt find a TX chan\n"; - - // no free TX chan found - port->send(s_response_allocate_channel, - pmt_list3(invocation_handle, - s_err_channel_unavailable, - PMT_NIL)); - return; -} - -/*! - * \brief Called by the handle_message() method if the incoming message to - * usrp_server is to deallocate a channel (cmd-deallocate-channel). The method - * ensures that the sender of the signal owns the channel and that the channel - * number is valid. A response-deallocate-channel signal is sent back with the - * result of the deallocation. - */ -void -usrp_server::handle_cmd_deallocate_channel( - mb_port_sptr port, - std::vector<struct channel_info> &chan_info, - pmt_t data) -{ - - pmt_t invocation_handle = pmt_nth(0, data); - long channel = pmt_to_long(pmt_nth(1, data)); - - // Ensure the channel is valid and the caller owns the port - if(!check_valid(port, channel, chan_info, - pmt_list2(s_response_deallocate_channel, invocation_handle))) - return; - - chan_info[channel].assigned_capacity = 0; - chan_info[channel].owner = PMT_NIL; - - port->send(s_response_deallocate_channel, - pmt_list2(invocation_handle, - PMT_T)); - return; -} - -/*! - * \brief Called by the handle_message() method if the incoming message to - * usrp_server is to transmit a frame (cmd-xmit-raw-frame). The method - * allocates enough memory to support a burst of packets which contain the frame - * over the bus of the frame, sets the packet headers, and sends a signal to the - * lower block for the data (packets) to be written to the bus. - * - * The \p port the command was sent on and the channel info (\p chan_info) of - * the channel the frame is to be transmitted on are passed to ensure that the - * caller owns the channel. - * - * The \p data parameter is in the format of a cmd-xmit-raw-frame signal. - * - * The properties - */ -void usrp_server::handle_cmd_xmit_raw_frame( - mb_port_sptr port, - std::vector<struct channel_info> &chan_info, - pmt_t data) -{ - size_t n_bytes, psize; - long max_payload_len = transport_pkt::max_payload(); - - pmt_t invocation_handle = pmt_nth(0, data); - long channel = pmt_to_long(pmt_nth(1, data)); - const void *samples = pmt_uniform_vector_elements(pmt_nth(2, data), n_bytes); - long timestamp = pmt_to_long(pmt_nth(3, data)); - pmt_t properties = pmt_nth(4, data); - - // Ensure the channel is valid and the caller owns the port - if(!check_valid(port, channel, chan_info, - pmt_list2(s_response_xmit_raw_frame, invocation_handle))) - return; - - // Read information from the properties of the packet - bool carrier_sense = false; - if(pmt_is_dict(properties)) { - - // Check if carrier sense is enabled for the frame - if(pmt_t p_carrier_sense = pmt_dict_ref(properties, - pmt_intern("carrier-sense"), - PMT_NIL)) { - if(pmt_eqv(p_carrier_sense, PMT_T)) - carrier_sense = true; - } - } - - - // Determine the number of packets to allocate contiguous memory for - // bursting over the USB and get a pointer to the memory to be used in - // building the packets - long n_packets = - static_cast<long>(std::ceil(n_bytes / (double)max_payload_len)); - - pmt_t v_packets = pmt_make_u8vector(sizeof(transport_pkt) * n_packets, 0); - - transport_pkt *pkts = - (transport_pkt *) pmt_u8vector_writable_elements(v_packets, psize); - - for(int n=0; n < n_packets; n++) { - - long payload_len = - std::min((long)(n_bytes-(n*max_payload_len)), (long)max_payload_len); - - if(n == 0) { // first packet gets start of burst flag and timestamp - - if(carrier_sense) - pkts[n].set_header(pkts[n].FL_START_OF_BURST - | pkts[n].FL_CARRIER_SENSE, - channel, 0, payload_len); - else - pkts[n].set_header(pkts[n].FL_START_OF_BURST, channel, 0, payload_len); - - pkts[n].set_timestamp(timestamp); - - } else { - pkts[n].set_header(0, channel, 0, payload_len); - pkts[n].set_timestamp(0xffffffff); - } - - memcpy(pkts[n].payload(), - (uint8_t *)samples+(max_payload_len * n), - payload_len); - - } - - - pkts[n_packets-1].set_end_of_burst(); // set the last packet's end of burst - - if (verbose && 0) - std::cout << "[USRP_SERVER] Received raw frame invocation: " - << invocation_handle << std::endl; - - // The actual response to the write will be generated by a - // s_response_usrp_write since we cannot determine whether to transmit was - // successful until we hear from the lower layers. - d_cs_usrp->send(s_cmd_usrp_write, - pmt_list3(invocation_handle, - pmt_from_long(channel), - v_packets)); - - return; -} - -/*! - * \brief Called by the handle_message() method to parse incoming control/status - * signals (cmd-to-control-channel). - * - * The \p port the command was sent on and the channel info (\p chan_info) of - * the channel are passed to ensure that the caller owns the channel. - * - * The \p data parameter is in the format of a PMT list, where each element - * follows the format of a control/status signal (i.e. op-ping-fixed). - * - * The method will parse all of the C/S commands included in \p data and place - * the commands in to a lower level packet sent to the control channel. The - * method will pack as many commands as possible in t oa single packet, and once - * it is fill generate as many lower level packets as needed. - * - * Anything that needs to be returned to the sender of the signal (i.e. the - * value of a register) will be generated by the parse_control_pkt() method as - * the responses to the commands are read back from the USRP. - */ -void usrp_server::handle_cmd_to_control_channel( - mb_port_sptr port, - std::vector<struct channel_info> &chan_info, - pmt_t data) -{ - - pmt_t invocation_handle = pmt_nth(0, data); - pmt_t subpackets = pmt_nth(1, data); - - long n_subpkts = pmt_length(subpackets); - long curr_subpkt = 0; - - size_t psize; - long payload_len = 0; - long channel = CONTROL_CHAN; - - if(verbose) - std::cout << "[USRP_SERVER] Handling " << n_subpkts << " commands\n"; - - // The design of the following code is optimized for simplicity, not - // performance. To performance optimize this code, the total size in bytes - // needed for all of the CS packets is needed to allocate contiguous memory - // which contains the USB packets for bursting over the bus. However to do - // this the packets subpackets would need to be parsed twice and their sizes - // would need to be determined. - // - // The approach taken is to keep parsing the subpackets and putting them in to - // USB packets. Once the USB packet is full, a write is sent for it and - // another packet is created. - // - // The subpacket creation methods will return false if the subpacket will not - // fit in to the current USB packet. In these cases a new USB packet is - // created and the old is sent. - - new_packet: - // This code needs to become "smart" and only make a new packet when full - pmt_t v_packet = pmt_make_u8vector(sizeof(transport_pkt), 0); - transport_pkt *pkt = (transport_pkt *) pmt_u8vector_writable_elements(v_packet, psize); - payload_len = 0; - - pkt->set_header(0, channel, 0, payload_len); - pkt->set_timestamp(0xffffffff); - - while(curr_subpkt < n_subpkts) { - - pmt_t subp = pmt_nth(curr_subpkt, subpackets); - pmt_t subp_cmd = pmt_nth(0, subp); - pmt_t subp_data = pmt_nth(1, subp); - - //--------- PING FIXED --------------// - if(pmt_eq(subp_cmd, s_op_ping_fixed)) { - - long urid = pmt_to_long(pmt_nth(0, subp_data)); - long pingval = pmt_to_long(pmt_nth(1, subp_data)); - - // USRP server sets request ID's to keep track of which application gets - // what response back. To allow a full 6-bits for an RID to the user, we - // keep a mapping and replace the RID's as the packets go in and out. If - // there are no RID's available, the command is thrown away silently. - long srid; - if((srid = next_rid()) == -1) - goto subpkt_bail; - - // We use a vector to store the owner of the ping request and will use it - // to send the request on any RX port they own. - d_rids[srid].owner = port->port_symbol(); - d_rids[srid].user_rid = urid; - - // Adds a ping after the previous command in the pkt - if(!pkt->cs_ping(srid, pingval)) - { - d_cs_usrp->send(s_cmd_usrp_write, - pmt_list3(invocation_handle, - pmt_from_long(channel), - v_packet)); - - // Return the RID - d_rids[srid].owner = PMT_NIL; - - goto new_packet; - } - - if(verbose) - std::cout << "[USRP_SERVER] Received ping command request" - << " assigning RID " << srid << std::endl; - - } - - //----------- WRITE REG ---------------// - if(pmt_eq(subp_cmd, s_op_write_reg)) { - - long reg_num = pmt_to_long(pmt_nth(0, subp_data)); - long val = pmt_to_long(pmt_nth(1, subp_data)); - - if(!pkt->cs_write_reg(reg_num, val)) - { - d_cs_usrp->send(s_cmd_usrp_write, - pmt_list3(invocation_handle, - pmt_from_long(channel), - v_packet)); - - goto new_packet; - } - - if(verbose) - std::cout << "[USRP_SERVER] Received write register request " - << "(" - << "Reg: " << reg_num << ", " - << "Val: " << val - << ")\n"; - } - - //------- WRITE REG MASKED ----------// - if(pmt_eq(subp_cmd, s_op_write_reg_masked)) { - - long reg_num = pmt_to_long(pmt_nth(0, subp_data)); - long val = pmt_to_long(pmt_nth(1, subp_data)); - long mask = pmt_to_long(pmt_nth(2, subp_data)); - - if(!pkt->cs_write_reg_masked(reg_num, val, mask)) - { - d_cs_usrp->send(s_cmd_usrp_write, - pmt_list3(invocation_handle, - pmt_from_long(channel), - v_packet)); - - goto new_packet; - } - - if(verbose) - std::cout << "[USRP_SERVER] Received write register masked request\n"; - } - - //------------ READ REG --------------// - if(pmt_eq(subp_cmd, s_op_read_reg)) { - - long urid = pmt_to_long(pmt_nth(0, subp_data)); - long reg_num = pmt_to_long(pmt_nth(1, subp_data)); - - long srid; - if((srid = next_rid()) == -1) - goto subpkt_bail; - - d_rids[srid].owner = port->port_symbol(); - d_rids[srid].user_rid = urid; - - if(!pkt->cs_read_reg(srid, reg_num)) - { - d_cs_usrp->send(s_cmd_usrp_write, - pmt_list3(invocation_handle, - pmt_from_long(channel), - v_packet)); - - // Return the rid - d_rids[srid].owner = PMT_NIL; - - goto new_packet; - } - - if(verbose) - std::cout << "[USRP_SERVER] Received read register request" - << " assigning RID " << srid << std::endl; - } - - //------------ DELAY --------------// - if(pmt_eq(subp_cmd, s_op_delay)) { - - long ticks = pmt_to_long(pmt_nth(0, subp_data)); - - if(!pkt->cs_delay(ticks)) - { - d_cs_usrp->send(s_cmd_usrp_write, - pmt_list3(invocation_handle, - pmt_from_long(channel), - v_packet)); - - goto new_packet; - } - - if(verbose) - std::cout << "[USRP_SERVER] Received delay request of " - << ticks << " ticks\n"; - } - - //--------- I2C WRITE -----------// - // FIXME: could check that byte count does not exceed 2^8 which - // is the max length in the subpacket for # of bytes to read. - if(pmt_eq(subp_cmd, s_op_i2c_write)) { - - long i2c_addr = pmt_to_long(pmt_nth(0, subp_data)); - pmt_t data = pmt_nth(1, subp_data); - - // Get a readable address to the data which also gives us the length - size_t data_len; - uint8_t *i2c_data = (uint8_t *) pmt_u8vector_writable_elements(data, data_len); - - // Make the USB packet - if(!pkt->cs_i2c_write(i2c_addr, i2c_data, data_len)) - { - d_cs_usrp->send(s_cmd_usrp_write, - pmt_list3(invocation_handle, - pmt_from_long(channel), - v_packet)); - - goto new_packet; - } - - if(verbose) - std::cout << "[USRP_SERVER] Received I2C write\n"; - } - - //----------- I2C Read -------------// - if(pmt_eq(subp_cmd, s_op_i2c_read)) { - - long urid = pmt_to_long(pmt_nth(0, subp_data)); - long i2c_addr = pmt_to_long(pmt_nth(1, subp_data)); - long i2c_bytes = pmt_to_long(pmt_nth(2, subp_data)); - - long srid; - if((srid = next_rid()) == -1) - goto subpkt_bail; - - d_rids[srid].owner = port->port_symbol(); - d_rids[srid].user_rid = urid; - - if(!pkt->cs_i2c_read(srid, i2c_addr, i2c_bytes)) - { - - d_cs_usrp->send(s_cmd_usrp_write, - pmt_list3(invocation_handle, - pmt_from_long(channel), - v_packet)); - - d_rids[srid].owner = PMT_NIL; - - goto new_packet; - } - - if(verbose) - std::cout << "[USRP_SERVER] Received I2C read\n"; - } - - //--------- SPI WRITE -----------// - if(pmt_eq(subp_cmd, s_op_spi_write)) { - - long enables = pmt_to_long(pmt_nth(0, subp_data)); - long format = pmt_to_long(pmt_nth(1, subp_data)); - long opt = pmt_to_long(pmt_nth(2, subp_data)); - pmt_t data = pmt_nth(3, subp_data); - - // Get a readable address to the data which also gives us the length - size_t data_len; - uint8_t *spi_data = (uint8_t *) pmt_u8vector_writable_elements(data, data_len); - - // Make the USB packet - if(!pkt->cs_spi_write(enables, format, opt, spi_data, data_len)) - { - d_cs_usrp->send(s_cmd_usrp_write, - pmt_list3(invocation_handle, - pmt_from_long(channel), - v_packet)); - - goto new_packet; - } - - if(verbose) - std::cout << "[USRP_SERVER] Received SPI write\n"; - } - - //--------- SPI READ -----------// - if(pmt_eq(subp_cmd, s_op_spi_read)) { - - long urid = pmt_to_long(pmt_nth(0, subp_data)); - long enables = pmt_to_long(pmt_nth(1, subp_data)); - long format = pmt_to_long(pmt_nth(2, subp_data)); - long opt = pmt_to_long(pmt_nth(3, subp_data)); - long n_bytes = pmt_to_long(pmt_nth(4, subp_data)); - - long srid; - if((srid = next_rid()) == -1) - goto subpkt_bail; - - d_rids[srid].owner = port->port_symbol(); - d_rids[srid].user_rid = urid; - - // Make the USB packet - if(!pkt->cs_spi_read(srid, enables, format, opt, n_bytes)) - { - d_cs_usrp->send(s_cmd_usrp_write, - pmt_list3(invocation_handle, - pmt_from_long(channel), - v_packet)); - - // Return the rid - d_rids[srid].owner = PMT_NIL; - - goto new_packet; - } - - if(verbose) - std::cout << "[USRP_SERVER] Received SPI read\n"; - } - - subpkt_bail: - curr_subpkt++; - - } - - - // If the current packets length is > 0, we know there are subpackets that - // need to be sent out still. - if(pkt->payload_len() > 0) - d_cs_usrp->send(s_cmd_usrp_write, - pmt_list3(invocation_handle, - pmt_from_long(channel), - v_packet)); - - return; -} - -/*! - * \brief Called by the handle_message() method when the incoming signal is a - * command to start reading samples from the USRP (cmd-start-recv-raw-samples). - * - * The \p port the command was sent on and the channel info (\p chan_info) of - * the channel are passed to ensure that the caller owns the channel. - * - * The \p data parameter should be in the format of a cmd-start-recv-raw-samples - * command where the first element in the list is an invocation handle, and the - * second is the channel the signal generator wants to receive the samples on. - */ -void -usrp_server::handle_cmd_start_recv_raw_samples( - mb_port_sptr port, - std::vector<struct channel_info> &chan_info, - pmt_t data) -{ - pmt_t invocation_handle = pmt_nth(0, data); - long channel = pmt_to_long(pmt_nth(1, data)); - - // Ensure the channel is valid and the caller owns the port - if(!check_valid(port, channel, chan_info, - pmt_list2(s_response_xmit_raw_frame, invocation_handle))) - return; - - // Already started receiving samples? (another start before a stop) - // Check the RX channel bitmask. - if(d_rx_chan_mask & (1 << channel)) { - port->send(s_response_recv_raw_samples, - pmt_list5(invocation_handle, - s_err_already_receiving, - PMT_NIL, - PMT_NIL, - PMT_NIL)); - return; - } - - // We only need to generate a 'start reading' command down to the - // low level interface if no other channel is already reading - // - // We carry this over the CS interface because the lower level - // interface does not care about the channel, we only demux it - // at the usrp_server on responses. - if(d_rx_chan_mask == 0) { - - if(verbose) - std::cout << "[USRP_SERVER] Sending read request down to start recv\n"; - - d_cs_usrp->send(s_cmd_usrp_start_reading, pmt_list1(invocation_handle)); - } - - d_rx_chan_mask |= 1<<channel; - - return; -} - -/*! - * \brief Called by the handle_message() method when the incoming signal is to - * stop receiving samples from the USRP (cmd-stop-recv-raw-samples). - * - * The \p port the command was sent on and the channel info (\p chan_info) of - * the channel are passed to ensure that the caller owns the channel. - * - * The \p data parameter should be in the format of a cmd-stop-recv-raw-samples - * command where the first element in the list is an invocation handle, and the - * second is the channel the signal generator wants to stop receiving the - * samples from. - */ -void -usrp_server::handle_cmd_stop_recv_raw_samples( - mb_port_sptr port, - std::vector<struct channel_info> &chan_info, - pmt_t data) -{ - pmt_t invocation_handle = pmt_nth(0, data); - long channel = pmt_to_long(pmt_nth(1, data)); - - // FIX ME : we have no responses to send an error... - // Ensure the channel is valid and the caller owns the port - //if(!check_valid(port, channel, chan_info, - // pmt_list2(s_response_xmit_raw_frame, invocation_handle))) - // return; - - // Remove this hosts bit from the receiver mask - d_rx_chan_mask &= ~(1<<channel); - - // We only need to generate a 'start reading' command down to the - // low level interface if no other channel is already reading - // - // We carry this over the CS interface because the lower level - // interface does not care about the channel, we only demux it - // at the usrp_server on responses. - if(d_rx_chan_mask == 0) { - - if(verbose) - std::cout << "[USRP_SERVER] Sending stop reading request down\n"; - - d_cs_usrp->send(s_cmd_usrp_stop_reading, pmt_list1(invocation_handle)); - } - - return; -} - -/*! - * \brief Called by the handle_message() method when an incoming signal is - * generated to USRP server that contains raw samples from the USRP. This - * method generates the response-recv-raw-samples signals that are the result of - * a cmd-start-recv-raw-samples signal. - * - * The raw lower-level packet is extracted from \p data, where the format for \p - * data is a PMT list. The PMT \p data list should contain an invocation handle - * as the first element, the status of the lower-level read as the second - * element, and a uniform vector representation of the packets as the third - * element. - * - * The packet contains a channel field that the samples are destined to, and the - * method determines where to send the samples based on this channel since each - * channel has an associated port which allocated it. - */ -void -usrp_server::handle_response_usrp_read(pmt_t data) -{ - - pmt_t invocation_handle = pmt_nth(0, data); - pmt_t status = pmt_nth(1, data); - pmt_t v_pkt = pmt_nth(2, data); - - size_t n_bytes; - size_t ignore; - - if (d_fake_rx) { - - pmt_t pkt = pmt_nth(2, data); - - d_rx[0]->send(s_response_recv_raw_samples, - pmt_list5(PMT_F, - PMT_T, - pkt, - pmt_from_long(0xffff), - PMT_NIL)); - - return; - } - - // Extract the packet and return appropriately - transport_pkt *pkt = (transport_pkt *) pmt_u8vector_writable_elements(v_pkt, n_bytes); - - // The channel is used to find the port to pass the samples on - long channel = pkt->chan(); - long payload_len = pkt->payload_len(); - long port; - - // Ignore packets which seem to have incorrect size or size 0 - if(payload_len > pkt->max_payload() || payload_len == 0) - return; - - // If the packet is a C/S packet, parse it separately - if(channel == CONTROL_CHAN) { - parse_control_pkt(invocation_handle, pkt); - return; - } - - if((port = rx_port_index(d_chaninfo_rx[channel].owner)) == -1) - return; // Don't know where to send the sample... possibility on abrupt close - - pmt_t v_samples = pmt_make_u8vector(payload_len, 0); - uint8_t *samples = pmt_u8vector_writable_elements(v_samples, ignore); - - memcpy(samples, pkt->payload(), payload_len); - - // Build a properties dictionary to store things such as the RSSI - pmt_t properties = pmt_make_dict(); - - pmt_dict_set(properties, - pmt_intern("rssi"), - pmt_from_long(pkt->rssi())); - - if(pkt->overrun()) - pmt_dict_set(properties, - pmt_intern("overrun"), - PMT_T); - - if(pkt->underrun()) - pmt_dict_set(properties, - pmt_intern("underrun"), - PMT_T); - - d_rx[port]->send(s_response_recv_raw_samples, - pmt_list6(invocation_handle, - status, - v_samples, - pmt_from_long(pkt->timestamp()), - pmt_from_long(channel), - properties)); - return; -} - -/*! - * \brief Called by handle_response_usrp_read() when the incoming packet has a - * channel of CONTROL_CHAN. This means that the incoming packet contains a - * response for a command sent to the control channel, which this method will - * parse. - * - * The \p pkt parameter is a pointer to the full packet (transport_pkt) in - * memory. - * - * Given that all commands sent to the control channel that require responses - * will carry an RID (request ID), the method will use the RID passed back with - * the response to determine which port the response should be sent on. - */ -void -usrp_server::parse_control_pkt(pmt_t invocation_handle, transport_pkt *pkt) -{ - - long payload_len = pkt->payload_len(); - long curr_payload = 0; - long port; - - // We dispatch based on the control packet type, however we can extract the - // opcode and the length immediately which is consistent in all responses. - // - // Since each control packet can have multiple responses, we keep reading the - // lengths of each subpacket until we reach the payload length. - while(curr_payload < payload_len) { - - pmt_t sub_packet = pkt->read_subpacket(curr_payload); - pmt_t op_symbol = pmt_nth(0, sub_packet); - - int len = pkt->cs_len(curr_payload); - - if(verbose) - std::cout << "[USRP_SERVER] Parsing subpacket " - << op_symbol << " ... length " << len << std::endl; - - //----------------- PING RESPONSE ------------------// - if(pmt_eq(op_symbol, s_op_ping_fixed_reply)) { - - long srid = pmt_to_long(pmt_nth(1, sub_packet)); - pmt_t pingval = pmt_nth(2, sub_packet); - - long urid = d_rids[srid].user_rid; - - if(verbose) - std::cout << "[USRP_SERVER] Found ping response " - << "(" - << "URID: " << urid << ", " - << "SRID: " << srid << ", " - << "VAL: " << pingval - << ")\n"; - - // Do some bounds checking incase of bogus/corrupt responses - if(srid > D_MAX_RID) - return; - - pmt_t owner = d_rids[srid].owner; - - // Return the RID - d_rids[srid].owner = PMT_NIL; - - // FIXME: should be 1 response for all subpackets here ? - if((port = tx_port_index(owner)) != -1) - d_tx[port]->send(s_response_from_control_channel, - pmt_list4(invocation_handle, - PMT_T, - pmt_list2(s_op_ping_fixed_reply, // subp - pmt_list2(pmt_from_long(urid), - pingval)), - pmt_from_long(pkt->timestamp()))); - } - - //----------------- READ REG RESPONSE ------------------// - else if(pmt_eq(op_symbol, s_op_read_reg_reply)) { - - long srid = pmt_to_long(pmt_nth(1, sub_packet)); - pmt_t reg_num = pmt_nth(2, sub_packet); - pmt_t reg_val = pmt_nth(3, sub_packet); - - long urid = d_rids[srid].user_rid; - - if(verbose) - std::cout << "[USRP_SERVER] Found read register response " - << "(" - << "URID: " << urid << ", " - << "SRID: " << srid << ", " - << "REG: " << reg_num << ", " - << "VAL: " << reg_val - << ")\n"; - - // Do some bounds checking to avoid seg faults - if(srid > D_MAX_RID) - return; - - pmt_t owner = d_rids[srid].owner; - - // Return the RID - d_rids[srid].owner = PMT_NIL; - - // FIXME: should be 1 response for all subpackets here ? - if((port = tx_port_index(owner)) != -1) - d_tx[port]->send(s_response_from_control_channel, - pmt_list4(invocation_handle, - PMT_T, - pmt_list2(s_op_read_reg_reply, // subp - pmt_list3(pmt_from_long(urid), - reg_num, - reg_val)), - pmt_from_long(pkt->timestamp()))); - } - - //------------------ I2C READ REPLY -------------------// - else if(pmt_eq(op_symbol, s_op_i2c_read_reply)) { - - long srid = pmt_to_long(pmt_nth(1, sub_packet)); - pmt_t i2c_addr = pmt_nth(2, sub_packet); - pmt_t i2c_data = pmt_nth(3, sub_packet); - - long urid = d_rids[srid].user_rid; - - if(verbose) - std::cout << "[USRP_SERVER] Found i2c read reply " - << "(" - << "URID: " << urid << ", " - << "SRID: " << srid << ", " - << "Addr: " << i2c_addr << ", " - << "Data: " << i2c_data - << ")\n"; - - // Do some bounds checking to avoid seg faults - if(srid > D_MAX_RID) - return; - - pmt_t owner = d_rids[srid].owner; - - // Return the RID - d_rids[srid].owner = PMT_NIL; - - if((port = tx_port_index(owner)) != -1) - d_tx[port]->send(s_response_from_control_channel, - pmt_list4(invocation_handle, - PMT_T, - pmt_list2(s_op_i2c_read_reply, - pmt_list3(pmt_from_long(urid), - i2c_addr, - i2c_data)), - pmt_from_long(pkt->timestamp()))); - } - - //------------------ SPI READ REPLY -------------------// - else if(pmt_eq(op_symbol, s_op_spi_read_reply)) { - - long srid = pmt_to_long(pmt_nth(1, sub_packet)); - pmt_t spi_data = pmt_nth(2, sub_packet); - - long urid = d_rids[srid].user_rid; - - if(verbose) - std::cout << "[USRP_SERVER] Found SPI read reply " - << "(" - << "URID: " << urid << ", " - << "SRID: " << srid << ", " - << "Data: " << spi_data - << ")\n"; - - // Bounds check the RID - if(srid > D_MAX_RID) - return; - - pmt_t owner = d_rids[srid].owner; - - // Return the RID - d_rids[srid].owner = PMT_NIL; - - if((port = tx_port_index(owner)) != -1) - d_tx[port]->send(s_response_from_control_channel, - pmt_list4(invocation_handle, - PMT_T, - pmt_list2(s_op_spi_read_reply, - pmt_list2(pmt_from_long(urid), - spi_data)), - pmt_from_long(pkt->timestamp()))); - } - - // Each subpacket has an unaccounted for 2 bytes which is the opcode - // and the length field - curr_payload += len + 2; - - // All subpackets are 32-bit aligned - int align_offset = 4 - (curr_payload % 4); - - if(align_offset != 4) - curr_payload += align_offset; - } -} - -/*! - * \brief Used to recall all incoming signals that were deferred when USRP - * server was in the initialization state. - */ -void -usrp_server::recall_defer_queue() -{ - - std::vector<mb_message_sptr> recall; - - while(!d_defer_queue.empty()) { - recall.push_back(d_defer_queue.front()); - d_defer_queue.pop(); - } - - // Parse the messages that were queued while waiting for an open response - for(int i=0; i < (int)recall.size(); i++) - handle_message(recall[i]); - - return; -} - -/*! - * \brief Commonly called by any method which handles outgoing frames or control - * packets to the USRP to check if the port on which the signal was sent owns - * the channel the outgoing packet will be associated with. This helps ensure - * that applications do not send data on other application's ports. - * - * The \p port parameter is the port symbol that the caller wishes to determine - * owns the channel specified by \p chan_info. - * - * The \p signal_info parameter is a PMT list containing two elements: the - * response signal to use if the permissions are invalid, and the invocation - * handle that was passed. This allows the method to generate detailed failure - * responses to signals without having to return some sort of structured - * information which the caller must then parse and interpret to determine the - * failure type. - * - * \returns true if \p port owns the channel specified by \p chan_info, false - * otherwise. - */ -bool -usrp_server::check_valid(mb_port_sptr port, - long channel, - std::vector<struct channel_info> &chan_info, - pmt_t signal_info) -{ - - pmt_t response_signal = pmt_nth(0, signal_info); - pmt_t invocation_handle = pmt_nth(1, signal_info); - - // not a valid channel number? - if(channel >= (long)chan_info.size() && channel != CONTROL_CHAN) { - port->send(response_signal, - pmt_list2(invocation_handle, - s_err_channel_invalid)); - - if(verbose) - std::cout << "[USRP_SERVER] Invalid channel number for event " - << response_signal << std::endl; - return false; - } - - // not the owner of the port? - if(chan_info[channel].owner != port->port_symbol()) { - port->send(response_signal, - pmt_list2(invocation_handle, - s_err_channel_permission_denied)); - - if(verbose) - std::cout << "[USRP_SERVER] Invalid permissions" - << " for " << response_signal - << " from " << port->port_symbol() - << " proper owner is " << chan_info[channel].owner - << " on channel " << channel - << " invocation " << invocation_handle - << std::endl; - return false; - } - - return true; -} - -/*! - * \brief Finds the next available RID for internal USRP server use with control - * and status packets. - * - * \returns the next valid RID or -1 if no more RIDs are available. - */ -long -usrp_server::next_rid() -{ - for(int i = 0; i < D_MAX_RID; i++) - if(pmt_eqv(d_rids[i].owner, PMT_NIL)) - return i; - - if(verbose) - std::cout << "[USRP_SERVER] No RIDs left\n"; - return -1; -} - -/*! - * \brief Called by handle_message() when USRP server gets a response that the - * USRP was opened successfully to initialize the registers using the new - * register read/write control packets. - */ -void -usrp_server::initialize_registers() -{ - // We use handle_cmd_to_control_channel() to create the register writes using - // PMT_NIL as the response port to tell usrp_server not to pass the response - // up to any application. - if(verbose) - std::cout << "[USRP_SERVER] Initializing registers...\n"; - - // RX mode to normal (0) - set_register(FR_MODE, 0); - - // FPGA debugging? - if(d_fpga_debug) { - set_register(FR_DEBUG_EN, 1); - // FIXME: need to figure out exact register writes to control daughterboard - // pins that need to be written to - } else { - set_register(FR_DEBUG_EN, 0); - } - - // Set the transmit sample rate divisor, which is 4-1 - set_register(FR_TX_SAMPLE_RATE_DIV, 3); - - // Dboard IO buffer and register settings - set_register(FR_OE_0, (0xffff << 16) | 0x0000); - set_register(FR_IO_0, (0xffff << 16) | 0x0000); - set_register(FR_OE_1, (0xffff << 16) | 0x0000); - set_register(FR_IO_1, (0xffff << 16) | 0x0000); - set_register(FR_OE_2, (0xffff << 16) | 0x0000); - set_register(FR_IO_2, (0xffff << 16) | 0x0000); - set_register(FR_OE_3, (0xffff << 16) | 0x0000); - set_register(FR_IO_3, (0xffff << 16) | 0x0000); - - // zero Tx side Auto Transmit/Receive regs - set_register(FR_ATR_MASK_0, 0); - set_register(FR_ATR_TXVAL_0, 0); - set_register(FR_ATR_RXVAL_0, 0); - set_register(FR_ATR_MASK_1, 0); - set_register(FR_ATR_TXVAL_1, 0); - set_register(FR_ATR_RXVAL_1, 0); - set_register(FR_ATR_MASK_2, 0); - set_register(FR_ATR_TXVAL_2, 0); - set_register(FR_ATR_RXVAL_2, 0); - set_register(FR_ATR_MASK_3, 0); - set_register(FR_ATR_TXVAL_3, 0); - set_register(FR_ATR_RXVAL_3, 0); - - // Configure TX mux, this is a hacked value - set_register(FR_TX_MUX, 0x00000081); - - // Set the interpolation rate, which is the rate divided by 4, minus 1 - set_register(FR_INTERP_RATE, (d_interp_tx/4)-1); - - // Apparently this register changes again - set_register(FR_TX_MUX, 0x00000981); - - // Set the receive sample rate divisor, which is 2-1 - set_register(FR_RX_SAMPLE_RATE_DIV, 1); - - // DC offset - set_register(FR_DC_OFFSET_CL_EN, 0x0000000f); - - // Reset the DC correction offsets - set_register(FR_ADC_OFFSET_0, 0); - set_register(FR_ADC_OFFSET_1, 0); - - // Some hard-coded RX configuration - set_register(FR_RX_FORMAT, 0x00000300); - set_register(FR_RX_MUX, 1); - - // RX decimation rate is divided by two, then subtract 1 - set_register(FR_DECIM_RATE, (d_decim_rx/2)-1); - - // More hard coding - set_register(FR_RX_MUX, 0x000e4e41); - - // Resetting RX registers - set_register(FR_RX_PHASE_0, 0); - set_register(FR_RX_PHASE_1, 0); - set_register(FR_RX_PHASE_2, 0); - set_register(FR_RX_PHASE_3, 0); - set_register(FR_RX_FREQ_0, 0x28000000); - set_register(FR_RX_FREQ_1, 0); - set_register(FR_RX_FREQ_2, 0); - set_register(FR_RX_FREQ_3, 0); - - // Enable debug bus - set_register(FR_DEBUG_EN, 0xf); - set_register(FR_OE_0, -1); - set_register(FR_OE_1, -1); - set_register(FR_OE_2, -1); - set_register(FR_OE_3, -1); - - // DEBUGGING - //check_register_initialization(); -} - -// FIXME: used for debugging to determine if all the registers are actually -// being set correctly -void -usrp_server::check_register_initialization() -{ - // RX mode to normal (0) - read_register(FR_MODE); - - // FPGA debugging? - if(d_fpga_debug) { - read_register(FR_DEBUG_EN); - // FIXME: need to figure out exact register writes to control daughterboard - // pins that need to be written to - } else { - read_register(FR_DEBUG_EN); - } - - // Set the transmit sample rate divisor, which is 4-1 - read_register(FR_TX_SAMPLE_RATE_DIV); - - // Dboard IO buffer and register settings - read_register(FR_OE_0); - read_register(FR_IO_0); - read_register(FR_OE_1); - read_register(FR_IO_1); - read_register(FR_OE_2); - read_register(FR_IO_2); - read_register(FR_OE_3); - read_register(FR_IO_3); - - // zero Tx side Auto Transmit/Receive regs - read_register(FR_ATR_MASK_0); - read_register(FR_ATR_TXVAL_0); - read_register(FR_ATR_RXVAL_0); - read_register(FR_ATR_MASK_1); - read_register(FR_ATR_TXVAL_1); - read_register(FR_ATR_RXVAL_1); - read_register(FR_ATR_MASK_2); - read_register(FR_ATR_TXVAL_2); - read_register(FR_ATR_RXVAL_2); - read_register(FR_ATR_MASK_3); - read_register(FR_ATR_TXVAL_3); - read_register(FR_ATR_RXVAL_3); - - // Configure TX mux, this is a hacked value - read_register(FR_TX_MUX); - - // Set the interpolation rate, which is the rate divided by 4, minus 1 - read_register(FR_INTERP_RATE); - - // Apparently this register changes again - read_register(FR_TX_MUX); - - // Set the receive sample rate divisor, which is 2-1 - read_register(FR_RX_SAMPLE_RATE_DIV); - - // DC offset - read_register(FR_DC_OFFSET_CL_EN); - - // Reset the DC correction offsets - read_register(FR_ADC_OFFSET_0); - read_register(FR_ADC_OFFSET_1); - - // Some hard-coded RX configuration - read_register(FR_RX_FORMAT); - read_register(FR_RX_MUX); - - // RX decimation rate is divided by two, then subtract 1 - read_register(FR_DECIM_RATE); - - // More hard coding - read_register(FR_RX_MUX); - - // Resetting RX registers - read_register(FR_RX_PHASE_0); - read_register(FR_RX_PHASE_1); - read_register(FR_RX_PHASE_2); - read_register(FR_RX_PHASE_3); - read_register(FR_RX_FREQ_0); - read_register(FR_RX_FREQ_1); - read_register(FR_RX_FREQ_2); - read_register(FR_RX_FREQ_3); -} - -/*! - * \brief Used to generate FPGA register write commands to reset all of the FPGA - * registers to a value of 0. - */ -void -usrp_server::reset_all_registers() -{ - for(int i=0; i<64; i++) - set_register(i, 0); -} - -/*! - * \brief Used internally by USRP server to generate a control/status packet - * which contains a register write. - * - * The \p reg parameter is the register number that the value \p val will be - * written to. - */ -void -usrp_server::set_register(long reg, long val) -{ - size_t psize; - long payload_len = 0; - - pmt_t v_packet = pmt_make_u8vector(sizeof(transport_pkt), 0); - transport_pkt *pkt = (transport_pkt *) pmt_u8vector_writable_elements(v_packet, psize); - - pkt->set_header(0, CONTROL_CHAN, 0, payload_len); - pkt->set_timestamp(0xffffffff); - - pkt->cs_write_reg(reg, val); - - d_cs_usrp->send(s_cmd_usrp_write, - pmt_list3(PMT_NIL, - pmt_from_long(CONTROL_CHAN), - v_packet)); -} - -/*! - * \brief Used internally by USRP server to generate a control/status packet - * which contains a register read. This is important to use internally so that - * USRP server can bypass the use of RIDs with register reads, as they are not - * needed and it would use up the finite number of RIDs available for use for - * applications to receive responses. - * - * The \p reg parameter is the register number that the value should be read - * from. - */ -void -usrp_server::read_register(long reg) -{ - size_t psize; - long payload_len = 0; - - pmt_t v_packet = pmt_make_u8vector(sizeof(transport_pkt), 0); - transport_pkt *pkt = (transport_pkt *) pmt_u8vector_writable_elements(v_packet, psize); - - pkt->set_header(0, CONTROL_CHAN, 0, payload_len); - pkt->set_timestamp(0xffffffff); - - pkt->cs_read_reg(0, reg); - - d_cs_usrp->send(s_cmd_usrp_write, - pmt_list3(PMT_NIL, - pmt_from_long(CONTROL_CHAN), - v_packet)); -} - -REGISTER_MBLOCK_CLASS(usrp_server); diff --git a/usrp/limbo/inband/usrp_server.h b/usrp/limbo/inband/usrp_server.h deleted file mode 100644 index dd1825d57..000000000 --- a/usrp/limbo/inband/usrp_server.h +++ /dev/null @@ -1,131 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_USRP_SERVER_H -#define INCLUDED_USRP_SERVER_H - -#include <mblock/mblock.h> -#include <vector> -#include <queue> -#include <fstream> -#include <usrp_inband_usb_packet.h> - -typedef usrp_inband_usb_packet transport_pkt; // makes conversion to gigabit easy - -/*! - * \brief Implements the lowest-level mblock usb_interface to the USRP - */ -class usrp_server : public mb_mblock -{ -public: - - // our ports - enum port_types { - RX_PORT = 0, - TX_PORT = 1 - }; - static const int N_PORTS = 4; - std::vector<mb_port_sptr> d_tx, d_rx; - mb_port_sptr d_cs; - mb_port_sptr d_cs_usrp; - - static const int D_USB_CAPACITY = 32 * 1024 * 1024; - static const int D_MAX_CHANNELS = 16; - long d_ntx_chan; - long d_nrx_chan; - - pmt_t d_usrp_dict; - - bool d_fpga_debug; - - long d_interp_tx; - long d_decim_rx; - - // Keep track of the request IDs - struct rid_info { - pmt_t owner; - long user_rid; - - rid_info() { - owner = PMT_NIL; - user_rid = 0; - } - }; - - static const long D_MAX_RID = 64; - std::vector<rid_info> d_rids; - - struct channel_info { - long assigned_capacity; // the capacity currently assignedby the channel - pmt_t owner; // port ID of the owner of the channel - - channel_info() { - assigned_capacity = 0; - owner = PMT_NIL; - } - }; - - long d_rx_chan_mask; // A bitmask representing the channels in the - // receiving state - - std::vector<struct channel_info> d_chaninfo_tx; - std::vector<struct channel_info> d_chaninfo_rx; - - std::queue<mb_message_sptr> d_defer_queue; - - bool d_defer; - bool d_opened; - - bool d_fake_rx; - -public: - usrp_server(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg); - ~usrp_server(); - - void initial_transition(); - void handle_message(mb_message_sptr msg); - -protected: - static int max_capacity() { return D_USB_CAPACITY; } - -private: - void handle_cmd_allocate_channel(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data); - void handle_cmd_deallocate_channel(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data); - void handle_cmd_xmit_raw_frame(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data); - void handle_cmd_to_control_channel(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data); - void handle_cmd_start_recv_raw_samples(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data); - void handle_cmd_stop_recv_raw_samples(mb_port_sptr port, std::vector<struct channel_info> &chan_info, pmt_t data); - int rx_port_index(pmt_t port_id); - int tx_port_index(pmt_t port_id); - long current_capacity_allocation(); - void recall_defer_queue(); - void reset_channels(); - void handle_response_usrp_read(pmt_t data); - bool check_valid(mb_port_sptr port, long channel, std::vector<struct channel_info> &chan_info, pmt_t signal_info); - void parse_control_pkt(pmt_t invocation_handle, transport_pkt *pkt); - long next_rid(); - void initialize_registers(); - void set_register(long reg, long val); - void read_register(long reg); - void check_register_initialization(); - void reset_all_registers(); -}; - -#endif /* INCLUDED_USRP_SERVER_H */ diff --git a/usrp/limbo/inband/usrp_server.mbh b/usrp/limbo/inband/usrp_server.mbh deleted file mode 100644 index ed7943fc3..000000000 --- a/usrp/limbo/inband/usrp_server.mbh +++ /dev/null @@ -1,255 +0,0 @@ -;; -*- scheme -*- ; not really, but tells emacs how to format this -;; -;; Copyright 2007 Free Software Foundation, Inc. -;; -;; This file is part of GNU Radio -;; -;; GNU Radio is free software; you can redistribute it and/or modify -;; it under the terms of the GNU General Public License as published by -;; the Free Software Foundation; either version 3, or (at your option) -;; any later version. -;; -;; GNU Radio is distributed in the hope that it will be useful, -;; but WITHOUT ANY WARRANTY; without even the implied warranty of -;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;; GNU General Public License for more details. -;; -;; You should have received a copy of the GNU General Public License along -;; with this program; if not, write to the Free Software Foundation, Inc., -;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -;; - -;; ---------------------------------------------------------------- -;; This is an mblock header file -;; -;; The format is very much a work-in-progress. -;; It'll be compiled to C++. -;; ---------------------------------------------------------------- - -;; In the outgoing messages described below, invocation-handle is an -;; identifier provided by the client to tag the method invocation. -;; The identifier will be returned with the response, to provide the -;; client with a mechanism to match asynchronous responses with the -;; commands that generate them. The value of the invocation-handle is -;; opaque the the server, and is not required by the server to be -;; unique. -;; -;; In the incoming messages described below, invocation-handle is the -;; identifier provided by the client in the prompting invocation. The -;; identifier is returned with the response, so that the client has a -;; mechanism to match asynchronous responses with the commands that -;; generated them. -;; -;; status is either #t, indicating success, or a symbol indicating an error. -;; All symbol's names shall begin with %error- - - -;; ---------------------------------------------------------------- -;; usrp-channel -;; -;; The protocol class is defined from the client's point-of-view. -;; (The client port is unconjugated, the server port is conjugated.) - -(define-protocol-class usrp-channel - - (:outgoing - - (cmd-allocate-channel invocation-handle capacity-reservation) - - ;; The cmd-allocate-channel message requests that the server - ;; allocates a logical channel in the FPGA for use. - ;; capacity-reservation specifies the number of bytes/s of - ;; interconnect capacity (USB or ethernet) to reserve for this - ;; channel. (The reservation is just a sanity check, no OS - ;; specific mechanism is used.) - - (cmd-deallocate-channel invocation-handle channel) - - ;; The integer channel specifies the channel to deallocate. - - ) - - (:incoming - - - (response-allocate-channel invocation-handle status channel) - - ;; If successful, a channel the specified capacity was allocated. - ;; channel, an integer, indicates which channel was allocated. - - (response-deallocate-channel invocation-handle status) - - ;; If successful, the specified channel and associated interconnect - ;; capacity were deallocated. - - ) - ) - -;; ---------------------------------------------------------------- -;; usrp-low-level-cs -;; -;; The protocol class is defined from the client's point-of-view. -;; (The client port is unconjugated, the server port is conjugated.) -;; -;; This defines a low level control and status interface to the usrp. -;; This will probably be replaced (or at least augmented) with a -;; higher level interface. For now, this will allow us to get on -;; the air. -;; -;; The subpackets are lists containing the relevant parameters. The -;; server will marshall them appropriately. Below is a list of -;; subpackets. See inband-signaling-usb for details. The opcodes are -;; symbols; unless otherwise indicated the remaining parameters are -;; integers. rid values are limited to 3-bits. -;; -;; (op-ping-fixed rid ping-value) -;; (op-ping-fixed-reply rid ping-value) -;; (op-write-reg reg-number reg-value) -;; (op-write-reg-masked reg-number reg-value mask-value) -;; (op-read-reg rid reg-number) -;; (op-read-reg-reply rid reg-number reg-value) -;; (op-i2c-write i2c-addr u8-vec) -;; (op-i2c-read rid i2c-addr nbytes) -;; (op-i2c-read-reply rid i2c-addr u8-vec) -;; (op-spi-write enables format opt-header-bytes u8-vec) -;; (op-spi-read rid enables format opt-header-bytes nbytes) -;; (op-spi-read-reply rid u8-vec) -;; (op-delay ticks) - - -(define-protocol-class usrp-low-level-cs - - (:outgoing - - (cmd-to-control-channel invocation-handle list-of-subpackets) - - ) - - (:incoming - - (response-from-control-channel invocation-handle status list-of-subpackets timestamp) - - ) - ) - -;; ---------------------------------------------------------------- -;; usrp-tx -;; -;; The protocol class is defined from the client's point-of-view. -;; (The client port is unconjugated, the server port is conjugated.) - -(define-protocol-class usrp-tx - (:include usrp-channel) - (:include usrp-low-level-cs) - - (:outgoing - - (cmd-xmit-raw-frame invocation-handle channel samples timestamp properties) - - ;; The argument channel must be an integer. It specifies the - ;; channel on which the frame of samples will be be sent. - ;; - ;; samples must be a uniform numeric vector. The contents of the - ;; sample vector is treated as opaque and is passed on to the FPGA - ;; unmodified. It is the responsibility of the sender to ensure - ;; that the binary format is sensible for the current FPGA - ;; configuration. - ;; - ;; timestamp is a 32-bit integer that specifies the time at which - ;; the first sample in samples shall be sent to the D/A converter. - ;; The format and interpration of time is specified in the file - ;; inband-signaling-usb - ) - - (:incoming - - (response-xmit-raw-frame invocation-handle status) - - ;; If successful, the samples of the associated frame have been - ;; transmitted to the USRP. This message may be used to implement - ;; Tx flow control. The client could for example implement a - ;; policy of never having more than 4 unacknowledged - ;; cmd-xmit-raw-frame's outstanding. - - ) - ) - -;; ---------------------------------------------------------------- -;; usrp-rx -;; -;; The protocol class is defined from the client's point-of-view. -;; (The client port is unconjugated, the server port is conjugated.) - -(define-protocol-class usrp-rx - (:include usrp-channel) - (:include usrp-low-level-cs) - - (:outgoing - - (cmd-start-recv-raw-samples invocation-handle channel) - - ;; The argument channel must be an integer. It specifies the - ;; channel from which frames of samples will be be received. The - ;; server will return response-recv-raw-samples messages until a - ;; cmd-stop-recv-raw-samples message is received. - - (cmd-stop-recv-raw-samples invocation-handle channel) - - ;; The argument channel must be an integer. There is no reply to - ;; this message. - - ) - - (:incoming - - (response-recv-raw-samples invocation-handle status samples timestamp channel properties) - - ;; samples is a uniform numeric vector. The contents of the sample - ;; vector is treated as opaque and is passed from the FPGA - ;; unmodified. It is the responsibility of the receiver to decode - ;; the binary format as appropriate for the current FPGA - ;; configuration. - ;; - ;; timestamp is a 32-bit integer that specifies the time at which - ;; the first sample in samples was received from the A/D converter. - ;; The format and interpretation of time is as specified in the - ;; file inband-signaling-usb. - ;; - ;; properties is a dictionary containing additional (key, value) - ;; pairs associated with the reception of these samples. In - ;; particular, the map may contain the Received Signal Strength - ;; Indication (RSSI) reported by the front end at the time the - ;; first sample was received from the A/D. - - ) - ) - - -;; ---------------------------------------------------------------- -;; usrp-server-cs -;; -;; Control and status port for usrp-server -;; -;; The protocol class is defined from the client's point-of-view. -;; (The client port is unconjugated, the server port is conjugated.) - -(define-protocol-class usrp-server-cs - - (:outgoing - (cmd-open invocation-handle which-usrp) - (cmd-close invocation-handle) - (cmd-max-capacity invocation-handle) - (cmd-ntx-chan invocation-handle) - (cmd-nrx-chan invocation-handle) - (cmd-current-capacity-allocation invocation-handle) - ) - - (:incoming - (response-open invocation-handle status) - (response-close invocation-handle status) - (response-max-capacity invocation-handle status capacity) - (response-ntx-chan invocation-handle status ntx-chan) - (response-nrx-chan invocation-handle status nrx-chan) - (response-current-capacity-allocation invocation-handle status capacity) - ) - ) diff --git a/usrp/limbo/inband/usrp_tx.cc b/usrp/limbo/inband/usrp_tx.cc deleted file mode 100644 index 0d4a84619..000000000 --- a/usrp/limbo/inband/usrp_tx.cc +++ /dev/null @@ -1,150 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <usrp_tx.h> -#include <iostream> -#include <usb.h> -#include <mblock/class_registry.h> -#include <usrp_inband_usb_packet.h> -#include <fpga_regs_common.h> -#include <usrp_standard.h> -#include <stdio.h> - -#include <symbols_usrp_tx_cs.h> - -typedef usrp_inband_usb_packet transport_pkt; - -static const bool verbose = false; - -usrp_tx::usrp_tx(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(rt, instance_name, user_arg), - d_disk_write(false) -{ - d_cs = define_port("cs", "usrp-tx-cs", true, mb_port::EXTERNAL); - - //d_disk_write=true; - - if(d_disk_write) { - d_ofile.open("tx_data.dat",std::ios::binary|std::ios::out); - d_cs_ofile.open("tx_cs.dat",std::ios::binary|std::ios::out); - } -} - -usrp_tx::~usrp_tx() -{ - if(d_disk_write) { - d_ofile.close(); - d_cs_ofile.close(); - } -} - -void -usrp_tx::initial_transition() -{ - -} - -/*! - * \brief Handles incoming signals to to the m-block, wihch should only ever be - * a single message: cmd-usrp-tx-write. - */ -void -usrp_tx::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); - pmt_t port_id = msg->port_id(); - pmt_t data = msg->data(); - - // Theoretically only have 1 message to ever expect, but - // want to make sure its at least what we want - if(pmt_eq(port_id, d_cs->port_symbol())) { - - if(pmt_eqv(event, s_cmd_usrp_tx_write)) - write(data); - } -} - -/*! - * \brief Performs the actual writing of data to the USB bus, called by - * handle_message() when a cmd-usrp-tx-write signal is received. - * - * The \p data parameter is a PMT list which contains three mandatory elements, - * in the following order: an invocation handle, a channel, and a uniform vector - * of memory which contains the packets to be written to the bus. - */ -void -usrp_tx::write(pmt_t data) -{ - pmt_t invocation_handle = pmt_nth(0, data); - pmt_t channel = pmt_nth(1, data); - pmt_t v_packets = pmt_nth(2, data); - d_utx = boost::any_cast<usrp_standard_tx_sptr>(pmt_any_ref(pmt_nth(3, data))); - - size_t n_bytes; - bool underrun; // this will need to go, as it is taken care of in the packet headers - - transport_pkt *pkts = (transport_pkt *) pmt_u8vector_writable_elements(v_packets, n_bytes); - - int ret = d_utx->write (pkts, n_bytes, &underrun); - - if (0 && underrun) - fprintf(stderr, "uU"); - - if (ret == (int) n_bytes) { - if (verbose) - std::cout << "[usrp_server] Write of " << n_bytes << " successful\n"; - // need to respond with the channel so the USRP server knows who to forward the result of - // the write to by looking up the owner of the channel - d_cs->send(s_response_usrp_tx_write, - pmt_list3(invocation_handle, PMT_T, channel)); - } - else { - if (verbose) - std::cout << "[usrp_server] Error writing " << n_bytes << " bytes to USB bus\n"; - d_cs->send(s_response_usrp_tx_write, - pmt_list3(invocation_handle, PMT_F, channel)); - } - - long n_packets = - static_cast<long>(std::ceil(n_bytes / (double)transport_pkt::max_pkt_size())); - - for(int i=0; i < n_packets; i++) { - - if(d_disk_write) { - if(pkts[i].chan() == CONTROL_CHAN) - d_cs_ofile.write((const char *)&pkts[i], transport_pkt::max_pkt_size()); - else - d_ofile.write((const char *)&pkts[i], transport_pkt::max_pkt_size()); - - d_cs_ofile.flush(); - d_ofile.flush(); - } - } - - - return; -} - -REGISTER_MBLOCK_CLASS(usrp_tx); diff --git a/usrp/limbo/inband/usrp_tx.h b/usrp/limbo/inband/usrp_tx.h deleted file mode 100644 index d3a6f8b54..000000000 --- a/usrp/limbo/inband/usrp_tx.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_USRP_TX_H -#define INCLUDED_USRP_TX_H - -#include <mblock/mblock.h> -#include <fstream> -#include "usrp_standard.h" - -/*! - * \brief Implements the low level usb interface to the USRP - */ -class usrp_tx : public mb_mblock -{ - mb_port_sptr d_cs; - usrp_standard_tx_sptr d_utx; - - bool d_disk_write; - std::ofstream d_ofile; - std::ofstream d_cs_ofile; - - public: - usrp_tx(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg); - ~usrp_tx(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - private: - void write(pmt_t data); -}; - - -#endif /* INCLUDED_USRP_TX_H */ - diff --git a/usrp/limbo/inband/usrp_tx_stub.cc b/usrp/limbo/inband/usrp_tx_stub.cc deleted file mode 100644 index c78b1a7b8..000000000 --- a/usrp/limbo/inband/usrp_tx_stub.cc +++ /dev/null @@ -1,344 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <iostream> -#include <vector> -#include <usb.h> -#include <mblock/class_registry.h> -#include <usrp_tx_stub.h> -#include <usrp_inband_usb_packet.h> -#include <fpga_regs_common.h> -#include "usrp_standard.h" -#include <stdio.h> -#include <fstream> -#include <usrp_rx_stub.h> - -#include <symbols_usrp_tx_cs.h> - -typedef usrp_inband_usb_packet transport_pkt; - -static const bool verbose = false; - -usrp_tx_stub::usrp_tx_stub(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(rt, instance_name, user_arg), - d_disk_write(false) -{ - d_cs = define_port("cs", "usrp-tx-cs", true, mb_port::EXTERNAL); - - //d_disk_write=true; - - if(d_disk_write) { - d_ofile.open("tx_stub_data.dat",std::ios::binary|std::ios::out); - d_cs_ofile.open("tx_stub_cs.dat",std::ios::binary|std::ios::out); - } -} - -usrp_tx_stub::~usrp_tx_stub() -{ - if(d_disk_write) { - d_ofile.close(); - d_cs_ofile.close(); - } -} - -void -usrp_tx_stub::initial_transition() -{ - -} - -void -usrp_tx_stub::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); - pmt_t port_id = msg->port_id(); - pmt_t data = msg->data(); - - // Theoretically only have 1 message to ever expect, but - // want to make sure its at least what we want - if(pmt_eq(port_id, d_cs->port_symbol())) { - - if(pmt_eqv(event, s_cmd_usrp_tx_write)) - write(data); - } -} - -void -usrp_tx_stub::write(pmt_t data) -{ - pmt_t invocation_handle = pmt_nth(0, data); - pmt_t channel = pmt_nth(1, data); - pmt_t v_packets = pmt_nth(2, data); - d_utx = boost::any_cast<usrp_standard_tx *>(pmt_any_ref(pmt_nth(3, data))); - - size_t n_bytes; - - transport_pkt *pkts = (transport_pkt *) pmt_u8vector_writable_elements(v_packets, n_bytes); - long n_packets = static_cast<long>(std::ceil(n_bytes / (double)transport_pkt::max_pkt_size())); - - // Parse the packets looking for C/S packets and dump them to a disk if - // necessary - for(long i=0; i<n_packets; i++) { - - if(d_disk_write) { - if(pkts[i].chan() == CONTROL_CHAN) - d_cs_ofile.write((const char *)&pkts[i], transport_pkt::max_pkt_size()); - else - d_ofile.write((const char *)&pkts[i], transport_pkt::max_pkt_size()); - - d_cs_ofile.flush(); - d_ofile.flush(); - } - - if(pkts[i].chan() == CONTROL_CHAN) - parse_cs(invocation_handle, pkts[i]); - } - - d_cs->send(s_response_usrp_tx_write, - pmt_list3(invocation_handle, PMT_T, channel)); - - return; -} - -void -usrp_tx_stub::parse_cs(pmt_t invocation_handle, transport_pkt pkt) -{ - - long payload_len = pkt.payload_len(); - long curr_payload = 0; - - size_t ignore; - - // There is the possibility that the responses for a single USB packet full of - // CS packets will not fit back in a single USB packet, considering some - // responses are greater than their commands (read registers). - new_packet: - pmt_t v_pkt = pmt_make_u8vector(sizeof(transport_pkt), 0); - - transport_pkt *q_pkt = - (transport_pkt *) pmt_u8vector_writable_elements(v_pkt, ignore); - - q_pkt->set_header(0, CONTROL_CHAN, 0, 0); - q_pkt->set_timestamp(0xffffffff); - - // We dispatch based on the control packet type, however we can extract the - // opcode and the length immediately which is consistent in all responses. - // - // Since each control packet can have multiple responses, we keep reading the - // lengths of each subpacket until we reach the payload length. - while(curr_payload < payload_len) { - - pmt_t sub_packet = pkt.read_subpacket(curr_payload); - pmt_t op_symbol = pmt_nth(0, sub_packet); - - int len = pkt.cs_len(curr_payload); - - if(verbose) - std::cout << "[USRP_TX_STUB] Parsing subpacket " - << op_symbol << " ... length " << len << std::endl; - - //----------------- PING FIXED ------------------// - if(pmt_eq(op_symbol, s_op_ping_fixed)) { - - long rid = pmt_to_long(pmt_nth(1, sub_packet)); - long pingval = pmt_to_long(pmt_nth(2, sub_packet)); - - // Generate a reply and put it in the queue for the RX stub to read - if(!q_pkt->cs_ping_reply(rid, pingval)) - goto new_packet; - - if(verbose) - std::cout << "[USRP_TX_STUB] Generated ping response " - << "(" - << "RID: " << rid << ", " - << "VAL: " << pingval - << ")\n"; - } - - //----------------- READ REG ------------------// - if(pmt_eq(op_symbol, s_op_read_reg)) { - - long rid = pmt_to_long(pmt_nth(1, sub_packet)); - long reg_num = pmt_to_long(pmt_nth(2, sub_packet)); - long reg_val = 0xdeef; - - // Generate a reply and put it in the queue for the RX stub to read - if(!q_pkt->cs_read_reg_reply(rid, reg_num, reg_val)) - goto new_packet; - - if(verbose) - std::cout << "[USRP_TX_STUB] Generated read register response " - << "(" - << "RID: " << rid << ", " - << "REG: " << reg_num << ", " - << "VAL: " << reg_val - << ")\n"; - } - - //----------------- DELAY ------------------// - if(pmt_eq(op_symbol, s_op_delay)) { - - long ticks = pmt_to_long(pmt_nth(1, sub_packet)); - - if(verbose) - std::cout << "[USRP_TX_STUB] Received delay command " - << "(" - << "Ticks: " << ticks - << ")\n"; - } - - //----------------- WRITE REG ------------------// - if(pmt_eq(op_symbol, s_op_write_reg)) { - - pmt_t reg_num = pmt_nth(1, sub_packet); - pmt_t reg_val = pmt_nth(2, sub_packet); - - if(verbose) - std::cout << "[USRP_TX_STUB] Received write register command " - << "(" - << "RegNum: " << reg_num << ", " - << "Val: " << reg_val - << ")\n"; - } - - //----------------- WRITE REG MASK ---------------// - if(pmt_eq(op_symbol, s_op_write_reg_masked)) { - - pmt_t reg_num = pmt_nth(1, sub_packet); - pmt_t reg_val = pmt_nth(2, sub_packet); - pmt_t mask = pmt_nth(3, sub_packet); - - if(verbose) - std::cout << "[USRP_TX_STUB] Received write register command " - << "(" - << "RegNum: " << reg_num << ", " - << "Val: " << reg_val << ", " - << "Mask: " << mask - << ")\n"; - } - - //---------------- I2C WRITE ------------------// - if(pmt_eq(op_symbol, s_op_i2c_write)) { - pmt_t i2c_addr = pmt_nth(1, sub_packet); - pmt_t i2c_data = pmt_nth(2, sub_packet); - - if(verbose) - std::cout << "[USRP_TX_STUB] Received i2c write command " - << "(" - << "Addr: " << i2c_addr << ", " - << "Data: " << i2c_data - << ")\n"; - } - - //---------------- I2C READ ------------------// - if(pmt_eq(op_symbol, s_op_i2c_read)) { - long rid = pmt_to_long(pmt_nth(1, sub_packet)); - long i2c_addr = pmt_to_long(pmt_nth(2, sub_packet)); - long i2c_bytes = pmt_to_long(pmt_nth(3, sub_packet)); - - // Create data to place as a response, filled with 0xff - size_t ignore; - pmt_t i2c_data = pmt_make_u8vector(i2c_bytes, 0xff); - uint8_t *w_data = (uint8_t *) pmt_u8vector_writable_elements(i2c_data, ignore); - - // Generate a reply and put it in the queue for the RX stub to read - if(!q_pkt->cs_i2c_read_reply(rid, i2c_addr, w_data, i2c_bytes)) - goto new_packet; - - if(verbose) - std::cout << "[USRP_TX_STUB] Received i2c read " - << "(" - << "RID: " << rid << ", " - << "Addr: " << i2c_addr << ", " - << "Bytes: " << i2c_bytes - << ")\n"; - } - - //---------------- SPI WRITE ------------------// - if(pmt_eq(op_symbol, s_op_spi_write)) { - long enables = pmt_to_long(pmt_nth(1, sub_packet)); - long format = pmt_to_long(pmt_nth(2, sub_packet)); - long opt = pmt_to_long(pmt_nth(3, sub_packet)); - pmt_t data = pmt_nth(4, sub_packet); - - if(verbose) - std::cout << "[USRP_TX_STUB] Received spi write command " - << "(" - << "Enables: " << enables << ", " - << "Format: " << format << ", " - << "Options: " << opt << ", " - << "Data: " << data - << ")\n"; - } - - //---------------- SPI READ ------------------// - if(pmt_eq(op_symbol, s_op_spi_read)) { - long rid = pmt_to_long(pmt_nth(1, sub_packet)); - long enables = pmt_to_long(pmt_nth(2, sub_packet)); - long format = pmt_to_long(pmt_nth(3, sub_packet)); - long opt = pmt_to_long(pmt_nth(4, sub_packet)); - long n_bytes = pmt_to_long(pmt_nth(5, sub_packet)); - - // Create data to place as a fake response - size_t ignore; - pmt_t spi_data = pmt_make_u8vector(n_bytes, 0xff); - uint8_t *w_data = (uint8_t *) pmt_u8vector_writable_elements(spi_data, ignore); - - // Generate a reply and put it in the queue for the RX stub to read - if(!q_pkt->cs_spi_read_reply(rid, w_data, n_bytes)) - goto new_packet; - - if(verbose) - std::cout << "[USRP_TX_STUB] Received spi read command " - << "(" - << "RID: " << rid << ", " - << "Enables: " << enables << ", " - << "Format: " << format << ", " - << "Options: " << opt << ", " - << "Bytes: " << n_bytes - << ")\n"; - - } - - // Each subpacket has an unaccounted for 2 bytes which is the opcode - // and the length field - curr_payload += len + 2; - - // All subpackets are 32-bit aligned - int align_offset = 4 - (curr_payload % 4); - - if(align_offset != 4) - curr_payload += align_offset; - - } - - // If the packet has data in the payload, it needs queued - if(q_pkt->payload_len() > 0) - d_cs_queue.push(pmt_list2(invocation_handle, v_pkt)); - - return; -} - -REGISTER_MBLOCK_CLASS(usrp_tx_stub); diff --git a/usrp/limbo/inband/usrp_tx_stub.h b/usrp/limbo/inband/usrp_tx_stub.h deleted file mode 100644 index b81037ad7..000000000 --- a/usrp/limbo/inband/usrp_tx_stub.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_USRP_TX_STUB_H -#define INCLUDED_USRP_TX_STUB_H - -#include <mblock/mblock.h> -#include <vector> -#include "usrp_standard.h" -#include <fstream> -#include <usrp_inband_usb_packet.h> - -typedef usrp_inband_usb_packet transport_pkt; - -/*! - * \brief Implements the low level usb interface to the USRP - */ -class usrp_tx_stub : public mb_mblock -{ - public: - - mb_port_sptr d_cs; - usrp_standard_tx* d_utx; - - std::ofstream d_ofile; - std::ofstream d_cs_ofile; - - bool d_disk_write; - - public: - usrp_tx_stub(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg); - ~usrp_tx_stub(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - - private: - void write(pmt_t data); - void parse_cs(pmt_t invocation_handle, transport_pkt pkt); - -}; - - -#endif /* INCLUDED_USRP_TX_STUB_H */ - diff --git a/usrp/limbo/inband/usrp_usb_interface.cc b/usrp/limbo/inband/usrp_usb_interface.cc deleted file mode 100644 index fb7109a5a..000000000 --- a/usrp/limbo/inband/usrp_usb_interface.cc +++ /dev/null @@ -1,601 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <usrp_usb_interface.h> - -#include <iostream> -#include <vector> -#include <usb.h> -#include <mblock/class_registry.h> -#include <usrp_inband_usb_packet.h> -#include <fpga_regs_common.h> -#include "usrp_rx.h" -#include <usrp_rx_stub.h> -#include "usrp_tx.h" -#include "usrp_standard.h" -#include <stdio.h> -#include <usrp_dbid.h> - -typedef usrp_inband_usb_packet transport_pkt; - -#include <symbols_usrp_interface_cs.h> -#include <symbols_usrp_tx_cs.h> -#include <symbols_usrp_rx_cs.h> -static pmt_t s_shutdown = pmt_intern("%shutdown"); - -static const bool verbose = false; - - -/*! - * \brief Initializes the USB interface m-block. - * - * The \p user_arg should be a PMT dictionary which can contain optional - * arguments for the block, such as the decimatoin and interpolation rate. - */ -usrp_usb_interface::usrp_usb_interface(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg) - : mb_mblock(rt, instance_name, user_arg), - d_fake_usrp(false), - d_rx_reading(false), - d_interp_tx(128), - d_decim_rx(128), - d_rf_freq(-1), - d_rbf("inband_tx_rx.rbf") -{ - // Dictionary for arguments to all of the components - pmt_t usrp_dict = user_arg; - - // Default TX/RX interface - std::string tx_interface = "usrp_tx"; - std::string rx_interface = "usrp_rx"; - - if (pmt_is_dict(usrp_dict)) { - - // The 'fake-usrp' key enables the TX and RX stubs if PMT_T - if(pmt_t fake_usrp = pmt_dict_ref(usrp_dict, - pmt_intern("fake-usrp"), - PMT_NIL)) { - if(pmt_eqv(fake_usrp, PMT_T)) { - tx_interface = "usrp_tx_stub"; - rx_interface = "usrp_rx_stub"; - d_fake_usrp=true; - } - } - - // Read the TX interpolations - if(pmt_t interp_tx = pmt_dict_ref(usrp_dict, - pmt_intern("interp-tx"), - PMT_NIL)) { - if(!pmt_eqv(interp_tx, PMT_NIL)) - d_interp_tx = pmt_to_long(interp_tx); - } - - // Read the RX decimation rate - if(pmt_t decim_rx = pmt_dict_ref(usrp_dict, - pmt_intern("decim-rx"), - PMT_NIL)) { - if(!pmt_eqv(decim_rx, PMT_NIL)) - d_decim_rx = pmt_to_long(decim_rx); - } - - // Read the RBF - if(pmt_t rbf = pmt_dict_ref(usrp_dict, - pmt_intern("rbf"), - PMT_NIL)) { - if(!pmt_eqv(rbf, PMT_NIL)) - d_rbf = pmt_symbol_to_string(rbf); - } - - // The RF center frequency - if(pmt_t rf_freq = pmt_dict_ref(usrp_dict, - pmt_intern("rf-freq"), - PMT_NIL)) { - if(!pmt_eqv(rf_freq, PMT_NIL)) - d_rf_freq = pmt_to_double(rf_freq); - } - } - - if (verbose) { - std::cout << "[USRP_USB_INTERFACE] Setting USRP RBF to " - << d_rbf << std::endl; - - std::cout << "[USRP_USB_INTERFACE] Setting TX interpolation to " - << d_interp_tx << std::endl; - - std::cout << "[USRP_USB_INTERFACE] Setting RX interpolation to " - << d_decim_rx << std::endl; - - std::cout << "[USRP_USB_INTERFACE] Using TX interface: " - << tx_interface << "\n"; - - std::cout << "[USRP_USB_INTERFACE] Using RX interface: " - << rx_interface << "\n"; - - } - - d_cs = define_port("cs", "usrp-interface-cs", true, mb_port::EXTERNAL); - d_rx_cs = define_port("rx_cs", "usrp-rx-cs", false, mb_port::INTERNAL); - d_tx_cs = define_port("tx_cs", "usrp-tx-cs", false, mb_port::INTERNAL); - - // Connect to TX and RX - define_component("tx", tx_interface, usrp_dict); - define_component("rx", rx_interface, usrp_dict); - connect("self", "rx_cs", "rx", "cs"); - connect("self", "tx_cs", "tx", "cs"); - - // FIXME: the code should query the FPGA to retrieve the number of channels and such - d_ntx_chan = 2; - d_nrx_chan = 2; -} - -usrp_usb_interface::~usrp_usb_interface() -{ - -} - -void -usrp_usb_interface::initial_transition() -{ - -} - -/*! - * \brief Handles all incoming signals to the block from the lowest m-blocks - * which read/write to the bus, or the higher m-block which is the USRP server. - */ -void -usrp_usb_interface::handle_message(mb_message_sptr msg) -{ - pmt_t event = msg->signal(); // the "name" of the message - pmt_t port_id = msg->port_id(); // which port it came in on - pmt_t data = msg->data(); - pmt_t invocation_handle; - - if (pmt_eq(event, s_shutdown)) // ignore (for now) - return; - - //------------- CONTROL / STATUS -------------// - if (pmt_eq(port_id, d_cs->port_symbol())) { - - //------------ OPEN --------------// - if (pmt_eq(event, s_cmd_usrp_open)){ - handle_cmd_open(data); - return; - } - //----------- CLOSE -------------// - else if (pmt_eq(event, s_cmd_usrp_close)) { - handle_cmd_close(data); - return; - } - //---------- NTX CHAN ----------// - else if (pmt_eq(event, s_cmd_usrp_ntx_chan)) { - invocation_handle = pmt_nth(0, data); - d_cs->send(s_response_usrp_ntx_chan, - pmt_list2(invocation_handle, - pmt_from_long(d_ntx_chan))); - return; - } - //---------- NRX CHAN ----------// - else if (pmt_eq(event, s_cmd_usrp_nrx_chan)) { - invocation_handle = pmt_nth(0, data); - d_cs->send(s_response_usrp_nrx_chan, - pmt_list2(invocation_handle, - pmt_from_long(d_nrx_chan))); - return; - } - //------------ WRITE -----------// - else if(pmt_eq(event, s_cmd_usrp_write)) { - handle_cmd_write(data); - return; - } - //-------- START READING --------// - else if(pmt_eq(event, s_cmd_usrp_start_reading)) { - handle_cmd_start_reading(data); - return; - } - //-------- STOP READING --------// - else if(pmt_eq(event, s_cmd_usrp_stop_reading)) { - handle_cmd_stop_reading(data); - return; - } - - goto unhandled; - } - - //---------------- RX ------------------// - if (pmt_eq(port_id, d_rx_cs->port_symbol())) { - - // Relay reads back up - if(pmt_eq(event, s_response_usrp_rx_read)) { - d_cs->send(s_response_usrp_read, data); - return; - } - - goto unhandled; - } - - //---------------- TX ------------------// - if (pmt_eq(port_id, d_tx_cs->port_symbol())) { - - if(pmt_eq(event, s_response_usrp_tx_write)) { - - pmt_t invocation_handle = pmt_nth(0, data); - pmt_t status = pmt_nth(1, data); - pmt_t channel = pmt_nth(2, data); - - d_cs->send(s_response_usrp_write, - pmt_list3(invocation_handle, - status, - channel)); - - return; - } - - goto unhandled; - } - - unhandled: - std::cout << "[USRP_USB_INTERFACE] unhandled msg: " << msg << std::endl; -} - -/*! - * \brief Called by the handle_message() method when the incoming signal is to - * open a USB connection to the USRP (cmd-usrp-open). - * - * The \p data parameter is a PMT list, where the elements are an invocation - * handle and the USRP number. - */ -void -usrp_usb_interface::handle_cmd_open(pmt_t data) -{ - pmt_t invocation_handle = pmt_nth(0, data); - long which_usrp = pmt_to_long(pmt_nth(1, data)); - pmt_t reply_data; - - if(d_fake_usrp) { - d_cs->send(s_response_usrp_open, pmt_list2(invocation_handle, PMT_T)); - return; - } - - if (verbose) - std::cout << "[USRP_USB_INTERFACE] Handling open request for USRP " << which_usrp << "\n"; - - // Open up a standard RX and TX for communication with the USRP - - d_utx = usrp_standard_tx::make(which_usrp, - d_interp_tx, - 1, // 1 channel - -1, // mux - 4096, // USB block size - 16, // nblocks for async transfers - d_rbf - ); - - if(d_utx==0) { - if (verbose) - std::cout << "[USRP_USB_INTERFACE] Failed to open TX\n"; - reply_data = pmt_list2(invocation_handle, PMT_F); - d_cs->send(s_response_usrp_open, reply_data); - return; - } - - // Perform TX daughterboard tuning - double target_freq; - unsigned int mux; - int tgain, rgain; - float input_rate; - bool ok; - usrp_tune_result r; - - // Cast to usrp_basic and then detect daughterboards - d_ub_tx = d_utx; - usrp_subdev_spec tspec = pick_tx_subdevice(); - db_base_sptr tsubdev = d_ub_tx->selected_subdev(tspec); - - // Set the TX mux value - mux = d_utx->determine_tx_mux_value(tspec); - d_utx->set_mux(mux); - - // Set the TX gain and determine rate - tgain = tsubdev->gain_max(); - tsubdev->set_gain(tgain); - input_rate = d_ub_tx->converter_rate() / d_utx->interp_rate(); - - // Perform the actual tuning, if no frequency specified then pick - if(d_rf_freq==-1) - target_freq = tsubdev->freq_min()+((tsubdev->freq_max()-tsubdev->freq_min())/2.0); - else - target_freq = d_rf_freq; - ok = d_utx->tune(tsubdev->which(), tsubdev, target_freq, &r); - tsubdev->set_enable(true); - - if(verbose) { - printf("TX Subdevice name is %s\n", tsubdev->name().c_str()); - printf("TX Subdevice freq range: (%g, %g)\n", - tsubdev->freq_min(), tsubdev->freq_max()); - printf("mux: %#08x\n", mux); - printf("target_freq: %f\n", target_freq); - printf("ok: %s\n", ok ? "true" : "false"); - printf("gain: %d\n", tgain); - printf("r.baseband_freq: %f\n", r.baseband_freq); - printf("r.dxc_freq: %f\n", r.dxc_freq); - printf("r.residual_freq: %f\n", r.residual_freq); - printf("r.inverted: %d\n", r.inverted); - } - - if(!ok) { - std::cerr << "[USRP_USB_INTERFACE] Failed to set center frequency on TX\n"; - reply_data = pmt_list2(invocation_handle, PMT_F); - d_cs->send(s_response_usrp_open, reply_data); - return; - } - - d_utx->start(); - - if (verbose) - std::cout << "[USRP_USB_INTERFACE] Setup TX channel\n"; - - d_urx = - usrp_standard_rx::make (which_usrp, - d_decim_rx, - 1, // nchan - -1, // mux - 0, // set blank mode to start - 4096, // USB block size - 16, // number of blocks for async transfers - d_rbf); - - if(!d_urx) { - if (verbose) - std::cout << "[usrp_server] Failed to open RX\n"; - reply_data = pmt_list2(invocation_handle, PMT_F); - d_cs->send(s_response_usrp_open, reply_data); - return; - } - - // Cast to usrp_basic and then detect daughterboards - d_ub_rx = d_urx; - usrp_subdev_spec rspec = pick_rx_subdevice(); - db_base_sptr rsubdev = d_ub_rx->selected_subdev(rspec); - - // Set the RX mux value - mux = d_urx->determine_rx_mux_value(rspec); - d_urx->set_mux(mux); - - // Set the RX gain and determine rate - rgain = rsubdev->gain_max()/2.0; - rsubdev->set_gain(rgain); - input_rate = d_ub_rx->converter_rate() / d_urx->decim_rate(); - - ok = d_urx->tune(rsubdev->which(), rsubdev, target_freq, &r); - rsubdev->set_enable(true); - - if(verbose) { - printf("RX Subdevice name is %s\n", rsubdev->name().c_str()); - printf("RX Subdevice freq range: (%g, %g)\n", - rsubdev->freq_min(), rsubdev->freq_max()); - printf("mux: %#08x\n", mux); - printf("target_freq: %f\n", target_freq); - printf("ok: %s\n", ok ? "true" : "false"); - printf("gain: %d\n", rgain); - printf("r.baseband_freq: %f\n", r.baseband_freq); - printf("r.dxc_freq: %f\n", r.dxc_freq); - printf("r.residual_freq: %f\n", r.residual_freq); - printf("r.inverted: %d\n", r.inverted); - } - - if(!ok) { - std::cerr << "[USRP_USB_INTERFACE] Failed to set center frequency on RX\n"; - reply_data = pmt_list2(invocation_handle, PMT_F); - d_cs->send(s_response_usrp_open, reply_data); - return; - } - - if (verbose) - std::cout << "[USRP_USB_INTERFACE] Setup RX channel\n"; - -// d_utx->_write_fpga_reg(FR_DEBUG_EN,0xf); -// d_utx->_write_oe(0, 0xffff, 0xffff); -// d_urx->_write_oe(0, 0xffff, 0xffff); -// d_utx->_write_oe(1, 0xffff, 0xffff); -// d_urx->_write_oe(1, 0xffff, 0xffff); - - d_cs->send(s_response_usrp_open, pmt_list2(invocation_handle, PMT_T)); -} - -/*! - * \brief Called by the handle_message() method when the incoming signal is to - * write data to the USB bus (cmd-usrp-write). - * - * The \p data parameter is a PMT list containing 3 mandatory elements in the - * following order: an invocation handle, channel, and a uniform vector - * representation of the packets. - */ -void -usrp_usb_interface::handle_cmd_write(pmt_t data) -{ - pmt_t invocation_handle = pmt_nth(0, data); - pmt_t channel = pmt_nth(1, data); - pmt_t pkts = pmt_nth(2, data); - - pmt_t tx_handle = pmt_make_any(d_utx); - - d_tx_cs->send(s_cmd_usrp_tx_write, - pmt_list4(invocation_handle, - channel, - pkts, - tx_handle)); -} - -/*! - * \brief Called by the handle_message() method when the incoming signal is to - * start reading data from the USB bus (cmd-usrp-start-reading). - * - * The \p data parameter is a PMT list with a single element: an invocation - * handle which can be returned with the response. - */ -void -usrp_usb_interface::handle_cmd_start_reading(pmt_t data) -{ - pmt_t invocation_handle = pmt_nth(0, data); - - if(verbose) - std::cout << "[USRP_USB_INTERFACE] Starting RX...\n"; - - if(!d_fake_usrp) - d_urx->start(); - - pmt_t rx_handle = pmt_make_any(d_urx); - - d_rx_cs->send(s_cmd_usrp_rx_start_reading, pmt_list2(PMT_NIL, rx_handle)); - - d_rx_reading = true; - - return; -} - -/*! - * \brief Called by the handle_message() method when the incoming signal is to - * stop reading data from the USB bus (cmd-usrp-stop-reading). - * - * The \p data parameter is a PMT list with a single element: an invocation - * handle which can be returned with the response. - */ -void -usrp_usb_interface::handle_cmd_stop_reading(pmt_t data) -{ - pmt_t invocation_handle = pmt_nth(0, data); - - if(!d_fake_usrp) { - if(verbose) - std::cout << "[USRP_USB_INTERFACE] Stopping RX...\n"; - usrp_rx_stop = true; - - // Used to allow a read() being called by a lower layer to complete before - // stopping, else there can be partial data left on the bus and can generate - // errors. - while(usrp_rx_stop) {usleep(1);} - d_urx->stop(); - } - else { - if(verbose) - std::cout << "[USRP_USB_INTERFACE] Stopping fake RX...\n"; - usrp_rx_stop_stub = true; // extern to communicate with stub to wait - } - - d_rx_reading = false; - - return; -} - -/*! - * \brief Called by the handle_message() method when the incoming signal is to - * close the USB connection to the USRP. - * - * The \p data parameter is a PMT list with a single element: an invocation - * handle which can be returned with the response. - */ -void -usrp_usb_interface::handle_cmd_close(pmt_t data) -{ - pmt_t invocation_handle = pmt_nth(0, data); - - if(d_rx_reading) - handle_cmd_stop_reading(PMT_NIL); - - if(d_fake_usrp) { - d_cs->send(s_response_usrp_close, pmt_list2(invocation_handle, PMT_T)); - return; - } - - if (verbose) - std::cout << "[USRP_USB_INTERFACE] Handling close request for USRP\n"; - - d_utx.reset(); - d_urx.reset(); - - d_cs->send(s_response_usrp_close, pmt_list2(invocation_handle, PMT_T)); - - // FIXME This seems like a _very_ strange place to be calling shutdown_all. - // That decision should be left to high-level code, not low-level code like this. - shutdown_all(PMT_T); -} - -usrp_subdev_spec -usrp_usb_interface::pick_rx_subdevice() -{ - int dbids[] = { - USRP_DBID_FLEX_400_RX, - USRP_DBID_FLEX_900_RX, - USRP_DBID_FLEX_1200_RX, - USRP_DBID_FLEX_2400_RX, - USRP_DBID_TV_RX, - USRP_DBID_TV_RX_REV_2, - USRP_DBID_DBS_RX, - USRP_DBID_BASIC_RX - }; - - std::vector<int> candidates(dbids, dbids+(sizeof(dbids)/sizeof(int))); - return pick_subdev(d_ub_rx, candidates); -} - -usrp_subdev_spec -usrp_usb_interface::pick_tx_subdevice() -{ - int dbids[] = { - USRP_DBID_FLEX_400_TX, - USRP_DBID_FLEX_900_TX, - USRP_DBID_FLEX_1200_TX, - USRP_DBID_FLEX_2400_TX, - USRP_DBID_BASIC_TX - }; - - std::vector<int> candidates(dbids, dbids+(sizeof(dbids)/sizeof(int))); - return pick_subdev(d_ub_tx, candidates); -} - -usrp_subdev_spec -usrp_usb_interface::pick_subdev(boost::shared_ptr<usrp_basic> d_usrp_basic, std::vector<int> candidates) -{ - int dbid0 = d_usrp_basic->selected_subdev(usrp_subdev_spec(0, 0))->dbid(); - int dbid1 = d_usrp_basic->selected_subdev(usrp_subdev_spec(1, 0))->dbid(); - - for (int i = 0; i < candidates.size(); i++) { - int dbid = candidates[i]; - if (dbid0 == dbid) - return usrp_subdev_spec(0, 0); - if (dbid1 == dbid) - return usrp_subdev_spec(1, 0); - } - - if (dbid0 >= 0) - return usrp_subdev_spec(0, 0); - if (dbid1 >= 0) - return usrp_subdev_spec(1, 0); - - throw std::runtime_error("No suitable daughterboard found!"); -} - - -REGISTER_MBLOCK_CLASS(usrp_usb_interface); diff --git a/usrp/limbo/inband/usrp_usb_interface.h b/usrp/limbo/inband/usrp_usb_interface.h deleted file mode 100644 index 4d7750a7d..000000000 --- a/usrp/limbo/inband/usrp_usb_interface.h +++ /dev/null @@ -1,78 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2007,2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_USRP_USB_INTERFACE_H -#define INCLUDED_USRP_USB_INTERFACE_H - -#include <mblock/mblock.h> -#include <vector> -#include "usrp_standard.h" - -/*! - * \brief Implements the low level usb interface to the USRP - */ -class usrp_usb_interface : public mb_mblock -{ - public: - - usrp_standard_tx_sptr d_utx; - usrp_standard_rx_sptr d_urx; - - boost::shared_ptr<usrp_basic> d_ub_tx; - boost::shared_ptr<usrp_basic> d_ub_rx; - - mb_port_sptr d_cs; - mb_port_sptr d_rx_cs; - mb_port_sptr d_tx_cs; - - long d_ntx_chan; - long d_nrx_chan; - - bool d_fake_usrp; - - bool d_rx_reading; - - long d_interp_tx; - long d_decim_rx; - - double d_rf_freq; - - std::string d_rbf; - - public: - usrp_usb_interface(mb_runtime *rt, const std::string &instance_name, pmt_t user_arg); - ~usrp_usb_interface(); - void initial_transition(); - void handle_message(mb_message_sptr msg); - usrp_subdev_spec pick_rx_subdevice(); - usrp_subdev_spec pick_tx_subdevice(); - usrp_subdev_spec pick_subdev(boost::shared_ptr<usrp_basic> d_usrp_basic, std::vector<int> candidates); - - private: - void handle_cmd_open(pmt_t data); - void handle_cmd_close(pmt_t data); - void handle_cmd_write(pmt_t data); - void handle_cmd_start_reading(pmt_t data); - void handle_cmd_stop_reading(pmt_t data); - -}; - - -#endif /* INCLUDED_USRP_USB_INTERFACE_H */ diff --git a/usrp/usrp.pc.in b/usrp/usrp.pc.in index d4794aa6f..3c30de622 100644 --- a/usrp/usrp.pc.in +++ b/usrp/usrp.pc.in @@ -6,6 +6,6 @@ includedir=@includedir@ Name: usrp Description: USRP Client Side C++ interface Requires: @LIBUSB_PKG_CONFIG_NAME@ -Version: @VERSION@ +Version: @LIBVER@ Libs: -L${libdir} -lusrp Cflags: -I${includedir} diff --git a/usrp2/firmware/apps/Makefile.am b/usrp2/firmware/apps/Makefile.am index 00f682fc7..1dc8b0a73 100644 --- a/usrp2/firmware/apps/Makefile.am +++ b/usrp2/firmware/apps/Makefile.am @@ -75,6 +75,7 @@ txrx_wbx_LDADD = ../lib/libu2fw_wbx.a txrx_xcvr_LDADD = ../lib/libu2fw_xcvr.a + noinst_HEADERS = \ app_common_v2.h \ app_passthru_v2.h \ diff --git a/usrp2/firmware/include/usrp2_types.h b/usrp2/firmware/include/usrp2_types.h index dd2bcf1ed..32cb25c41 100644 --- a/usrp2/firmware/include/usrp2_types.h +++ b/usrp2/firmware/include/usrp2_types.h @@ -50,6 +50,12 @@ u2_fxpt_freq_round_to_int(u2_fxpt_freq_t fx) return (int)((fx+(1<<(U2_FPF_RP-1)))>>U2_FPF_RP); } +static inline unsigned int +u2_fxpt_freq_round_to_uint(u2_fxpt_freq_t fx) +{ + return (unsigned int)((fx+(1<<(U2_FPF_RP-1)))>>U2_FPF_RP); +} + static inline double u2_fxpt_freq_to_double(u2_fxpt_freq_t fx) { diff --git a/usrp2/firmware/lib/Makefile.am b/usrp2/firmware/lib/Makefile.am index 0a7d5c39b..d6bb4edc3 100644 --- a/usrp2/firmware/lib/Makefile.am +++ b/usrp2/firmware/lib/Makefile.am @@ -22,26 +22,19 @@ noinst_LIBRARIES = \ libu2fw_wbx.a \ libu2fw_xcvr.a - -libu2fw_a_SOURCES = \ +U2FW_COMMON = \ + _exit.c \ abort.c \ ad9510.c \ - adf4350.c \ - adf4350_regs.c \ ad9777.c \ bsm12.c \ buffer_pool.c \ clocks.c \ db_basic.c \ - db_dbsrx.c \ - db_rfx.c \ - db_tvrx.c \ - db_init.c \ dbsm.c \ eeprom.c \ - ethernet.c \ eth_mac.c \ - _exit.c \ + ethernet.c \ exit.c \ hal_io.c \ hal_uart.c \ @@ -53,88 +46,37 @@ libu2fw_a_SOURCES = \ memset_wa.c \ nonstdio.c \ pic.c \ + print_buffer.c \ + print_fxpt.c \ print_mac_addr.c \ print_rmon_regs.c \ - print_fxpt.c \ - print_buffer.c \ printf.c \ sd.c \ spi.c \ - u2_init.c + u2_init.c + +libu2fw_a_SOURCES = \ + $(U2FW_COMMON) \ + db_init.c \ + db_bitshark_rx.c \ + db_dbsrx.c \ + db_rfx.c \ + db_tvrx.c libu2fw_wbx_a_SOURCES = \ - abort.c \ - ad9510.c \ + $(U2FW_COMMON) \ + db_init_wbx.c \ adf4350.c \ adf4350_regs.c \ - ad9777.c \ - bsm12.c \ - buffer_pool.c \ - clocks.c \ - db_basic.c \ - db_wbxng.c \ - db_init_wbx.c \ - dbsm.c \ - eeprom.c \ - ethernet.c \ - eth_mac.c \ - _exit.c \ - exit.c \ - hal_io.c \ - hal_uart.c \ - i2c.c \ - lsadc.c \ - lsdac.c \ - mdelay.c \ - memcpy_wa.c \ - memset_wa.c \ - nonstdio.c \ - pic.c \ - print_mac_addr.c \ - print_rmon_regs.c \ - print_fxpt.c \ - print_buffer.c \ - printf.c \ - sd.c \ - spi.c \ - u2_init.c + db_wbxng.c libu2fw_xcvr_a_SOURCES = \ - abort.c \ - ad9510.c \ + $(U2FW_COMMON) \ + db_init_xcvr.c \ adf4350.c \ adf4350_regs.c \ - ad9777.c \ - bsm12.c \ - buffer_pool.c \ - clocks.c \ - db_basic.c \ - db_xcvr2450.c \ - db_init_xcvr.c \ - dbsm.c \ - eeprom.c \ - ethernet.c \ - eth_mac.c \ - _exit.c \ - exit.c \ - hal_io.c \ - hal_uart.c \ - i2c.c \ - lsadc.c \ - lsdac.c \ - mdelay.c \ - memcpy_wa.c \ - memset_wa.c \ - nonstdio.c \ - pic.c \ - print_mac_addr.c \ - print_rmon_regs.c \ - print_fxpt.c \ - print_buffer.c \ - printf.c \ - sd.c \ - spi.c \ - u2_init.c + db_xcvr2450.c + noinst_HEADERS = \ ad9510.h \ @@ -149,6 +91,7 @@ noinst_HEADERS = \ db.h \ db_base.h \ db_wbxng.h \ + db_bitshark_rx.h \ dbsm.h \ eth_mac.h \ eth_mac_regs.h \ diff --git a/usrp2/firmware/lib/db_bitshark_rx.c b/usrp2/firmware/lib/db_bitshark_rx.c new file mode 100644 index 000000000..4c126de9b --- /dev/null +++ b/usrp2/firmware/lib/db_bitshark_rx.c @@ -0,0 +1,337 @@ +/* + * Copyright 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#include "db_bitshark_rx.h" +#include <memory_map.h> +#include <db_base.h> +#include <hal_io.h> +#include <mdelay.h> +#include <lsdac.h> +#include <clocks.h> +#include <stdio.h> +#include <stdint.h> +#include <string.h> +#include <i2c.h> + +/* Note: Thie general structure of this file is based on the db_wbxng.c + codebase for the wbx daughterboard. */ + +/* The following defines specify the address map provided by the + Bitshark USRP Rx (BURX) board. These registers are all accessed over I2C. */ +#define RF_CENTER_FREQ_REG 0x00 +#define RF_CHAN_FILTER_BW_REG 0x01 +#define RF_GAIN_REG 0x02 +#define BB_GAIN_REG 0x03 +#define ADF4350_REG 0x10 +#define SKY73202_REG 0x11 +#define CLOCK_SCHEME_REG 0x20 + +/* The following table lists the registers provided by the Bitshark board + that are accessible over I2C: + -------------------------------------------------------- + |RegAddr: 0x00-RF Center Freq register | + |4-bytes 0x00| + |4-byte unsigned RF center freq (in KHz)| + |RegAddr: 0x01-RF channel filter bandwidth register | + |4-bytes 0x00| + |4-byte unsigned RF channel filter bw (in KHz)| + |RegAddr: 0x02-RF gain register | + |7-bytes 0x00| + |1-byte signed RF gain (in dB)| + |RegAddr: 0x03-Baseband gain register | + |4-bytes 0x00| + |4-byte signed baseband filter gain (in dB)| + |RegAddr: 0x10-ADF4350 register | + |4-bytes 0x00| + |4-byte ADF4350 register value (actual ADF4350 reg addr embedded + within 4-byte value)| + |RegAddr: 0x11-SKY73202 register | + |5-bytes 0x00| + |1-byte reg 0 of SKY73202 | + |1-byte reg 1 of SKY73202 | + |1-byte reg 2 of SKY73202 | + |RegAddr: 0x20-Clock Scheme | + |3-bytes 0x00| + |1-byte indicating clocking scheme: + -0x00 -> BURX local TCXO off, BURX accepts ref clock from + USRP2 (freq of USRP2's ref clock specified in bytes 2-5) + -0x01 -> BURX local TCXO on, BURX uses its local TCXO as its ref + clock, TCXO signal output for use as phase lock for USRP2 | + |4-byte USRP2 ref clock freq in hz (only needed if byte 1 set to 0x00) | + + --------------------------------------------------------------------------- + + As an example, lets say the client wants to set an RF center freq of + 1000 MHz. In KHz, this translates to 1000000 (resolution is only down to + steps of 1 KHz), which is 0x000F4240 in hex. So the complete 9-byte I2C + sequence that the client should send is as follows: + byte 0: 0x00-register 0x00 is the target of the write operation + bytes 1-4: 0x00 (padding) + byte 5: 0x00 (MSB of the 1000000 KHz value, in hex) + byte 6: 0x0F + byte 7: 0x42 + byte 8: 0x40 (LSB of the 1000000 KHz value, in hex) + + How about another example...lets say the client wants to setup the clock + scheme to use scheme #1 where the 26 MHz TCXO on the BURX board is enabled, + and is provided to the USRP2 for it to phase lock to it as an external ref. + 26 MHz (i.e. 26 million), in hex, is 0x18CBA80. + So the complete 9-byte I2C sequence that the client should send is as follows: + byte 0: 0x20-register 0x20 is the target of the write operation + bytes 1-3: 0x00 (padding) + byte 4: 0x01 (indicating that clock scheme #1 is wanted) + byte 5: 0x01 (MSB of the BURX ref clk freq) + byte 6: 0x8C + byte 7: 0xBA + byte 8: 0x80 (LSB of the BURX ref clk freq) + + Note: The endian-ness of 4-byte values used in I2C cmds is different on + USRP2 compared to USRP1. + +*/ + +#define NUM_BYTES_IN_I2C_CMD 9 +#define I2C_ADDR 0x47 + +bool bitshark_rx_init(struct db_base *dbb); +bool bitshark_rx_set_freq(struct db_base *dbb, u2_fxpt_freq_t freq, u2_fxpt_freq_t *dc); +bool bitshark_rx_set_gain(struct db_base *dbb, u2_fxpt_gain_t gain); +bool bitshark_rx_set_bw(struct db_base *dbb, uint16_t bw); + +static bool set_clock_scheme(uint8_t clock_scheme, uint32_t ref_clk_freq); + +/* + * The class instances + */ +struct db_bitshark_rx db_bitshark_rx = { + .base.dbid = 0x0070, + .base.is_tx = false, + .base.output_enables = 0x0000, + .base.used_pins = 0x0000, + .base.freq_min = U2_DOUBLE_TO_FXPT_FREQ(300e6), + .base.freq_max = U2_DOUBLE_TO_FXPT_FREQ(4000e6), + .base.gain_min = U2_DOUBLE_TO_FXPT_GAIN(0), + .base.gain_max = U2_DOUBLE_TO_FXPT_GAIN(42), + .base.gain_step_size = U2_DOUBLE_TO_FXPT_GAIN(6), + .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 = bitshark_rx_init, + .base.set_freq = bitshark_rx_set_freq, + .base.set_gain = bitshark_rx_set_gain, + .base.set_tx_enable = 0, + .base.atr_mask = 0x0000, + .base.atr_txval = 0, + .base.atr_rxval = 0, + .base.set_antenna = 0, + .extra.bw_min = 660, /* in KHz, so 660 KHz */ + .extra.bw_max = 56000, /* in KHz, so 56 MHz */ + .extra.set_bw = bitshark_rx_set_bw +}; + +bool +bitshark_rx_init(struct db_base *dbb) +{ + struct db_bitshark_rx_dummy *db = (struct db_bitshark_rx_dummy *) dbb; + + clocks_enable_rx_dboard(true, 0); + /* hal_gpio_write( GPIO_RX_BANK, ENABLE_5|ENABLE_33, ENABLE_5|ENABLE_33 ); */ + /* above isn't needed, since we don't have any GPIO from the FPGA */ + + /* setup the clock scheme to accept the USRP2's 100 MHz ref clk */ + set_clock_scheme(0,100000000); + + /* initial setting of gain */ + dbb->set_gain(dbb,U2_DOUBLE_TO_FXPT_GAIN(20.0)); + + /* Set the freq now to get the one time 10ms delay out of the way. */ + u2_fxpt_freq_t dc; + dbb->set_freq(dbb, dbb->freq_min, &dc); + + /* set up the RF bandwidth of the signal of interest...Note: there + doesn't appear to be a standard way of setting this bandwidth + in USRP2-land (compared to USRP1-land, where we have the + straight-forward set_bw() method). Not sure why this is, but + for now, simply set the bandwidth once for the intended + application. */ + db->extra.set_bw(dbb, 25000); /* 25 MHz channel bw */ + + return true; +} + +bool +bitshark_rx_set_freq(struct db_base *dbb, u2_fxpt_freq_t freq, u2_fxpt_freq_t *dc) +{ + struct db_bitshark_rx_dummy *db = (struct db_bitshark_rx_dummy *) dbb; + unsigned char args[NUM_BYTES_IN_I2C_CMD]; + unsigned char val[4]; + uint32_t freq_in_khz = (uint32_t)(u2_fxpt_freq_round_to_uint(freq)/1000); + + if(!(freq>=db->base.freq_min && freq<=db->base.freq_max)) + { + return false; + } + + memset(args,0x00,NUM_BYTES_IN_I2C_CMD); + memcpy(val,&freq_in_khz,4); + args[0] = RF_CENTER_FREQ_REG; + args[5] = val[3]; + args[6] = val[2]; + args[7] = val[1]; + args[8] = val[0]; + + i2c_write(I2C_ADDR, args, NUM_BYTES_IN_I2C_CMD); + /* Add a brief delay after each command. This only seems to be + necessary when sending a sequence of commands one after the other. + This issue appears to be specific to the USRP2, since it isn't + necessary on the USRP1. The 5 mS delay is a bit of + an emperical compromise: too short (say, 1 mS), and every once + in a great while a command will still be magically dropped on its + way out...too long (say, 500 mS) and higher-level apps such as + usrp2_fft.py seem to choke because the init sequence is taking + too long. So 5 mS was tested repeatedly without error, and deemed + reasonable. Not sure if this is an issue with the I2C master + code in the microblaze or some place else, and I hate magic + delays too, but this seems to be stable. */ + mdelay(5); + + *dc = freq; + return true; +} + +bool +bitshark_rx_set_gain(struct db_base *dbb, u2_fxpt_gain_t gain) +{ + struct db_bitshark_rx_dummy *db = (struct db_bitshark_rx_dummy *) dbb; + + unsigned char args[NUM_BYTES_IN_I2C_CMD]; + uint8_t final_gain = (uint8_t)(u2_fxpt_gain_round_to_int(gain)); + + if(!(gain >= db->base.gain_min && gain <= db->base.gain_max)) + { + return false; + } + + memset(args,0x00,NUM_BYTES_IN_I2C_CMD); + args[0] = RF_GAIN_REG; + args[5] = final_gain; + + i2c_write(I2C_ADDR, args, NUM_BYTES_IN_I2C_CMD); + /* Add a brief delay after each command. This only seems to be + necessary when sending a sequence of commands one after the other. + This issue appears to be specific to the USRP2, since it isn't + necessary on the USRP1. The 5 mS delay is a bit of + an emperical compromise: too short (say, 1 mS), and every once + in a great while a command will still be magically dropped on its + way out...too long (say, 500 mS) and higher-level apps such as + usrp2_fft.py seem to choke because the init sequence is taking + too long. So 5 mS was tested repeatedly without error, and deemed + reasonable. Not sure if this is an issue with the I2C master + code in the microblaze or some place else, and I hate magic + delays too, but this seems to be stable. */ + mdelay(5); + + return true; +} + +bool +bitshark_rx_set_bw(struct db_base *dbb, uint16_t bw_in_khz) +{ + struct db_bitshark_rx_dummy *db = (struct db_bitshark_rx_dummy *) dbb; + unsigned char val[2]; + unsigned char args[NUM_BYTES_IN_I2C_CMD]; + + if(!(bw_in_khz >= db->extra.bw_min && bw_in_khz <= db->extra.bw_max)) + { + return false; + } + + memset(args,0x00,NUM_BYTES_IN_I2C_CMD); + memcpy(val,&bw_in_khz,2); + args[0] = RF_CHAN_FILTER_BW_REG; + args[5] = val[1]; + args[6] = val[0]; + + i2c_write(I2C_ADDR, args, NUM_BYTES_IN_I2C_CMD); + /* Add a brief delay after each command. This only seems to be + necessary when sending a sequence of commands one after the other. + This issue appears to be specific to the USRP2, since it isn't + necessary on the USRP1. The 5 mS delay is a bit of + an emperical compromise: too short (say, 1 mS), and every once + in a great while a command will still be magically dropped on its + way out...too long (say, 500 mS) and higher-level apps such as + usrp2_fft.py seem to choke because the init sequence is taking + too long. So 5 mS was tested repeatedly without error, and deemed + reasonable. Not sure if this is an issue with the I2C master + code in the microblaze or some place else, and I hate magic + delays too, but this seems to be stable. */ + mdelay(5); + + return true; +} + +static bool +set_clock_scheme(uint8_t clock_scheme, uint32_t ref_clk_freq) +{ + /* Set the clock scheme for determining how the BURX + dboard receives its clock. For the USRP2, there is really only + one way of doing this, which is to use the 100 MHz ref clk + on the USRP2 as its reference. However, it is possible to + use the BURX's 26 MHz TCXO as the external reference input to + the USRP, which would provide phase lock between our oscillator + and the USRP's 100 MHz oscillator. And since the BURX board + provides the ability to warp the oscillator, this may be + useful to some folks. Otherwise, the BURX board will always + just take the 100 MHz reference from the USRP2 as its reference. + */ + + unsigned char args[NUM_BYTES_IN_I2C_CMD]; + char val[4]; + + if (clock_scheme > 1) + { + return false; + } + + memcpy(val,&ref_clk_freq,4); + args[0] = CLOCK_SCHEME_REG; + args[4] = clock_scheme; + args[5] = val[3]; + args[6] = val[2]; + args[7] = val[1]; + args[8] = val[0]; + + i2c_write(I2C_ADDR, args, NUM_BYTES_IN_I2C_CMD); + /* Add a brief delay after each command. This only seems to be + necessary when sending a sequence of commands one after the other. + This issue appears to be specific to the USRP2, since it isn't + necessary on the USRP1. The 5 mS delay is a bit of + an emperical compromise: too short (say, 1 mS), and every once + in a great while a command will still be magically dropped on its + way out...too long (say, 500 mS) and higher-level apps such as + usrp2_fft.py seem to choke because the init sequence is taking + too long. So 5 mS was tested repeatedly without error, and deemed + reasonable. Not sure if this is an issue with the I2C master + code in the microblaze or some place else, and I hate magic + delays too, but this seems to be stable. */ + mdelay(5); + + return true; +} + diff --git a/usrp2/firmware/lib/db_bitshark_rx.h b/usrp2/firmware/lib/db_bitshark_rx.h new file mode 100644 index 000000000..3651f27b8 --- /dev/null +++ b/usrp2/firmware/lib/db_bitshark_rx.h @@ -0,0 +1,46 @@ +/* + * Copyright 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 + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ + +#ifndef DB_BITSHARK_RX_H +#define DB_BITSHARK_RX_H + +#include <db_base.h> + +struct db_bitshark_rx_extra +{ + uint16_t bw_min; + uint16_t bw_max; + bool (*set_bw)(struct db_base *, uint16_t bw); + +}; + +struct db_bitshark_rx_dummy +{ + struct db_base base; + struct db_bitshark_rx_extra extra; +}; + + +struct db_bitshark_rx +{ + struct db_base base; + struct db_bitshark_rx_extra extra; +}; + + +#endif /* DB_BITSHARK_RX_H */ diff --git a/usrp2/firmware/lib/db_init.c b/usrp2/firmware/lib/db_init.c index bc82946fc..d58badc9e 100644 --- a/usrp2/firmware/lib/db_init.c +++ b/usrp2/firmware/lib/db_init.c @@ -51,6 +51,7 @@ extern struct db_base db_tvrx1; extern struct db_base db_tvrx2; extern struct db_base db_tvrx3; extern struct db_base db_dbsrx; +extern struct db_base db_bitshark_rx; struct db_base *all_dboards[] = { &db_basic_tx, @@ -73,6 +74,7 @@ struct db_base *all_dboards[] = { #endif &db_tvrx3, &db_dbsrx, + &db_bitshark_rx, 0 }; diff --git a/usrp2/firmware/lib/db_rfx.c b/usrp2/firmware/lib/db_rfx.c index 546559010..d07d3c1fb 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/lib/Makefile.am b/usrp2/host/lib/Makefile.am index cda051bb0..209cb7095 100644 --- a/usrp2/host/lib/Makefile.am +++ b/usrp2/host/lib/Makefile.am @@ -30,6 +30,8 @@ usrp2_socket_opener_SOURCES = usrp2_socket_opener.cc lib_LTLIBRARIES = \ libusrp2.la +libusrp2_la_LDFLAGS = $(LTVERSIONFLAGS) + libusrp2_la_SOURCES = \ control.cc \ copiers.cc \ diff --git a/usrp2/host/lib/usrp2.cc b/usrp2/host/lib/usrp2.cc index f0ee564be..0842482e4 100644 --- a/usrp2/host/lib/usrp2.cc +++ b/usrp2/host/lib/usrp2.cc @@ -38,9 +38,9 @@ namespace usrp2 { struct usrp_table_entry { // inteface + normalized mac addr ("eth0:01:23:45:67:89:ab") std::string key; - boost::weak_ptr<usrp2::usrp2> value; + boost::weak_ptr<usrp2> value; - usrp_table_entry(const std::string &_key, boost::weak_ptr<usrp2::usrp2> _value) + usrp_table_entry(const std::string &_key, boost::weak_ptr<usrp2> _value) : key(_key), value(_value) {} }; @@ -70,7 +70,7 @@ namespace usrp2 { // We don't have the USRP2 we're looking for // create a new one and stick it in the table. - usrp2::sptr r(new usrp2::usrp2(ifc, pr, rx_bufsize)); + usrp2::sptr r(new usrp2(ifc, pr, rx_bufsize)); usrp_table_entry t(key, r); s_table.push_back(t); diff --git a/usrp2/host/lib/usrp2_impl.cc b/usrp2/host/lib/usrp2_impl.cc index 882ad7414..333e2d1e7 100644 --- a/usrp2/host/lib/usrp2_impl.cc +++ b/usrp2/host/lib/usrp2_impl.cc @@ -25,6 +25,7 @@ #include <usrp2/copiers.h> #include <gruel/inet.h> #include <gruel/realtime.h> +#include <boost/bind.hpp> #include <usrp2_types.h> #include "usrp2_impl.h" #include "eth_buffer.h" diff --git a/usrp2/host/usrp2.pc.in b/usrp2/host/usrp2.pc.in index eaef5f41d..0c862a877 100644 --- a/usrp2/host/usrp2.pc.in +++ b/usrp2/host/usrp2.pc.in @@ -5,7 +5,7 @@ includedir=@includedir@ Name: usrp2 Description: Universal Software Radio Peripheral 2 -Requires: gnuradio-omnithread gruel -Version: @VERSION@ +Requires: gruel +Version: @LIBVER@ Libs: -L${libdir} -lusrp2 Cflags: -I${includedir} @DEFINES@ diff --git a/version.sh b/version.sh index b2cad877d..70d6d74f9 100644 --- a/version.sh +++ b/version.sh @@ -1,4 +1,4 @@ MAJOR_VERSION=3 API_COMPAT=3 -MINOR_VERSION=git -MAINT_VERSION= +MINOR_VERSION=1 +MAINT_VERSION=git diff --git a/vrt/.gitignore b/vrt/.gitignore deleted file mode 100644 index 8d802d8ff..000000000 --- a/vrt/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -Makefile -Makefile.in -vrt.pc diff --git a/vrt/Makefile.am b/vrt/Makefile.am deleted file mode 100644 index 791b8d65c..000000000 --- a/vrt/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright 2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -include $(top_srcdir)/Makefile.common - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = vrt.pc - -EXTRA_DIST = \ - vrt.pc.in - -SUBDIRS = include lib apps diff --git a/vrt/apps/.gitignore b/vrt/apps/.gitignore deleted file mode 100644 index dab7a7fd6..000000000 --- a/vrt/apps/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -Makefile -Makefile.in -.deps -.libs - diff --git a/vrt/apps/Makefile.am b/vrt/apps/Makefile.am deleted file mode 100644 index 45772055b..000000000 --- a/vrt/apps/Makefile.am +++ /dev/null @@ -1,18 +0,0 @@ -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -include $(top_srcdir)/Makefile.common diff --git a/vrt/include/Makefile.am b/vrt/include/Makefile.am deleted file mode 100644 index 3ce6a8f32..000000000 --- a/vrt/include/Makefile.am +++ /dev/null @@ -1,23 +0,0 @@ -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = vrt diff --git a/vrt/include/vrt/Makefile.am b/vrt/include/vrt/Makefile.am deleted file mode 100644 index 183eaf9ce..000000000 --- a/vrt/include/vrt/Makefile.am +++ /dev/null @@ -1,30 +0,0 @@ -# -# Copyright 2008,2009 Free Software Foundation, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -include $(top_srcdir)/Makefile.common - -INCLUDES = - -vrtincludedir = $(includedir)/vrt - -vrtinclude_HEADERS = \ - bits.h \ - copiers.h \ - expanded_header.h \ - rx.h \ - rx_packet_handler.h \ - types.h diff --git a/vrt/include/vrt/bits.h b/vrt/include/vrt/bits.h deleted file mode 100644 index 54eeec7b4..000000000 --- a/vrt/include/vrt/bits.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef INCLUDED_VRT_BITS_H -#define INCLUDED_VRT_BITS_H - -#include <stdint.h> - - -/* VRT Header bits */ - -#define VRTH_PT_MASK (0xf << 28) -#define VRTH_PT_IF_DATA_NO_SID (0x0 << 28) // IF-Data, no stream id -#define VRTH_PT_IF_DATA_WITH_SID (0x1 << 28) // IF-Data, w/ stream id -#define VRTH_PT_EXT_DATA_NO_SID (0x2 << 28) -#define VRTH_PT_EXT_DATA_WITH_SID (0x3 << 28) -#define VRTH_PT_IF_CONTEXT (0x4 << 28) -#define VRTH_PT_EXT_CONTEXT (0x5 << 28) - -#define VRTH_HAS_CLASSID (1 << 27) -#define VRTH_HAS_TRAILER (1 << 26) // Data pkts only -#define VRTH_START_OF_BURST (1 << 25) // Data (Tx) pkts only -#define VRTH_END_OF_BURST (1 << 24) // Data (Tx) pkts only -#define VRTH_TSM (1 << 24) // Context pkts only - -#define VRTH_TSI_MASK (0x3 << 22) -#define VRTH_TSI_NONE (0x0 << 22) -#define VRTH_TSI_UTC (0x1 << 22) -#define VRTH_TSI_GPS (0x2 << 22) -#define VRTH_TSI_OTHER (0x3 << 22) - -#define VRTH_TSF_MASK (0x3 << 20) -#define VRTH_TSF_NONE (0x0 << 20) -#define VRTH_TSF_SAMPLE_CNT (0x1 << 20) -#define VRTH_TSF_REAL_TIME_PS (0x2 << 20) -#define VRTH_TSF_FREE_RUNNING (0x3 << 20) - -#define VRTH_PKT_CNT_SHIFT 16 -#define VRTH_PKT_CNT_MASK (0xf << 16) - -#define VRTH_PKT_SIZE_MASK 0xffff - - -static inline int -vrth_pkt_cnt(uint32_t h) -{ - return (h & VRTH_PKT_CNT_MASK) >> 16; -} - -static inline int -vrth_pkt_size(uint32_t h) -{ - return h & VRTH_PKT_SIZE_MASK; -} - -/* - * Trailer bits - */ -#define TR_E (1 << 8) - -#define TR_ENABLE(x) ((x) << 20) -#define TR_STATE(x) ((x) << 8) - -// Use these with TR_ENABLE and TR_STATE -#define TR_CAL_TIME (1 << 11) -#define TR_VALID_DATA (1 << 10) -#define TR_REF_LOCK (1 << 9) -#define TR_AGC (1 << 8) -#define TR_DETECTED_SIG (1 << 7) -#define TR_SPECTRAL_INVERSION (1 << 6) -#define TR_OVER_RANGE (1 << 5) -#define TR_SAMPLE_LOSS (1 << 4) -#define TR_USER_3 (1 << 3) -#define TR_USER_2 (1 << 2) -#define TR_USER_1 (1 << 1) -#define TR_USER_0 (1 << 0) - -#endif /* INCLUDED_VRT_BITS_H */ diff --git a/vrt/include/vrt/copiers.h b/vrt/include/vrt/copiers.h deleted file mode 100644 index 990538c42..000000000 --- a/vrt/include/vrt/copiers.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifndef INCLUDED_VRT_COPIERS_H -#define INCLUDED_VRT_COPIERS_H - -#include <stdint.h> -#include <stddef.h> -#include <complex> - -namespace vrt { - - /*! - * \brief Copy and convert from net format to host format - */ - void - copy_net_16sc_to_host_16sc(size_t nitems, - const uint32_t *items, - std::complex<int16_t> *host_items); - - - /*! - * \brief Copy and convert from net format to host format mapping [-32768, 32767] -> [1.0, +1.0) - */ - void - copy_net_16sc_to_host_32fc(size_t nitems, - const uint32_t *items, - std::complex<float> *host_items); -}; - -#endif /* INCLUDED_VRT_COPIERS_H */ diff --git a/vrt/include/vrt/expanded_header.h b/vrt/include/vrt/expanded_header.h deleted file mode 100644 index b3333a72e..000000000 --- a/vrt/include/vrt/expanded_header.h +++ /dev/null @@ -1,112 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_VRT_EXPANDED_HEADER_H -#define INCLUDED_VRT_EXPANDED_HEADER_H - -#include <stdint.h> -#include <stddef.h> -#include <vrt/bits.h> - -namespace vrt { - - static const size_t HEADER_MAX_N32_BIT_WORDS = 7; - static const size_t TRAILER_MAX_N32_BIT_WORDS = 1; - - /*! - * \brief All headers and trailer for VRT IF-Data, Extension-Data, - * IF-Context and Extension-Context packets. - * - * There are fields allocated for each possible header. Their content may - * or may not be valid. Check the header field to confirm their validity. - * All values are in host-endian format. - */ - struct expanded_header { - uint32_t header; // first word of all packets - uint32_t stream_id; // optional stream identifier - uint64_t class_id; // optional class identifier - uint32_t integer_secs; // optional integer seconds timestamp - uint64_t fractional_secs; // optional fractional seconds timestamp - uint32_t trailer; // optional trailer (only possible in data pkts) - - expanded_header() - : header(0) /*, stream_id(0), class_id(0), - integer_secs(0), fractional_secs(0), trailer(0)*/ {} - - - int pkt_type() const { - return (header & VRTH_PT_MASK) >> 28; - } - - int pkt_cnt() const { return vrth_pkt_cnt(header); } - size_t pkt_size() const { return vrth_pkt_size(header); } - - - // packet type predicates - bool if_data_p() const { return s_if_data[pkt_type()]; } - bool ext_data_p() const { return s_ext_data[pkt_type()]; } - bool if_context_p() const { return (header & VRTH_PT_MASK) == VRTH_PT_IF_CONTEXT; } - bool ext_context_p() const { return (header & VRTH_PT_MASK) == VRTH_PT_EXT_CONTEXT; } - - bool data_p() const { return s_data[pkt_type()]; } // if_data_p() || ext_data_p() - bool context_p() const { return s_context[pkt_type()]; } // if_context_p() || ext_context_p() - - // optional info predicates - bool stream_id_p() const { return s_stream_id[pkt_type()]; } - bool class_id_p() const { return (header & VRTH_HAS_CLASSID) != 0; } - bool integer_secs_p() const { return (header & VRTH_TSI_MASK) != 0; } - bool fractional_secs_p() const { return (header & VRTH_TSF_MASK) != 0; } - bool trailer_p() const { return (header & VRTH_HAS_TRAILER) != 0 && data_p(); } - - - /*! - * \brief unparse expanded header, fill-in the words of a vrt packet header and trailer - * This method is only intended to fill the buffers with header and trailer information. - * The actual handling of the separate header, payload, trailer buffers is up to the caller. - */ - static void unparse(const expanded_header *hdr, // in - size_t n32_bit_words_payload, // in - uint32_t *header, // out - size_t *n32_bit_words_header, // out - uint32_t *trailer, // out - size_t *n32_bit_words_trailer);// out - - /*! - * \brief parse packet, fill-in expanded header, start of payload and len of payload - */ - static bool parse(const uint32_t *packet, // in - size_t n32_bit_words_packet, // in - expanded_header *hdr, // out - const uint32_t **payload, // out - size_t *n32_bit_words_payload); // out - - private: - static unsigned char s_if_data[16]; - static unsigned char s_ext_data[16]; - static unsigned char s_data[16]; - static unsigned char s_context[16]; - static unsigned char s_stream_id[16]; - - }; - -}; // vrt - - -#endif /* INCLUDED_VRT_EXPANDED_HEADER_H */ diff --git a/vrt/include/vrt/rx.h b/vrt/include/vrt/rx.h deleted file mode 100644 index ff3ce85fb..000000000 --- a/vrt/include/vrt/rx.h +++ /dev/null @@ -1,93 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_VRT_RX_H -#define INCLUDED_VRT_RX_H - -#include <boost/shared_ptr.hpp> -#include <boost/utility.hpp> -#include <vrt/rx_packet_handler.h> - -namespace vrt { - - class socket_rx_buffer; - - /*! - * Relatively low-level interface to receive VRT packets over a datagram socket. - * - * (We'll refactor this if/when we use a non-UDP transport.) - * No VRT control issues are addressed here. - */ - class rx : boost::noncopyable - { - int d_socket_fd; - socket_rx_buffer *d_srb; - - public: - /*! - * Shared pointer to this class - */ - typedef boost::shared_ptr<rx> sptr; - - /*! - * \brief Static function to return an instance of rx as a shared pointer. - * - * \param socket_fd file descriptor that data grams will be received from. - * It is assumed that some higher-level control software - * opened the appropriate UDP socket for us. This object - * assumes management of the socket's lifetime. The - * socket will be closed when our destructor fires. - * - * \param rx_bufsize is a hint as to the number of bytes of memory - * to allocate for received ethernet frames (0 -> reasonable default) - */ - static sptr make(int socket_fd, size_t rx_bufsize = 0); - - /*! - * \param socket_fd file descriptor that data grams will be received from. - * It is assumed that some higher-level control software - * opened the appropriate UDP socket for us. This object - * assumes management of the socket's lifetime. The - * socket will be closed when our destructor fires. - * - * \param rx_bufsize is a hint as to the number of bytes of memory - * to allocate for received ethernet frames (0 -> reasonable default) - */ - rx(int socket_fd, size_t rx_bufsize = 0); - ~rx(); - - /*! - * \brief Receive packets from the given socket file descriptor. - * - * \p handler will be invoked for all available packets. - * Unless \p dont_wait is true, this function blocks until at - * least one packet has been processed. - */ - bool rx_packets(rx_packet_handler *handler, bool dont_wait = false); - - /* - * \returns the socket_fd. Useful for select or poll. - */ - int socket_fd() const { return d_socket_fd; } - }; - -} - -#endif /* INCLUDED_VRT_RX_H */ diff --git a/vrt/include/vrt/rx_packet_handler.h b/vrt/include/vrt/rx_packet_handler.h deleted file mode 100644 index ad3407813..000000000 --- a/vrt/include/vrt/rx_packet_handler.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_VRT_RX_PACKET_HANDLER_H -#define INCLUDED_VRT_RX_PACKET_HANDLER_H - -#include <vrt/expanded_header.h> -#include <stddef.h> - -namespace vrt { - - /*! - * \brief Abstract function object called to handle received VRT packets. - * - * An object derived from this class is passed to vrt_rx_udp::rx_packets - * to process the received packets. - */ - class rx_packet_handler { - public: - virtual ~rx_packet_handler(); - - /*! - * \param payload points to the first 32-bit word of the payload field. - * \param n32_bit_words is the number of 32-bit words in the payload field. - * \param hdr is the expanded version of the mandatory and optional header fields (& trailer). - * - * \p payload points to the raw payload section of the packet received off - * the wire. The data is network-endian (aka big-endian) 32-bit integers. - * - * This is the general purpose, low level interface and relies on other - * functions to handle all required endian-swapping and format conversion - * of the payload. \sa FIXME. - * - * \returns true if the object wants to be called again with new data; - * false if no additional data is wanted. - */ - virtual bool operator()(const uint32_t *payload, - size_t n32_bit_words, - const expanded_header *hdr); - }; - -}; // vrt - - -#endif /* INCLUDED_VRT_RX_PACKET_HANDLER_H */ diff --git a/vrt/include/vrt/types.h b/vrt/include/vrt/types.h deleted file mode 100644 index edfa4ec37..000000000 --- a/vrt/include/vrt/types.h +++ /dev/null @@ -1,138 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ -#ifndef INCLUDED_VRT_TYPES_H -#define INCLUDED_VRT_TYPES_H - -#include <stdint.h> - -/* macros for dealing with fixed point numbers */ -#define _FXPT_C(_type, _x, _rp) ((_type)((_x)*(1ll << _rp))) -#define _FXPT_TO_INT(_x, _one) (((_x) + ((_one)/2))/(_one)) -#define _FXPT_TO_DOUBLE(_x, _one) ((double)(_x) * (1.0/(_one))) - -/*********************************************************************** - * The VRT Altitude Type (meters) - **********************************************************************/ -typedef int32_t vrt_altitude_t; -#define VRT_ALTITUDE_RP 5 -#define VRT_ALTITUDE_C(_x) _FXPT_C(vrt_altitude_t, _x, VRT_ALTITUDE_RP) - -static inline vrt_altitude_t -double_to_vrt_altitude(double num){ - return VRT_ALTITUDE_C(num); -} - -static inline int32_t -vrt_altitude_round_to_int(vrt_altitude_t fx){ - return _FXPT_TO_INT(fx, VRT_ALTITUDE_C(1)); -} - -static inline double -vrt_altitude_to_double(vrt_altitude_t fx){ - return _FXPT_TO_DOUBLE(fx, VRT_ALTITUDE_C(1)); -} - -/*********************************************************************** - * The VRT Geolocation Angle Type (degrees) - **********************************************************************/ -typedef int32_t vrt_geo_angle_t; -#define VRT_GEO_ANGLE_RP 22 -#define VRT_GEO_ANGLE_C(_x) _FXPT_C(vrt_geo_angle_t, _x, VRT_GEO_ANGLE_RP) - -static inline vrt_geo_angle_t -double_to_vrt_geo_angle(double num){ - return VRT_GEO_ANGLE_C(num); -} - -static inline int16_t -vrt_geo_angle_round_to_int(vrt_geo_angle_t fx){ - return _FXPT_TO_INT(fx, VRT_GEO_ANGLE_C(1)); -} - -static inline double -vrt_geo_angle_to_double(vrt_geo_angle_t fx){ - return _FXPT_TO_DOUBLE(fx, VRT_GEO_ANGLE_C(1)); -} - -/*********************************************************************** - * The VRT Frequency Type (Hz) - **********************************************************************/ -typedef int64_t vrt_freq_t; -#define VRT_FREQ_RP 20 -#define VRT_FREQ_C(_x) _FXPT_C(vrt_freq_t, _x, VRT_FREQ_RP) - -static inline vrt_freq_t -double_to_vrt_freq(double num){ - return VRT_FREQ_C(num); -} - -static inline int64_t -vrt_freq_round_to_int(vrt_freq_t fx){ - return _FXPT_TO_INT(fx, VRT_FREQ_C(1)); -} - -static inline double -vrt_freq_to_double(vrt_freq_t fx){ - return _FXPT_TO_DOUBLE(fx, VRT_FREQ_C(1)); -} - -/*********************************************************************** - * The VRT Gain Type (dB) - **********************************************************************/ -typedef int16_t vrt_gain_t; -#define VRT_GAIN_RP 7 -#define VRT_GAIN_C(_x) _FXPT_C(vrt_gain_t, _x, VRT_GAIN_RP) - -static inline vrt_gain_t -double_to_vrt_gain(double num){ - return VRT_GAIN_C(num); -} - -static inline int16_t -vrt_gain_round_to_int(vrt_gain_t fx){ - return _FXPT_TO_INT(fx, VRT_GAIN_C(1)); -} - -static inline double -vrt_gain_to_double(vrt_gain_t fx){ - return _FXPT_TO_DOUBLE(fx, VRT_GAIN_C(1)); -} - -/*********************************************************************** - * The VRT Temperature Type (Celcius) - **********************************************************************/ -typedef int16_t vrt_temp_t; -#define VRT_TEMP_RP 6 -#define VRT_TEMP_C(_x) _FXPT_C(vrt_temp_t, _x, VRT_TEMP_RP) - -static inline vrt_temp_t -double_to_vrt_temp(double num){ - return VRT_TEMP_C(num); -} - -static inline int16_t -vrt_temp_round_to_int(vrt_temp_t fx){ - return _FXPT_TO_INT(fx, VRT_TEMP_C(1)); -} - -static inline double -vrt_temp_to_double(vrt_temp_t fx){ - return _FXPT_TO_DOUBLE(fx, VRT_TEMP_C(1)); -} - -#endif /* INCLUDED_VRT_TYPES_H */ diff --git a/vrt/lib/.gitignore b/vrt/lib/.gitignore deleted file mode 100644 index 02b052397..000000000 --- a/vrt/lib/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -Makefile -Makefile.in -.deps -.libs diff --git a/vrt/lib/Makefile.am b/vrt/lib/Makefile.am deleted file mode 100644 index 303384c6e..000000000 --- a/vrt/lib/Makefile.am +++ /dev/null @@ -1,50 +0,0 @@ -# -# Copyright 2007,2008,2009 Free Software Foundation, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# - -include $(top_srcdir)/Makefile.common - -AM_CPPFLAGS = \ - $(VRT_INCLUDES) \ - $(BOOST_CPPFLAGS) \ - $(CPPUNIT_INCLUDES) \ - $(GRUEL_INCLUDES) - -bin_PROGRAMS = - -lib_LTLIBRARIES = \ - libvrt.la - -libvrt_la_SOURCES = \ - copiers.cc \ - data_handler.cc \ - expanded_header.cc \ - rx.cc \ - rx_packet_handler.cc \ - socket_rx_buffer.cc - -libvrt_la_LIBADD = - -# Private headers not needed for above the API development -noinst_HEADERS = \ - data_handler.h \ - expanded_header_parse_switch_body.h \ - expanded_header_unparse_switch_body.h \ - socket_rx_buffer.h - -EXTRA_DIST = \ - gen_parse_switch_body.py \ - gen_unparse_switch_body.py diff --git a/vrt/lib/copiers.cc b/vrt/lib/copiers.cc deleted file mode 100644 index ddf82abcf..000000000 --- a/vrt/lib/copiers.cc +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <vrt/copiers.h> -#include <arpa/inet.h> -#include <assert.h> -#include <string.h> - -namespace vrt { - - void - copy_net_16sc_to_host_16sc(size_t nitems, - const uint32_t *items, - std::complex<int16_t> *host_items) - { -#ifdef WORDS_BIGENDIAN - - assert(sizeof(items[0]) == sizeof(host_items[0])); - memcpy(host_items, items, nitems * sizeof(items[0])); - -#else - - // FIXME SIMD welcome here - - for (size_t i = 0; i < nitems; i++){ - uint32_t t = ntohl(items[i]); - //printf("%9d\n", items[i]); - host_items[i] = std::complex<int16_t>((t >> 16), t & 0xffff); - } - -#endif - } - - void - copy_net_16sc_to_host_32fc(size_t nitems, - const uint32_t *items, - std::complex<float> *host_items) - { - // FIXME SIMD welcome here - - for (size_t i = 0; i < nitems; i++){ - uint32_t t = ntohl(items[i]); - int16_t re = (t >> 16) & 0xffff; - int16_t im = (t & 0xffff); - host_items[i] = std::complex<float>(re * 1.0/32768, im * 1.0/32768); - } - } - -}; - diff --git a/vrt/lib/data_handler.cc b/vrt/lib/data_handler.cc deleted file mode 100644 index 7d1f73a9a..000000000 --- a/vrt/lib/data_handler.cc +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#include "data_handler.h" - -namespace vrt { - - data_handler::~data_handler() - { - // default nop destructor - } - -} - diff --git a/vrt/lib/data_handler.h b/vrt/lib/data_handler.h deleted file mode 100644 index c041e48be..000000000 --- a/vrt/lib/data_handler.h +++ /dev/null @@ -1,53 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_VRT_DATA_HANDLER_H -#define INCLUDED_VRT_DATA_HANDLER_H - -#include <stdint.h> -#include <stddef.h> - -namespace vrt { - - /*! - * \brief Abstract function object called to handle received data blocks. - */ - class data_handler - { - public: - - enum result_bits { - DONE = 0x0002, //< do not call this object again - }; - - typedef int result; //< bitmask of result_bits - - /*! - * \param base points to the beginning of the data - * \param len is the length in bytes of the data - * \returns bitmask composed of DONE - */ - virtual result operator()(const void *base, size_t len) = 0; - virtual ~data_handler(); - }; - -} // namespace vrt - -#endif /* INCLUDED_VRT_DATA_HANDLER_H */ diff --git a/vrt/lib/expanded_header.cc b/vrt/lib/expanded_header.cc deleted file mode 100644 index 8b22fb925..000000000 --- a/vrt/lib/expanded_header.cc +++ /dev/null @@ -1,135 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <vrt/expanded_header.h> -#include <gruel/inet.h> -//#include <stdio.h> - -namespace vrt { - - // lookup tables indexed by packet type - unsigned char expanded_header::s_if_data[16] = { - 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - unsigned char expanded_header::s_ext_data[16] = { - 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - unsigned char expanded_header::s_data[16] = { - 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - unsigned char expanded_header::s_context[16] = { - 0, 0, 0, 0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - unsigned char expanded_header::s_stream_id[16] = { - 0, 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 - }; - - - // dispatch codeword bits - static const int HAS_STREAM_ID = 1 << 0; - static const int HAS_CLASS_ID = 1 << 1; - static const int HAS_INTEGER_SECS = 1 << 2; - static const int HAS_FRACTIONAL_SECS = 1 << 3; - static const int HAS_TRAILER = 1 << 4; - - static int - compute_codeword(const expanded_header &h) - { - int cw = 0; - if (h.stream_id_p()) cw |= HAS_STREAM_ID; - if (h.class_id_p()) cw |= HAS_CLASS_ID; - if (h.integer_secs_p()) cw |= HAS_INTEGER_SECS; - if (h.fractional_secs_p()) cw |= HAS_FRACTIONAL_SECS; - if (h.trailer_p()) cw |= HAS_TRAILER; - return cw; - } - - void expanded_header::unparse(const expanded_header *h, // in - size_t n32_bit_words_payload, // in - uint32_t *header, // out - size_t *n32_bit_words_header, // out - uint32_t *trailer, // out - size_t *n32_bit_words_trailer){// out - int cw = compute_codeword(*h); - //fills in the header (except word0), header length, trailer, trailer length - switch (cw & 0x1f){ -#include "expanded_header_unparse_switch_body.h" - } - //fill in the header word 0 with the calculated length - size_t n32_bit_words_packet = *n32_bit_words_header + n32_bit_words_payload + *n32_bit_words_trailer; - header[0] = htonl((h->header & ~VRTH_PKT_SIZE_MASK) | (n32_bit_words_packet & VRTH_PKT_SIZE_MASK)); - } - - bool - expanded_header::parse(const uint32_t *packet, // in - size_t n32_bit_words_packet, // in - expanded_header *h, // out - const uint32_t **payload, // out - size_t *n32_bit_words_payload) // out - { - size_t n32_bit_words_header = 0; - size_t n32_bit_words_trailer = 0; - size_t len = n32_bit_words_packet; - const uint32_t *p = packet; - - *payload = 0; - *n32_bit_words_payload = 0; - - // printf("parse: n32_bit_words_packet = %zd\n", n32_bit_words_packet); - - if (len < 1){ // must have at least the header word - h->header = 0; - return false; - } - - h->header = ntohl(p[0]); - - if (h->pkt_size() > len) - return false; // VRT header says packet is bigger than what we've got - - len = h->pkt_size(); // valid length of packet - - int cw = compute_codeword(*h); - switch (cw & 0x1f){ -#include "expanded_header_parse_switch_body.h" - } - - if (n32_bit_words_header + n32_bit_words_trailer > len) - return false; // negative payload len - - *payload = p + n32_bit_words_header; - *n32_bit_words_payload = len - (n32_bit_words_header + n32_bit_words_trailer); - - // printf("parse: hdr = 0x%08x, cw = 0x%02x, n32_bit_words_header = %d, n32_bit_words_trailer = %d\n", - // h->header, cw, n32_bit_words_header, n32_bit_words_trailer); - - return true; - } - - -}; // vrt diff --git a/vrt/lib/expanded_header_parse_switch_body.h b/vrt/lib/expanded_header_parse_switch_body.h deleted file mode 100644 index 6bfaf3799..000000000 --- a/vrt/lib/expanded_header_parse_switch_body.h +++ /dev/null @@ -1,320 +0,0 @@ - case 0: - h->stream_id = 0; - h->class_id = 0; - h->integer_secs = 0; - h->fractional_secs = 0; - n32_bit_words_header = 1; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 1: - h->stream_id = ntohl(p[1]); - h->class_id = 0; - h->integer_secs = 0; - h->fractional_secs = 0; - n32_bit_words_header = 2; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 2: - h->stream_id = 0; - h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]); - h->integer_secs = 0; - h->fractional_secs = 0; - n32_bit_words_header = 3; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 3: - h->stream_id = ntohl(p[1]); - h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]); - h->integer_secs = 0; - h->fractional_secs = 0; - n32_bit_words_header = 4; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 4: - h->stream_id = 0; - h->class_id = 0; - h->integer_secs = ntohl(p[1]); - h->fractional_secs = 0; - n32_bit_words_header = 2; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 5: - h->stream_id = ntohl(p[1]); - h->class_id = 0; - h->integer_secs = ntohl(p[2]); - h->fractional_secs = 0; - n32_bit_words_header = 3; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 6: - h->stream_id = 0; - h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]); - h->integer_secs = ntohl(p[3]); - h->fractional_secs = 0; - n32_bit_words_header = 4; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 7: - h->stream_id = ntohl(p[1]); - h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]); - h->integer_secs = ntohl(p[4]); - h->fractional_secs = 0; - n32_bit_words_header = 5; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 8: - h->stream_id = 0; - h->class_id = 0; - h->integer_secs = 0; - h->fractional_secs = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]); - n32_bit_words_header = 3; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 9: - h->stream_id = ntohl(p[1]); - h->class_id = 0; - h->integer_secs = 0; - h->fractional_secs = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]); - n32_bit_words_header = 4; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 10: - h->stream_id = 0; - h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]); - h->integer_secs = 0; - h->fractional_secs = ((uint64_t)(ntohl(p[3])) << 32) | ntohl(p[4]); - n32_bit_words_header = 5; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 11: - h->stream_id = ntohl(p[1]); - h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]); - h->integer_secs = 0; - h->fractional_secs = ((uint64_t)(ntohl(p[4])) << 32) | ntohl(p[5]); - n32_bit_words_header = 6; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 12: - h->stream_id = 0; - h->class_id = 0; - h->integer_secs = ntohl(p[1]); - h->fractional_secs = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]); - n32_bit_words_header = 4; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 13: - h->stream_id = ntohl(p[1]); - h->class_id = 0; - h->integer_secs = ntohl(p[2]); - h->fractional_secs = ((uint64_t)(ntohl(p[3])) << 32) | ntohl(p[4]); - n32_bit_words_header = 5; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 14: - h->stream_id = 0; - h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]); - h->integer_secs = ntohl(p[3]); - h->fractional_secs = ((uint64_t)(ntohl(p[4])) << 32) | ntohl(p[5]); - n32_bit_words_header = 6; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 15: - h->stream_id = ntohl(p[1]); - h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]); - h->integer_secs = ntohl(p[4]); - h->fractional_secs = ((uint64_t)(ntohl(p[5])) << 32) | ntohl(p[6]); - n32_bit_words_header = 7; - h->trailer = 0; - n32_bit_words_trailer = 0; - break; - - case 16: - h->stream_id = 0; - h->class_id = 0; - h->integer_secs = 0; - h->fractional_secs = 0; - n32_bit_words_header = 1; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 17: - h->stream_id = ntohl(p[1]); - h->class_id = 0; - h->integer_secs = 0; - h->fractional_secs = 0; - n32_bit_words_header = 2; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 18: - h->stream_id = 0; - h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]); - h->integer_secs = 0; - h->fractional_secs = 0; - n32_bit_words_header = 3; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 19: - h->stream_id = ntohl(p[1]); - h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]); - h->integer_secs = 0; - h->fractional_secs = 0; - n32_bit_words_header = 4; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 20: - h->stream_id = 0; - h->class_id = 0; - h->integer_secs = ntohl(p[1]); - h->fractional_secs = 0; - n32_bit_words_header = 2; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 21: - h->stream_id = ntohl(p[1]); - h->class_id = 0; - h->integer_secs = ntohl(p[2]); - h->fractional_secs = 0; - n32_bit_words_header = 3; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 22: - h->stream_id = 0; - h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]); - h->integer_secs = ntohl(p[3]); - h->fractional_secs = 0; - n32_bit_words_header = 4; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 23: - h->stream_id = ntohl(p[1]); - h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]); - h->integer_secs = ntohl(p[4]); - h->fractional_secs = 0; - n32_bit_words_header = 5; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 24: - h->stream_id = 0; - h->class_id = 0; - h->integer_secs = 0; - h->fractional_secs = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]); - n32_bit_words_header = 3; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 25: - h->stream_id = ntohl(p[1]); - h->class_id = 0; - h->integer_secs = 0; - h->fractional_secs = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]); - n32_bit_words_header = 4; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 26: - h->stream_id = 0; - h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]); - h->integer_secs = 0; - h->fractional_secs = ((uint64_t)(ntohl(p[3])) << 32) | ntohl(p[4]); - n32_bit_words_header = 5; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 27: - h->stream_id = ntohl(p[1]); - h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]); - h->integer_secs = 0; - h->fractional_secs = ((uint64_t)(ntohl(p[4])) << 32) | ntohl(p[5]); - n32_bit_words_header = 6; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 28: - h->stream_id = 0; - h->class_id = 0; - h->integer_secs = ntohl(p[1]); - h->fractional_secs = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]); - n32_bit_words_header = 4; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 29: - h->stream_id = ntohl(p[1]); - h->class_id = 0; - h->integer_secs = ntohl(p[2]); - h->fractional_secs = ((uint64_t)(ntohl(p[3])) << 32) | ntohl(p[4]); - n32_bit_words_header = 5; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 30: - h->stream_id = 0; - h->class_id = ((uint64_t)(ntohl(p[1])) << 32) | ntohl(p[2]); - h->integer_secs = ntohl(p[3]); - h->fractional_secs = ((uint64_t)(ntohl(p[4])) << 32) | ntohl(p[5]); - n32_bit_words_header = 6; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - - case 31: - h->stream_id = ntohl(p[1]); - h->class_id = ((uint64_t)(ntohl(p[2])) << 32) | ntohl(p[3]); - h->integer_secs = ntohl(p[4]); - h->fractional_secs = ((uint64_t)(ntohl(p[5])) << 32) | ntohl(p[6]); - n32_bit_words_header = 7; - h->trailer = ntohl(p[len-1]); - n32_bit_words_trailer = 1; - break; - diff --git a/vrt/lib/expanded_header_unparse_switch_body.h b/vrt/lib/expanded_header_unparse_switch_body.h deleted file mode 100644 index ca6e14989..000000000 --- a/vrt/lib/expanded_header_unparse_switch_body.h +++ /dev/null @@ -1,272 +0,0 @@ - case 0: - *n32_bit_words_header = 1; - *n32_bit_words_trailer = 0; - break; - - case 1: - header[1] = htonl(h->stream_id); - *n32_bit_words_header = 2; - *n32_bit_words_trailer = 0; - break; - - case 2: - header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - *n32_bit_words_header = 3; - *n32_bit_words_trailer = 0; - break; - - case 3: - header[1] = htonl(h->stream_id); - header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - *n32_bit_words_header = 4; - *n32_bit_words_trailer = 0; - break; - - case 4: - header[1] = htonl(h->integer_secs); - *n32_bit_words_header = 2; - *n32_bit_words_trailer = 0; - break; - - case 5: - header[1] = htonl(h->stream_id); - header[2] = htonl(h->integer_secs); - *n32_bit_words_header = 3; - *n32_bit_words_trailer = 0; - break; - - case 6: - header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - header[3] = htonl(h->integer_secs); - *n32_bit_words_header = 4; - *n32_bit_words_trailer = 0; - break; - - case 7: - header[1] = htonl(h->stream_id); - header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - header[4] = htonl(h->integer_secs); - *n32_bit_words_header = 5; - *n32_bit_words_trailer = 0; - break; - - case 8: - header[1] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[2] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 3; - *n32_bit_words_trailer = 0; - break; - - case 9: - header[1] = htonl(h->stream_id); - header[2] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[3] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 4; - *n32_bit_words_trailer = 0; - break; - - case 10: - header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - header[3] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[4] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 5; - *n32_bit_words_trailer = 0; - break; - - case 11: - header[1] = htonl(h->stream_id); - header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - header[4] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[5] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 6; - *n32_bit_words_trailer = 0; - break; - - case 12: - header[1] = htonl(h->integer_secs); - header[2] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[3] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 4; - *n32_bit_words_trailer = 0; - break; - - case 13: - header[1] = htonl(h->stream_id); - header[2] = htonl(h->integer_secs); - header[3] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[4] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 5; - *n32_bit_words_trailer = 0; - break; - - case 14: - header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - header[3] = htonl(h->integer_secs); - header[4] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[5] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 6; - *n32_bit_words_trailer = 0; - break; - - case 15: - header[1] = htonl(h->stream_id); - header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - header[4] = htonl(h->integer_secs); - header[5] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[6] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 7; - *n32_bit_words_trailer = 0; - break; - - case 16: - *n32_bit_words_header = 1; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 17: - header[1] = htonl(h->stream_id); - *n32_bit_words_header = 2; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 18: - header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - *n32_bit_words_header = 3; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 19: - header[1] = htonl(h->stream_id); - header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - *n32_bit_words_header = 4; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 20: - header[1] = htonl(h->integer_secs); - *n32_bit_words_header = 2; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 21: - header[1] = htonl(h->stream_id); - header[2] = htonl(h->integer_secs); - *n32_bit_words_header = 3; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 22: - header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - header[3] = htonl(h->integer_secs); - *n32_bit_words_header = 4; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 23: - header[1] = htonl(h->stream_id); - header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - header[4] = htonl(h->integer_secs); - *n32_bit_words_header = 5; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 24: - header[1] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[2] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 3; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 25: - header[1] = htonl(h->stream_id); - header[2] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[3] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 4; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 26: - header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - header[3] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[4] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 5; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 27: - header[1] = htonl(h->stream_id); - header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - header[4] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[5] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 6; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 28: - header[1] = htonl(h->integer_secs); - header[2] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[3] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 4; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 29: - header[1] = htonl(h->stream_id); - header[2] = htonl(h->integer_secs); - header[3] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[4] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 5; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 30: - header[1] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[2] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - header[3] = htonl(h->integer_secs); - header[4] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[5] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 6; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - - case 31: - header[1] = htonl(h->stream_id); - header[2] = htonl((uint32_t)((h->class_id >> 32) & 0xffffffff)); - header[3] = htonl((uint32_t)((h->class_id >> 0) & 0xffffffff)); - header[4] = htonl(h->integer_secs); - header[5] = htonl((uint32_t)((h->fractional_secs >> 32) & 0xffffffff)); - header[6] = htonl((uint32_t)((h->fractional_secs >> 0) & 0xffffffff)); - *n32_bit_words_header = 7; - trailer[0] = htonl(h->trailer); - *n32_bit_words_trailer = 1; - break; - diff --git a/vrt/lib/gen_parse_switch_body.py b/vrt/lib/gen_parse_switch_body.py deleted file mode 100755 index d13e490b7..000000000 --- a/vrt/lib/gen_parse_switch_body.py +++ /dev/null @@ -1,85 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -import sys - -# dispatch codeword bits -HAS_STREAM_ID = 1 << 0; -HAS_CLASS_ID = 1 << 1; -HAS_INTEGER_SECS = 1 << 2; -HAS_FRACTIONAL_SECS = 1 << 3; -HAS_TRAILER = 1 << 4; - -def do_case(f, cw): - - def do32(name, mask, index): - f.write(" ") - if cw & mask: - f.write("h->%s = ntohl(p[%d]);\n" % (name, index)) - return 1 - else: - f.write("h->%s = 0;\n" % (name,)) - return 0 - - def do64(name, mask, index): - f.write(" ") - if cw & mask: - f.write("h->%s = ((uint64_t)(ntohl(p[%d])) << 32) | ntohl(p[%d]);\n" % (name, index, index+1)) - return 2 - else: - f.write("h->%s = 0;\n" % (name,)) - return 0 - - def dolength(index): - f.write(" n32_bit_words_header = %d;\n"%index) - - def dotrailer(name, mask): - if cw & mask: - f.write(" h->%s = ntohl(p[len-1]);\n" % (name,)) - f.write(" n32_bit_words_trailer = 1;\n") - return 1 - else: - f.write(" h->%s = 0;\n" % (name,)) - f.write(" n32_bit_words_trailer = 0;\n") - return 0 - - f.write(" case %d:\n" % (cw,)) - - index = 1 - index += do32("stream_id", HAS_STREAM_ID, index) - index += do64("class_id", HAS_CLASS_ID, index) - index += do32("integer_secs", HAS_INTEGER_SECS, index) - index += do64("fractional_secs", HAS_FRACTIONAL_SECS, index) - dolength(index) - dotrailer("trailer", HAS_TRAILER) - - f.write(" break;\n\n") - - -def main(): - f = sys.stdout - - for cw in range(32): - do_case(f, cw) - - -if __name__ == '__main__': - main() diff --git a/vrt/lib/gen_unparse_switch_body.py b/vrt/lib/gen_unparse_switch_body.py deleted file mode 100755 index 6c7cd01b3..000000000 --- a/vrt/lib/gen_unparse_switch_body.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -import sys - -# dispatch codeword bits -HAS_STREAM_ID = 1 << 0; -HAS_CLASS_ID = 1 << 1; -HAS_INTEGER_SECS = 1 << 2; -HAS_FRACTIONAL_SECS = 1 << 3; -HAS_TRAILER = 1 << 4; - -def do_case(f, cw): - - def do32(name, mask, index): - if cw & mask: - f.write(" header[%d] = htonl(h->%s);\n" % (index, name)) - return 1 - return 0 - - def do64(name, mask, index): - if cw & mask: - f.write(" header[%d] = htonl((uint32_t)((h->%s >> 32) & 0xffffffff));\n" % (index, name)) - f.write(" header[%d] = htonl((uint32_t)((h->%s >> 0) & 0xffffffff));\n" % (index+1, name)) - return 2 - return 0 - - def dolength(index): - f.write(" *n32_bit_words_header = %d;\n"%index) - - def dotrailer(name, mask): - if cw & mask: - f.write(" trailer[%d] = htonl(h->%s);\n" % (0, name)) - f.write(" *n32_bit_words_trailer = 1;\n") - return 1 - else: - f.write(" *n32_bit_words_trailer = 0;\n") - return 0 - - f.write(" case %d:\n" % (cw,)) - - index = 1 - index += do32("stream_id", HAS_STREAM_ID, index) - index += do64("class_id", HAS_CLASS_ID, index) - index += do32("integer_secs", HAS_INTEGER_SECS, index) - index += do64("fractional_secs", HAS_FRACTIONAL_SECS, index) - dolength(index) - dotrailer("trailer", HAS_TRAILER) - - f.write(" break;\n\n") - - -def main(): - f = sys.stdout - - for cw in range(32): - do_case(f, cw) - - -if __name__ == '__main__': - main() diff --git a/vrt/lib/rx.cc b/vrt/lib/rx.cc deleted file mode 100644 index 2d741e908..000000000 --- a/vrt/lib/rx.cc +++ /dev/null @@ -1,124 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <vrt/rx.h> -#include <vrt/expanded_header.h> -#include "socket_rx_buffer.h" -#include "data_handler.h" -#include <unistd.h> -#include <stdio.h> -#include <stdexcept> - -static void -print_words(FILE *fp, size_t offset, const uint32_t *buf, size_t n) -{ - size_t i; - for (i = 0; i < n; i++){ - if (i % 4 == 0){ - fprintf(fp, "%04zx:", i); - } - - putc(' ', fp); - fprintf(fp, "%08x", buf[i]); - if (i % 4 == 3) - putc('\n', fp); - } - - putc('\n', fp); -} - - - -namespace vrt { - - rx::sptr - rx::make(int socket_fd, size_t rx_bufsize) - { - return sptr(new rx(socket_fd, rx_bufsize)); - } - - rx::rx(int socket_fd, size_t rx_bufsize) - : d_socket_fd(socket_fd), - d_srb(new socket_rx_buffer(socket_fd, rx_bufsize)) - { - } - - rx::~rx() - { - delete d_srb; - ::close(d_socket_fd); - } - - - class vrt_data_handler : public data_handler - { - rx_packet_handler *d_handler; - - public: - vrt_data_handler(rx_packet_handler *handler) - : d_handler(handler){} - - ~vrt_data_handler(); - - result operator()(const void *base, size_t len); - }; - - vrt_data_handler::~vrt_data_handler(){} - - // N.B., There may be more than 1 VRT packet in a frame (usually IF-Context packets) - data_handler::result - vrt_data_handler::operator()(const void *base, size_t len) - { - const uint32_t *word_base = (const uint32_t *) base; - size_t word_len = len/(sizeof(uint32_t)); - - bool want_more = true; - while (word_len > 0 && want_more){ - const uint32_t *payload; - size_t n32_bit_words; - expanded_header hdr; - if (!expanded_header::parse(word_base, word_len, - &hdr, &payload, &n32_bit_words)){ - if (1){ - fprintf(stderr, "vrt_data_handler: malformed VRT packet!\n"); - print_words(stderr, 0, word_base, word_len); - } - return 0; - } - want_more = (*d_handler)(payload, n32_bit_words, &hdr); - word_base += hdr.pkt_size(); - word_len -= hdr.pkt_size(); - } - return !want_more ? data_handler::DONE : 0; - } - - - bool - rx::rx_packets(rx_packet_handler *handler, bool dont_wait) - { - vrt_data_handler h(handler); - socket_rx_buffer::result r = d_srb->rx_frames(&h, dont_wait ? 0 : -1); - return r == socket_rx_buffer::EB_OK || r == socket_rx_buffer::EB_WOULD_BLOCK; - } - -}; // vrt diff --git a/vrt/lib/rx_packet_handler.cc b/vrt/lib/rx_packet_handler.cc deleted file mode 100644 index 11f90278d..000000000 --- a/vrt/lib/rx_packet_handler.cc +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <vrt/rx_packet_handler.h> - -namespace vrt { - - rx_packet_handler::~rx_packet_handler(){} - - // default operator is a NOP - bool - rx_packet_handler::operator()(const uint32_t *payload, - size_t n32_bit_words, - const expanded_header *hdr) - { - return true; - } - - -}; // vrt diff --git a/vrt/lib/socket_rx_buffer.cc b/vrt/lib/socket_rx_buffer.cc deleted file mode 100644 index 6ed211b9a..000000000 --- a/vrt/lib/socket_rx_buffer.cc +++ /dev/null @@ -1,278 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include "socket_rx_buffer.h" -#include "data_handler.h" -#include <linux/if_packet.h> -#include <sys/socket.h> -#include <sys/mman.h> -#include <sys/poll.h> -#include <iostream> -#include <cmath> -#include <errno.h> -#include <stdexcept> -#include <string.h> -#include <fcntl.h> -#include <cstdio> - - -#define SOCKET_RX_BUFFER_DEBUG 1 // define to 0 or 1 -#if SOCKET_RX_BUFFER_DEBUG -#define DEBUG_LOG(x) ::write(2, (x), 1) -#else -#define DEBUG_LOG(X) -#endif - -#define DEFAULT_MEM_SIZE 62.5e6 // ~0.5s @ 125 MB/s -#define MAX_MEM_SIZE 1000e6 // ~10.00s @ 100 MB/s. -#define MAX_SLAB_SIZE 131072 // 128 KB (FIXME fish out of /proc/slabinfo) - - -namespace vrt { - - const unsigned int socket_rx_buffer::MAX_PKTLEN = 8192; - const unsigned int socket_rx_buffer::MIN_PKTLEN = 64; - - socket_rx_buffer::socket_rx_buffer(int socket_fd, size_t rx_bufsize) - : d_fd(socket_fd), d_using_tpring(false), d_buflen(0), d_buf(0), d_frame_nr(0), - d_frame_size(0), d_head(0), d_ring(0) - { - if (rx_bufsize == 0) - d_buflen = (size_t)DEFAULT_MEM_SIZE; - else - d_buflen = std::min((size_t)MAX_MEM_SIZE, rx_bufsize); - - if (!open()){ - throw std::runtime_error("socket_rx_buffer::open failed"); - } - } - - socket_rx_buffer::~socket_rx_buffer() - { - close(); - } - - bool - socket_rx_buffer::open() - { - if (try_packet_ring()){ - d_using_tpring = true; - // fprintf(stderr, "socket_rx_buffer: using memory mapped interface\n"); - } - else { - d_using_tpring = false; - // fprintf(stderr, "socket_rx_buffer: NOT using memory mapped interface\n"); - - // Increase socket buffer if possible - - int rcvbuf_size = d_buflen; -#if defined(SO_RCVBUFFORCE) - if (setsockopt(d_fd, SOL_SOCKET, SO_RCVBUFFORCE, &rcvbuf_size, sizeof(rcvbuf_size)) != 0){ - perror("setsockopt(SO_RCVBUFFORCE)"); - fprintf(stderr, "Are you running as root? If not, please do.\n"); - } - else { - fprintf(stderr, "SO_RCVBUFFORCE = %zd\n", d_buflen); - } -#endif - } - - return true; - } - - bool - socket_rx_buffer::try_packet_ring() - { - struct tpacket_req req; - size_t page_size = getpagesize(); - - // Calculate minimum power-of-two aligned size for frames - req.tp_frame_size = - (unsigned int)rint(pow(2, ceil(log2(TPACKET_ALIGN(TPACKET_HDRLEN)+TPACKET_ALIGN(MAX_PKTLEN))))); - d_frame_size = req.tp_frame_size; - - // Calculate minimum contiguous pages needed to enclose a frame - int npages = (page_size > req.tp_frame_size) ? 1 : ((req.tp_frame_size+page_size-1)/page_size); - req.tp_block_size = page_size << (int)ceil(log2(npages)); - - // Calculate number of blocks - req.tp_block_nr = (int)(d_buflen/req.tp_block_size); - - - // Recalculate buffer length - d_buflen = req.tp_block_nr*req.tp_block_size; - - // Finally, calculate total number of frames. Since frames, blocks, - // and pages are all power-of-two aligned, frames are contiguous - req.tp_frame_nr = d_buflen/req.tp_frame_size; - d_frame_nr = req.tp_frame_nr; - -#if 0 - if (SOCKET_RX_BUFFER_DEBUG) - std::cerr << "socket_rx_buffer:" - << " frame_size=" << req.tp_frame_size - << " block_size=" << req.tp_block_size - << " block_nr=" << req.tp_block_nr - << " frame_nr=" << req.tp_frame_nr - << " buflen=" << d_buflen - << std::endl; -#endif - - // Try to get kernel shared memory buffer - if (setsockopt(d_fd, SOL_PACKET, PACKET_RX_RING, (void *)&req, sizeof(req)) != 0){ - // perror("socket_rx_buffer: setsockopt"); - return false; - } - - void *p = mmap(0, d_buflen, PROT_READ|PROT_WRITE, MAP_SHARED, d_fd, 0); - if (p == MAP_FAILED){ - perror("socket_rx_buffer: mmap"); - return false; - } - d_buf = (uint8_t *) p; - - // Initialize our pointers into the packet ring - d_ring.resize(req.tp_frame_nr); - for (unsigned int i=0; i < req.tp_frame_nr; i++) - d_ring[i] = (uint8_t *)(d_buf+i*req.tp_frame_size); - - return true; - } - - bool - socket_rx_buffer::close() - { - return true; - } - - inline bool - socket_rx_buffer::frame_available() - { - return (((tpacket_hdr *)d_ring[d_head])->tp_status != TP_STATUS_KERNEL); - } - - socket_rx_buffer::result - socket_rx_buffer::rx_frames(data_handler *f, int timeout_in_ms) - { - if (!d_using_tpring){ - - // ---------------------------------------------------------------- - // Use recv instead of kernel Rx packet ring - // ---------------------------------------------------------------- - - unsigned char buf[MAX_PKTLEN]; - bool dont_wait = timeout_in_ms == 0; // FIXME treating timeout as 0 or inf - int flags = dont_wait ? MSG_DONTWAIT : 0; - - ssize_t rr = recv(d_fd, buf, sizeof(buf), flags); - if (rr == -1){ // error? - if (errno == EAGAIN){ // non-blocking, nothing there - return EB_WOULD_BLOCK; - } - perror("rx_frames: recv"); - return EB_ERROR; - } - - // Got first packet. Call handler - - data_handler::result r = (*f)(buf, rr); - if (r & data_handler::DONE) - return EB_OK; - - // Now do as many as we can without blocking - - while (1){ - rr = recv(d_fd, buf, sizeof(buf), MSG_DONTWAIT); - if (rr == -1){ // error? - if (errno == EAGAIN) // non-blocking, nothing there - return EB_OK; // return OK; we've processed >= 1 packets - perror("rx_frames: recv"); - return EB_ERROR; - } - - r = (*f)(buf, rr); - if (r & data_handler::DONE) - break; - } - return EB_OK; - } - - // ---------------------------------------------------------------- - // Use kernel Rx packet ring - // ---------------------------------------------------------------- - - DEBUG_LOG("\n"); - - while (!frame_available()) { - if (timeout_in_ms == 0) { - DEBUG_LOG("w"); - return EB_WOULD_BLOCK; - } - - struct pollfd pfd; - pfd.fd = d_fd; - pfd.revents = 0; - pfd.events = POLLIN; - - // DEBUG_LOG("P"); - - int pres = poll(&pfd, 1, timeout_in_ms); - if (pres == -1) { - perror("poll"); - return EB_ERROR; - } - - if (pres == 0) { - DEBUG_LOG("t"); - return EB_TIMED_OUT; - } - } - - // Iterate through available packets - while (frame_available()) { - // Get start of ethernet frame and length - tpacket_hdr *hdr = (tpacket_hdr *)d_ring[d_head]; - void *base = (uint8_t *)hdr+hdr->tp_mac; - size_t len = hdr->tp_len; - - if (1) - fprintf(stderr, "socket_rx_buffer: base = %p tp_mac = %3d tp_net = %3d\n", - base, hdr->tp_mac, hdr->tp_net); - - // Invoke data handler - data_handler::result r = (*f)(base, len); - hdr->tp_status = TP_STATUS_KERNEL; // mark it free - - inc_head(); - - if (r & data_handler::DONE) - break; - } - - DEBUG_LOG("|"); - return EB_OK; - } - -} // namespace vrt diff --git a/vrt/lib/socket_rx_buffer.h b/vrt/lib/socket_rx_buffer.h deleted file mode 100644 index 053c30c12..000000000 --- a/vrt/lib/socket_rx_buffer.h +++ /dev/null @@ -1,122 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_VRT_SOCKET_RX_BUFFER_H -#define INCLUDED_VRT_SOCKET_RX_BUFFER_H - -#include <boost/utility.hpp> -#include <vector> -#include <memory> -#include <stdint.h> - -namespace vrt { - - class data_handler; - - /*! - * \brief high-performance interface to receive datagrams - * - * On many systems it should be possible to implement this on top of libpcap - * - * \internal - */ - class socket_rx_buffer : boost::noncopyable - { - - int d_fd; // socket file descriptor - bool d_using_tpring; // using kernel mapped packet ring - size_t d_buflen; // length of our buffer - uint8_t *d_buf; // packet ring - unsigned int d_frame_nr; // max frames on ring - size_t d_frame_size; // frame storage size - unsigned int d_head; // pointer to next frame - - std::vector<uint8_t *> d_ring; // pointers into buffer - - bool frame_available(); - - void inc_head() - { - if (d_head + 1 >= d_frame_nr) - d_head = 0; - else - d_head = d_head + 1; - } - - bool open(); - bool close(); - bool try_packet_ring(); - - public: - - enum result { - EB_OK, //< everything's fine - EB_ERROR, //< A non-recoverable error occurred - EB_WOULD_BLOCK, //< A timeout of 0 was specified and nothing was ready - EB_TIMED_OUT, //< The timeout expired before anything was ready - }; - - static const unsigned int MAX_PKTLEN; - static const unsigned int MIN_PKTLEN; - - /*! - * \param socket_fd file descriptor that corresponds to a socket - * \param rx_bufsize is a hint as to the number of bytes of memory - * to allocate for received ethernet frames (0 -> reasonable default) - */ - socket_rx_buffer(int socket_fd, size_t rx_bufsize = 0); - ~socket_rx_buffer(); - - /*! - * \brief Call \p f for each frame in the receive buffer. - * \param f is the frame data handler - * \param timeout (in ms) controls behavior when there are no frames to read - * - * If \p timeout is 0, rx_frames will not wait for frames if none are - * available, and f will not be invoked. If \p timeout is -1 (the - * default), rx_frames will block indefinitely until frames are - * available. If \p timeout is positive, it indicates the number of - * milliseconds to wait for a frame to become available. Once the - * timeout has expired, rx_frames will return, f never having been - * invoked. - * - * \p f will be called on each frame that is available. - * \p f returns a bit mask with one of the following set or cleared: - * - * data_handler::DONE - return from rx_frames now even though more frames - * might be available; otherwise continue if more - * frames are ready. - * - * \returns EB_OK if at least one frame was received - * \returns EB_WOULD_BLOCK if \p timeout is 0 and the call would have blocked - * \returns EB_TIMED_OUT if timeout occurred - * \returns EB_ERROR if there was an unrecoverable error. - */ - result rx_frames(data_handler *f, int timeout=-1); - - /* - * \brief Returns maximum possible number of frames in buffer - */ - unsigned int max_frames() const { return d_using_tpring ? d_frame_nr : 0; } - }; - -}; // namespace vrt - -#endif /* INCLUDED_VRT_SOCKET_RX_BUFFER_H */ diff --git a/vrt/vrt.pc.in b/vrt/vrt.pc.in deleted file mode 100644 index 0f8cb938b..000000000 --- a/vrt/vrt.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: vrt -Description: Host implementation of Virtual Radio Transport (VITA-49) -Requires: -Version: @VERSION@ -Libs: -L${libdir} -lvrt -Cflags: -I${includedir} |