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
grc_gr_video_sdl.m4 \
grc_gr_wxgui.m4 \
grc_gruel.m4 \
- grc_vrt.m4 \
gr_check_createfilemapping.m4 \
gr_check_mc4020.m4 \
gr_check_shm_open.m4 \
-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
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
])
-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
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 release.
- RELEASE=$RELEASE.$MINOR_VERSION
+ 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)
])
+++ /dev/null
-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)
-])
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
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
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
GRC_GNURADIO_CORE
GRC_USRP
GRC_USRP2
-GRC_VRT
GRC_GR_USRP dnl this must come after GRC_USRP
GRC_GR_USRP2
GRC_GR_GCELL dnl this must come after GRC_GCELL and GRC_GNURADIO_CORE
--- /dev/null
+#!/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)
Name: gcell
Description: The GNU Radio SPE scheduler and RPC mechanism
Requires:
-Version: @VERSION@
+Version: @LIBVER@
Libs: -L${libdir} -lgcell
Cflags: -I${includedir} @DEFINES@
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 \
runtime/libruntime-qa.la \
wrapper/libwrapper-qa.la \
$(CPPUNIT_LIBS)
-
-
-
-
-
-
Name: gnuradio-core
Description: GNU Software Radio toolkit
Requires: gruel fftw3f gsl
-Version: @VERSION@
+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}
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
#
-# Copyright 2001,2004,2009 Free Software Foundation, Inc.
+# Copyright 2001,2004,2009,2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# 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 \
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)
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 \
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 \
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 \
#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>
%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"
+++ /dev/null
-/* -*- 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;
-}
+++ /dev/null
-/* -*- 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
+++ /dev/null
-/* -*- 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);
-};
#include <stdio.h>
#include <cassert>
#include <stdexcept>
+#include <gr_prefs.h>
boost::mutex &
reinterpret_cast<fftwf_complex *>(d_inbuf),
reinterpret_cast<fftwf_complex *>(d_outbuf),
forward ? FFTW_FORWARD : FFTW_BACKWARD,
- FFTW_MEASURE);
+ gr_prefs::singleton()->get_bool("fftw", "estimate", false) == true ? FFTW_ESTIMATE
+ : FFTW_MEASURE);
+
if (d_plan == NULL) {
fprintf(stderr, "gri_fft_complex: error creating plan\n");
d_plan = fftwf_plan_dft_r2c_1d (fft_size,
d_inbuf,
reinterpret_cast<fftwf_complex *>(d_outbuf),
- FFTW_MEASURE);
+ gr_prefs::singleton()->get_bool("fftw", "estimate", false) == true ? FFTW_ESTIMATE
+ : FFTW_MEASURE);
if (d_plan == NULL) {
fprintf(stderr, "gri_fft_real_fwd: error creating plan\n");
/* -*- 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
*
#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
#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
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 gr_udp_sink_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
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
}
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;
+}
/* -*- 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
*
#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;
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?
/* -*- c++ -*- */
/*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
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();
+
};
/* -*- 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
*
#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
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);
+
}
-void
-gr_udp_source::close()
+gr_udp_source_sptr
+gr_make_udp_source (size_t itemsize, const char *ipaddr,
+ unsigned short port, int payload_size, bool eof, bool wait)
{
- gruel::scoped_lock guard(d_mutex); // hold mutex for duration of this function
+ return gr_udp_source_sptr (new gr_udp_source (itemsize, ipaddr,
+ port, payload_size, eof, wait));
+}
+
+gr_udp_source::~gr_udp_source ()
+{
+ 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
// 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);
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);
+}
/* -*- 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
*
#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
* \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,
/* -*- c++ -*- */
/*
- * Copyright 2007 Free Software Foundation, Inc.
+ * Copyright 2007,2010 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
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();
};
#
-# 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
#
qa_unpack_k_bits.py \
qa_repeat.py \
qa_scrambler.py \
+ qa_udp_sink_source.py \
qa_vector_sink_source.py
--- /dev/null
+#!/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_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.main ()
+
#!/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
#
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
#!/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
#
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
#!/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
#
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
#!/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
#
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
# 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
except KeyboardInterrupt:
# Ctrl-C exits
pass
-
#!/usr/bin/env python
#
-# Copyright 2006 Free Software Foundation, Inc.
+# Copyright 2006,2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
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
#!/usr/bin/env python
#
-# Copyright 2006 Free Software Foundation, Inc.
+# Copyright 2006,2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
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
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}
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
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}
$(GNURADIO_CORE_LA) \
$(ALSA_LIBS)
-libgnuradio_audio_alsa_la_LDFLAGS = \
- $(NO_UNDEFINED)
+libgnuradio_audio_alsa_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS)
if PYTHON
###################################
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}
$(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
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}
$(GNURADIO_CORE_LA) \
$(OSS_LIBS)
-libgnuradio_audio_oss_la_LDFLAGS = \
- $(NO_UNDEFINED)
+libgnuradio_audio_oss_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS)
if PYTHON
###################################
-framework AudioUnit \
-framework CoreAudio \
-framework AudioToolbox \
- $(NO_UNDEFINED)
+ $(NO_UNDEFINED) \
+ $(LTVERSIONFLAGS)
if PYTHON
###################################
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}
$(GNURADIO_CORE_LA) \
$(PORTAUDIO_LIBS)
-libgnuradio_audio_portaudio_la_LDFLAGS = \
- $(NO_UNDEFINED)
+libgnuradio_audio_portaudio_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS)
if PYTHON
libgnuradio_audio_windows_la_LDFLAGS = \
$(LIBGNURADIO_CORE_EXTRA_LDFLAGS) \
- $(NO_UNDEFINED)
+ $(NO_UNDEFINED) \
+ $(LTVERSIONFLAGS)
if PYTHON
###################################
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}
$(GNURADIO_CORE_LA) \
$(COMEDI_LIBS)
-libgnuradio_comedi_la_LDFLAGS = \
- $(NO_UNDEFINED)
+libgnuradio_comedi_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS)
if PYTHON
###################################
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}
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
###################################
$(GNURADIO_CORE_LA) \
$(GCELL_LA)
-libgnuradio_gcell_la_LDFLAGS = $(NO_UNDEFINED)
+libgnuradio_gcell_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS)
if PYTHON
# ----------------------------------------------------------------
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}
$(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
# 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) \
# 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
#! /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
# Free Software Foundation, Inc.
-timestamp='2009-11-20'
+timestamp='2008-01-23'
# 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
# the same distribution terms that you use for the rest of that program.
-# Originally written by Per Bothner. Please send patches (context
-# diff format) to <config-patches@gnu.org> and include a ChangeLog
-# entry.
+# 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.
#
# 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.
#
-# 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
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
me=`echo "$0" | sed -e 's,.*/,,'`
arm*|i386|m68k|ns32k|sh3*|sparc|vax)
eval $set_cc_for_build
if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
- | grep -q __ELF__
+ | grep __ELF__ >/dev/null
then
# Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
# Return netbsd for either. FIX?
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.*:*)
- 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/[^.]*//'`
+ echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
exit ;;
sun4*:SunOS:6*:*)
# According to config.sub, this is the proper way to canonicalize
# => hppa64-hp-hpux11.23
if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
- grep -q __LP64__
+ grep __LP64__ >/dev/null
then
HP_ARCH="hppa2.0w"
else
i*:PW*:*)
echo ${UNAME_MACHINE}-pc-pw32
exit ;;
- *:Interix*:*)
+ *:Interix*:[3456]*)
case ${UNAME_MACHINE} in
x86)
echo i586-pc-interix${UNAME_RELEASE}
exit ;;
- authenticamd | genuineintel | EM64T)
+ EM64T | authenticamd)
echo x86_64-unknown-interix${UNAME_RELEASE}
exit ;;
IA64)
[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
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 \
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 ;;
m68*:Linux:*:*)
echo ${UNAME_MACHINE}-unknown-linux-gnu
exit ;;
- mips:Linux:*:* | mips64:Linux:*:*)
+ 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:*:*)
eval $set_cc_for_build
sed 's/^ //' << EOF >$dummy.c
#undef CPU
- #undef ${UNAME_MACHINE}
- #undef ${UNAME_MACHINE}el
+ #undef mips64
+ #undef mips64el
#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
- CPU=${UNAME_MACHINE}el
+ CPU=mips64el
#else
#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
- CPU=${UNAME_MACHINE}
+ CPU=mips64
#else
CPU=
#endif
#endif
EOF
- eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
+ 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; }
;;
or32:Linux:*:*)
echo or32-unknown-linux-gnu
exit ;;
- padre:Linux:*:*)
- echo sparc-unknown-linux-gnu
+ ppc:Linux:*:*)
+ echo powerpc-unknown-linux-gnu
exit ;;
- parisc64:Linux:*:* | hppa64:Linux:*:*)
- echo hppa64-unknown-linux-gnu
+ ppc64:Linux:*:*)
+ echo powerpc64-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}
exit ;;
parisc:Linux:*:* | hppa:Linux:*:*)
# Look for CPU level
*) echo hppa-unknown-linux-gnu ;;
esac
exit ;;
- ppc64:Linux:*:*)
- echo powerpc64-unknown-linux-gnu
- exit ;;
- ppc:Linux:*:*)
- echo powerpc-unknown-linux-gnu
+ parisc64:Linux:*:* | hppa64:Linux:*:*)
+ echo hppa64-unknown-linux-gnu
exit ;;
s390:Linux:*:* | s390x:Linux:*:*)
echo ${UNAME_MACHINE}-ibm-linux
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
i*86:syllable:*:*)
echo ${UNAME_MACHINE}-pc-syllable
exit ;;
- i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
echo i386-unknown-lynxos${UNAME_RELEASE}
exit ;;
i*86:*DOS:*:*)
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 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
+ # the processor, so we play safe by assuming i386.
+ echo i386-pc-msdosdjgpp
exit ;;
Intel:Mach:3*:*)
echo i386-pc-mach3
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 ;;
rs6000:LynxOS:2.*:*)
echo rs6000-unknown-lynxos${UNAME_RELEASE}
exit ;;
- PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
echo powerpc-unknown-lynxos${UNAME_RELEASE}
exit ;;
SM[BE]S:UNIX_SV:*:*)
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 ;;
*: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}
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
#! /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
# Free Software Foundation, Inc.
-timestamp='2009-11-20'
+timestamp='2008-01-16'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# Please send patches to <config-patches@gnu.org>. Submit a context
-# diff and a properly formatted GNU ChangeLog entry.
+# diff and a properly formatted 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.
case $maybe_os in
nto-qnx* | linux-gnu* | 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/'`
-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 | -microblaze)
+ -apple | -axis | -knuth | -cray)
os=
basic_machine=$1
;;
- -bluegene*)
- os=-cnk
- ;;
-sim | -cisco | -oki | -wec | -winbond)
os=
basic_machine=$1
| 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 | metag \
+ | maxq | mb | microblaze | mcore | mep \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
- | mips64octeon | mips64octeonel \
- | mips64orion | mips64orionel \
- | mips64r5900 | mips64r5900el \
| mips64vr | mips64vrel \
+ | mips64orion | mips64orionel \
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
- | moxie \
| mt \
| msp430 \
| nios | nios2 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \
- | rx \
| score \
- | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+ | sh | sh[1234] | sh[24]a | 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 \
- | ubicom32 \
| v850 | v850e \
| we32k \
| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
- | z8k | z80)
+ | z8k)
basic_machine=$basic_machine-unknown
;;
- m6811 | m68hc11 | m6812 | m68hc12 | picochip)
+ m6811 | m68hc11 | m6812 | m68hc12)
# Motorola 68HC11/12.
basic_machine=$basic_machine-unknown
os=-none
| 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-* | metag-* | microblaze-* \
+ | m88110-* | m88k-* | maxq-* | mcore-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
- | mips64octeon-* | mips64octeonel-* \
- | mips64orion-* | mips64orionel-* \
- | mips64r5900-* | mips64r5900el-* \
| mips64vr-* | mips64vrel-* \
+ | mips64orion-* | mips64orionel-* \
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
- | romp-* | rs6000-* | rx-* \
- | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
+ | romp-* | rs6000-* \
+ | sh-* | sh[1234]-* | sh[24]a-* | 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-* \
+ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tron-* \
- | ubicom32-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
| xstormy16-* | xtensa*-* \
| ymp-* \
- | z8k-* | z80-*)
+ | z8k-*)
;;
# Recognize the basic CPU types without company name, with glob match.
xtensa*)
basic_machine=m68k-apollo
os=-bsd
;;
- aros)
- basic_machine=i386-pc
- os=-aros
- ;;
aux)
basic_machine=m68k-apple
os=-aux
basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
- bluegene*)
- basic_machine=powerpc-ibm
- os=-cnk
- ;;
c90)
basic_machine=c90-cray
os=-unicos
;;
- cegcc)
- basic_machine=arm-unknown
- os=-cegcc
- ;;
convex-c1)
basic_machine=c1-convex
os=-bsd
basic_machine=m88k-motorola
os=-sysv3
;;
- dicos)
- basic_machine=i686-pc
- os=-dicos
- ;;
djgpp)
basic_machine=i586-pc
os=-msdosdjgpp
basic_machine=ns32k-utek
os=-sysv
;;
- microblaze)
- basic_machine=microblaze-xilinx
- ;;
mingw32)
basic_machine=i386-pc
os=-mingw32
basic_machine=z8k-unknown
os=-sim
;;
- z80-*-coff)
- basic_machine=z80-unknown
- os=-sim
- ;;
none)
basic_machine=none-none
os=-none
we32k)
basic_machine=we32k-att
;;
- sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
+ sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown
;;
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
# 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|'`
;;
# 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* | -cnk* | -sunos | -sunos[34]*\
- | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
- | -sym* | -kopensolaris* \
+ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
| -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
- | -aos* | -aros* \
+ | -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
- | -chorusos* | -chorusrdb* | -cegcc* \
+ | -chorusos* | -chorusrdb* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
- | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es*)
+ | -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
-zvmoe)
os=-zvmoe
;;
- -dicos*)
- os=-dicos
- ;;
-none)
;;
*)
-sunos*)
vendor=sun
;;
- -cnk*|-aix*)
+ -aix*)
vendor=ibm
;;
-beos*)
-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
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
])
-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
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 release.
- RELEASE=$RELEASE.$MINOR_VERSION
+ 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)
])
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)
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.
MAJOR_VERSION=3
API_COMPAT=3
-MINOR_VERSION=0-rc0
+MINOR_VERSION=0
MAINT_VERSION=0
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}
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
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
#################################
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 \
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}
libgnuradio_pager_la_LIBADD = \
$(GNURADIO_CORE_LA)
-libgnuradio_pager_la_LDFLAGS = \
- $(NO_UNDEFINED)
+libgnuradio_pager_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS)
#
-# Copyright 2008,2009 Free Software Foundation, Inc.
+# Copyright 2008,2009,2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
SpectrumGUIClass.cc \
spectrumUpdateEvents.cc \
plot_waterfall.cc \
- $(QMAKE_SOURCES) \
qtgui_sink_c.cc \
qtgui_sink_f.cc
qtgui_sink_c.h \
qtgui_sink_f.h
+nodist_libqtsrc_la_SOURCES = $(QMAKE_SOURCES)
+
%_moc.cc : %.h
$(QT_MOC_EXEC) -DQT_SHARED -DQT_NO_DEBUG -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_CORE_LIB -p $(srcdir) $< -o $@
$(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) \
#include <qwt_raster_data.h>
#include <qwt3d_function.h>
+#include <inttypes.h>
class Waterfall3DDisplayPlot;
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}
libgnuradio_trellis_la_LIBADD = \
$(GNURADIO_CORE_LA)
-libgnuradio_trellis_la_LDFLAGS = \
- $(NO_UNDEFINED)
-
-
+libgnuradio_trellis_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS)
if PYTHON
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}
$(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 \
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}
lib_LTLIBRARIES = libgnuradio-usrp2.la
+libgnuradio_usrp2_la_LDFLAGS = $(LTVERSIONFLAGS)
+
libgnuradio_usrp2_la_SOURCES = \
rx_16sc_handler.cc \
rx_32fc_handler.cc \
%include <usrp2/tune_result.h>
%include <usrp2/mimo_config.h>
+%include <usrp2/metadata.h>
%template(uint32_t_vector) std::vector<uint32_t>;
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);
};
// ----------------------------------------------------------------
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
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
: 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
}
{
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;
+}
const std::string &mac)
throw (std::runtime_error);
+ bool d_should_wait;
+ usrp2::fpga_timestamp d_tx_time;
+
public:
~usrp2_sink_base();
* \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 */
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}
$(SDL_LIBS) \
$(GNURADIO_CORE_LA)
-libgnuradio_video_sdl_la_LDFLAGS = \
- $(NO_UNDEFINED)
+libgnuradio_video_sdl_la_LDFLAGS = $(NO_UNDEFINED) $(LTVERSIONFLAGS)
if PYTHON
#################################
Name: gr-wxgui
Description: A simple wx gui for GNU Radio applications
Requires: gnuradio-core
-Version: @VERSION@
+Version: @LIBVER@
Libs:
Cflags:
#
-# Copyright 2008 Free Software Foundation, Inc.
+# Copyright 2008,2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
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'
#
-# Copyright 2008, 2009 Free Software Foundation, Inc.
+# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
##################################################
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
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)
)
#set sizer
self.SetSizerAndFit(control_box)
+
#mouse wheel event
def on_mouse_wheel(event):
if event.GetWheelRotation() < 0: self._on_incr_ref_level(event)
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
avg_alpha_key,
peak_hold,
msg_key,
+ use_persistence,
+ persist_alpha,
):
+
pubsub.pubsub.__init__(self)
#setup
self.samples = EMPTY_TRACE
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
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)
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.
#
-# Copyright 2008,2009 Free Software Foundation, Inc.
+# Copyright 2008,2009,2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
from gnuradio import gr, blks2
from pubsub import pubsub
from constants import *
+import math
##################################################
# FFT sink block (wrapper for old wxgui)
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,
)
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)
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
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.
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")
#!/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
#
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
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
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
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),
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,
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),
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,
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)
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)
"""
#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:
self.peak_hold = False
self.peak_vals = None
+
+ self.use_persistence=False
+ self.persist_alpha=0.2
+
self.plot.SetEnableGrid (True)
# self.SetEnableZoom (True)
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
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())
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)
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")
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,
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.
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,
#
# 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)
#
# 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
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"""
# 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= ''):
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))
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:
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
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."""
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):
# 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
#
-# Copyright 2008, 2009 Free Software Foundation, Inc.
+# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
"""
#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)
#
-# Copyright 2008, 2009 Free Software Foundation, Inc.
+# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
@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()
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.
"""
self.lock()
self._resized_flag = True
+ self.clear_accum=True
self.unlock()
def _on_paint(self, event):
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()
#
-# Copyright 2008 Free Software Foundation, Inc.
+# Copyright 2008,2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
# 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_WIN_SIZE = (600, 300)
COUPLING_MODES = (
('DC', False),
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
##################################################
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
##################################################
trigger_channel_key,
decimation_key,
msg_key,
+ use_persistence,
+ persist_alpha,
):
pubsub.pubsub.__init__(self)
#check num inputs
self[TRIGGER_MODE_KEY] = gr.gr_TRIG_MODE_AUTO
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
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
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)
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()
self.plotter.set_y_grid(self.get_y_min(), self.get_y_max(), self[Y_PER_DIV_KEY])
#redraw current sample
self.handle_samples()
+
#
-# Copyright 2008 Free Software Foundation, Inc.
+# Copyright 2008,2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
from gnuradio import gr
from pubsub import pubsub
from constants import *
+import math
class ac_couple_block(gr.hier_block2):
"""
ac_couple=False,
num_inputs=1,
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__(
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
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
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...
# 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")
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 \
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 \
<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>
<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>
--- /dev/null
+<?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>
+++ /dev/null
-<?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>
<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>
</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>
<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>
<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>
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)
<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>
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)
<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>
<option>
<name>Bool</name>
<key>bool</key>
- <opt>get:getbool</opt>
+ <opt>get:getboolean</opt>
</option>
<option>
<name>String</name>
#
-# Copyright 2008,2009 Free Software Foundation, Inc.
+# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
include $(top_srcdir)/Makefile.common
ourdatadir = $(pkgdatadir)/grc/freedesktop
-
dist_ourdata_DATA = \
grc-icon-256.png \
grc-icon-128.png \
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' $< > $@
@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"
Version=1.0
Type=Application
Name=GRC
-Exec=grc %F
+Exec=gnuradio-companion %F
Categories=Development;
MimeType=application/gnuradio-grc;
Icon=gnuradio-grc
#!/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
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"
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):
"""
@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
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)
#
-# Copyright 2008, 2009 Free Software Foundation, Inc.
+# Copyright 2008, 2009, 2010 Free Software Foundation, Inc.
#
# This file is part of GNU Radio
#
include $(top_srcdir)/Makefile.common
-dist_bin_SCRIPTS = grc usrp2_probe usrp_probe
+dist_bin_SCRIPTS = gnuradio-companion usrp2_probe usrp_probe
--- /dev/null
+#!/usr/bin/env python
+"""
+Copyright 2009 Free Software Foundation, Inc.
+This file is part of GNU Radio
+
+GNU Radio Companion 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
+of the License, or (at your option) any later version.
+
+GNU Radio Companion 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 pygtk
+pygtk.require('2.0')
+import gtk
+
+try: from gnuradio import gr
+except ImportError, e:
+ d = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE, message_format="""
+Cannot import gnuradio. Are your PYTHONPATH and LD_LIBRARY_PATH set correctly?""")
+ d.set_title(str(e))
+ d.run()
+ exit(-1)
+
+from gnuradio import gr
+from optparse import OptionParser
+
+if __name__ == "__main__":
+ usage = 'usage: %prog [options] [saved flow graphs]'
+ version = """
+GNU Radio Companion %s
+
+This program is part of GNU Radio
+GRC comes with ABSOLUTELY NO WARRANTY.
+This is free software,
+and you are welcome to redistribute it.
+"""%gr.version()
+ parser = OptionParser(usage=usage, version=version)
+ (options, args) = parser.parse_args()
+ from gnuradio.grc.python.Platform import Platform
+ from gnuradio.grc.gui.ActionHandler import ActionHandler
+ #setup icon using icon theme
+ try: gtk.window_set_default_icon(gtk.IconTheme().load_icon('gnuradio-grc', 256, 0))
+ except: pass
+ ActionHandler(args, Platform())
+
+++ /dev/null
-#!/usr/bin/env python
-"""
-Copyright 2009 Free Software Foundation, Inc.
-This file is part of GNU Radio
-
-GNU Radio Companion 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
-of the License, or (at your option) any later version.
-
-GNU Radio Companion 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 pygtk
-pygtk.require('2.0')
-import gtk
-
-try: from gnuradio import gr
-except ImportError, e:
- d = gtk.MessageDialog(type=gtk.MESSAGE_ERROR, buttons=gtk.BUTTONS_CLOSE, message_format="""
-Cannot import gnuradio. Are your PYTHONPATH and LD_LIBRARY_PATH set correctly?""")
- d.set_title(str(e))
- d.run()
- exit(-1)
-
-from gnuradio import gr
-from optparse import OptionParser
-
-if __name__ == "__main__":
- usage = 'usage: %prog [options] [saved flow graphs]'
- version = """
-GNU Radio Companion %s
-
-This program is part of GNU Radio
-GRC comes with ABSOLUTELY NO WARRANTY.
-This is free software,
-and you are welcome to redistribute it.
-"""%gr.version()
- parser = OptionParser(usage=usage, version=version)
- (options, args) = parser.parse_args()
- from gnuradio.grc.python.Platform import Platform
- from gnuradio.grc.gui.ActionHandler import ActionHandler
- #setup icon using icon theme
- try: gtk.window_set_default_icon(gtk.IconTheme().load_icon('gnuradio-grc', 256, 0))
- except: pass
- ActionHandler(args, Platform())
-
Name: gruel
Description: The GNU Radio Utility Etcetera Library
Requires:
-Version: @VERSION@
+Version: @LIBVER@
Libs: -L${libdir} -lgruel
Cflags: -I${includedir}
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)
# ----------------------------------------------------------------
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]
'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)),
}
usrpinclude_HEADERS = \
db_base.h \
db_basic.h \
+ db_bitshark_rx.h \
db_dbs_rx.h \
db_dtt754.h \
db_dtt768.h \
--- /dev/null
+/* -*- 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
//----------------------------------------------------------------------
+class _2200_common : public _AD4360_common
+{
+ public:
+ _2200_common();
+ ~_2200_common() {}
+
+ double freq_min();
+ double freq_max();
+};
+
+//----------------------------------------------------------------------
+
class _2400_common : public _AD4360_common
{
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:
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);
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();
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();
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) \
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 \
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
--- /dev/null
+//
+// 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;
+}
#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>
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)));
//----------------------------------------------------------------------
+_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()
{
//------------------------------------------------------------
+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)
{
#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
wbxng_base::~wbxng_base()
{
- if (d_common)
- delete d_common;
+}
+
+int
+wbxng_base::_refclk_divisor()
+{
+ return 1;
}
struct freq_result_t
// 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*/
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
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());
}
bool
-wbxng_base_tx::set_auto_tr(bool on)
+db_wbxng_tx::set_auto_tr(bool on)
{
bool ok = true;
if(on) {
}
bool
-wbxng_base_tx::set_enable(bool on)
+db_wbxng_tx::set_enable(bool on)
{
/*
Enable transmitter if on is true
}
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.
/**************************************************************************/
-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
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");
/*
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) {
}
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.
}
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.
}
bool
-wbxng_base_rx::set_gain(float gain)
+db_wbxng_rx::set_gain(float gain)
{
/*
Set the 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());
}
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;
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()
{
return 0.05;
}
-
bool
db_wbxng_rx::i_and_q_swapped()
{
#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 */
#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;
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{
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);
}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;
}
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;
};
/* 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);
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
+adf4350_regs::compute_register(uint8_t addr){
uint32_t data;
switch (addr){
case 0: data = (
_reg_shift(s_output_power, 3)); break;
case 5: data = (
_reg_shift(s_ld_pin_mode, 22)); break;
- default: return;
+ default: return data;
}
- /* write the data out to spi */
- d_adf4350->_write(addr, data);
+ /* return the data to write out to spi */
+ return data;
}
+
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;
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 */
"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
"XCVR2450 Tx" 0x0060
"XCVR2450 Rx" 0x0061
+"Bitshark Rx" 0x0070
+
"Experimental Tx" 0xfffe
"Experimental Rx" 0xffff
Name: usrp
Description: USRP Client Side C++ interface
Requires: @LIBUSB_PKG_CONFIG_NAME@
-Version: @VERSION@
+Version: @LIBVER@
Libs: -L${libdir} -lusrp
Cflags: -I${includedir}
txrx_xcvr_LDADD = ../lib/libu2fw_xcvr.a
+
noinst_HEADERS = \
app_common_v2.h \
app_passthru_v2.h \
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)
{
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 \
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 \
db.h \
db_base.h \
db_wbxng.h \
+ db_bitshark_rx.h \
dbsm.h \
eth_mac.h \
eth_mac_regs.h \
--- /dev/null
+/*
+ * 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;
+}
+
--- /dev/null
+/*
+ * 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 */
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,
#endif
&db_tvrx3,
&db_dbsrx,
+ &db_bitshark_rx,
0
};
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;
};
+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,
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
+#include <boost/bind.hpp>
#include <vector>
#include <complex>
#include <usrp2/rx_sample_handler.h>
lib_LTLIBRARIES = \
libusrp2.la
+libusrp2_la_LDFLAGS = $(LTVERSIONFLAGS)
+
libusrp2_la_SOURCES = \
control.cc \
copiers.cc \
Name: usrp2
Description: Universal Software Radio Peripheral 2
Requires: gruel
-Version: @VERSION@
+Version: @LIBVER@
Libs: -L${libdir} -lusrp2
Cflags: -I${includedir} @DEFINES@
MAJOR_VERSION=3
API_COMPAT=3
-MINOR_VERSION=0-rc0
-MAINT_VERSION=0
+MINOR_VERSION=1
+MAINT_VERSION=git
+++ /dev/null
-Makefile
-Makefile.in
-vrt.pc
+++ /dev/null
-#
-# 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
+++ /dev/null
-Makefile
-Makefile.in
-.deps
-.libs
-
+++ /dev/null
-#
-# 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
+++ /dev/null
-#
-# 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
+++ /dev/null
-#
-# 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
+++ /dev/null
-/* -*- 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 */
+++ /dev/null
-/* -*- 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 */
+++ /dev/null
-/* -*- 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 */
+++ /dev/null
-/* -*- 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 */
+++ /dev/null
-/* -*- 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 */
+++ /dev/null
-/* -*- 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 */
+++ /dev/null
-Makefile
-Makefile.in
-.deps
-.libs
+++ /dev/null
-#
-# 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
+++ /dev/null
-/* -*- 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);
- }
- }
-
-};
-
+++ /dev/null
-/* -*- 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
- }
-
-}
-
+++ /dev/null
-/* -*- 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 */
+++ /dev/null
-/* -*- 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
+++ /dev/null
- 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;
-
+++ /dev/null
- 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;
-
+++ /dev/null
-#!/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()
+++ /dev/null
-#!/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()
+++ /dev/null
-/* -*- 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
+++ /dev/null
-/* -*- 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
+++ /dev/null
-/* -*- 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
+++ /dev/null
-/* -*- 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 */
+++ /dev/null
-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}