diff options
48 files changed, 0 insertions, 5794 deletions
diff --git a/config/Makefile.am b/config/Makefile.am index ca655d2c1..473f88488 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -68,7 +68,6 @@ m4macros = \ gr_check_usrp.m4 \ grc_usrp.m4 \ grc_usrp2.m4 \ - grc_gr_msdd6000.m4 \ gr_doxygen.m4 \ gr_fortran.m4 \ gr_gcell.m4 \ diff --git a/config/grc_gr_msdd6000.m4 b/config/grc_gr_msdd6000.m4 deleted file mode 100644 index 0c6fc320e..000000000 --- a/config/grc_gr_msdd6000.m4 +++ /dev/null @@ -1,38 +0,0 @@ -dnl Copyright 2001,2002,2003,2004,2005,2006,2008 Free Software Foundation, Inc. -dnl -dnl This file is part of GNU Radio -dnl -dnl GNU Radio is free software; you can redistribute it and/or modify -dnl it under the terms of the GNU General Public License as published by -dnl the Free Software Foundation; either version 3, or (at your option) -dnl any later version. -dnl -dnl GNU Radio is distributed in the hope that it will be useful, -dnl but WITHOUT ANY WARRANTY; without even the implied warranty of -dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -dnl GNU General Public License for more details. -dnl -dnl You should have received a copy of the GNU General Public License -dnl along with GNU Radio; see the file COPYING. If not, write to -dnl the Free Software Foundation, Inc., 51 Franklin Street, -dnl Boston, MA 02110-1301, USA. - -AC_DEFUN([GRC_GR_MSDD6000],[ - GRC_ENABLE([gr-msdd6000]) - - AC_CONFIG_FILES([\ - gr-msdd6000/Makefile \ - gr-msdd6000/gnuradio-msdd6000.pc \ - gr-msdd6000/src/Makefile - ]) - - dnl Don't do gr-msdd6000 if gnuradio-core skipped - GRC_CHECK_DEPENDENCY(gr-msdd6000, gnuradio-core) - - AC_CHECK_HEADERS(netinet/in.h arpa/inet.h sys/socket.h netdb.h, [], [passed=no]) - - GRC_BUILD_CONDITIONAL([gr-msdd6000],[ - dnl run_tests is created from run_tests.in. Make it executable. - dnl AC_CONFIG_COMMANDS([run_tests_msdd6000], [chmod +x gr-msdd6000/src/run_tests]) - ]) -]) diff --git a/configure.ac b/configure.ac index 886d2eb7d..1d2ca6f2a 100644 --- a/configure.ac +++ b/configure.ac @@ -358,7 +358,6 @@ GRC_USRP2 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 -GRC_GR_MSDD6000 GRC_GR_AUDIO GRC_GR_ATSC GRC_GR_COMEDI diff --git a/gr-msdd6000/.gitignore b/gr-msdd6000/.gitignore deleted file mode 100644 index a37fc0c1a..000000000 --- a/gr-msdd6000/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/Makefile -/Makefile.in -/*.pc diff --git a/gr-msdd6000/Makefile.am b/gr-msdd6000/Makefile.am deleted file mode 100644 index 89405d08c..000000000 --- a/gr-msdd6000/Makefile.am +++ /dev/null @@ -1,27 +0,0 @@ -# -# Copyright 2008 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = src - -pkgconfigdir = $(libdir)/pkgconfig -dist_pkgconfig_DATA = gnuradio-msdd6000.pc diff --git a/gr-msdd6000/doc/Softronics_Ltd_msdd6000_BlockDiagram.pdf b/gr-msdd6000/doc/Softronics_Ltd_msdd6000_BlockDiagram.pdf Binary files differdeleted file mode 100644 index 34356da75..000000000 --- a/gr-msdd6000/doc/Softronics_Ltd_msdd6000_BlockDiagram.pdf +++ /dev/null diff --git a/gr-msdd6000/gnuradio-msdd6000.pc.in b/gr-msdd6000/gnuradio-msdd6000.pc.in deleted file mode 100644 index 565420718..000000000 --- a/gr-msdd6000/gnuradio-msdd6000.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: gnuradio-comedi -Description: GNU Radio blocks for the Softronics MSDD 6000 -Requires: gnuradio-core -Version: @LIBVER@ -Libs: -L${libdir} -lgnuradio-msdd6000 -Cflags: -I${includedir} diff --git a/gr-msdd6000/src/.gitignore b/gr-msdd6000/src/.gitignore deleted file mode 100644 index 3b0356f86..000000000 --- a/gr-msdd6000/src/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -/Makefile -/Makefile.in -/.libs -/.deps -/msdd.cc -/msdd.py -/msdd_rs.cc -/msdd_rs.py -/gnuradio -/guile -/python diff --git a/gr-msdd6000/src/Makefile.am b/gr-msdd6000/src/Makefile.am deleted file mode 100644 index 91173702f..000000000 --- a/gr-msdd6000/src/Makefile.am +++ /dev/null @@ -1,79 +0,0 @@ -# -# Copyright 2007,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 2, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common -include $(top_srcdir)/Makefile.swig - - -AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \ - $(WITH_INCLUDES) - -# C/C++ headers get installed in ${prefix}/include/gnuradio -grinclude_HEADERS = \ - msdd_source_simple.h \ - msdd_buffer_copy_behaviors.h \ - msdd6000.h \ - msdd_rs_source_simple.h \ - msdd6000_rs.h - -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_rs_la_SOURCES = \ - msdd_rs_source_simple.cc \ - msdd6000_rs.cc - -libgnuradio_msdd6000_la_LIBADD = \ - $(GNURADIO_CORE_LA) - -libgnuradio_msdd6000_rs_la_LIBADD = \ - $(GNURADIO_CORE_LA) - - -################################# -# SWIG interfaces and libraries - -TOP_SWIG_IFILES = \ - msdd.i msdd_rs.i - -# Install so that they end up available as: -# import gnuradio.msdd -# This ends up at: -# ${prefix}/lib/python${python_version}/site-packages/gnuradio -msdd_pythondir_category = \ - gnuradio - -msdd_rs_pythondir_category = \ - gnuradio - -# additional libraries for linking with the SWIG-generated library -msdd_la_swig_libadd = \ - libgnuradio-msdd6000.la - -msdd_rs_la_swig_libadd = \ - libgnuradio-msdd6000_rs.la diff --git a/gr-msdd6000/src/Makefile.swig.gen b/gr-msdd6000/src/Makefile.swig.gen deleted file mode 100644 index dbf137334..000000000 --- a/gr-msdd6000/src/Makefile.swig.gen +++ /dev/null @@ -1,290 +0,0 @@ -# -*- Makefile -*- -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# Makefile.swig.gen for msdd.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/msdd -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/msdd -## -## The following can be overloaded to change the install location, but -## this has to be done in the including Makefile.am -before- -## Makefile.swig is included. - -msdd_pythondir_category ?= gnuradio/msdd -msdd_pylibdir_category ?= $(msdd_pythondir_category) -msdd_pythondir = $(pythondir)/$(msdd_pythondir_category) -msdd_pylibdir = $(pyexecdir)/$(msdd_pylibdir_category) - -# The .so libraries for the guile modules get installed whereever guile -# is installed, usually /usr/lib/guile/gnuradio/ -# FIXME: determince whether these should be installed with gnuradio. -msdd_scmlibdir = $(libdir) - -# The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/msdd -# FIXME: determince whether these should be installed with gnuradio. -msdd_scmdir = $(guiledir) - -## SWIG headers are always installed into the same directory. - -msdd_swigincludedir = $(swigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -msdd_swiginclude_HEADERS = \ - msdd.i \ - $(msdd_swiginclude_headers) - -if PYTHON -msdd_pylib_LTLIBRARIES = \ - _msdd.la - -_msdd_la_SOURCES = \ - python/msdd.cc \ - $(msdd_la_swig_sources) - -msdd_python_PYTHON = \ - msdd.py \ - $(msdd_python) - -_msdd_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(msdd_la_swig_libadd) - -_msdd_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(msdd_la_swig_ldflags) - -_msdd_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(msdd_la_swig_cxxflags) - -python/msdd.cc: msdd.py -msdd.py: msdd.i - -# Include the python dependencies for this file --include python/msdd.d - -endif # end of if python - -if GUILE - -msdd_scmlib_LTLIBRARIES = \ - libguile-gnuradio-msdd.la -libguile_gnuradio_msdd_la_SOURCES = \ - guile/msdd.cc \ - $(msdd_la_swig_sources) -nobase_msdd_scm_DATA = \ - gnuradio/msdd.scm \ - gnuradio/msdd-primitive.scm -libguile_gnuradio_msdd_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(msdd_la_swig_libadd) -libguile_gnuradio_msdd_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(msdd_la_swig_ldflags) -libguile_gnuradio_msdd_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(msdd_la_swig_cxxflags) - -guile/msdd.cc: gnuradio/msdd.scm -gnuradio/msdd.scm: msdd.i -gnuradio/msdd-primitive.scm: gnuradio/msdd.scm - -# Include the guile dependencies for this file --include guile/msdd.d - -endif # end of GUILE - - -# -*- Makefile -*- -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -# Makefile.swig.gen for msdd_rs.i - -## Default install locations for these files: -## -## Default location for the Python directory is: -## ${prefix}/lib/python${python_version}/site-packages/[category]/msdd_rs -## Default location for the Python exec directory is: -## ${exec_prefix}/lib/python${python_version}/site-packages/[category]/msdd_rs -## -## The following can be overloaded to change the install location, but -## this has to be done in the including Makefile.am -before- -## Makefile.swig is included. - -msdd_rs_pythondir_category ?= gnuradio/msdd_rs -msdd_rs_pylibdir_category ?= $(msdd_rs_pythondir_category) -msdd_rs_pythondir = $(pythondir)/$(msdd_rs_pythondir_category) -msdd_rs_pylibdir = $(pyexecdir)/$(msdd_rs_pylibdir_category) - -# The .so libraries for the guile modules get installed whereever guile -# is installed, usually /usr/lib/guile/gnuradio/ -# FIXME: determince whether these should be installed with gnuradio. -msdd_rs_scmlibdir = $(libdir) - -# The scm files for the guile modules get installed where ever guile -# is installed, usually /usr/share/guile/site/msdd_rs -# FIXME: determince whether these should be installed with gnuradio. -msdd_rs_scmdir = $(guiledir) - -## SWIG headers are always installed into the same directory. - -msdd_rs_swigincludedir = $(swigincludedir) - -## This is a template file for a "generated" Makefile addition (in -## this case, "Makefile.swig.gen"). By including the top-level -## Makefile.swig, this file will be used to generate the SWIG -## dependencies. Assign the variable TOP_SWIG_FILES to be the list of -## SWIG .i files to generated wrappings for; there can be more than 1 -## so long as the names are unique (no sorting is done on the -## TOP_SWIG_FILES list). This file explicitly assumes that a SWIG .i -## file will generate .cc, .py, and possibly .h files -- meaning that -## all of these files will have the same base name (that provided for -## the SWIG .i file). -## -## This code is setup to ensure parallel MAKE ("-j" or "-jN") does the -## right thing. For more info, see < -## http://sources.redhat.com/automake/automake.html#Multiple-Outputs > - -## Other cleaned files: dependency files generated by SWIG or this Makefile - -MOSTLYCLEANFILES += $(DEPDIR)/*.S* - -## Various SWIG variables. These can be overloaded in the including -## Makefile.am by setting the variable value there, then including -## Makefile.swig . - -msdd_rs_swiginclude_HEADERS = \ - msdd_rs.i \ - $(msdd_rs_swiginclude_headers) - -if PYTHON -msdd_rs_pylib_LTLIBRARIES = \ - _msdd_rs.la - -_msdd_rs_la_SOURCES = \ - python/msdd_rs.cc \ - $(msdd_rs_la_swig_sources) - -msdd_rs_python_PYTHON = \ - msdd_rs.py \ - $(msdd_rs_python) - -_msdd_rs_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(msdd_rs_la_swig_libadd) - -_msdd_rs_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(msdd_rs_la_swig_ldflags) - -_msdd_rs_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(msdd_rs_la_swig_cxxflags) - -python/msdd_rs.cc: msdd_rs.py -msdd_rs.py: msdd_rs.i - -# Include the python dependencies for this file --include python/msdd_rs.d - -endif # end of if python - -if GUILE - -msdd_rs_scmlib_LTLIBRARIES = \ - libguile-gnuradio-msdd_rs.la -libguile_gnuradio_msdd_rs_la_SOURCES = \ - guile/msdd_rs.cc \ - $(msdd_rs_la_swig_sources) -nobase_msdd_rs_scm_DATA = \ - gnuradio/msdd_rs.scm \ - gnuradio/msdd_rs-primitive.scm -libguile_gnuradio_msdd_rs_la_LIBADD = \ - $(STD_SWIG_LA_LIB_ADD) \ - $(msdd_rs_la_swig_libadd) -libguile_gnuradio_msdd_rs_la_LDFLAGS = \ - $(STD_SWIG_LA_LD_FLAGS) \ - $(msdd_rs_la_swig_ldflags) -libguile_gnuradio_msdd_rs_la_CXXFLAGS = \ - $(STD_SWIG_CXX_FLAGS) \ - -I$(top_builddir) \ - $(msdd_rs_la_swig_cxxflags) - -guile/msdd_rs.cc: gnuradio/msdd_rs.scm -gnuradio/msdd_rs.scm: msdd_rs.i -gnuradio/msdd_rs-primitive.scm: gnuradio/msdd_rs.scm - -# Include the guile dependencies for this file --include guile/msdd_rs.d - -endif # end of GUILE - - diff --git a/gr-msdd6000/src/README b/gr-msdd6000/src/README deleted file mode 100644 index 230b7b6cf..000000000 --- a/gr-msdd6000/src/README +++ /dev/null @@ -1,34 +0,0 @@ -This block implements an interface between the Softronics MSDD6000 and GR - -Jul 13, 2008 - -Tools / Waveforms - - - - python-examples/new_msdd/fft.py - A clone of the original usrp_fft.py - adapted to work with the new msdd.source_simple - source block. - run ./new_msdd_fft.py -W - for waterfall mode. - - -GNU Radio Blocks, - - - msdd.source_simple - this block produces a stream of - interleaved complex shorts and - currently works with FAPP.LDR - - if you want complex floats, - put a gr.interleaved_short_to_complex() - block immidiately following. - - - - msdd.source_s / source_c / source_base - These were written with the - old TCP based app.ldr protocol - and will no longer work. - data was never streamed - without discontinuities - through this method. diff --git a/gr-msdd6000/src/msdd.i b/gr-msdd6000/src/msdd.i deleted file mode 100644 index 935bf2b58..000000000 --- a/gr-msdd6000/src/msdd.i +++ /dev/null @@ -1,64 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%include "gnuradio.i" // the common stuff - -%{ -#include "msdd_source_simple.h" -%} - - -GR_SWIG_BLOCK_MAGIC(msdd,source_simple) - -msdd_source_simple_sptr -msdd_make_source_simple ( - const char *src, - unsigned short port_src - ); - -class msdd_source_simple : public gr_sync_block { - protected: - msdd_source_simple( - const char *src, - unsigned short port_src - ); - - public: - ~msdd_source_c(); - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool start(); - bool stop(); - - long adc_freq(); - int decim_rate(); - gr_vector_int gain_range(); - gr_vector_float freq_range(); - - bool set_decim_rate(unsigned int); - bool set_rx_freq(int,double); - bool set_pga(int,double); - - - }; diff --git a/gr-msdd6000/src/msdd6000.cc b/gr-msdd6000/src/msdd6000.cc deleted file mode 100644 index f0a13936c..000000000 --- a/gr-msdd6000/src/msdd6000.cc +++ /dev/null @@ -1,209 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <msdd6000.h> - -#include <stdio.h> -#include <string.h> -#include <unistd.h> - -#ifdef HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif -#ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> -#endif -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif - -#define DEBUG(A) printf("=debug=> %s\n", A) - -static void -optimize_socket(int socket); - -/* - * Holds types that need autoconf help. They're here and not in the .h file because - * here we've got access to config.h - */ -class MSDD6000::detail { -public: - struct sockaddr_in d_sockaddr; -}; - - -MSDD6000::MSDD6000(char* addr) - : d_detail(new MSDD6000::detail()) -{ - d_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); - - optimize_socket(d_sock); - - - // set up remote sockaddr -// int s = inet_aton(addr, &d_adx); - d_detail->d_sockaddr.sin_family = AF_INET; - d_detail->d_sockaddr.sin_port = htons(10000); - int s = inet_aton(addr, &d_detail->d_sockaddr.sin_addr); - - // set up local sockaddr - struct in_addr d_myadx; - struct sockaddr_in d_mysockaddr; - short int port = 10010; - d_myadx.s_addr = INADDR_ANY; - d_mysockaddr.sin_family = AF_INET; - d_mysockaddr.sin_port = htons(port); - memcpy(&d_mysockaddr.sin_addr.s_addr, &d_myadx.s_addr, sizeof(in_addr)); - //d_sockaddr.sin_addr = INADDR_ANY; - s = bind(d_sock, (const sockaddr*) &d_mysockaddr, sizeof(d_mysockaddr)); - - // set default values - d_decim = 2; - d_ddc_gain = 2; - d_rf_attn = 0; - d_state = STATE_STOPPED; -} - -MSDD6000::~MSDD6000() -{ - // printf("MSDD6000::Destructing\n"); - close(d_sock); -} - - -static void -optimize_socket(int socket){ -#define BANDWIDTH 1000000000/8 -#define DELAY 0.5 - int ret; - - int sock_buf_size = static_cast<int>(2*BANDWIDTH*DELAY); - char textbuf[512]; - snprintf(textbuf, sizeof(textbuf), "%d", sock_buf_size); - printf("sock_buf_size = %d\n", sock_buf_size); - - ret = setsockopt(socket, SOL_SOCKET, SO_SNDBUF, - &sock_buf_size, sizeof(sock_buf_size)); - - ret = setsockopt(socket, SOL_SOCKET, SO_RCVBUF, - &sock_buf_size, sizeof(sock_buf_size)); - - int uid = getuid(); - if(uid!=0){ - printf(" ****** COULD NOT OPTIMIZE SYSTEM NETWORK PARAMETERS BECAUSE YOU ARE NOT RUNNING AS ROOT *******\n ****** YOUR MSDD6000 RECIEVER PERFORMANCE IS GOING TO BE TERRIBLE *******\n"); - return; - } - - - // SET UP SOME SYSTEM WIDE TCP SOCKET PARAMETERS - // FIXME seems like kind of a big hammer. Are you sure you need this? - FILE* fd = fopen("/proc/sys/net/core/netdev_max_backlog", "w"); - if (fd){ - fwrite("10000", 1, strlen("10000"), fd); - fclose(fd); - } - - fd = fopen("/proc/sys/net/core/rmem_max", "w"); - if (fd){ - fwrite(textbuf, 1, strlen(textbuf), fd); - fclose(fd); - } - - fd = fopen("/proc/sys/net/core/wmem_max", "w"); - if (fd){ - fwrite(textbuf, 1, strlen(textbuf), fd); - fclose(fd); - } - - // just incase these were rejected before because of max sizes... - - ret = setsockopt( socket, SOL_SOCKET, SO_SNDBUF, - (char *)&sock_buf_size, sizeof(sock_buf_size) ); - - ret = setsockopt( socket, SOL_SOCKET, SO_RCVBUF, - (char *)&sock_buf_size, sizeof(sock_buf_size) ); - -} - - -void MSDD6000::set_decim(int decim_pow2){ - DEBUG("SETTING NEW DECIM"); - d_decim = decim_pow2; - - if(d_state==STATE_STARTED) - send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz); -} - -void MSDD6000::set_rf_attn(int attn){ - DEBUG("SETTING NEW RF ATTN"); - d_rf_attn = attn; - if(d_state==STATE_STARTED) - send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz); -} - -void MSDD6000::set_ddc_gain(int gain){ - DEBUG("SETTING NEW DDC GAIN"); - d_ddc_gain = gain; - if(d_state==STATE_STARTED) - send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz); -} - -void MSDD6000::set_fc(int center_mhz, int offset_hz){ - DEBUG("SETTING NEW FC"); - d_fc_mhz = center_mhz; - d_offset_hz = offset_hz; - - if(d_state==STATE_STARTED) - send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz); -} - - -void MSDD6000::start(){ - send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz); - d_state = STATE_STARTED; - } - - -void MSDD6000::stop(){ - // new request with 0 decim tells it to halt - send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, 0, d_offset_hz); - d_state = STATE_STOPPED; - } - - -void MSDD6000::send_request(float freq_mhz, float rf_attn, float ddc_gain, float ddc_dec, float ddc_offset_hz){ - static char buff[512]; - sprintf(buff, "%f %f %f %f %f\n",freq_mhz, rf_attn, ddc_gain, ddc_dec, ddc_offset_hz); - printf("sending: %s\n", buff); - int flags = 0; - sendto( d_sock, buff, strlen(buff)+1, flags, - (const sockaddr*)&(d_detail->d_sockaddr), sizeof(d_detail->d_sockaddr)); - } - - -int MSDD6000::read(char* buf, int size){ - int flags = 0; - return recv(d_sock, buf, size, flags); - } - - diff --git a/gr-msdd6000/src/msdd6000.h b/gr-msdd6000/src/msdd6000.h deleted file mode 100644 index 808a8386f..000000000 --- a/gr-msdd6000/src/msdd6000.h +++ /dev/null @@ -1,45 +0,0 @@ -#ifndef MSDD6000_H -#define MSDD6000_H - -#include <boost/scoped_ptr.hpp> - -class MSDD6000 { - class detail; - - //! holds objects with system dependent types - boost::scoped_ptr<detail> d_detail; - -public: - - enum state { - STATE_STOPPED, STATE_STARTED, - }; - - MSDD6000(char* ip_addr); - ~MSDD6000(); - - void set_decim(int decim_pow2); - void set_fc(int center_mhz, int offset_hz); - void set_ddc_gain(int gain); - void set_rf_attn(int attn); - - void set_output(int mode, void* arg); - - void start(); - void stop(); - - void send_request(float,float,float,float,float); - int read(char*, int); - - int d_decim; - int d_fc_mhz; - int d_offset_hz; - int d_rf_attn; - int d_ddc_gain; - int d_sock; - state d_state; - -}; - - -#endif diff --git a/gr-msdd6000/src/msdd6000_rs.cc b/gr-msdd6000/src/msdd6000_rs.cc deleted file mode 100644 index d78f2b4da..000000000 --- a/gr-msdd6000/src/msdd6000_rs.cc +++ /dev/null @@ -1,286 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif -#include <msdd6000_rs.h> - -#include <stdio.h> -#include <string.h> -#include <unistd.h> - -#ifdef HAVE_ARPA_INET_H -#include <arpa/inet.h> -#endif -#ifdef HAVE_NETINET_IN_H -#include <netinet/in.h> -#endif -#ifdef HAVE_SYS_SOCKET_H -#include <sys/socket.h> -#endif - -#define DEBUG(A) printf("=debug=> %s\n", A) - -static void -optimize_socket(int socket); - -/* - * Holds types that need autoconf help. They're here and not in the .h file because - * here we've got access to config.h - */ -class MSDD6000_RS::detail { -public: - struct sockaddr_in d_sockaddr; -}; - - -MSDD6000_RS::MSDD6000_RS(char* addr) - : d_detail(new MSDD6000_RS::detail()) -{ - d_sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); - - optimize_socket(d_sock); - - - // set up remote sockaddr -// int s = inet_aton(addr, &d_adx); - d_detail->d_sockaddr.sin_family = AF_INET; - d_detail->d_sockaddr.sin_port = htons(10000); - int s = inet_aton(addr, &d_detail->d_sockaddr.sin_addr); - - // set up local sockaddr - struct in_addr d_myadx; - struct sockaddr_in d_mysockaddr; - short int port = 10010; - d_myadx.s_addr = INADDR_ANY; - d_mysockaddr.sin_family = AF_INET; - d_mysockaddr.sin_port = htons(port); - memcpy(&d_mysockaddr.sin_addr.s_addr, &d_myadx.s_addr, sizeof(in_addr)); - //d_sockaddr.sin_addr = INADDR_ANY; - s = bind(d_sock, (const sockaddr*) &d_mysockaddr, sizeof(d_mysockaddr)); - - // set default values - //d_decim = 2; - d_ddc_gain = 2; - d_rf_attn = 0; - d_fc_mhz = 3500; - d_offset_hz = 0; - d_ddc_gain = 0; - d_ddc_sample_rate_khz = 25600; - d_ddc_bw_khz = 25600; - d_start = 0; - d_state = STATE_STOPPED; -} - -MSDD6000_RS::~MSDD6000_RS() -{ - //printf("MSDD6000_RS::Destructing\n"); - close(d_sock); -} - - -static void -optimize_socket(int socket){ -#define BANDWIDTH 1000000000/8 -#define DELAY 0.5 - int ret; - - int sock_buf_size = static_cast<int>(2*BANDWIDTH*DELAY); - char textbuf[512]; - snprintf(textbuf, sizeof(textbuf), "%d", sock_buf_size); - printf("sock_buf_size = %d\n", sock_buf_size); - - ret = setsockopt(socket, SOL_SOCKET, SO_SNDBUF, - &sock_buf_size, sizeof(sock_buf_size)); - - ret = setsockopt(socket, SOL_SOCKET, SO_RCVBUF, - &sock_buf_size, sizeof(sock_buf_size)); - - int uid = getuid(); - if(uid!=0){ - printf(" ****** COULD NOT OPTIMIZE SYSTEM NETWORK PARAMETERS BECAUSE YOU ARE NOT RUNNING AS ROOT *******\n ****** YOUR MSDD6000_RS RECIEVER PERFORMANCE IS GOING TO BE TERRIBLE *******\n"); - return; - } - - - // SET UP SOME SYSTEM WIDE TCP SOCKET PARAMETERS - // FIXME seems like kind of a big hammer. Are you sure you need this? - FILE* fd = fopen("/proc/sys/net/core/netdev_max_backlog", "w"); - if (fd){ - fwrite("10000", 1, strlen("10000"), fd); - fclose(fd); - } - - fd = fopen("/proc/sys/net/core/rmem_max", "w"); - if (fd){ - fwrite(textbuf, 1, strlen(textbuf), fd); - fclose(fd); - } - - fd = fopen("/proc/sys/net/core/wmem_max", "w"); - if (fd){ - fwrite(textbuf, 1, strlen(textbuf), fd); - fclose(fd); - } - - // just incase these were rejected before because of max sizes... - - ret = setsockopt( socket, SOL_SOCKET, SO_SNDBUF, - (char *)&sock_buf_size, sizeof(sock_buf_size) ); - - ret = setsockopt( socket, SOL_SOCKET, SO_RCVBUF, - (char *)&sock_buf_size, sizeof(sock_buf_size) ); - -} - - -//void MSDD6000_RS::set_decim(int decim_pow2){ -// DEBUG("SETTING NEW DECIM"); -// d_decim = decim_pow2; -// -// if(d_state==STATE_STARTED) -// send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz); -//} - -void MSDD6000_RS::set_rf_attn(int attn){ - DEBUG("SETTING NEW RF ATTN"); - d_rf_attn = attn; - if(d_state==STATE_STARTED) - send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); -} - -void MSDD6000_RS::set_ddc_gain(int gain){ - DEBUG("SETTING NEW DDC GAIN"); - d_ddc_gain = gain; - if(d_state==STATE_STARTED) - send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); -} - -void MSDD6000_RS::set_fc(int center_mhz, int offset_hz){ - DEBUG("SETTING NEW FC"); - d_fc_mhz = center_mhz; - d_offset_hz = offset_hz; - - send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); -// if(d_state==STATE_STARTED) -// send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_decim, d_offset_hz); -// send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); -// -} - -void MSDD6000_RS::set_ddc_samp_rate(float sample_rate_khz){ - DEBUG("SETTING NEW SAMPLE RATE"); - d_ddc_sample_rate_khz = sample_rate_khz; - send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); -} - -void MSDD6000_RS::set_ddc_bw(float bw_khz){ - DEBUG("SETTING NEW DDC BW"); - d_ddc_bw_khz = bw_khz; - send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); -} - -void MSDD6000_RS::start(){ - send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); - return; -} - -void MSDD6000_RS::stop(){ - // new request with 0 decim tells it to halt - stop_data(); -} - - -int MSDD6000_RS::start_data(){ - d_start = 1; - send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); - d_state = STATE_STARTED; - return 0; - } - - -int MSDD6000_RS::stop_data(){ - // new request with 0 decim tells it to halt - d_start = 0; - send_request(d_fc_mhz, d_rf_attn, d_ddc_gain, d_offset_hz, d_ddc_sample_rate_khz, d_ddc_bw_khz, d_start); - d_state = STATE_STOPPED; - return 0; - } - -/* Query functions */ -float MSDD6000_RS::pull_ddc_samp_rate(){ - return d_ddc_sample_rate_khz; -} -float MSDD6000_RS::pull_ddc_bw(){ - return d_ddc_bw_khz; -} - -float MSDD6000_RS::pull_rx_freq(){ - return d_fc_mhz; -} -int MSDD6000_RS::pull_ddc_gain(){ - return d_ddc_gain; -} - -int MSDD6000_RS::pull_rf_atten(){ - return d_rf_attn; -} - - -void MSDD6000_RS::send_request(float freq_mhz, float rf_attn, float ddc_gain, float ddc_offset_hz, float ddc_samp_rate_khz, float ddc_input_bw_khz, float ddc_start){ - static char buff[512]; - // Send MSDD6000_RS control frame. - sprintf(buff, "%f %f %f %f %f %f %f\n",freq_mhz, rf_attn, ddc_gain, ddc_offset_hz, ddc_samp_rate_khz, ddc_input_bw_khz, ddc_start); //ddc_dec, ddc_offset_hz); - printf("sending: %s\n", buff); - int flags = 0; - sendto( d_sock, buff, strlen(buff)+1, flags, - (const sockaddr*)&(d_detail->d_sockaddr), sizeof(d_detail->d_sockaddr)); - } - - -int MSDD6000_RS::read(char* buf, int size){ - int flags = 0; - return recv(d_sock, buf, size, flags); - } - -int MSDD6000_RS::parse_control(char* buf, int size){ - //packet_len = sprintf(&txbuff[6], "%f %f %f %f %f %f %f",downsamp,ddc_dec_rate,ddc_step_int,ddc_step_frac,ddc_samp_rate_khz,ddc_input_bw_khz,ddc_start); - - float downsamp; - float ddc_dec_rate; - float ddc_step_int; - float ddc_step_frac; - float ddc_samp_rate_khz; - float ddc_input_bw_khz; - float ddc_start; - - sscanf(&buf[6],"%f %f %f %f %f %f %f",&downsamp,&ddc_dec_rate,&ddc_step_int,&ddc_step_frac,&ddc_samp_rate_khz,&ddc_input_bw_khz,&ddc_start); - - // pull off sample rate - d_ddc_sample_rate_khz = ddc_samp_rate_khz; - printf("Sample Rate %f\n",d_ddc_sample_rate_khz); - // pull off bw - d_ddc_bw_khz = ddc_input_bw_khz; - printf("BW %f\n", d_ddc_bw_khz); - return 0; -} - - diff --git a/gr-msdd6000/src/msdd6000_rs.h b/gr-msdd6000/src/msdd6000_rs.h deleted file mode 100644 index 4be4624be..000000000 --- a/gr-msdd6000/src/msdd6000_rs.h +++ /dev/null @@ -1,66 +0,0 @@ -#ifndef MSDD_RS__RS_6000_H -#define MSDD_RS__RS_6000_H - -#include <boost/scoped_ptr.hpp> - -class MSDD6000_RS { - class detail; - - //! holds objects with system dependent types - boost::scoped_ptr<detail> d_detail; - -public: - - enum state { - STATE_STOPPED, STATE_STARTED - }; - - MSDD6000_RS(char* ip_addr); - ~MSDD6000_RS(); - - /* set functions -- sets digitizer parameters */ - - // void set_output(int mode, void* arg); - - void set_rf_attn(int attn); - void set_ddc_gain(int gain); - void set_fc(int center_mhz, int offset_hz); - void set_ddc_samp_rate(float sample_rate_khz); - void set_ddc_bw(float bw_khz); - - void start(); - void stop(); - - /* function starts the flow of data from the digitizer */ - int start_data(); - /* function stops the flow of data from the digitizer */ - int stop_data(); - - /* query functions -- queries digitizer 'actual' parameters */ - float pull_ddc_samp_rate(); - float pull_ddc_bw(); - float pull_rx_freq(); - int pull_ddc_gain(); - int pull_rf_atten(); - - void send_request(float,float,float,float,float,float,float); - int read(char*, int); - - int parse_control(char*, int); - -private: - // parameters for a receiver object. - int d_fc_mhz; - int d_offset_hz; - int d_rf_attn; - int d_ddc_gain; - float d_ddc_sample_rate_khz; - float d_ddc_bw_khz; - int d_start; - int d_sock; - state d_state; - -}; - - -#endif diff --git a/gr-msdd6000/src/msdd_buffer_copy_behaviors.h b/gr-msdd6000/src/msdd_buffer_copy_behaviors.h deleted file mode 100644 index 398f8ae66..000000000 --- a/gr-msdd6000/src/msdd_buffer_copy_behaviors.h +++ /dev/null @@ -1,38 +0,0 @@ -#ifndef MSDD_BUFFER_COPY_BEHAVIORS_H_ -#define MSDD_BUFFER_COPY_BEHAVIORS_H_ - -namespace msdd { - - class BufferCopyBehavior - { - public: - virtual void operator() (gr_vector_void_star &a, const void * b, unsigned int output_index, unsigned int nitems) = 0; - virtual ~BufferCopyBehavior() {}; - }; - - template <class Tin, class Tout> - class BufferCopyBehaviorGeneric : public BufferCopyBehavior { - void operator() (gr_vector_void_star &a, const void * b, unsigned int output_index, unsigned int nitems) { - Tout *out(&(reinterpret_cast<Tout *>(a[0]))[output_index]); // sloppy - const Tin *in(reinterpret_cast<const Tin *>(b)); // equisloppy - - for (unsigned int i = 0; i < nitems; ++i) { - out[i] = in[i]; - } - } - }; - - template <class Tin> - class BufferCopyBehaviorComplex : public BufferCopyBehavior { - void operator() (gr_vector_void_star &a, const void * b, unsigned int output_index, unsigned int nitems) { - gr_complex *out(&(reinterpret_cast<gr_complex *>(a[0]))[output_index]); // sloppy - const Tin *in(reinterpret_cast<const Tin *>(b)); // equisloppy - - for (unsigned int i = 0; i < nitems; ++i) { - out[i] = gr_complex (in[4*i+1],in[4*i+3]); - } - } - }; -} - -#endif /*MSDD_BUFFER_COPY_BEHAVIORS_H_*/ diff --git a/gr-msdd6000/src/msdd_rs.i b/gr-msdd6000/src/msdd_rs.i deleted file mode 100644 index 8afb1fb7e..000000000 --- a/gr-msdd6000/src/msdd_rs.i +++ /dev/null @@ -1,103 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2004,2009 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNU Radio; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, - * Boston, MA 02110-1301, USA. - */ - -%include "gnuradio.i" // the common stuff - -%{ -#include "msdd_rs_source_simple.h" -%} - - -GR_SWIG_BLOCK_MAGIC(msdd_rs,source_simple) - -msdd_rs_source_simple_sptr -msdd_rs_make_source_simple ( - const char *src, - unsigned short port_src - ); - -class msdd_rs_source_simple : public gr_sync_block { - protected: - msdd_rs_source_simple( - const char *src, - unsigned short port_src - ); - - public: - ~msdd_rs_source_c(); - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - - bool start(); - bool stop(); - - /* function starts the flow of data */ - int start_data(); - - /* function stops the flow of data */ - int stop_data(); - - long pull_adc_freq(); - /* Request the current ddc sample rate */ - float pull_ddc_samp_rate(); - /* Request the current ddc bandwidth */ - float pull_ddc_bw(); - /* Request the current rx freq */ - float pull_rx_freq(); - /* Request current ddc gain */ - int pull_ddc_gain(); - /* Request current RF attenuation */ - int pull_rf_atten(); - - - /* int decim_rate(); */ - gr_vector_int gain_range(); - gr_vector_float freq_range(); - - /* Set Functions */ - /* bool set_decim_rate(unsigned int); */ - bool set_rx_freq(double); /* set_rx_freq(int,double); */ - /* bool set_pga(int,double); */ - - bool set_ddc_gain(double); - /* Set desired sample rate of MSDD6000 -- Note bounds checking is - done by the module and it will return the value actually used in the hardware. */ - bool set_ddc_samp_rate(double); - /* Set desired input BW of MSDD6000 -- Note bounds checking is - // done by the module and it will return the value actually used in the hardware. */ - bool set_ddc_bw(double); - - bool set_rf_atten(double); - - - }; - -#if SWIGGUILE -%scheme %{ -(load-extension-global "libguile-gnuradio-msdd_rs" "scm_init_gnuradio_msdd_rs_module") -%} - -%goops %{ -(use-modules (gnuradio gnuradio_core_runtime)) -%} -#endif diff --git a/gr-msdd6000/src/msdd_rs_source_simple.cc b/gr-msdd6000/src/msdd_rs_source_simple.cc deleted file mode 100644 index 70e692d83..000000000 --- a/gr-msdd6000/src/msdd_rs_source_simple.cc +++ /dev/null @@ -1,240 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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 <msdd_rs_source_simple.h> -#include <gr_io_signature.h> -#include <string.h> -#include <cstdio> - - -msdd_rs_source_simple_sptr -msdd_rs_make_source_simple ( const char *src, unsigned short port_src) -{ - return gnuradio::get_initial_sptr(new msdd_rs_source_simple ( src, port_src)); -} - - -msdd_rs_source_simple::msdd_rs_source_simple ( - const char *src, - unsigned short port_src) - : gr_sync_block("MSDD_RS_SOURCE_SIMPLE", - gr_make_io_signature (0,0,0), - gr_make_io_signature (1, 1, sizeof (short))), - rcv(new MSDD6000_RS((char*) src)), d_lastseq(0) -{ -} - -msdd_rs_source_simple::~msdd_rs_source_simple () -{ -} - - -int -msdd_rs_source_simple::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - -#define BUF_LEN (366*sizeof(short)*2 + 6) - - float* out1 =(float*) output_items[0]; - - char buffer[BUF_LEN]; - /* Read a buffer out -- looking at UDP payload at this point.*/ - rcv->read( &buffer[0], BUF_LEN ); - - //int seq = *((int*) &buffer[2]); - int seq; - memcpy(&seq, &buffer[2], 4*sizeof(char)); - - char type = buffer[0]; - //printf("Sequence %d\n",seq); - - // FIXME get rid of these magic 366's! - if(d_lastseq == -366) - { - if (type != 0){ - /* Received control packet -- parse and update locally stored parameters */ - printf("Parsing control Packet\n"); - rcv->parse_control(&buffer[0], seq); - } - else{ - // not started case - if(seq == 0){ - d_lastseq = 0; - } - else - { - // THROW AWAY SAMPLES WE ARE NOT STARTED YET! - return 0; - } - } - } - // Started case - else - { - if (type != 0){ - /* Received control packet -- parse and update locally stored parameters */ - printf("Parsing control Packet\n"); - rcv->parse_control(&buffer[0], seq); - } - - else { - int samples_missed = seq - d_lastseq - 366; - if(samples_missed > 0) - { - printf("dropped %d samples.\n", samples_missed); - } - d_lastseq = seq; - } - } - - if(noutput_items< 366*2){ - printf("NOT ENOUGH SPACE IN OUTPUT BUFFER!!! >:-(\n"); - } - - memcpy(&out1[0], &buffer[6], BUF_LEN - 6); - -// for(int i = 0; i < 366*2; i++){ -// out1[i] = (float) (*((short*) &buffer[6+2*i]) ); -// } - - return 366*2; -} - -//bool msdd_rs_source_simple::set_decim_rate(unsigned int rate) -//{ -// // FIXME seems buggy. How about a floor or ceil? -// rcv->set_decim((int) log2(rate)); -// return true; -//} - -bool msdd_rs_source_simple::set_rx_freq(double freq) -{ - long new_fc = (long)freq; - rcv->set_fc( new_fc/1000000, new_fc%1000000); - return true; -} - - -bool msdd_rs_source_simple::set_ddc_gain(double gain) -{ - if(gain < 0 || gain > 7){ // only 3 bits available. - printf("GAIN IS OUTSIDE ACCEPTABLE RANGE!\n"); - return false; - } - //decimation gain - rcv->set_ddc_gain((int)gain); - return true; -} - -// Set desired sample rate of MSDD6000 -- Note bounds checking is -// done by the module and it will return the value actually used in the hardware. -bool msdd_rs_source_simple::set_ddc_samp_rate(double rate) -{ - rcv->set_ddc_samp_rate((float) rate); - return true; -} - -// Set desired input BW of MSDD6000 -- Note bounds checking is -// done by the module and it will return the value actually used in the hardware. -bool msdd_rs_source_simple::set_ddc_bw(double bw) -{ - rcv->set_ddc_bw((float) bw); - return true; -} - -bool msdd_rs_source_simple::set_rf_atten(double rf_atten) -{ - rcv->set_rf_attn((int) rf_atten); - return true; -} - -bool msdd_rs_source_simple::start() -{ - rcv->start(); - rcv->stop_data(); - return true; -} - -bool msdd_rs_source_simple::stop() -{ - rcv->stop(); - return true; -} - -int msdd_rs_source_simple::start_data() -{ - return rcv->start_data(); -} - -int msdd_rs_source_simple::stop_data() -{ - return rcv->stop_data(); -} - -/* Query functions */ -long msdd_rs_source_simple::pull_adc_freq(){ - return 102400000; -} - -/* Request the current ddc sample rate */ -float msdd_rs_source_simple::pull_ddc_samp_rate(){ - return(rcv->pull_ddc_samp_rate()); -} - -/* Request the current ddc bandwidth */ -float msdd_rs_source_simple::pull_ddc_bw(){ - return(rcv->pull_ddc_bw()); - -} - -/* Request the current rx freq */ -float msdd_rs_source_simple::pull_rx_freq(){ - return(rcv->pull_rx_freq()); -} - -/* Request current ddc gain */ -int msdd_rs_source_simple::pull_ddc_gain(){ - return(rcv->pull_ddc_gain()); -} - -/* Request current RF attenuation */ -int msdd_rs_source_simple::pull_rf_atten(){ - return(rcv->pull_rf_atten()); -} - -std::vector<int> msdd_rs_source_simple::gain_range(){ - static std::vector<int> r; - r.push_back(0); - r.push_back(12); - return r; -} - -std::vector<float> msdd_rs_source_simple::freq_range(){ - std::vector<float> r; - r.push_back(30.0*1000*1000); - r.push_back(6.0*1000*1000*1000); - return r; -} diff --git a/gr-msdd6000/src/msdd_rs_source_simple.h b/gr-msdd6000/src/msdd_rs_source_simple.h deleted file mode 100644 index f320cbb4d..000000000 --- a/gr-msdd6000/src/msdd_rs_source_simple.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MSDD_RS_SOURCE_SIMPLE_H -#define INCLUDED_MSDD_RS_SOURCE_SIMPLE_H - -#include <gr_sync_block.h> -#include <msdd6000_rs.h> -#include <boost/scoped_ptr.hpp> - -class msdd_rs_source_simple; -typedef boost::shared_ptr<msdd_rs_source_simple> msdd_rs_source_simple_sptr; - - -// public shared_ptr constructor - -msdd_rs_source_simple_sptr msdd_rs_make_source_simple ( const char *src, unsigned short port_src); - - -class msdd_rs_source_simple : public gr_sync_block { - private: - friend msdd_rs_source_simple_sptr - msdd_rs_make_source_simple ( const char *src, unsigned short port_src); - - boost::scoped_ptr<MSDD6000_RS> rcv; - int d_lastseq; - - protected: - msdd_rs_source_simple (const char *src, unsigned short port_src); - - public: - ~msdd_rs_source_simple (); - bool stop(); - bool start(); - - /* function starts the flow of data from the digitizer */ - int start_data(); - /* function stops the flow of data from the digitizer */ - int stop_data(); - - // Do not need this // -// bool set_decim_rate(unsigned int); - /* Adding functions for setting the sample rate and - * receiver bandwidth - */ - - /* hardware commands -- change current state of digitizer */ - bool set_ddc_samp_rate(double); - bool set_ddc_bw(double); - - bool set_rx_freq(double); - bool set_ddc_gain(double); - bool set_rf_atten(double); - - int work(int, gr_vector_const_void_star&, gr_vector_void_star&); - - /* Query methods -- query current state of digitizer */ - long pull_adc_freq(); - float pull_ddc_samp_rate(); - float pull_ddc_bw(); - float pull_rx_freq(); - int pull_ddc_gain(); - int pull_rf_atten(); - - /* Pulling back gain and frequency ranges */ - std::vector<int> gain_range(); - std::vector<float> freq_range(); -}; - -#endif /* INCLUDED_MSDD_RS__RS__SOURCE_C_H */ diff --git a/gr-msdd6000/src/msdd_source_simple.cc b/gr-msdd6000/src/msdd_source_simple.cc deleted file mode 100644 index 20b15c43d..000000000 --- a/gr-msdd6000/src/msdd_source_simple.cc +++ /dev/null @@ -1,168 +0,0 @@ -/* -*- c++ -*- */ -/* - * 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 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 <msdd_source_simple.h> -#include <gr_io_signature.h> -#include <string.h> -#include <cstdio> - - -msdd_source_simple_sptr -msdd_make_source_simple (const char *src, unsigned short port_src) -{ - return gnuradio::get_initial_sptr(new msdd_source_simple ( src, port_src)); -} - - -msdd_source_simple::msdd_source_simple (const char *src, - unsigned short port_src) - : gr_sync_block("MSDD_SOURCE_SIMPLE", - gr_make_io_signature (0,0,0), - gr_make_io_signature (1, 1, sizeof (short))), - rcv(new MSDD6000((char*) src)), d_lastseq(0), d_firstrun(true) -{ - set_output_multiple(MSDD_COMPLEX_SAMPLES_PER_PACKET*2); -} - -msdd_source_simple::~msdd_source_simple () -{ -} - - -int -msdd_source_simple::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) -{ - -#define BUF_LEN (MSDD_COMPLEX_SAMPLES_PER_PACKET*sizeof(short)*2 + 6) - - signed short* out1 =(signed short*) output_items[0]; - - for(int i=0; i<floor(noutput_items*1.0/(2*MSDD_COMPLEX_SAMPLES_PER_PACKET));i++){ - char buffer[BUF_LEN]; - rcv->read( &buffer[0], BUF_LEN ); - - //int seq = *((int*) &buffer[2]); - int seq; - memcpy(&seq, &buffer[2], 4*sizeof(char)); - - if(d_lastseq == -MSDD_COMPLEX_SAMPLES_PER_PACKET){ - // not started case - if(seq == 0){ - d_lastseq = 0; - } else { - // THROW AWAY SAMPLES WE ARE NOT STARTED YET! - return 0; - } - - } else { - // started case - int samples_missed = seq - d_lastseq - MSDD_COMPLEX_SAMPLES_PER_PACKET; - if(samples_missed > 0){ - if(d_firstrun == true){ - // we may have missed some initial samples off the beginning of - // a stream but there are no drop outs in the middle of what we have - } else { - printf("dropped %d samples.\n", samples_missed); - } - } - d_lastseq = seq; - } - - int out_idx = i*MSDD_COMPLEX_SAMPLES_PER_PACKET*2; - memcpy(&out1[out_idx], &buffer[6], BUF_LEN - 6); - d_firstrun = false; - } - - return noutput_items; - -} - -bool msdd_source_simple::set_decim_rate(unsigned int rate) -{ - rcv->set_decim((int) floor(log2(rate))); - return true; -} - - -bool msdd_source_simple::set_rx_freq(int channel, double freq) -{ - long new_fc = (long)freq; - rcv->set_fc( new_fc/1000000, new_fc%1000000); - return true; -} - - -bool msdd_source_simple::set_pga(int which, double gain) -{ - if(gain < 0 || gain > 10){ - printf("GAIN IS OUTSIDE ACCEPTABLE RANGE!\n"); - return false; - } - // ok i lied this is not really a pga, its decimation gain - rcv->set_ddc_gain((int)gain); - return true; -} - - -bool msdd_source_simple::start() -{ - rcv->start(); - return true; -} - - -bool msdd_source_simple::stop() -{ - rcv->stop(); - return true; -} - -long msdd_source_simple::adc_freq() -{ - return 102400000; -} - -int msdd_source_simple::decim_rate() -{ - return 1 << rcv->d_decim; -} - - -std::vector<int> msdd_source_simple::gain_range() -{ - static std::vector<int> r; - r.push_back(0); - r.push_back(12); - return r; -} - -std::vector<float> msdd_source_simple::freq_range() -{ - std::vector<float> r; - r.push_back(30.0*1000*1000); - r.push_back(6.0*1000*1000*1000); - return r; -} diff --git a/gr-msdd6000/src/msdd_source_simple.h b/gr-msdd6000/src/msdd_source_simple.h deleted file mode 100644 index 142c544a4..000000000 --- a/gr-msdd6000/src/msdd_source_simple.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2008 Free Software Foundation, Inc. - * - * This file is part of GNU Radio - * - * GNU Radio is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3, or (at your option) - * any later version. - * - * GNU Radio is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - */ -#ifndef INCLUDED_MSDD_SOURCE_SIMPLE_H -#define INCLUDED_MSDD_SOURCE_SIMPLE_H - -#include <gr_sync_block.h> -#include <msdd6000.h> -#include <boost/scoped_ptr.hpp> - -#define MSDD_COMPLEX_SAMPLES_PER_PACKET 366 - -class msdd_source_simple; -typedef boost::shared_ptr<msdd_source_simple> msdd_source_simple_sptr; - - -// public shared_ptr constructor - -msdd_source_simple_sptr msdd_make_source_simple(const char *src, unsigned short port_src); - - -class msdd_source_simple : public gr_sync_block { - private: - friend msdd_source_simple_sptr - msdd_make_source_simple(const char *src, unsigned short port_src); - - boost::scoped_ptr<MSDD6000> rcv; - int d_lastseq; - bool d_firstrun; - - protected: - msdd_source_simple(const char *src, unsigned short port_src); - - public: - ~msdd_source_simple(); - bool stop(); - bool start(); - - bool set_decim_rate(unsigned int); - bool set_rx_freq(int,double); - bool set_pga(int,double); - - int work(int, gr_vector_const_void_star&, gr_vector_void_star&); - - long adc_freq(); - int decim_rate(); - std::vector<int> gain_range(); - std::vector<float> freq_range(); -}; - -#endif /* INCLUDED_MSDD_SOURCE_C_H */ diff --git a/gr-msdd6000/src/python-examples/msdd_dynamics.py b/gr-msdd6000/src/python-examples/msdd_dynamics.py deleted file mode 100755 index 8cd1e52bc..000000000 --- a/gr-msdd6000/src/python-examples/msdd_dynamics.py +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2008 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr -from gnuradio import msdd -from gnuradio.eng_option import eng_option -from optparse import OptionParser -import time - -class benchmark_msdd6000(gr.top_block): - def __init__(self, address, options): - gr.top_block.__init__(self) - - # Extract the initial options - self.frequency = options.frequency - self.filename = options.filename - self.decim = options.decim - self.gain = options.gain - self.address = address - - # Set up and initialize the MSDD receiver - self.port = 10001 # required port - self.src = msdd.source_c(0, 1, self.address, self.port) - self.src.set_decim_rate(self.decim) - self.src.set_desired_packet_size(0, 1460) - self.src.set_pga(0, self.gain) - self.src.set_rx_freq(0, self.frequency) - - # Display some info - print "Min PGA: ", self.src.pga_min() - print "Max PGA: ", self.src.pga_max() - print "PGA: ", self.src.pga(0) - print "Decim: ", self.src.decim_rate() - print "Freq: ", self.src.rx_freq(0) - - # Build a file sink to save the info for post analysis - self.snk = gr.file_sink(gr.sizeof_gr_complex, self.filename) - - # Connect the reciever source to file sink - self.connect(self.src, self.snk) - -def main(): - ''' This is a simple little script to play with retunning of the MSDD board. - You can cycle through frequencies or the attenuation of the board here. - ''' - - usage="%prog: [options] host_address" - parser = OptionParser(usage=usage, option_class=eng_option, conflict_handler="resolve") - parser.add_option("-f", "--frequency", type="eng_float", default=100e6, - help="set frequency (Hz) [default=%default]") - parser.add_option("-d", "--decim", type="int", default=256, - help="set decimation rate [default=%default]") - parser.add_option("-g", "--gain", type="int", default=32, - help="set receiver gain (dB) [default=%default]") - parser.add_option("-F", "--filename", type="string", default="output.dat", - help="set output filename [default=%default]") - (options, args) = parser.parse_args () - host_address = args[0] - - # Set up benchmark system that simply connects the MSDD source to a file sink - tb = benchmark_msdd6000(host_address, options) - tb.start() # start it here - - # Adjust your parameters here. Use the time.sleep(x) function to set a wait period - # between adjusting the parameter. - for i in range(7): - time.sleep(0.5) - if 0: - freq = (tb.src.rx_freq(0) + 1) * 1e6 - tb.src.set_rx_freq(0, freq) - print "Setting frequency: ", freq - if 1: - pga = tb.src.pga(0)+10 - tb.src.set_pga(0, pga) - print "Setting PGA: ", pga - - tb.stop() # stop the radio - -if __name__ == '__main__': - main() diff --git a/gr-msdd6000/src/python-examples/msdd_fft.py b/gr-msdd6000/src/python-examples/msdd_fft.py deleted file mode 100755 index 813a77d38..000000000 --- a/gr-msdd6000/src/python-examples/msdd_fft.py +++ /dev/null @@ -1,277 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2005,2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gru -from gnuradio import msdd -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import stdgui2, fftsink2, waterfallsink2, scopesink2, form, slider -from optparse import OptionParser -import wx -import sys - - -def pick_subdevice(u): - """ - The user didn't specify a subdevice on the command line. - If there's a daughterboard on A, select A. - If there's a daughterboard on B, select B. - Otherwise, select A. - """ - if u.db[0][0].dbid() >= 0: # dbid is < 0 if there's no d'board or a problem - return (0, 0) - if u.db[1][0].dbid() >= 0: - return (1, 0) - return (0, 0) - - -class app_top_block(stdgui2.std_top_block): - def __init__(self, frame, panel, vbox, argv): - stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) - - self.frame = frame - self.panel = panel - - parser = OptionParser(option_class=eng_option) - parser.add_option("-w", "--which", type="int", default=0, - help="select which MSDD (0, 1, ...) default is %default", - metavar="NUM") - parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, - help="select MSDD Rx side A or B (default=first one with a daughterboard)") - parser.add_option("-A", "--antenna", default=None, - help="select Rx Antenna (only on RFX-series boards)") - parser.add_option("-d", "--decim", type="int", default=16, - help="set fgpa decimation rate to DECIM [default=%default]") - parser.add_option("-f", "--freq", type="eng_float", default=None, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("-W", "--waterfall", action="store_true", default=False, - help="Enable waterfall display") - parser.add_option("-8", "--width-8", action="store_true", default=False, - help="Enable 8-bit samples across USB") - parser.add_option("-S", "--oscilloscope", action="store_true", default=False, - help="Enable oscilloscope display") - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - - self.show_debug_info = True - - # build the graph - - #self.u = MSDD.source_simo(which=options.which, decim_rate=options.decim) - self.u = msdd.source_simple("192.168.1.200", 0) - self.u.set_decim_rate(options.decim) #(16) - -# msdd_src = gr.file_source(gr.sizeof_gr_complex, 'msdd.dat') -# thr = gr.throttle(gr.sizeof_gr_complex, 200000) -# self.connect(msdd_src, thr) - -# if options.rx_subdev_spec is None: -# options.rx_subdev_spec = pick_subdevice(self.u) -# self.u.set_mux(MSDD.determine_rx_mux_value(self.u, options.rx_subdev_spec)) - -# if options.width_8: -# width = 8 -# shift = 8 -# format = self.u.make_format(width, shift) -# print "format =", hex(format) -# r = self.u.set_format(format) -# print "set_format =", r - - # determine the daughterboard subdevice we're using -# self.subdev = MSDD.selected_subdev(self.u, options.rx_subdev_spec) - -# print "Initial Freq", self.u.rx_freq(0), "deci: ", self.u.decim_rate() -# input_rate = 50e6 / self.u.decim_rate() - input_rate = 50e6 / options.decim; - - if options.waterfall: - self.scope = \ - waterfallsink2.waterfall_sink_c (panel, fft_size=1024, sample_rate=input_rate) - elif options.oscilloscope: - self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate) - else: - self.scope = fftsink2.fft_sink_c (panel, fft_size=1024, sample_rate=input_rate) - -# self.connect(self.u, self.scope) - - msdd_sink = gr.file_sink(gr.sizeof_gr_complex, 'schmen1.dat') - - self.conv = gr.interleaved_short_to_complex(); - self.connect(self.u, self.conv, msdd_sink) - self._build_gui(vbox) - - # set initial values - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - #g = self.subdev.gain_range() - self.gain_range = (20,70,.5); - options.gain = float(self.gain_range[0]+self.gain_range[1])/2 - - if options.freq is None: - # if no freq was specified, use the mid-point - #r = self.subdev.freq_range() - r = (30e6,6e9,1e6) - options.freq = float(r[0]+r[1])/2 - - self.set_gain(options.gain) -# -# if options.antenna is not None: -# print "Selecting antenna %s" % (options.antenna,) -# self.subdev.select_rx_antenna(options.antenna) - - if self.show_debug_info: - #self.myform['decim'].set_value(self.u.decim_rate()) - self.myform['decim'].set_value(options.decim) - # self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate()) - # self.myform['dbname'].set_value(self.subdev.name()) - self.myform['baseband'].set_value(0) - self.myform['ddc'].set_value(0) - - if not(self.set_freq(options.freq)): - self._set_status_msg("Failed to set initial frequency") - - def _set_status_msg(self, msg): - self.frame.GetStatusBar().SetStatusText(msg, 0) - - def _build_gui(self, vbox): - - def _form_set_freq(kv): - return self.set_freq(kv['freq']) - - vbox.Add(self.scope.win, 10, wx.EXPAND) - - # add control area at the bottom - self.myform = myform = form.form() - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0, 0) - myform['freq'] = form.float_field( - parent=self.panel, sizer=hbox, label="Center freq", weight=1, - callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) - - hbox.Add((5,0), 0, 0) - g = self.gain_range = (20,50,.5); - myform['gain'] = form.slider_field(parent=self.panel, sizer=hbox, label="Gain", - weight=3, - min=int(g[0]), max=int(g[1]), - callback=self.set_gain) - - hbox.Add((5,0), 0, 0) - vbox.Add(hbox, 0, wx.EXPAND) - - self._build_subpanel(vbox) - - def _build_subpanel(self, vbox_arg): - # build a secondary information panel (sometimes hidden) - - # FIXME figure out how to have this be a subpanel that is always - # created, but has its visibility controlled by foo.Show(True/False) - - def _form_set_decim(kv): - return self.set_decim(kv['decim']) - - if not(self.show_debug_info): - return - - panel = self.panel - vbox = vbox_arg - myform = self.myform - - #panel = wx.Panel(self.panel, -1) - #vbox = wx.BoxSizer(wx.VERTICAL) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - - myform['decim'] = form.int_field( - parent=panel, sizer=hbox, label="Decim", - callback=myform.check_input_and_call(_form_set_decim, self._set_status_msg)) - -# hbox.Add((5,0), 1) -# myform['fs@usb'] = form.static_float_field( -# parent=panel, sizer=hbox, label="Fs@USB") - - hbox.Add((5,0), 1) - myform['dbname'] = form.static_text_field( - parent=panel, sizer=hbox) - - hbox.Add((5,0), 1) - myform['baseband'] = form.static_float_field( - parent=panel, sizer=hbox, label="Analog BB") - - hbox.Add((5,0), 1) - myform['ddc'] = form.static_float_field( - parent=panel, sizer=hbox, label="DDC") - - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - - Tuning is a two step process. First we ask the front-end to - tune as close to the desired frequency as it can. Then we use - the result of that operation and our target_frequency to - determine the value for the digital down converter. - """ - r = self.u.set_rx_freq (0, target_freq) - #r = self.u.tune(0, self.subdev, target_freq) - if r: - self.myform['freq'].set_value(target_freq) # update displayed value -# if self.show_debug_info: -# self.myform['baseband'].set_value(r.baseband_freq) -# self.myform['ddc'].set_value(r.dxc_freq) - return True - - return False - - def set_gain(self, gain): - self.myform['gain'].set_value(gain) # update displayed value - #self.subdev.set_gain(gain) - self.u.set_pga(0, gain) - - def set_decim(self, decim): - ok = self.u.set_decim_rate(decim) - if not ok: - print "set_decim failed" - #input_rate = 20e6 / self.u.decim_rate() - #self.scope.set_sample_rate(input_rate) - if self.show_debug_info: # update displayed values - self.myform['decim'].set_value(decim) - #self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate()) - return ok - -def main (): - app = stdgui2.stdapp(app_top_block, "MSDD FFT", nstatus=1) - app.MainLoop() - -if __name__ == '__main__': - main () diff --git a/gr-msdd6000/src/python-examples/msdd_rcv.py b/gr-msdd6000/src/python-examples/msdd_rcv.py deleted file mode 100755 index cc2f3e4a3..000000000 --- a/gr-msdd6000/src/python-examples/msdd_rcv.py +++ /dev/null @@ -1,287 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2006,2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gru, eng_notation -from gnuradio import msdd -from gnuradio import blks2 -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import slider, powermate -from gnuradio.wxgui import stdgui2, form -from gnuradio.wxgui import fftsink2 -from optparse import OptionParser -#from usrpm import usrp_dbid -import sys -import math -import wx - -class wfm_rx_block (stdgui2.std_top_block): - def __init__(self,frame,panel,vbox,argv): - stdgui2.std_top_block.__init__ (self,frame,panel,vbox,argv) - - parser=OptionParser(option_class=eng_option) -# parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, -# help="select MSDD Rx side A or B (default=A)") - parser.add_option("-f", "--freq", type="eng_float", default=100.1e6, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=40, - help="set gain in dB (default is midpoint)") -# parser.add_option("-V", "--volume", type="eng_float", default=None, -# help="set volume (default is midpoint)") -# parser.add_option("-O", "--audio-output", type="string", default="", -# help="pcm device name. E.g., hw:0,0 or surround51 or /dev/dsp") - - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - - self.frame = frame - self.panel = panel - - self.vol = 0 - self.gain_range = (10, 70, .5) - self.state = "FREQ" - self.freq = 0 - msdd_decim = 2 - - # build graph - self.fft_size = 8192 - self.sample_rate = 200 - self.u = msdd.source_c(0, 1, "10.45.4.44", 10000) - self.u.set_decim_rate(4) - self.u.set_desired_packet_size(0, 1460*100) - - - #self.u.set_decim_rate(msdd_decim) -# usrp_rate = adc_rate / msdd_decim # 320 kS/s -# chanfilt_decim = 1 -# demod_rate = usrp_rate / chanfilt_decim -# audio_decimation = 10 -# audio_rate = demod_rate / audio_decimation # 32 kHz -# -# if options.rx_subdev_spec is None: -# options.rx_subdev_spec = pick_subdevice(self.u) -# -# self.u.set_mux(usrp.determine_rx_mux_value(self.u, options.rx_subdev_spec)) -# self.subdev = usrp.selected_subdev(self.u, options.rx_subdev_spec) -# print "Using RX d'board %s" % (self.subdev.side_and_name(),) -# -# -# chan_filt_coeffs = optfir.low_pass (1, # gain -# usrp_rate, # sampling rate -# 80e3, # passband cutoff -# 115e3, # stopband cutoff -# 0.1, # passband ripple -# 60) # stopband attenuation -# #print len(chan_filt_coeffs) -# chan_filt = gr.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) -# -# self.guts = blks2.wfm_rcv (demod_rate, audio_decimation) -# -# self.volume_control = gr.multiply_const_ff(self.vol) -# -# # sound card as final sink -# audio_sink = audio.sink (int (audio_rate), -# options.audio_output, -# False) # ok_to_block - - # now wire it all together - #self.connect (self.u, chan_filt, self.guts, self.volume_control, audio_sink) - - self._build_gui(vbox) - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - #g = self.subdev.gain_range() - g = self.gain_range - options.gain = float(g[0]+g[1])/2 -# -# if options.volume is None: -# g = self.volume_range() -# options.volume = float(g[0]+g[1])/2 -# -# if abs(options.freq) < 1e6: -# options.freq *= 1e6 - - # set initial values -# - self.set_gain(options.gain) -# self.set_vol(options.volume) - if not(self.set_freq(options.freq)): - self._set_status_msg("Failed to set initial frequency") - print "Frequency: ", self.u.rx_freq(0) - - - def _set_status_msg(self, msg, which=0): - self.frame.GetStatusBar().SetStatusText(msg, which) - - - def _build_gui(self, vbox): - - def _form_set_freq(kv): - return self.set_freq(kv['freq']) - - self.src_fft = None - if 1: - self.src_fft = fftsink2.fft_sink_c(self.panel, title="Data from MSDD", - fft_size=512, sample_rate=512) -# self.s2f1 = gr.short_to_float() -# self.scope = scopesink2.scope_sink_f(self.panel, sample_rate=self.sample_rate*self.fft_size) - - self.connect (self.u, self.src_fft) - #self.connect (self.s2f1, self.scope) - vbox.Add (self.src_fft.win, 4, wx.EXPAND) -# -# if 1: -# post_filt_fft = fftsink2.fft_sink_f(self.panel, title="Post Demod", -# fft_size=1024, sample_rate=usrp_rate, -# y_per_div=10, ref_level=0) -# self.connect (self.guts.fm_demod, post_filt_fft) -# vbox.Add (post_filt_fft.win, 4, wx.EXPAND) -# -# if 0: -# post_deemph_fft = fftsink2.fft_sink_f(self.panel, title="Post Deemph", -# fft_size=512, sample_rate=audio_rate, -# y_per_div=10, ref_level=-20) -# self.connect (self.guts.deemph, post_deemph_fft) -# vbox.Add (post_deemph_fft.win, 4, wx.EXPAND) - - - # control area form at bottom - self.myform = myform = form.form() - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - myform['freq'] = form.float_field( - parent=self.panel, sizer=hbox, label="Freq", weight=1, - callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) - - hbox.Add((5,0), 0) - myform['freq_slider'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, weight=3, - range=(30e6, 6e9, 1e6), - callback=self.set_freq) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) -# -# myform['volume'] = \ -# form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Volume", -# weight=3, range=self.volume_range(), -# callback=self.set_vol) -# hbox.Add((5,0), 1) - - myform['gain'] = \ - form.quantized_slider_field(parent=self.panel, sizer=hbox, label="Gain", - weight=3, range=self.gain_range, - callback=self.set_gain) - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) -# -# try: -# self.knob = powermate.powermate(self.frame) -# self.rot = 0 -# powermate.EVT_POWERMATE_ROTATE (self.frame, self.on_rotate) -# powermate.EVT_POWERMATE_BUTTON (self.frame, self.on_button) -# except: -# print "FYI: No Powermate or Contour Knob found" - - - def on_rotate (self, event): - self.rot += event.delta - if (self.state == "FREQ"): - if self.rot >= 3: - self.set_freq(self.freq + .1e6) - self.rot -= 3 - elif self.rot <=-3: - self.set_freq(self.freq - .1e6) - self.rot += 3 - else: - step = self.volume_range()[2] - if self.rot >= 3: - self.set_vol(self.vol + step) - self.rot -= 3 - elif self.rot <=-3: - self.set_vol(self.vol - step) - self.rot += 3 - - def on_button (self, event): - if event.value == 0: # button up - return - self.rot = 0 - if self.state == "FREQ": - self.state = "VOL" - else: - self.state = "FREQ" - self.update_status_bar () -# -# -# def set_vol (self, vol): -# g = self.volume_range() -# self.vol = max(g[0], min(g[1], vol)) -# self.volume_control.set_k(10**(self.vol/10)) -# self.myform['volume'].set_value(self.vol) -# self.update_status_bar () - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - - Tuning is a two step process. First we ask the front-end to - tune as close to the desired frequency as it can. Then we use - the result of that operation and our target_frequency to - determine the value for the digital down converter. - """ - r = self.u.set_rx_freq(0, target_freq); - - if r: - self.freq = target_freq - self.myform['freq'].set_value(target_freq) # update displayed value - self.myform['freq_slider'].set_value(target_freq) # update displayed value - self.update_status_bar() - self._set_status_msg("OK", 0) - return True - - self._set_status_msg("Failed", 0) - return False - - def set_gain(self, gain): - self.myform['gain'].set_value(gain) # update displayed value - self.u.set_pga(0,gain) - - def update_status_bar (self): - msg = "Volume:%r Setting:%s" % (self.vol, self.state) - self._set_status_msg(msg, 1) - #self.src_fft.set_baseband_freq(self.freq) -# -# def volume_range(self): -# return (-20.0, 0.0, 0.5) - - -if __name__ == '__main__': - app = stdgui2.stdapp (wfm_rx_block, "MSDD FFT RX") - app.MainLoop () diff --git a/gr-msdd6000/src/python-examples/msdd_rs_spec_an.py b/gr-msdd6000/src/python-examples/msdd_rs_spec_an.py deleted file mode 100755 index 4855375b8..000000000 --- a/gr-msdd6000/src/python-examples/msdd_rs_spec_an.py +++ /dev/null @@ -1,350 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with 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 -from gnuradio import msdd_rs -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from gnuradio.qtgui import qtgui -from optparse import OptionParser -import sys,time - -try: - from gnuradio.qtgui import qtgui - from PyQt4 import QtGui, QtCore - import sip -except ImportError: - print "Please install gr-qtgui." - sys.exit(1) - -try: - from msdd_display_qtgui import Ui_MainWindow -except ImportError: - print "Error: could not find msdd_display_qtgui.py:" - print "\t\"pyuic4 msdd_display_qtgui.ui -o msdd_display_qtgui.py\"" - sys.exit(1) - - -# //////////////////////////////////////////////////////////////////// -# Define the QT Interface and Control Dialog -# //////////////////////////////////////////////////////////////////// - - -class main_window(QtGui.QMainWindow): - def __init__(self, snk, fg, parent=None): - - QtGui.QWidget.__init__(self, parent) - self.gui = Ui_MainWindow() - self.gui.setupUi(self) - - self.fg = fg - - # Add the qtsnk widgets to the layout box - self.gui.sinkLayout.addWidget(snk) - - self.gui.dcGainEdit.setText(QtCore.QString("%1").arg(0.001)) - - # Connect up some signals - self.connect(self.gui.pauseButton, QtCore.SIGNAL("clicked()"), - self.pauseFg) - self.connect(self.gui.frequencyEdit, QtCore.SIGNAL("editingFinished()"), - self.frequencyEditText) - self.connect(self.gui.gainEdit, QtCore.SIGNAL("editingFinished()"), - self.gainEditText) - self.connect(self.gui.bandwidthEdit, QtCore.SIGNAL("editingFinished()"), - self.bandwidthEditText) - self.connect(self.gui.amplifierEdit, QtCore.SIGNAL("editingFinished()"), - self.amplifierEditText) - - self.connect(self.gui.actionSaveData, QtCore.SIGNAL("activated()"), - self.saveData) - self.gui.actionSaveData.setShortcut(QtGui.QKeySequence.Save) - - self.connect(self.gui.dcGainEdit, QtCore.SIGNAL("editingFinished()"), - self.dcGainEditText) - self.connect(self.gui.dcCancelCheckBox, QtCore.SIGNAL("clicked(bool)"), - self.dcCancelClicked) - - def pauseFg(self): - if(self.gui.pauseButton.text() == "Pause"): - self.fg.stop() - self.fg.wait() - self.fg.stop_data() - self.gui.pauseButton.setText("Unpause") - else: - self.fg.start() - self.fg.start_data() - self.gui.pauseButton.setText("Pause") - - - # Functions to set the values in the GUI - def set_frequency(self, freq): - self.freq = freq - sfreq = eng_notation.num_to_str(self.freq) - self.gui.frequencyEdit.setText(QtCore.QString("%1").arg(sfreq)) - - def set_gain(self, gain): - self.gain = gain - self.gui.gainEdit.setText(QtCore.QString("%1").arg(self.gain)) - - def set_bandwidth(self, bw): - self.bw = bw - sbw = eng_notation.num_to_str(self.bw) - self.gui.bandwidthEdit.setText(QtCore.QString("%1").arg(sbw)) - - def set_amplifier(self, amp): - self.amp = amp - self.gui.amplifierEdit.setText(QtCore.QString("%1").arg(self.amp)) - - - # Functions called when signals are triggered in the GUI - def frequencyEditText(self): - try: - freq = eng_notation.str_to_num(self.gui.frequencyEdit.text().toAscii()) - self.fg.set_frequency(freq) - self.freq = freq - except RuntimeError: - pass - - def gainEditText(self): - try: - gain = float(self.gui.gainEdit.text()) - self.fg.set_gain(gain) - self.gain = gain - except ValueError: - pass - - def bandwidthEditText(self): - try: - bw = eng_notation.str_to_num(self.gui.bandwidthEdit.text().toAscii()) - self.fg.set_bandwidth(bw) - self.bw = bw - except ValueError: - pass - - def amplifierEditText(self): - try: - amp = float(self.gui.amplifierEdit.text()) - self.fg.set_amplifier_gain(amp) - self.amp = amp - except ValueError: - pass - - def saveData(self): - fileName = QtGui.QFileDialog.getSaveFileName(self, "Save data to file", "."); - if(len(fileName)): - self.fg.save_to_file(str(fileName)) - - def dcGainEditText(self): - gain = float(self.gui.dcGainEdit.text()) - self.fg.set_dc_gain(gain) - - def dcCancelClicked(self, state): - self.dcGainEditText() - self.fg.cancel_dc(state) - - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - parser = OptionParser(option_class=eng_option) - parser.add_option("-e", "--interface", type="string", default="eth0", - help="select Ethernet interface, default is eth0") - parser.add_option("-m", "--mac-addr", type="string", default="", - help="select USRP by MAC address, default is auto-select") - parser.add_option("-W", "--bw", type="float", default=1e6, - help="set bandwidth of receiver [default=%default]") - parser.add_option("-f", "--freq", type="eng_float", default="2.4G", - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("--fft-size", type="int", default=2048, - help="Set number of FFT bins [default=%default]") - (options, args) = parser.parse_args() - - if len(args) != 0: - parser.print_help() - sys.exit(1) - self.options = options - self.show_debug_info = True - - self.qapp = QtGui.QApplication(sys.argv) - -# self.u = usrp2.source_32fc(options.interface, options.mac_addr) - self.u = msdd_rs.source_simple("192.168.1.20", 10000); - self.conv = gr.interleaved_short_to_complex(); - self._adc_rate = self.u.pull_adc_freq() - self.set_bandwidth(options.bw) - - if options.gain is None: - # if no gain was specified, use the mid-point in dB -# g = self.u.gain_range() - g = [0, 10] - #options.gain = float(g[0]+g[1])/2 - options.gain = float(0) - self.set_gain(options.gain) - - if options.freq is None: - options.freq = 2.4e9; -# # if no frequency was specified, use the mid-point of the subdev -# f = self.u.freq_range() -# options.freq = float(f[0]+f[1])/2 - - self.set_frequency(options.freq) - - self._fftsize = options.fft_size - - - self._freq = options.freq; - self._bandwidth = 400; - - self.set_bandwidth(self._bandwidth); - - self.snk = qtgui.sink_c(options.fft_size, gr.firdes.WIN_BLACKMAN_hARRIS, - self._freq, self._bandwidth, - "USRP2 Display", - True, True, False, True, False) - - # Set up internal amplifier - self.amp = gr.multiply_const_cc(0.0) - self.set_amplifier_gain(0.01) - - # Create a single-pole IIR filter to remove DC - # but don't connect it yet - self.dc_gain = 0.001 - self.dc = gr.single_pole_iir_filter_cc(self.dc_gain) - self.dc_sub = gr.sub_cc() - - self.agc = gr.agc2_cc(1e-3, 1e-5, 0.01, 0.01, 10); - - self.connect(self.u, self.conv, self.snk) - #self.connect(self.u, self.conv, self.amp, self.snk) - - if self.show_debug_info: - print "Decimation rate: ", self._decim - print "Bandwidth: ", self._bandwidth -# print "D'board: ", self.u.daughterboard_id() - - # Get the reference pointer to the SpectrumDisplayForm QWidget - # Wrap the pointer as a PyQt SIP object - # This can now be manipulated as a PyQt4.QtGui.QWidget - self.pysink = sip.wrapinstance(self.snk.pyqwidget(), QtGui.QWidget) - - self.main_win = main_window(self.pysink, self) - - self.main_win.set_frequency(self._freq) - self.main_win.set_gain(self._gain) - self.main_win.set_bandwidth(self._bandwidth) - self.main_win.set_amplifier(self._amp_value) - - self.main_win.show() - - - def save_to_file(self, name): - self.lock() - - # Add file sink to save data - self.file_sink = gr.file_sink(gr.sizeof_gr_complex, name) - self.connect(self.conv, self.file_sink) - - self.unlock() - - def set_gain(self, gain): - self._gain = gain - self.u.set_ddc_gain(self._gain) - - def set_frequency(self, freq): - self._freq = freq - r = self.u.set_rx_freq(freq) - - try: - self.snk.set_frequency_range(self._freq, self._bandwidth) - except: - pass - - def set_bandwidth(self, bw): - self._bandwidth = bw - self._decim = int(self._adc_rate / self._bandwidth) -# self.u.set_decim_rate(self._decim) - r1 = self.u.set_ddc_samp_rate( bw ); - r2 = self.u.set_ddc_bw( bw ); - self.u.start_data(); - - print r1 - print r2; - - time.sleep(0.05); - bw = self.u.pull_ddc_bw(); - sr = self.u.pull_ddc_samp_rate(); - fc = self.u.pull_rx_freq(); - - #self.snk.d_bandwidth = sr; - - print bw; - print sr; - print fc; - -# sys.exit(-1); - - try: - self.snk.set_frequency_range(self._freq, self._bandwidth) - except: - pass - - def set_amplifier_gain(self, amp): - self._amp_value = amp - self.amp.set_k(self._amp_value) - - def set_dc_gain(self, gain): - self.dc.set_taps(gain) - - def cancel_dc(self, state): - self.lock() - - if(state): - self.disconnect(self.u, self.amp) - self.connect(self.u, (self.dc_sub,0)) - self.connect(self.u, self.dc, (self.dc_sub,1)) - self.connect(self.dc_sub, self.amp) - else: - self.disconnect(self.dc_sub, self.amp) - self.disconnect(self.dc, (self.dc_sub,1)) - self.disconnect(self.u, self.dc) - self.disconnect(self.u, (self.dc_sub,0)) - self.connect(self.u, self.amp) - - self.unlock() - -def main (): - tb = my_top_block() - tb.start() - tb.u.start_data(); - tb.snk.exec_(); - -if __name__ == '__main__': - try: - main () - except KeyboardInterrupt: - pass - diff --git a/gr-msdd6000/src/python-examples/msdd_spectrum_sense.py b/gr-msdd6000/src/python-examples/msdd_spectrum_sense.py deleted file mode 100755 index e3d182b03..000000000 --- a/gr-msdd6000/src/python-examples/msdd_spectrum_sense.py +++ /dev/null @@ -1,296 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2008 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gru, eng_notation, optfir, window -from gnuradio import msdd -from gnuradio.eng_option import eng_option -from optparse import OptionParser -import sys -import math -import struct -from pylab import * -from numpy import array -import time - -matplotlib.interactive(True) -matplotlib.use('TkAgg') - -class tune(gr.feval_dd): - """ - This class allows C++ code to callback into python. - """ - def __init__(self, tb): - gr.feval_dd.__init__(self) - self.tb = tb - - def eval(self, ignore): - """ - This method is called from gr.bin_statistics_f when it wants to change - the center frequency. This method tunes the front end to the new center - frequency, and returns the new frequency as its result. - """ - try: - # We use this try block so that if something goes wrong from here - # down, at least we'll have a prayer of knowing what went wrong. - # Without this, you get a very mysterious: - # - # terminate called after throwing an instance of 'Swig::DirectorMethodException' - # Aborted - # - # message on stderr. Not exactly helpful ;) - - new_freq = self.tb.set_next_freq() - return new_freq - - except Exception, e: - print "tune: Exception: ", e - - -class parse_msg(object): - def __init__(self, sample_rate, percent, alpha=0.01): - self.axis_font_size = 16 - self.label_font_size = 18 - self.title_font_size = 20 - self.text_size = 22 - - self.fig = figure(1, facecolor="w", figsize=(12,9)) - self.sp = self.fig.add_subplot(1,1,1) - self.pl = self.sp.plot(range(100), 100*[1,]) - - params = {'backend': 'ps', - 'xtick.labelsize': self.axis_font_size, - 'ytick.labelsize': self.axis_font_size, - 'text.usetex': False} - rcParams.update(params) - - self.sp.set_title(("FFT"), fontsize=self.title_font_size, fontweight="bold") - self.sp.set_xlabel("Frequency (Hz)", fontsize=self.label_font_size, fontweight="bold") - self.sp.set_ylabel("Magnitude (dB)", fontsize=self.label_font_size, fontweight="bold") - self.text_alpha = figtext(0.10, 0.94, ('Moving average alpha: %s' % alpha), weight="heavy", size=self.text_size) - - self.cfreqs = list() - self.freqrange = list() - self.data = list() #array('f') - - self.alpha = alpha - - self.index = 0 - self.full = False - self.last_cfreq = 0 - - self.sample_rate = sample_rate - self.percent = (1.0-percent)/2.0 - - def parse(self, msg): - self.center_freq = msg.arg1() - self.vlen = int(msg.arg2()) - assert(msg.length() == self.vlen * gr.sizeof_float) - - - if(self.center_freq < self.last_cfreq): - print "Plotting spectrum\n" - self.full = True - - self.pl[0].set_data([self.freqrange, self.data]) - self.sp.set_ylim([min(self.data), max(self.data)]) - self.sp.set_xlim([min(self.freqrange), max(self.freqrange)]) - draw() - - self.index = 0 - del self.freqrange - self.freqrange = list() - #raw_input() - - self.last_cfreq = self.center_freq - - startind = int(self.percent * self.vlen) - endind = int((1.0 - self.percent) * self.vlen) - - fstep = self.sample_rate / self.vlen - f = [self.center_freq - self.sample_rate/2.0 + i*fstep for i in range(startind, endind)] - self.freqrange += f - - t = msg.to_string() - d = struct.unpack('%df' % (self.vlen,), t) - - if self.full: - for i in range(startind, endind): - self.data[self.index] = (1.0-self.alpha)*self.data[self.index] + (self.alpha)*d[i] - self.index += 1 - else: - self.data += [di for di in d[startind:endind]] - - -class my_top_block(gr.top_block): - - def __init__(self): - gr.top_block.__init__(self) - - usage = "usage: %prog [options] host min_freq max_freq" - parser = OptionParser(option_class=eng_option, usage=usage) - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("", "--tune-delay", type="eng_float", default=5e-5, metavar="SECS", - help="time to delay (in seconds) after changing frequency [default=%default]") - parser.add_option("", "--dwell-delay", type="eng_float", default=50e-5, metavar="SECS", - help="time to dwell (in seconds) at a given frequncy [default=%default]") - parser.add_option("-F", "--fft-size", type="int", default=256, - help="specify number of FFT bins [default=%default]") - parser.add_option("-d", "--decim", type="intx", default=16, - help="set decimation to DECIM [default=%default]") - parser.add_option("", "--real-time", action="store_true", default=False, - help="Attempt to enable real-time scheduling") - - (options, args) = parser.parse_args() - if len(args) != 3: - parser.print_help() - sys.exit(1) - - self.address = args[0] - self.min_freq = eng_notation.str_to_num(args[1]) - self.max_freq = eng_notation.str_to_num(args[2]) - - self.decim = options.decim - self.gain = options.gain - - if self.min_freq > self.max_freq: - self.min_freq, self.max_freq = self.max_freq, self.min_freq # swap them - - self.fft_size = options.fft_size - - if not options.real_time: - realtime = False - else: - # Attempt to enable realtime scheduling - r = gr.enable_realtime_scheduling() - if r == gr.RT_OK: - realtime = True - else: - realtime = False - print "Note: failed to enable realtime scheduling" - - adc_rate = 102.4e6 - self.int_rate = adc_rate / self.decim - print "Sampling rate: ", self.int_rate - - # build graph - self.port = 10001 - self.src = msdd.source_simple(self.address, self.port) - self.src.set_decim_rate(self.decim) - - self.set_gain(self.gain) - self.set_freq(self.min_freq) - - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) - - mywindow = window.blackmanharris(self.fft_size) - fft = gr.fft_vcc(self.fft_size, True, mywindow, True) - power = 0 - for tap in mywindow: - power += tap*tap - - norm = gr.multiply_const_cc(1.0/self.fft_size) - c2mag = gr.complex_to_mag_squared(self.fft_size) - - # FIXME the log10 primitive is dog slow - log = gr.nlog10_ff(10, self.fft_size, - -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size)) - - # Set the freq_step to % of the actual data throughput. - # This allows us to discard the bins on both ends of the spectrum. - self.percent = 0.4 - - self.freq_step = self.percent * self.int_rate - self.min_center_freq = self.min_freq + self.freq_step/2 - nsteps = math.ceil((self.max_freq - self.min_freq) / self.freq_step) - self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step) - - self.next_freq = self.min_center_freq - - tune_delay = max(0, int(round(options.tune_delay * self.int_rate / self.fft_size))) # in fft_frames - dwell_delay = max(1, int(round(options.dwell_delay * self.int_rate / self.fft_size))) # in fft_frames - - self.msgq = gr.msg_queue(16) - self._tune_callback = tune(self) # hang on to this to keep it from being GC'd - stats = gr.bin_statistics_f(self.fft_size, self.msgq, - self._tune_callback, tune_delay, dwell_delay) - - # FIXME leave out the log10 until we speed it up - self.connect(self.src, s2v, fft, c2mag, log, stats) - - - def set_next_freq(self): - target_freq = self.next_freq - self.next_freq = self.next_freq + self.freq_step - if self.next_freq >= self.max_center_freq: - self.next_freq = self.min_center_freq - - if not self.set_freq(target_freq): - print "Failed to set frequency to", target_freq - - return target_freq - - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - - """ - return self.src.set_rx_freq(0, target_freq) - - - def set_gain(self, gain): - self.src.set_pga(0, gain) - - -def main_loop(tb): - msgparser = parse_msg(tb.int_rate, tb.percent) - - while 1: - - # Get the next message sent from the C++ code (blocking call). - # It contains the center frequency and the mag squared of the fft - msgparser.parse(tb.msgq.delete_head()) - - # Print center freq so we know that something is happening... - print msgparser.center_freq - - # FIXME do something useful with the data... - - # m.data are the mag_squared of the fft output (they are in the - # standard order. I.e., bin 0 == DC.) - # You'll probably want to do the equivalent of "fftshift" on them - # m.raw_data is a string that contains the binary floats. - # You could write this as binary to a file. - - -if __name__ == '__main__': - tb = my_top_block() - try: - tb.start() # start executing flow graph in another thread... - main_loop(tb) - - except KeyboardInterrupt: - pass diff --git a/gr-msdd6000/src/python-examples/msdd_spectrum_waterfall.py b/gr-msdd6000/src/python-examples/msdd_spectrum_waterfall.py deleted file mode 100755 index 05f047e11..000000000 --- a/gr-msdd6000/src/python-examples/msdd_spectrum_waterfall.py +++ /dev/null @@ -1,306 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2008 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gru, eng_notation, optfir, window -from gnuradio import msdd -from gnuradio.eng_option import eng_option -from optparse import OptionParser -import sys -import math -import struct -from pylab import * -from numpy import array -import time - -matplotlib.interactive(True) -matplotlib.use('TkAgg') - -class tune(gr.feval_dd): - """ - This class allows C++ code to callback into python. - """ - def __init__(self, tb): - gr.feval_dd.__init__(self) - self.tb = tb - - def eval(self, ignore): - """ - This method is called from gr.bin_statistics_f when it wants to change - the center frequency. This method tunes the front end to the new center - frequency, and returns the new frequency as its result. - """ - try: - # We use this try block so that if something goes wrong from here - # down, at least we'll have a prayer of knowing what went wrong. - # Without this, you get a very mysterious: - # - # terminate called after throwing an instance of 'Swig::DirectorMethodException' - # Aborted - # - # message on stderr. Not exactly helpful ;) - - new_freq = self.tb.set_next_freq() - return new_freq - - except Exception, e: - print "tune: Exception: ", e - - -class parse_msg(object): - def __init__(self, sample_rate, percent): - self.axis_font_size = 16 - self.label_font_size = 18 - self.title_font_size = 20 - self.text_size = 22 - - # Set up figures and subplots - self.fig = figure(1, facecolor="w", figsize=(12,9)) - self.sp = self.fig.add_subplot(1,1,1) - self.pl = self.sp.matshow(100*[range(100),]) - - params = {'xtick.labelsize': self.axis_font_size, - 'ytick.labelsize': self.axis_font_size} - rcParams.update(params) - - # Throw up some title info - self.sp.set_title(("FFT"), fontsize=self.title_font_size, fontweight="bold") - self.sp.set_xlabel("Frequency (Hz)", fontsize=self.label_font_size, fontweight="bold") - self.sp.set_ylabel("Sample index (should be time)", fontsize=self.label_font_size, fontweight="bold") - - self.freqrange = list() - self.data = list() - self.data3 = list() - - self.index = 0 - self.last_cfreq = 0 - - # So we know how to splice the data - self.sample_rate = sample_rate - self.percent = (1.0-percent)/2.0 - - def parse(self, msg): - self.center_freq = msg.arg1() # read the current center frequency - self.vlen = int(msg.arg2()) # read the length of the data set received - - # wait until we wrap around before plotting the entire collected band - if(self.center_freq < self.last_cfreq): - #print "Plotting spectrum\n" - - # If we have 100 sets, start dropping the oldest - if(len(self.data3) > 100): - self.data3.pop(0) - self.data3.append(self.data) - - # add the new data to the plot - self.pl.set_data(self.data3) - draw() - - # reset lists to collect next round - self.index = 0 - del self.freqrange - self.freqrange = list() - del self.data - self.data = list() - #raw_input() - - self.last_cfreq = self.center_freq - - startind = int(self.percent * self.vlen) - endind = int((1.0 - self.percent) * self.vlen) - - fstep = self.sample_rate / self.vlen - f = [self.center_freq - self.sample_rate/2.0 + i*fstep for i in range(startind, endind)] - self.freqrange += f - - t = msg.to_string(); - - d = struct.unpack('%df' % (self.vlen,), t) - - self.data += [di for di in d[startind:endind]] - - -class my_top_block(gr.top_block): - def __init__(self): - gr.top_block.__init__(self) - - # Build an options parser to bring in information from the user on usage - usage = "usage: %prog [options] host min_freq max_freq" - parser = OptionParser(option_class=eng_option, usage=usage) - parser.add_option("-g", "--gain", type="eng_float", default=32, - help="set gain in dB (default is midpoint)") - parser.add_option("", "--tune-delay", type="eng_float", default=5e-5, metavar="SECS", - help="time to delay (in seconds) after changing frequency [default=%default]") - parser.add_option("", "--dwell-delay", type="eng_float", default=50e-5, metavar="SECS", - help="time to dwell (in seconds) at a given frequncy [default=%default]") - parser.add_option("-F", "--fft-size", type="int", default=256, - help="specify number of FFT bins [default=%default]") - parser.add_option("-d", "--decim", type="intx", default=16, - help="set decimation to DECIM [default=%default]") - parser.add_option("", "--real-time", action="store_true", default=False, - help="Attempt to enable real-time scheduling") - - (options, args) = parser.parse_args() - if len(args) != 3: - parser.print_help() - sys.exit(1) - - # get user-provided info on address of MSDD and frequency to sweep - self.address = args[0] - self.min_freq = eng_notation.str_to_num(args[1]) - self.max_freq = eng_notation.str_to_num(args[2]) - - self.decim = options.decim - self.gain = options.gain - - if self.min_freq > self.max_freq: - self.min_freq, self.max_freq = self.max_freq, self.min_freq # swap them - - self.fft_size = options.fft_size - - if not options.real_time: - realtime = False - else: - # Attempt to enable realtime scheduling - r = gr.enable_realtime_scheduling() - if r == gr.RT_OK: - realtime = True - else: - realtime = False - print "Note: failed to enable realtime scheduling" - - # Sampling rate is hardcoded and cannot be read off device - adc_rate = 102.4e6 - self.int_rate = adc_rate / self.decim - print "Sampling rate: ", self.int_rate - - # build graph - self.port = 10001 # required port for UDP packets - - # which board, op mode, adx, port -# self.src = msdd.source_c(0, 1, self.address, self.port) # build source object - - self.conv = gr.interleaved_short_to_complex(); - - self.src = msdd.source_simple(self.address,self.port); - self.src.set_decim_rate(self.decim) # set decimation rate -# self.src.set_desired_packet_size(0, 1460) # set packet size to collect - - self.set_gain(self.gain) # set receiver's attenuation - self.set_freq(self.min_freq) # set receiver's rx frequency - - # restructure into vector format for FFT input - s2v = gr.stream_to_vector(gr.sizeof_gr_complex, self.fft_size) - - # set up FFT processing block - mywindow = window.blackmanharris(self.fft_size) - fft = gr.fft_vcc(self.fft_size, True, mywindow, True) - power = 0 - for tap in mywindow: - power += tap*tap - - # calculate magnitude squared of output of FFT - c2mag = gr.complex_to_mag_squared(self.fft_size) - - # FIXME the log10 primitive is dog slow - log = gr.nlog10_ff(10, self.fft_size, - -20*math.log10(self.fft_size)-10*math.log10(power/self.fft_size)) - - # Set the freq_step to % of the actual data throughput. - # This allows us to discard the bins on both ends of the spectrum. - self.percent = 0.4 - - # Calculate the frequency steps to use in the collection over the whole bandwidth - self.freq_step = self.percent * self.int_rate - self.min_center_freq = self.min_freq + self.freq_step/2 - nsteps = math.ceil((self.max_freq - self.min_freq) / self.freq_step) - self.max_center_freq = self.min_center_freq + (nsteps * self.freq_step) - - self.next_freq = self.min_center_freq - - # use these values to set receiver settling time between samples and sampling time - # the default values provided seem to work well with the MSDD over 100 Mbps ethernet - tune_delay = max(0, int(round(options.tune_delay * self.int_rate / self.fft_size))) # in fft_frames - dwell_delay = max(1, int(round(options.dwell_delay * self.int_rate / self.fft_size))) # in fft_frames - - # set up message callback routine to get data from bin_statistics_f block - self.msgq = gr.msg_queue(16) - self._tune_callback = tune(self) # hang on to this to keep it from being GC'd - - # FIXME this block doesn't like to work with negatives because of the "d_max[i]=0" on line - # 151 of gr_bin_statistics_f.cc file. Set this to -10000 or something to get it to work. - stats = gr.bin_statistics_f(self.fft_size, self.msgq, - self._tune_callback, tune_delay, dwell_delay) - - # FIXME there's a concern over the speed of the log calculation - # We can probably calculate the log inside the stats block - self.connect(self.src, self.conv, s2v, fft, c2mag, log, stats) - - - def set_next_freq(self): - ''' Find and set the next frequency of the reciver. After going past the maximum frequency, - the frequency is wrapped around to the start again''' - target_freq = self.next_freq - self.next_freq = self.next_freq + self.freq_step - if self.next_freq >= self.max_center_freq: - self.next_freq = self.min_center_freq - - if not self.set_freq(target_freq): - print "Failed to set frequency to", target_freq - - return target_freq - - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - - """ - return self.src.set_rx_freq(0, target_freq) - - - def set_gain(self, gain): - self.src.set_pga(0, gain) - - -def main_loop(tb): - # Set up parser to get data from stats block and display them. - msgparser = parse_msg(tb.int_rate, tb.percent) - - while 1: - # Get the next message sent from the C++ code (blocking call). - # It contains the center frequency and the mag squared of the fft - d = tb.msgq.delete_head(); - print d.to_string(); - msgparser.parse(d) - #print msgparser.center_freq - -if __name__ == '__main__': - tb = my_top_block() - try: - tb.start() # start executing flow graph in another thread... - main_loop(tb) - - except KeyboardInterrupt: - pass diff --git a/gr-msdd6000/src/python-examples/new_msdd_fft.py b/gr-msdd6000/src/python-examples/new_msdd_fft.py deleted file mode 100755 index 782ecb66e..000000000 --- a/gr-msdd6000/src/python-examples/new_msdd_fft.py +++ /dev/null @@ -1,299 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2004,2005,2007,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, gru -from gnuradio import usrp -from gnuradio import msdd -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from gnuradio.wxgui import stdgui2, fftsink2, waterfallsink2, scopesink2, form, slider -from optparse import OptionParser -import wx -import sys -import numpy - -def pick_subdevice(u): - """ - The user didn't specify a subdevice on the command line. - If there's a daughterboard on A, select A. - If there's a daughterboard on B, select B. - Otherwise, select A. - """ - return (0, 0) - - -class app_top_block(stdgui2.std_top_block): - def __init__(self, frame, panel, vbox, argv): - stdgui2.std_top_block.__init__(self, frame, panel, vbox, argv) - - self.frame = frame - self.panel = panel - - parser = OptionParser(option_class=eng_option) - parser.add_option("-w", "--which", type="int", default=0, - help="select which USRP (0, 1, ...) default is %default", - metavar="NUM") - parser.add_option("-R", "--rx-subdev-spec", type="subdev", default=None, - help="select USRP Rx side A or B (default=first one with a daughterboard)") - parser.add_option("-A", "--antenna", default=None, - help="select Rx Antenna (only on RFX-series boards)") - parser.add_option("-d", "--decim", type="int", default=16, - help="set fgpa decimation rate to DECIM [default=%default]") - parser.add_option("-f", "--freq", type="eng_float", default=None, - help="set frequency to FREQ", metavar="FREQ") - parser.add_option("-g", "--gain", type="eng_float", default=None, - help="set gain in dB (default is midpoint)") - parser.add_option("-W", "--waterfall", action="store_true", default=False, - help="Enable waterfall display") - parser.add_option("-8", "--width-8", action="store_true", default=False, - help="Enable 8-bit samples across USB") - parser.add_option( "--no-hb", action="store_true", default=False, - help="don't use halfband filter in usrp") - parser.add_option("-S", "--oscilloscope", action="store_true", default=False, - help="Enable oscilloscope display") - parser.add_option("", "--avg-alpha", type="eng_float", default=1e-1, - help="Set fftsink averaging factor, default=[%default]") - parser.add_option("", "--ref-scale", type="eng_float", default=13490.0, - help="Set dBFS=0dB input value, default=[%default]") - (options, args) = parser.parse_args() - if len(args) != 0: - parser.print_help() - sys.exit(1) - self.options = options - self.show_debug_info = True - - # build the graph - if options.no_hb or (options.decim<8): - #Min decimation of this firmware is 4. - #contains 4 Rx paths without halfbands and 0 tx paths. - self.fpga_filename="std_4rx_0tx.rbf" -# self.u = usrp.source_c(which=options.which, decim_rate=options.decim, fpga_filename=self.fpga_filename) - self.u = msdd.source_simple("192.168.1.200",0); - else: - #Min decimation of standard firmware is 8. - #standard fpga firmware "std_2rxhb_2tx.rbf" - #contains 2 Rx paths with halfband filters and 2 tx paths (the default) - #self.u = usrp.source_c(which=options.which, decim_rate=options.decim) - self.u = msdd.source_simple("192.168.1.200",0); - - - input_rate = self.u.adc_freq() / self.u.decim_rate() - - if options.waterfall: - self.scope = \ - waterfallsink2.waterfall_sink_c (panel, fft_size=1024, sample_rate=input_rate) - elif options.oscilloscope: - self.scope = scopesink2.scope_sink_c(panel, sample_rate=input_rate) - else: - self.scope = fftsink2.fft_sink_c (panel, fft_size=1024, sample_rate=input_rate, - ref_scale=options.ref_scale, ref_level=0.0, y_divs = 10, - avg_alpha=options.avg_alpha) - - self.conv = gr.interleaved_short_to_complex(); - self.connect(self.u, self.conv, self.scope) - - self._build_gui(vbox) - self._setup_events() - - # set initial values - - if options.gain is None: - # if no gain was specified, use the mid-point in dB - #g = self.subdev.gain_range() - #g = self.u.gain_range() - g = [0,10] - options.gain = float(g[0]+g[1])/2 - - if options.freq is None: - # if no freq was specified, use the mid-point - #r = self.subdev.freq_range() - #r = self.u.freq_range() - r = [30e6, 6e9] - options.freq = float(r[0]+r[1])/2 - - self.set_gain(options.gain) - - if options.antenna is not None: - print "Selecting antenna %s" % (options.antenna,) - self.subdev.select_rx_antenna(options.antenna) - - if self.show_debug_info: - self.myform['decim'].set_value(self.u.decim_rate()) - self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate()) - self.myform['dbname'].set_value("no subdevs used") - self.myform['baseband'].set_value(0) - self.myform['ddc'].set_value(0) - - if not(self.set_freq(options.freq)): - self._set_status_msg("Failed to set initial frequency") - - def _set_status_msg(self, msg): - self.frame.GetStatusBar().SetStatusText(msg, 0) - - def _build_gui(self, vbox): - - def _form_set_freq(kv): - return self.set_freq(kv['freq']) - - vbox.Add(self.scope.win, 10, wx.EXPAND) - - # add control area at the bottom - self.myform = myform = form.form() - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0, 0) - myform['freq'] = form.float_field( - parent=self.panel, sizer=hbox, label="Center freq", weight=1, - callback=myform.check_input_and_call(_form_set_freq, self._set_status_msg)) - - hbox.Add((5,0), 0, 0) - #g = self.subdev.gain_range() - #g = self.u.gain_range() - g = [0,10] - myform['gain'] = form.slider_field(parent=self.panel, sizer=hbox, label="Gain", - weight=3, - min=int(g[0]), max=int(g[1]), - callback=self.set_gain) - - hbox.Add((5,0), 0, 0) - vbox.Add(hbox, 0, wx.EXPAND) - - self._build_subpanel(vbox) - - def _build_subpanel(self, vbox_arg): - # build a secondary information panel (sometimes hidden) - - # FIXME figure out how to have this be a subpanel that is always - # created, but has its visibility controlled by foo.Show(True/False) - - def _form_set_decim(kv): - return self.set_decim(kv['decim']) - - if not(self.show_debug_info): - return - - panel = self.panel - vbox = vbox_arg - myform = self.myform - - #panel = wx.Panel(self.panel, -1) - #vbox = wx.BoxSizer(wx.VERTICAL) - - hbox = wx.BoxSizer(wx.HORIZONTAL) - hbox.Add((5,0), 0) - - myform['decim'] = form.int_field( - parent=panel, sizer=hbox, label="Decim", - callback=myform.check_input_and_call(_form_set_decim, self._set_status_msg)) - - hbox.Add((5,0), 1) - myform['fs@usb'] = form.static_float_field( - parent=panel, sizer=hbox, label="Fs@gigE") - - hbox.Add((5,0), 1) - myform['dbname'] = form.static_text_field( - parent=panel, sizer=hbox) - - hbox.Add((5,0), 1) - myform['baseband'] = form.static_float_field( - parent=panel, sizer=hbox, label="Analog BB") - - hbox.Add((5,0), 1) - myform['ddc'] = form.static_float_field( - parent=panel, sizer=hbox, label="DDC") - - hbox.Add((5,0), 0) - vbox.Add(hbox, 0, wx.EXPAND) - - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - - Tuning is a two step process. First we ask the front-end to - tune as close to the desired frequency as it can. Then we use - the result of that operation and our target_frequency to - determine the value for the digital down converter. - """ - #r = self.u.tune(0, self.subdev, target_freq) - r = self.u.set_rx_freq(0, target_freq) - - if r: - self.myform['freq'].set_value(target_freq) # update displayed value -# if self.show_debug_info: -# self.myform['baseband'].set_value(r.baseband_freq) -# self.myform['ddc'].set_value(r.dxc_freq) - if not self.options.waterfall and not self.options.oscilloscope: - self.scope.set_baseband_freq(target_freq) - return True - - return False - - def set_gain(self, gain): - self.myform['gain'].set_value(gain) # update displayed value - self.u.set_pga(0,gain) - - def set_decim(self, decim): - ok = self.u.set_decim_rate(decim) - if not ok: - print "set_decim failed" - input_rate = self.u.adc_freq() / self.u.decim_rate() - self.scope.set_sample_rate(input_rate) - if self.show_debug_info: # update displayed values - self.myform['decim'].set_value(self.u.decim_rate()) - self.myform['fs@usb'].set_value(self.u.adc_freq() / self.u.decim_rate()) - return ok - - def _setup_events(self): - if not self.options.waterfall and not self.options.oscilloscope: - self.scope.win.Bind(wx.EVT_LEFT_DCLICK, self.evt_left_dclick) - - def evt_left_dclick(self, event): - (ux, uy) = self.scope.win.GetXY(event) - if event.CmdDown(): - # Re-center on maximum power - points = self.scope.win._points - if self.scope.win.peak_hold: - if self.scope.win.peak_vals is not None: - ind = numpy.argmax(self.scope.win.peak_vals) - else: - ind = int(points.shape()[0]/2) - else: - ind = numpy.argmax(points[:,1]) - (freq, pwr) = points[ind] - target_freq = freq/self.scope.win._scale_factor - print ind, freq, pwr - self.set_freq(target_freq) - else: - # Re-center on clicked frequency - target_freq = ux/self.scope.win._scale_factor - self.set_freq(target_freq) - - -def main (): - app = stdgui2.stdapp(app_top_block, "USRP FFT", nstatus=1) - app.MainLoop() - -if __name__ == '__main__': - main () diff --git a/gr-msdd6000/src/python-examples/ofdm/benchmark_ofdm_rx.py b/gr-msdd6000/src/python-examples/ofdm/benchmark_ofdm_rx.py deleted file mode 100755 index deb82e111..000000000 --- a/gr-msdd6000/src/python-examples/ofdm/benchmark_ofdm_rx.py +++ /dev/null @@ -1,184 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2006, 2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, blks2 -from gnuradio import msdd -from gnuradio import eng_notation -from gnuradio.eng_option import eng_option -from optparse import OptionParser - -import struct, sys - -# from current dir -from receive_path import receive_path - -class my_top_block(gr.top_block): - def __init__(self, address, callback, options): - gr.top_block.__init__(self) - - self._address = address - self._rx_freq = options.rx_freq # receiver's center frequency - self._rx_gain = options.rx_gain # receiver's gain - self._decim = options.decim # Decimating rate for the USRP (prelim) - - if self._rx_freq is None: - sys.stderr.write("-f FREQ or --freq FREQ or --rx-freq FREQ must be specified\n") - raise SystemExit - - # Set up USRP source - self._setup_source() - - #taps = gr.firdes.low_pass(1, 1, 0.4, 0.2) - #self.resample = gr.rational_resampler_base_ccf(5, 8, taps) - self.resample = blks2.rational_resampler_ccf(5, 8) - - # Set up receive path - self.rxpath = receive_path(callback, options) - - self.connect(self.src, self.resample, self.rxpath) - #self.connect(self.src, gr.file_sink(gr.sizeof_gr_complex, "receive.dat")) - #self.connect(self.resample, gr.file_sink(gr.sizeof_gr_complex, "resampled.dat")) - - def _setup_source(self): - # build graph - self._port = 10001 - self.src = msdd.source_c(0, 1, self._address, self._port) - self.src.set_decim_rate(self._decim) - self.src.set_desired_packet_size(0, 1460) - - self.set_gain(self._rx_gain) - self.set_freq(self._rx_freq) - - def set_freq(self, target_freq): - """ - Set the center frequency we're interested in. - - @param target_freq: frequency in Hz - @rypte: bool - """ - r = self.src.set_rx_freq(0, target_freq) - if r: - return True - return False - - def set_gain(self, gain): - """ - Sets the analog gain in the USRP - """ - return self.src.set_pga(0, gain) - - def decim(self): - return self._decim - - def add_options(normal, expert): - """ - Adds usrp-specific options to the Options Parser - """ - add_freq_option(normal) - normal.add_option("", "--rx-gain", type="eng_float", default=32, metavar="GAIN", - help="set receiver gain in dB [default=%default].") - normal.add_option("-v", "--verbose", action="store_true", default=False) - - expert.add_option("", "--rx-freq", type="eng_float", default=None, - help="set Rx frequency to FREQ [default=%default]", metavar="FREQ") - expert.add_option("-d", "--decim", type="intx", default=128, - help="set fpga decimation rate to DECIM [default=%default]") - expert.add_option("", "--snr", type="eng_float", default=30, - help="set the SNR of the channel in dB [default=%default]") - - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - -def add_freq_option(parser): - """ - Hackery that has the -f / --freq option set both tx_freq and rx_freq - """ - def freq_callback(option, opt_str, value, parser): - parser.values.rx_freq = value - parser.values.tx_freq = value - - if not parser.has_option('--freq'): - parser.add_option('-f', '--freq', type="eng_float", - action="callback", callback=freq_callback, - help="set Tx and/or Rx frequency to FREQ [default=%default]", - metavar="FREQ") - -# ///////////////////////////////////////////////////////////////////////////// -# main -# ///////////////////////////////////////////////////////////////////////////// - -def main(): - - global n_rcvd, n_right - - n_rcvd = 0 - n_right = 0 - - def rx_callback(ok, payload): - global n_rcvd, n_right - n_rcvd += 1 - (pktno,) = struct.unpack('!H', payload[0:2]) - if ok: - n_right += 1 - print "ok: %r \t pktno: %d \t n_rcvd: %d \t n_right: %d" % (ok, pktno, n_rcvd, n_right) - - if 0: - printlst = list() - for x in payload[2:]: - t = hex(ord(x)).replace('0x', '') - if(len(t) == 1): - t = '0' + t - printlst.append(t) - printable = ''.join(printlst) - - print printable - print "\n" - - usage = "usage: %prog [options] host" - parser = OptionParser(usage=usage, option_class=eng_option, conflict_handler="resolve") - expert_grp = parser.add_option_group("Expert") - parser.add_option("","--discontinuous", action="store_true", default=False, - help="enable discontinuous") - - my_top_block.add_options(parser, expert_grp) - receive_path.add_options(parser, expert_grp) - blks2.ofdm_mod.add_options(parser, expert_grp) - blks2.ofdm_demod.add_options(parser, expert_grp) - - (options, args) = parser.parse_args () - address = args[0] - - # build the graph - tb = my_top_block(address, rx_callback, options) - - #r = gr.enable_realtime_scheduling() - #if r != gr.RT_OK: - # print "Warning: failed to enable realtime scheduling" - - tb.start() # start flow graph - tb.wait() # wait for it to finish - -if __name__ == '__main__': - try: - main() - except KeyboardInterrupt: - pass diff --git a/gr-msdd6000/src/python-examples/ofdm/gr_plot_ofdm.py b/gr-msdd6000/src/python-examples/ofdm/gr_plot_ofdm.py deleted file mode 100755 index 0bca41037..000000000 --- a/gr-msdd6000/src/python-examples/ofdm/gr_plot_ofdm.py +++ /dev/null @@ -1,268 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2007 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -import scipy, pylab, math -import struct, sys -from pylab import * -from matplotlib.font_manager import fontManager, FontProperties -from optparse import OptionParser -from scipy import fftpack -from math import log10 - -matplotlib.interactive(True) -matplotlib.use('TkAgg') - -class draw_constellation: - def __init__(self, options): - derot_file = "ofdm_frame_sink_c.dat" - acq_file = "ofdm_frame_acq_c.dat" - fft_file = "fft_out_c.dat" - - self.h_derot_file = open(derot_file, "r") - self.h_acq_file = open(acq_file, "r") - self.h_fft_file = open(fft_file, "r") - - self.occ_tones = options.occ_tones - self.fft_size = options.fft_size - self.symbol = options.start - self.sample_rate = options.sample_rate - - self.axis_font_size = 16 - self.label_font_size = 18 - self.title_font_size = 20 - self.text_size = 22 - - # Setup PLOT - self.fig = figure(1, figsize=(14, 9), facecolor='w') - rcParams['xtick.labelsize'] = self.axis_font_size - rcParams['ytick.labelsize'] = self.axis_font_size - - self.text_sym = figtext(0.05, 0.95, ("Symbol: %s" % self.symbol), weight="heavy", size=self.text_size) - - self.make_plots() - - self.button_left_axes = self.fig.add_axes([0.45, 0.01, 0.05, 0.05], frameon=True) - self.button_left = Button(self.button_left_axes, "<") - self.button_left_callback = self.button_left.on_clicked(self.button_left_click) - - self.button_right_axes = self.fig.add_axes([0.50, 0.01, 0.05, 0.05], frameon=True) - self.button_right = Button(self.button_right_axes, ">") - self.button_right_callback = self.button_right.on_clicked(self.button_right_click) - - self.xlim = self.sp_eq.get_xlim() - - self.manager = get_current_fig_manager() - #connect('draw_event', self.zoom) - connect('key_press_event', self.click) - show() - - def get_data(self): - self.text_sym.set_text("Symbol: %d" % (self.symbol)) - - derot_data = scipy.fromfile(self.h_derot_file, dtype=scipy.complex64, count=self.occ_tones) - acq_data = scipy.fromfile(self.h_acq_file, dtype=scipy.complex64, count=self.occ_tones) - fft_data = scipy.fromfile(self.h_fft_file, dtype=scipy.complex64, count=self.fft_size) - if(len(acq_data) == 0): - print "End of File" - else: - self.acq_data_reals = [r.real for r in acq_data] - self.acq_data_imags = [i.imag for i in acq_data] - self.derot_data_reals = [r.real for r in derot_data] - self.derot_data_imags = [i.imag for i in derot_data] - - self.unequalized_angle = [math.atan2(x.imag, x.real) for x in fft_data] - self.equalized_angle = [math.atan2(x.imag, x.real) for x in acq_data] - self.derot_equalized_angle = [math.atan2(x.imag, x.real) for x in derot_data] - - self.time = [i*(1/self.sample_rate) for i in range(len(acq_data))] - ffttime = [i*(1/self.sample_rate) for i in range(len(fft_data))] - - self.freq = self.get_freq(ffttime, self.sample_rate) - - for i in range(len(fft_data)): - if(abs(fft_data[i]) == 0.0): - fft_data[i] = complex(1e-6,1e-6) - self.fft_data = [20*log10(abs(f)) for f in fft_data] - - def get_freq(self, time, sample_rate, T=1): - N = len(time) - Fs = 1.0 / (max(time) - min(time)) - Fn = 0.5 * sample_rate - freq = [-Fn + i*Fs for i in range(N)] - return freq - - def make_plots(self): - self.h_acq_file.seek(8*self.symbol*self.occ_tones, 0) - self.h_fft_file.seek(8*self.symbol*self.fft_size, 0) - self.h_derot_file.seek(8*self.symbol*self.occ_tones, 0) - - self.get_data() - - # Subplot: constellation of rotated symbols - self.sp_const = self.fig.add_subplot(4,1,1, position=[0.15, 0.55, 0.3, 0.35]) - self.sp_const.set_title(("Constellation"), fontsize=self.title_font_size, fontweight="bold") - self.sp_const.set_xlabel("Inphase", fontsize=self.label_font_size, fontweight="bold") - self.sp_const.set_ylabel("Qaudrature", fontsize=self.label_font_size, fontweight="bold") - self.plot_const = plot(self.acq_data_reals, self.acq_data_imags, 'bo') - self.plot_const += plot(self.derot_data_reals, self.derot_data_imags, 'ro') - self.sp_const.axis([-2, 2, -2, 2]) - - # Subplot: unequalized angle - self.sp_uneq = self.fig.add_subplot(4,2,1, position=[0.575, 0.55, 0.3, 0.35]) - self.sp_uneq.set_title(("Unequalized Angle"), fontsize=self.title_font_size, fontweight="bold") - self.sp_uneq.set_xlabel("Time (s)", fontsize=self.label_font_size, fontweight="bold") - self.sp_uneq.set_ylabel("Angle", fontsize=self.label_font_size, fontweight="bold") - uneqscale = range(len(self.unequalized_angle)) - self.plot_uneq = plot(uneqscale, self.unequalized_angle, 'bo') - - # Subplot: equalized angle - self.sp_eq = self.fig.add_subplot(4,1,2, position=[0.15, 0.1, 0.3, 0.35]) - self.sp_eq.set_title(("Equalized Angle"), fontsize=self.title_font_size, fontweight="bold") - self.sp_eq.set_xlabel("Time (s)", fontsize=self.label_font_size, fontweight="bold") - self.sp_eq.set_ylabel("Angle", fontsize=self.label_font_size, fontweight="bold") - eqscale = range(len(self.equalized_angle)) - self.plot_eq = plot(eqscale, self.equalized_angle, 'bo') - self.plot_eq += plot(eqscale, self.derot_equalized_angle, 'ro', markersize=4) - - # Subplot: FFT - self.sp_fft = self.fig.add_subplot(4,2,2, position=[0.575, 0.1, 0.3, 0.35]) - self.sp_fft.set_title(("FFT"), fontsize=self.title_font_size, fontweight="bold") - self.sp_fft.set_xlabel("Frequency (MHz)", fontsize=self.label_font_size, fontweight="bold") - self.sp_fft.set_ylabel("Power (dBm)", fontsize=self.label_font_size, fontweight="bold") - self.plot_fft = plot(self.freq, self.fft_data, '-bo') - - draw() - - def update_plots(self): - eqscale = range(len(self.equalized_angle)) - uneqscale = range(len(self.unequalized_angle)) - self.plot_eq[0].set_data([eqscale, self.equalized_angle]) - self.plot_eq[1].set_data([eqscale, self.derot_equalized_angle]) - self.plot_uneq[0].set_data([uneqscale, self.unequalized_angle]) - self.sp_eq.set_ylim([-4, 4]) - self.sp_uneq.set_ylim([-4, 4]) - - #self.sp_iq.axis([min(self.time), max(self.time), - # 1.5*min([min(self.acq_data_reals), min(self.acq_data_imags)]), - # 1.5*max([max(self.acq_data_reals), max(self.acq_data_imags)])]) - - self.plot_const[0].set_data([self.acq_data_reals, self.acq_data_imags]) - self.plot_const[1].set_data([self.derot_data_reals, self.derot_data_imags]) - self.sp_const.axis([-2, 2, -2, 2]) - - self.plot_fft[0].set_data([self.freq, self.fft_data]) - - draw() - - def zoom(self, event): - newxlim = self.sp_eq.get_xlim() - if(newxlim != self.xlim): - self.xlim = newxlim - r = self.reals[int(ceil(self.xlim[0])) : int(ceil(self.xlim[1]))] - i = self.imags[int(ceil(self.xlim[0])) : int(ceil(self.xlim[1]))] - - self.plot_const[0].set_data(r, i) - self.sp_const.axis([-2, 2, -2, 2]) - self.manager.canvas.draw() - draw() - - def click(self, event): - forward_valid_keys = [" ", "down", "right"] - backward_valid_keys = ["up", "left"] - - if(find(event.key, forward_valid_keys)): - self.step_forward() - - elif(find(event.key, backward_valid_keys)): - self.step_backward() - - def button_left_click(self, event): - self.step_backward() - - def button_right_click(self, event): - self.step_forward() - - def step_forward(self): - self.symbol += 1 - self.get_data() - self.update_plots() - - def step_backward(self): - # Step back in file position - self.symbol -= 1 - if(self.h_acq_file.tell() >= 16*self.occ_tones): - self.h_acq_file.seek(-16*self.occ_tones, 1) - else: - self.symbol = 0 - self.h_acq_file.seek(-self.h_acq_file.tell(),1) - - - if(self.h_derot_file.tell() >= 16*self.occ_tones): - self.h_derot_file.seek(-16*self.occ_tones, 1) - else: - self.symbol = 0 - self.h_derot_file.seek(-self.h_derot_file.tell(),1) - - - if(self.h_fft_file.tell() >= 16*self.fft_size): - self.h_fft_file.seek(-16*self.fft_size, 1) - else: - self.symbol = 0 - self.h_fft_file.seek(-self.h_fft_file.tell(),1) - - self.get_data() - self.update_plots() - - - -#FIXME: there must be a way to do this with a Python builtin -def find(item_in, list_search): - for l in list_search: - if item_in == l: - return True - return False - -def main(): - usage="%prog: [options]" - - parser = OptionParser(conflict_handler="resolve", usage=usage) - parser.add_option("", "--fft-size", type="int", default=512, - help="Specify the size of the FFT [default=%default]") - parser.add_option("", "--occ-tones", type="int", default=200, - help="Specify the number of occupied tones [default=%default]") - parser.add_option("-s", "--start", type="int", default=0, - help="Specify the starting symbol to plot [default=%default]") - parser.add_option("-R", "--sample-rate", type="float", default=1.0, - help="Set the sampler rate of the data [default=%default]") - - (options, args) = parser.parse_args () - - dc = draw_constellation(options) - -if __name__ == "__main__": - try: - main() - except KeyboardInterrupt: - pass - - - diff --git a/gr-msdd6000/src/python-examples/ofdm/receive_path.py b/gr-msdd6000/src/python-examples/ofdm/receive_path.py deleted file mode 100644 index 11c714aaf..000000000 --- a/gr-msdd6000/src/python-examples/ofdm/receive_path.py +++ /dev/null @@ -1,102 +0,0 @@ -#!/usr/bin/env python -# -# Copyright 2005,2006 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -from gnuradio import gr, gru, blks2 -from gnuradio import usrp -from gnuradio import eng_notation -import copy -import sys - -# ///////////////////////////////////////////////////////////////////////////// -# receive path -# ///////////////////////////////////////////////////////////////////////////// - -class receive_path(gr.hier_block2): - def __init__(self, rx_callback, options): - - gr.hier_block2.__init__(self, "receive_path", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(0, 0, 0)) # Output signature - - - options = copy.copy(options) # make a copy so we can destructively modify - - self._verbose = options.verbose - self._log = options.log - self._rx_callback = rx_callback # this callback is fired when there's a packet available - - # receiver - self.ofdm_rx = \ - blks2.ofdm_demod(options, callback=self._rx_callback) - - # Carrier Sensing Blocks - alpha = 0.001 - thresh = 30 # in dB, will have to adjust - self.probe = gr.probe_avg_mag_sqrd_c(thresh,alpha) - - self.connect(self, self.ofdm_rx) - self.connect(self.ofdm_rx, self.probe) - - # Display some information about the setup - if self._verbose: - self._print_verbage() - - def carrier_sensed(self): - """ - Return True if we think carrier is present. - """ - #return self.probe.level() > X - return self.probe.unmuted() - - def carrier_threshold(self): - """ - Return current setting in dB. - """ - return self.probe.threshold() - - def set_carrier_threshold(self, threshold_in_db): - """ - Set carrier threshold. - - @param threshold_in_db: set detection threshold - @type threshold_in_db: float (dB) - """ - self.probe.set_threshold(threshold_in_db) - - - def add_options(normal, expert): - """ - Adds receiver-specific options to the Options Parser - """ - normal.add_option("-v", "--verbose", action="store_true", default=False) - expert.add_option("", "--log", action="store_true", default=False, - help="Log all parts of flow graph to files (CAUTION: lots of data)") - - # Make a static method to call before instantiation - add_options = staticmethod(add_options) - - - def _print_verbage(self): - """ - Prints information about the receive path - """ - pass diff --git a/gr-msdd6000/src/python-examples/playback_samples.m b/gr-msdd6000/src/python-examples/playback_samples.m deleted file mode 100644 index 332296e72..000000000 --- a/gr-msdd6000/src/python-examples/playback_samples.m +++ /dev/null @@ -1,12 +0,0 @@ -t = read_complex_binary('msdd.dat',10000000); - -fftsize=256; -w = [0:pi/fftsize:pi]; - -for i = 0:length(t)/fftsize - fftdata = fft(i*fftsize:i*fftsize+fftsize); - clear plot; - plot(w,fftdata); -endfor - -pause; diff --git a/gr-msdd6000/src/python-examples/read_complex_binary.m b/gr-msdd6000/src/python-examples/read_complex_binary.m deleted file mode 100644 index 67158b528..000000000 --- a/gr-msdd6000/src/python-examples/read_complex_binary.m +++ /dev/null @@ -1,48 +0,0 @@ -% -% Copyright 2001 Free Software Foundation, Inc. -% -% This file is part of GNU Radio -% -% GNU Radio is free software; you can redistribute it and/or modify -% it under the terms of the GNU General Public License as published by -% the Free Software Foundation; either version 3, or (at your option) -% any later version. -% -% GNU Radio is distributed in the hope that it will be useful, -% but WITHOUT ANY WARRANTY; without even the implied warranty of -% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% GNU General Public License for more details. -% -% You should have received a copy of the GNU General Public License -% along with GNU Radio; see the file COPYING. If not, write to -% the Free Software Foundation, Inc., 51 Franklin Street, -% Boston, MA 02110-1301, USA. -% - -function v = read_complex_binary (filename, count) - - %% usage: read_complex_binary (filename, [count]) - %% - %% open filename and return the contents as a column vector, - %% treating them as 32 bit complex numbers - %% - - m = nargchk (1,2,nargin); - if (m) - usage (m); - end - - if (nargin < 2) - count = Inf; - end - - f = fopen (filename, 'rb'); - if (f < 0) - v = 0; - else - t = fread (f, [2, count], 'float'); - fclose (f); - v = t(1,:) + t(2,:)*i; - [r, c] = size (v); - v = reshape (v, c, r); - end diff --git a/gr-msdd6000/src/python_test/capture_tcp_one_set.py b/gr-msdd6000/src/python_test/capture_tcp_one_set.py deleted file mode 100644 index 7a106a63a..000000000 --- a/gr-msdd6000/src/python_test/capture_tcp_one_set.py +++ /dev/null @@ -1,156 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = random.randint(1025,65535); -filename = "output.dat"; - -port = 10000 -host = "10.45.4.46" -#host = "10.45.4.41" -myaddr = ('',myport); - -buf = 100000; - -TCPSock = socket(AF_INET,SOCK_STREAM); -TCPSock.bind(myaddr); -TCPSock.connect((host,port)); - -#f_mhz = 2647; # roof ofdm -if(len(sys.argv)!= 3): - print "usage: %s fc_ghz decim_pow2_exponent"%(sys.argv[0]); - sys.exit(-1); - -f_mhz = float(sys.argv[1])*1000; -decim = int(sys.argv[2]); - -#f_mhz = 3500; -#f_mhz = 2600; -f_hz = 0; # offset -gain = 0; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman - -samples = 65536; -#samples = 16777216; -samples = samples*4; #bytes of data we are requesting -samples=samples*2; -#decim = 2; #0-8 (3 => 2^3 = 8) -decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats -mode = 0; #0=IQ, 1=MAG, 2=MAGDB -sets = 1; - -raw_data = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain, samples, decim, sets); - -data = raw_data; - -TCPSock.send(data); - -print "sent" - - - -count = 0; - -total_data = []; - -state = 0; - -vals = []; -mags = []; -re = []; - -sample_count = 0; -IQ_bytes=0; -while(TCPSock): - if(state==0): - data = TCPSock.recv(4); - [opcode] = struct.unpack("<I", data); - print "Opcode = %d"%(opcode); - if(opcode==1): - state = 1; - - elif(state==1): - data = TCPSock.recv(7*4); - args = struct.unpack("<IIIIIII", data); - print ["reply_len", "freq_mhz", "offset_hz", "gain", "sample_bytes", "decim", "sets_remain"]; - print args; - IQ_bytes = args[0] - 7*4; - state =2; - - elif(state==2): - data = TCPSock.recv(4); - [i,q] = struct.unpack("<hh", data); - tmp = complex(i,q); - - re.append(i); - vals.append(tmp); - mags.append(abs(tmp)); - - - sample_count = sample_count + 1; -# print "sample count %d"%(sample_count) - - IQ_bytes = IQ_bytes - 4; - if(IQ_bytes < 4): - print "got all data (total %d)"%(sample_count); - print "remaining: %d"%(IQ_bytes); - break; - - -TCPSock.close(); - -print "done" -nmags = [] -for i in mags: - if i == 0: - i=1; - nmags.append(i); - - -subplot(2,1,1); -plot(nmags); -#plot(10*log10(nmags)); - -dlen = len(vals); -fftlen = (dlen-1024)/1024; - -fft_data = [] -for i in range(1, dlen-1025, 1024): - - t_in = []; - for ind in range(i, i+1024): - t_in.append(vals[ind]); - - #tmp = 20*log10(fftshift(fft(t_in))); - tmp = (fftshift(fft(t_in))); - - if(len(fft_data) == 0): - for ind in range(0,1024): - fft_data.append( tmp[ind] ); - else: - for ind in range(0,1024): - fft_data[ind] = fft_data[ind] + tmp[ind]; - -#fft_data = 20*log10(fftshift(fft(vals))); - - -subplot(2,1,2); -plot(fft_data); -show(); - -f = open(filename, "w"); -for sample in vals: - binchunk = struct.pack("<ff",float(sample.real), float(sample.imag) ); - f.write(binchunk); -f.close(); - - diff --git a/gr-msdd6000/src/python_test/flood_udp.py b/gr-msdd6000/src/python_test/flood_udp.py deleted file mode 100644 index e59208a7a..000000000 --- a/gr-msdd6000/src/python_test/flood_udp.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; - -msdd_port = 10001 -msdd_host = "10.45.4.43" - -my_udp_addr = ("10.45.1.229",10001); - -buf = 1024; - -#myport = random.randint(1025,65535); -#my_tcp_addr = ("10.45.1.229",myport); -#TCPSock = socket(AF_INET,SOCK_STREAM); -#TCPSock.bind(my_tcp_addr); -#TCPSock.connect((msdd_host,msdd_port)); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -SETS_STREAM = 0xffffffff; - -f_mhz = 2400; -f_hz = 1; -gain = 3; -samples = 512; -decim = 4; -#sets = 16; -sets = SETS_STREAM; -window = 3; -mode = 1; - - - -for first_byte in range(0,0xff): - for second_byte in range(0,0xff): - for third_byte in range(0,0xff): - data = struct.pack("!III", first_byte, second_byte,third_byte); - UDPSock.sendto(data, (msdd_host,msdd_port)) - - -# construct the 3 different request type packets -#fft_data = struct.pack("<IIIIIIIIII", 0x02, 0x20, f_mhz, f_hz, gain,window, samples, decim, mode,sets); -#raw_data = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain,samples, decim,sets); -#stat_data = struct.pack("!II", 0x0000, 0x0000) - -# send appropriate udp request packet - - - - - - - - - diff --git a/gr-msdd6000/src/python_test/halt.py b/gr-msdd6000/src/python_test/halt.py deleted file mode 100644 index 0285f7817..000000000 --- a/gr-msdd6000/src/python_test/halt.py +++ /dev/null @@ -1,40 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = random.randint(1025,65535); -filename = "output.dat"; - -msdd_port = 10001 -msdd_host = "10.45.4.43" - -buf = 100000; - -my_udp_addr = ('',10001); -my_udp_addr = ('10.45.1.229 ',10001); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -halt_data = struct.pack("<II", 0x04, 0x00); -halt_data = struct.pack("<II", 0x04, 0x00); - -data = halt_data; - -UDPSock.sendto(data, (msdd_host, msdd_port)); - -print "sent" - -UDPSock.close(); - - - diff --git a/gr-msdd6000/src/python_test/newtest.py b/gr-msdd6000/src/python_test/newtest.py deleted file mode 100644 index 9596a0675..000000000 --- a/gr-msdd6000/src/python_test/newtest.py +++ /dev/null @@ -1,140 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = random.randint(1025,65535); -filename = "output.dat"; - -msdd_port = 10001 -msdd_host = "10.45.4.43" - -buf = 100000; - -my_udp_addr = ('',10001); -my_udp_addr = ('10.45.1.229 ',10001); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -#f_mhz = 3500; -#f_mhz = 3500; -f_mhz = 100; -f_hz = 0; -gain = 0; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman - -samples = 12000; -samples = samples*4; #bytes of data we are requesting - -decim = 2; #0-8 (3 => 2^3 = 8) -decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats -mode = 0; #0=IQ, 1=MAG, 2=MAGDB -#sets = 0; -sets = 0xffffffff; - -size_int = 4; -request_len = 6*size_int; # 6 int items not including the 8 bytes for opcode and length fields -print "request len = %d"%(request_len); - -#raw_data = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain, samples, decim, sets); -raw_data = struct.pack("<IIIIIIII", 0x01, request_len, f_mhz, f_hz, gain, samples, decim, sets); - -data = raw_data; - -UDPSock.sendto(data, (msdd_host, msdd_port)); - -print "sent" - - - -count = 0; - -total_data = []; - -state = 0; - -vals = []; -mags = []; -re = []; - -sample_count = 0; -IQ_bytes=0; - -while(True): - print state; - if(state==0): - data = UDPSock.recv(4); - [opcode] = struct.unpack("<I", data); - print "Opcode = %d"%(opcode); - if(opcode==1): - - # if UDP mode and sets_stream requested, - # we do not get a header reply back, only data - if(sets == 0): - state = 1; - else: - state = 2; - - elif(state==1): - data = UDPSock.recv(7*4); - args = struct.unpack("<IIIIIII", data); - print ["reply_len", "freq_mhz", "offset_hz", "gain", "sample_bytes", "decim", "sets_remain"]; - print args; - IQ_bytes = args[0] - 7*4; - state =2; - - elif(state==2): - data = UDPSock.recv(4); - [i,q] = struct.unpack("<hh", data); - tmp = complex(i,q); - - re.append(i); - vals.append(tmp); - mags.append(abs(tmp)); - - - sample_count = sample_count + 1; -# print "sample count %d"%(sample_count) - - IQ_bytes = IQ_bytes - 4; - if(IQ_bytes < 4): - print "got all data (total %d)"%(sample_count); - print "remaining: %d"%(IQ_bytes); - break; - - -UDPSock.close(); - -print "done" -nmags = [] -for i in mags: - if i == 0: - i=1; - nmags.append(i); - - -subplot(2,1,1); -plot(20*log10(nmags)); - -fft_data = 20*log10(fftshift(fft(vals))); - -subplot(2,1,2); -plot(fft_data); -show(); - -f = open(filename, "w"); -for sample in vals: - binchunk = struct.pack("<ff",float(sample.real), float(sample.imag) ); - f.write(binchunk); -f.close(); - - diff --git a/gr-msdd6000/src/python_test/spectrogram.py b/gr-msdd6000/src/python_test/spectrogram.py deleted file mode 100644 index 015dd9105..000000000 --- a/gr-msdd6000/src/python_test/spectrogram.py +++ /dev/null @@ -1,87 +0,0 @@ -#!/usr/bin/python - -fft_bins = 1024; -stride = 256; - -#filename = "output.dat"; -#decim = 4; -#Fs = (102.4/decim) * 1e6; - - -from gnuradio import gr; -from Numeric import *; -import FFT; -import numpy.fft; -from numpy import *; -from pylab import *; -import sys; - -if len(sys.argv) <2: - print "usage: %s filename <sample_rate_in_MSPS> <stride_samples>"%(sys.argv[0]); - sys.exit(-1); - -filename = sys.argv[1]; -fs = 0; -if(len(sys.argv)>2): - fs = float(sys.argv[2])*1000000; -print "opening %s.\n"%(filename); - -if(len(sys.argv)>=4): - stride = int(sys.argv[3]); - print "using stride = %d"%(stride); - -tb = gr.top_block(); -src = gr.file_source(gr.sizeof_gr_complex, filename, False) -sink = gr.vector_sink_c(); -tb.connect(src,sink); -tb.run(); - -data = sink.data(); -dataa = array(data); -datalen = len( data ); - -time_bins = (datalen - fft_bins) / stride; - -print "output vector :: fft_bins = %d, time_bins = %d\n"%(fft_bins,time_bins); - -start_idx = 0; - -b = numpy.zeros((time_bins, fft_bins), complex); -l = []; - -window = numpy.blackman(fft_bins); - -for i in range(0,time_bins): - - time_chunk = take( dataa, range(start_idx,start_idx + fft_bins), 0); - time_chunk = time_chunk * window; - fft_chunk = numpy.fft.fftshift(numpy.fft.fft(time_chunk)); - psd = 10*log10(fft_chunk * conj(fft_chunk)+0.001); - - b[i] = psd.real; - l.append( psd.real.tolist() ); - - start_idx = start_idx + stride; - -#c = array(b, 10); - -print b[0]; -c = array(b); -#l = c.tolist(); -print size(l); - -x = range(0,time_bins); -print size(x); -y = range(0,fft_bins); -print size(y); - -print size(l); - -contourf(l); -#contourf([x,y], l); -colorbar(); -show(); - -#print c[1,1]; - - diff --git a/gr-msdd6000/src/python_test/test_tcp.py b/gr-msdd6000/src/python_test/test_tcp.py deleted file mode 100755 index b02db815d..000000000 --- a/gr-msdd6000/src/python_test/test_tcp.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; - -myport = random.randint(1025,65535); - -port = 10000 -host = "10.45.4.43" -myaddr = ("10.45.1.229",myport); - -buf = 100000; - -TCPSock = socket(AF_INET,SOCK_STREAM); -#TCPSock = socket(AF_INET,SOCK_DGRAM); -TCPSock.bind(myaddr); -TCPSock.connect((host,port)); - -f_mhz = 2400; -f_hz = 0; -gain = 2; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman -#samples = 0xffffffff; #8-15 fft:(returns 2^number[8-15]) raw:(returns number) -samples = 2; #8-15 fft:(returns 2^number[8-15]) raw:(returns number) -decim = 2; #0-8 -#decim = decim+16; # +16 to use 16bit instead of 32 bit -mode = 1; #0=IQ, 1=MAG, 2=MAGDB -sets = 0xffffffff; -#sets = 1; - -fft_data = struct.pack("<IIIIIIIIII", 0x02, 0x20, f_mhz, f_hz, gain,window, samples, decim, mode,sets); -raw_data = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain,samples, decim,sets); -stat_data = struct.pack("!II", 0x0000, 0x0000) - -data = raw_data; - -#TCPSock.sendto(data, (host,port)) -TCPSock.send(data); - -print "sent" - - - -count = 0; -while(1): - data,addr = TCPSock.recvfrom(buf); - - print "got response" - - print "Data length: %d bytes."%(len(data)); - if(len(data)==12): - a,b,c = struct.unpack("!III",data); - print "%x,%x,%x"%(a,b,c); - - datavector = []; - - for d in data: - a = struct.unpack("<b",d); - datavector.append(a); - - print datavector; - - count = count + 1; - - if(count > 1): - sets = 3; - raw_data_2 = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain,samples, decim,sets); - TCPSock.send(raw_data_2); - - - -TCPSock.close(); - - - diff --git a/gr-msdd6000/src/python_test/test_tcp_fft.py b/gr-msdd6000/src/python_test/test_tcp_fft.py deleted file mode 100644 index b02db815d..000000000 --- a/gr-msdd6000/src/python_test/test_tcp_fft.py +++ /dev/null @@ -1,78 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; - -myport = random.randint(1025,65535); - -port = 10000 -host = "10.45.4.43" -myaddr = ("10.45.1.229",myport); - -buf = 100000; - -TCPSock = socket(AF_INET,SOCK_STREAM); -#TCPSock = socket(AF_INET,SOCK_DGRAM); -TCPSock.bind(myaddr); -TCPSock.connect((host,port)); - -f_mhz = 2400; -f_hz = 0; -gain = 2; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman -#samples = 0xffffffff; #8-15 fft:(returns 2^number[8-15]) raw:(returns number) -samples = 2; #8-15 fft:(returns 2^number[8-15]) raw:(returns number) -decim = 2; #0-8 -#decim = decim+16; # +16 to use 16bit instead of 32 bit -mode = 1; #0=IQ, 1=MAG, 2=MAGDB -sets = 0xffffffff; -#sets = 1; - -fft_data = struct.pack("<IIIIIIIIII", 0x02, 0x20, f_mhz, f_hz, gain,window, samples, decim, mode,sets); -raw_data = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain,samples, decim,sets); -stat_data = struct.pack("!II", 0x0000, 0x0000) - -data = raw_data; - -#TCPSock.sendto(data, (host,port)) -TCPSock.send(data); - -print "sent" - - - -count = 0; -while(1): - data,addr = TCPSock.recvfrom(buf); - - print "got response" - - print "Data length: %d bytes."%(len(data)); - if(len(data)==12): - a,b,c = struct.unpack("!III",data); - print "%x,%x,%x"%(a,b,c); - - datavector = []; - - for d in data: - a = struct.unpack("<b",d); - datavector.append(a); - - print datavector; - - count = count + 1; - - if(count > 1): - sets = 3; - raw_data_2 = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain,samples, decim,sets); - TCPSock.send(raw_data_2); - - - -TCPSock.close(); - - - diff --git a/gr-msdd6000/src/python_test/test_udp.py b/gr-msdd6000/src/python_test/test_udp.py deleted file mode 100755 index fd93847e9..000000000 --- a/gr-msdd6000/src/python_test/test_udp.py +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; - -msdd_port = 10001 -msdd_host = "10.45.4.43" - -my_udp_addr = ("10.45.1.229",10001); - -buf = 1024; - -#myport = random.randint(1025,65535); -#my_tcp_addr = ("10.45.1.229",myport); -#TCPSock = socket(AF_INET,SOCK_STREAM); -#TCPSock.bind(my_tcp_addr); -#TCPSock.connect((msdd_host,msdd_port)); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -SETS_STREAM = 0xffffffff; - -f_mhz = 2400; -f_hz = 1; -gain = 3; -samples = 512; - -decim = 2; - -#sets = 16; -sets = SETS_STREAM; -window = 3; -mode = 1; - - -# construct the 3 different request type packets -fft_data = struct.pack("<IIIIIIIIII", 0x02, 0x20, f_mhz, f_hz, gain,window, samples, decim, mode,sets); -raw_data = struct.pack("<IIIIIIII", 0x01, 0x18, f_mhz, f_hz, gain,samples, decim,sets); -stat_data = struct.pack("!II", 0x0000, 0x0000) - -# send appropriate udp request packet -UDPSock.sendto(raw_data, (msdd_host,msdd_port)) - -#TCPSock.send(raw_data); - - -print "sent request" - - -print "waiting for response" -data,addr = UDPSock.recvfrom(buf); - -print "got response" - -print data; diff --git a/gr-msdd6000/src/python_test/udp_stream_cap.py b/gr-msdd6000/src/python_test/udp_stream_cap.py deleted file mode 100644 index 6326f27c5..000000000 --- a/gr-msdd6000/src/python_test/udp_stream_cap.py +++ /dev/null @@ -1,110 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = random.randint(1025,65535); -filename = "output.dat"; - -msdd_port = 10001 -msdd_host = "10.45.4.43" - -buf = 100000; - -my_udp_addr = ('',10001); -my_udp_addr = ('10.45.1.229 ',10001); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -#f_mhz = 3500; -#f_mhz = 3500; -f_mhz = 1000; -f_hz = 0; -gain = 0; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman - -#samples = 65535; -samples = 16384; -#samples = samples*4; #bytes of data we are requesting - -decim = 4; #0-8 (3 => 2^3 = 8) -decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats -mode = 0; #0=IQ, 1=MAG, 2=MAGDB -#sets = 0; -sets = 0xffffffff; - -size_int = 4; -request_len = 6*size_int; # 6 int items not including the 8 bytes for opcode and length fields -print "request len = %d"%(request_len); - -raw_data = struct.pack("<IIIIIIII", 0x01, request_len, f_mhz, f_hz, gain, samples, decim, sets); - -data = raw_data; - -UDPSock.sendto(data, (msdd_host, msdd_port)); - -print "sent" - - - -count = 0; - -total_data = []; - -state = 0; - -vals = []; -mags = []; -re = []; - -sample_count = 0; -IQ_bytes=0; - - -numtocap = 1000; -IQ_bytes = 4 * numtocap; - -numbytes = 100 * 65536; - -num_rx = 0; -start = time.time(); - -d = []; -while(num_rx < numbytes): - data = UDPSock.recv(65536); - num_rx = num_rx + len(data); - d.append(data); - -mags = []; -for i in range(0, len(d)/4): - v = struct.unpack_from("<f",d, i*4); - mags.append(abs(v)); -plot(mags); -show(); - -end = time.time(); -print "recieved %d bytes in %f sec"%(numbytes, end-start); - -bytes_per_sec = numbytes / (end-start); -samples_per_sec = bytes_per_sec / 4; -MSPS = samples_per_sec / 1000000.0; - -print "Got %f MSPS"%(MSPS); -print "Expected %f MSPS"%(102.4/math.pow(2,(1+decim-16))); - - -halt_data = struct.pack("<II", 0x04, 0x00); -UDPSock.sendto(halt_data, (msdd_host, msdd_port)); - - -UDPSock.close(); - diff --git a/gr-msdd6000/src/python_test/udp_stream_rate_test.py b/gr-msdd6000/src/python_test/udp_stream_rate_test.py deleted file mode 100644 index 0b75f2372..000000000 --- a/gr-msdd6000/src/python_test/udp_stream_rate_test.py +++ /dev/null @@ -1,106 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = random.randint(1025,65535); -filename = "output.dat"; - -msdd_port = 10001 -msdd_host = "10.45.4.46" - -buf = 100000; - -my_udp_addr = ('',10001); -my_udp_addr = ('10.45.1.229 ',10001); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -#f_mhz = 3500; -#f_mhz = 3500; -f_mhz = 1000; -f_hz = 0; -gain = 0; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman - -#samples = 65535; -samples = 16384; -#samples = samples*4; #bytes of data we are requesting - -decim = 2; #0-8 (3 => 2^3 = 8) # ok -decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats -mode = 0; #0=IQ, 1=MAG, 2=MAGDB -#sets = 0; -sets = 0xffffffff; - -size_int = 4; -request_len = 6*size_int; # 6 int items not including the 8 bytes for opcode and length fields -print "request len = %d"%(request_len); - -raw_data = struct.pack("<IIIIIIII", 0x01, request_len, f_mhz, f_hz, gain, samples, decim, sets); - -data = raw_data; - -UDPSock.sendto(data, (msdd_host, msdd_port)); - -print "sent" - - - -count = 0; - -total_data = []; - -state = 0; - -vals = []; -mags = []; -re = []; - -sample_count = 0; -IQ_bytes=0; - - -numtocap = 1000; -IQ_bytes = numtocap * numtocap; - -numbytes = 1000 * 65536; - -num_rx = 0; -start = -1; -while(num_rx < numbytes): - data = UDPSock.recv(65536); - - if(start==-1): - start = time.time(); - - num_rx = num_rx + len(data); -# print num_rx; - - -end = time.time(); -print "recieved %d bytes in %f sec"%(numbytes, end-start); - -bytes_per_sec = numbytes / (end-start); -samples_per_sec = bytes_per_sec / 4; -MSPS = samples_per_sec / 1000000.0; - -print "Got %f MSPS"%(MSPS); -print "Expected %f MSPS"%(102.4/math.pow(2,(decim-16))); - - -halt_data = struct.pack("<II", 0x04, 0x00); -UDPSock.sendto(halt_data, (msdd_host, msdd_port)); - - -UDPSock.close(); - diff --git a/gr-msdd6000/src/python_test/udp_stream_rate_test_plot.py b/gr-msdd6000/src/python_test/udp_stream_rate_test_plot.py deleted file mode 100644 index eef78f51b..000000000 --- a/gr-msdd6000/src/python_test/udp_stream_rate_test_plot.py +++ /dev/null @@ -1,161 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -from random import *; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = randint(1025,65535); -filename = "output.dat"; - -msdd_port = 10001 -msdd_host = "10.45.4.46" - -buf = 100000; - -my_udp_addr = ('',randint(1025,65535)); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -f_mhz = 2500; - -print "fc = %d"%(f_mhz); - -f_hz = 0; -gain = 20; # attenuation -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman - -samples = 65535*4*2; -#samples = 16384; -#samples = 16*1024*1024; -#samples = samples*4; #bytes of data we are requesting - -# decim 0-8 ( 3 - 8 ) -#decim = 5; # rate ok -decim = 8; -decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats -mode = 0; #0=IQ, 1=MAG, 2=MAGDB -#sets = 0; -sets = 0xffffffff; - -size_int = 4; -request_len = 6*size_int; # 6 int items not including the 8 bytes for opcode and length fields -print "request len = %d"%(request_len); - -raw_data = struct.pack("<IIIIIIII", 0x01, request_len, f_mhz, f_hz, gain, samples, decim, sets); - -data = raw_data; - -UDPSock.sendto(data, (msdd_host, msdd_port)); - -print "sent" - - - -count = 0; - -total_data = []; - -state = 0; - -vals = []; -mags = []; -re = []; - -sample_count = 0; -IQ_bytes=0; - - -numtocap = 1000; -IQ_bytes = 4 * numtocap; - -numbytes = 65536*100; -#numbytes = 65536*2; -#numbytes = 1024; - -num_rx = 0; -start = time.time(); -l = []; -arr = []; - -while(num_rx < numbytes): - data = UDPSock.recv(1024); - l.append(data); - num_rx = num_rx + len(data); - - -end = time.time(); - -# send stop command -halt_data = struct.pack(">II", 0x04, 0x00); -UDPSock.sendto(halt_data, (msdd_host, msdd_port)); - -# perform timing analysis -print "recieved %d bytes in %f sec"%(numbytes, end-start); -bytes_per_sec = numbytes / (end-start); -samples_per_sec = bytes_per_sec / 4; -MSPS = samples_per_sec / 1000000.0; - -print "Got %f MSPS"%(MSPS); -print "Expected %f MSPS"%(102.4/math.pow(2,(decim-16))); - - -# plot data -val_arr = []; -mag_arr = []; -mag_arr2 = []; - -print "Repacking data..." -f = open("out.dat","w"); -for li in l: - for p in range(0, len(li)/4): - [i,q] = struct.unpack_from("<hh", li, p*4); - val = complex(i,q); - mag_arr.append((val*conj(val)).real); - val_arr.append(val); - binchunk = struct.pack("<ff",float(val.real), float(val.imag) ); - f.write(binchunk); -f.close(); - - -dlen = len(val_arr)-1; -fft_data = []; -for i in range(1, dlen-1024, 1024*1024): - - t_in = []; - for ind in range(i, i+1024): - t_in.append(val_arr[ind]); - - tmp = 20*log10(fftshift(fft(t_in))); - #tmp = (fftshift(fft(t_in))); - - if(len(fft_data) == 0): - for ind in range(0,1024): - fft_data.append( tmp[ind] ); - else: - for ind in range(0,1024): - fft_data[ind] = fft_data[ind] + tmp[ind]; - - - - -print "Plotting..." -subplot(2,1,1); -plot(mag_arr); -title("T power"); -subplot(2,1,2); -plot(10*log10(fft_data)); -title("PSD"); -show(); - - - -UDPSock.close(); - diff --git a/gr-msdd6000/src/python_test/udp_stream_rate_test_plot_loop.py b/gr-msdd6000/src/python_test/udp_stream_rate_test_plot_loop.py deleted file mode 100644 index 185afc48c..000000000 --- a/gr-msdd6000/src/python_test/udp_stream_rate_test_plot_loop.py +++ /dev/null @@ -1,150 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = random.randint(1025,65535); -filename = "output.dat"; - -msdd_port = 10001 -#msdd_host = "10.45.4.43" -msdd_host = "10.45.4.45" - -buf = 100000; - -my_udp_addr = ('',10001); -my_udp_addr = ('10.45.1.229 ',10001); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -#f_mhz = 3500; -f_mhz = 1500; -#f_mhz = 1000; -f_hz = 0; -gain = 80; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman - -#samples = 65535; -samples = 16384; -#samples = samples*4; #bytes of data we are requesting - -# decim 0-8 ( 3 - 8 ) -#decim = 5; # rate ok -decim = 4; -decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats -mode = 0; #0=IQ, 1=MAG, 2=MAGDB -#sets = 0; -sets = 0xffffffff; - -size_int = 4; -request_len = 6*size_int; # 6 int items not including the 8 bytes for opcode and length fields -print "request len = %d"%(request_len); - -raw_data = struct.pack("<IIIIIIII", 0x01, request_len, f_mhz, f_hz, gain, samples, decim, sets); - -data = raw_data; - -UDPSock.sendto(data, (msdd_host, msdd_port)); -start = time.time(); - -print "sent" - - - -count = 0; - -total_data = []; - -state = 0; - -vals = []; -mags = []; -re = []; - -sample_count = 0; -IQ_bytes=0; - - -numtocap = 1000; -IQ_bytes = 4 * numtocap; - -#numbytes = 65536*100; -numbytes = 65536; - - - -while(True): - - data = []; - l = []; - num_rx = 0; - while(num_rx < numbytes): - data = UDPSock.recv(65536); - num_rx = num_rx + len(data); - l.append(data); - - end = time.time(); - - # send stop command - #halt_data = struct.pack("<II", 0x04, 0x00); - #UDPSock.sendto(halt_data, (msdd_host, msdd_port)); - - # perform timing analysis - print "recieved %d bytes in %f sec"%(numbytes, end-start); - bytes_per_sec = numbytes / (end-start); - samples_per_sec = bytes_per_sec / 4; - MSPS = samples_per_sec / 1000000.0; - - print "Got %f MSPS"%(MSPS); - print "Expected %f MSPS"%(102.4/math.pow(2,(decim-16))); - - - # plot data - val_arr = []; - mag_arr = []; - - print "Repacking data..." - for li in l: - for p in range(0, len(li)/4): - [i,q] = struct.unpack_from("<hh", li, p); - val = complex(i,q); - mag_arr.append(abs(val)); - val_arr.append(val); - - - print "Calculating Time Domain Power..." - tpwr = []; - for i in val_arr: - tpwr.append( (i*conj(i)).real ); - - print "Calculating PSD..." - freqz = fft(val_arr); - - #freqz = []; - # - #for i in range(0, floor(len(val_arr)/2048)): - # tmp = val_arr(range(i,i+2048)); - # if len(freqz) == 0: - # freqz = tmp; - # - - psd = (freqz * conj(freqz)).real; - - print "Plotting..." - subplot(2,1,1); - plot(tpwr); - subplot(2,1,2); - plot(10*log10(psd)); - show(); - -UDPSock.close(); - diff --git a/gr-msdd6000/src/python_test/udp_stream_test.py b/gr-msdd6000/src/python_test/udp_stream_test.py deleted file mode 100644 index 6136d16c5..000000000 --- a/gr-msdd6000/src/python_test/udp_stream_test.py +++ /dev/null @@ -1,127 +0,0 @@ -#!/usr/bin/python - -from socket import * -import string -import time -import struct; -import random; -import array; -import cmath; -from numpy import *; -from numpy.fft import *; -from pylab import *; - -myport = random.randint(1025,65535); -filename = "output.dat"; - -msdd_port = 10001 -msdd_host = "10.45.4.46" - -buf = 100000; - -my_udp_addr = ('',10001); -my_udp_addr = ('10.45.1.229 ',10001); - -UDPSock = socket(AF_INET,SOCK_DGRAM); -UDPSock.bind(my_udp_addr); - -#f_mhz = 3500; -#f_mhz = 3500; -f_mhz = 2500; -f_hz = 0; -gain = 0; -window = 3; #0=rect, 1=hanning, 2=hamming, 3=blackman - -samples = 65535; -samples = samples*4; #bytes of data we are requesting - -decim = 2; #0-8 (3 => 2^3 = 8) -decim = decim+16; # +16 to use 16bit floats instead of 32 bit floats -mode = 0; #0=IQ, 1=MAG, 2=MAGDB -#sets = 0; -sets = 0xffffffff; - -size_int = 4; -request_len = 6*size_int; # 6 int items not including the 8 bytes for opcode and length fields -print "request len = %d"%(request_len); - -raw_data = struct.pack("<IIIIIIII", 0x01, request_len, f_mhz, f_hz, gain, samples, decim, sets); - -data = raw_data; - -UDPSock.sendto(data, (msdd_host, msdd_port)); - -print "sent" - - - -count = 0; - -total_data = []; - -state = 0; - -vals = []; -mags = []; -re = []; - -sample_count = 0; -IQ_bytes=0; - - -numtocap = 1000; -IQ_bytes = 4 * numtocap; - -while(True): - data = UDPSock.recv(4); - [i,q] = struct.unpack("<hh", data); - tmp = complex(i,q); - - re.append(i); - vals.append(tmp); - mags.append(abs(tmp)); - - - sample_count = sample_count + 1; -# print "sample count %d"%(sample_count) - - IQ_bytes = IQ_bytes - 4; - if(IQ_bytes % 200 == 0): - print IQ_bytes; - if(IQ_bytes < 4): - print "got all data (total %d)"%(sample_count); - print "remaining: %d"%(IQ_bytes); - break; - - -halt_data = struct.pack("<II", 0x04, 0x00); -UDPSock.sendto(halt_data, (msdd_host, msdd_port)); - - - -UDPSock.close(); - -print "done" -nmags = [] -for i in mags: - if i == 0: - i=1; - nmags.append(i); - - -subplot(2,1,1); -plot(20*log10(nmags)); - -fft_data = 20*log10(fftshift(fft(vals))); - -subplot(2,1,2); -plot(fft_data); -show(); - -f = open(filename, "w"); -for sample in vals: - binchunk = struct.pack("<ff",float(sample.real), float(sample.imag) ); - f.write(binchunk); -f.close(); - - diff --git a/gr-msdd6000/src/qa_msdd_source_simple.py b/gr-msdd6000/src/qa_msdd_source_simple.py deleted file mode 100755 index 5262fcef0..000000000 --- a/gr-msdd6000/src/qa_msdd_source_simple.py +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/python - -from pylab import *; -#from scipy.fftpack import fftshift; - -import math; - -from gnuradio import msdd,gr; - - -tb = gr.top_block(); - - -src = msdd.source_simple("10.45.4.43",0); -convert = gr.interleaved_short_to_complex(); -sink = gr.vector_sink_c(); - -gain = 40; - -fc = 2.4e9; - -src.set_decim_rate(8); -#src.set_rx_freq(0,3500000000); -src.set_rx_freq(0,fc); -src.set_pga(0,gain); - - -tb.connect(src, convert, sink); - - -tb.start(); - -v = [] -for i in range(0,10000): - b = math.sqrt(i); - v.append(b); - -tb.stop(); - -#print sink.data(); - -data = sink.data(); - -plot(10*log10(fftshift(fft(sink.data())))); -show(); |