summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-core/src/lib/general/gr_head.cc6
-rw-r--r--gnuradio-core/src/lib/general/gr_head.h10
-rw-r--r--gnuradio-core/src/lib/general/gr_head.i2
-rw-r--r--gr-msdd6000/src/.gitignore2
-rw-r--r--gr-msdd6000/src/Makefile.am26
-rw-r--r--gr-msdd6000/src/Makefile.swig.gen193
-rw-r--r--gr-msdd6000/src/msdd6000_rs.cc286
-rw-r--r--gr-msdd6000/src/msdd6000_rs.h66
-rw-r--r--gr-msdd6000/src/msdd_rs.i93
-rw-r--r--gr-msdd6000/src/msdd_rs_source_simple.cc236
-rw-r--r--gr-msdd6000/src/msdd_rs_source_simple.h87
-rwxr-xr-xgr-msdd6000/src/python-examples/msdd_rs_spec_an.py350
-rw-r--r--grc/base/Block.py2
-rw-r--r--grc/base/FlowGraph.py2
-rw-r--r--grc/blocks/pad_sink.xml15
-rw-r--r--grc/blocks/pad_source.xml16
-rw-r--r--grc/grc_gnuradio/usrp/dual_usrp.py2
-rw-r--r--grc/grc_gnuradio/usrp/simple_usrp.py2
-rw-r--r--grc/grc_gnuradio/wxgui/top_block_gui.py1
-rw-r--r--grc/gui/ActionHandler.py1
-rw-r--r--grc/gui/Block.py21
-rw-r--r--grc/gui/Dialogs.py1
-rw-r--r--grc/gui/Element.py3
-rw-r--r--grc/gui/FlowGraph.py1
-rw-r--r--grc/gui/Param.py10
-rw-r--r--grc/gui/Port.py13
-rw-r--r--grc/gui/Utils.py23
-rw-r--r--grc/python/Constants.py1
-rw-r--r--grc/python/FlowGraph.py36
-rw-r--r--grc/python/Param.py1
-rw-r--r--grc/python/convert_hier.py14
-rw-r--r--grc/python/flow_graph.tmpl18
-rw-r--r--usrp/host/lib/db_xcvr2450.cc4
-rw-r--r--usrp/host/lib/usrp_prims_libusb0.cc2
-rw-r--r--usrp2/firmware/lib/db_xcvr2450.c4
-rw-r--r--vrt/lib/expanded_header.cc6
-rw-r--r--vrt/lib/rx.cc36
37 files changed, 1460 insertions, 132 deletions
diff --git a/gnuradio-core/src/lib/general/gr_head.cc b/gnuradio-core/src/lib/general/gr_head.cc
index 01035ffcd..b52735c06 100644
--- a/gnuradio-core/src/lib/general/gr_head.cc
+++ b/gnuradio-core/src/lib/general/gr_head.cc
@@ -27,7 +27,7 @@
#include <gr_io_signature.h>
#include <string.h>
-gr_head::gr_head (size_t sizeof_stream_item, int nitems)
+gr_head::gr_head (size_t sizeof_stream_item, unsigned long long nitems)
: gr_sync_block ("head",
gr_make_io_signature (1, 1, sizeof_stream_item),
gr_make_io_signature (1, 1, sizeof_stream_item)),
@@ -36,7 +36,7 @@ gr_head::gr_head (size_t sizeof_stream_item, int nitems)
}
gr_head_sptr
-gr_make_head (size_t sizeof_stream_item, int nitems)
+gr_make_head (size_t sizeof_stream_item, unsigned long long nitems)
{
return gnuradio::get_initial_sptr(new gr_head (sizeof_stream_item, nitems));
}
@@ -49,7 +49,7 @@ gr_head::work (int noutput_items,
if (d_ncopied_items >= d_nitems)
return -1; // Done!
- unsigned n = std::min (d_nitems - d_ncopied_items, noutput_items);
+ unsigned n = std::min (d_nitems - d_ncopied_items, (unsigned long long) noutput_items);
if (n == 0)
return 0;
diff --git a/gnuradio-core/src/lib/general/gr_head.h b/gnuradio-core/src/lib/general/gr_head.h
index 430d5f8b9..f7eee1064 100644
--- a/gnuradio-core/src/lib/general/gr_head.h
+++ b/gnuradio-core/src/lib/general/gr_head.h
@@ -38,11 +38,11 @@ typedef boost::shared_ptr<gr_head> gr_head_sptr;
class gr_head : public gr_sync_block
{
- friend gr_head_sptr gr_make_head (size_t sizeof_stream_item, int nitems);
- gr_head (size_t sizeof_stream_item, int nitems);
+ friend gr_head_sptr gr_make_head (size_t sizeof_stream_item, unsigned long long nitems);
+ gr_head (size_t sizeof_stream_item, unsigned long long nitems);
- int d_nitems;
- int d_ncopied_items;
+ unsigned long long d_nitems;
+ unsigned long long d_ncopied_items;
public:
int work (int noutput_items,
@@ -53,7 +53,7 @@ class gr_head : public gr_sync_block
};
gr_head_sptr
-gr_make_head (size_t sizeof_stream_item, int nitems);
+gr_make_head (size_t sizeof_stream_item, unsigned long long nitems);
#endif /* INCLUDED_GR_HEAD_H */
diff --git a/gnuradio-core/src/lib/general/gr_head.i b/gnuradio-core/src/lib/general/gr_head.i
index 2a88b885f..3aece9601 100644
--- a/gnuradio-core/src/lib/general/gr_head.i
+++ b/gnuradio-core/src/lib/general/gr_head.i
@@ -22,7 +22,7 @@
GR_SWIG_BLOCK_MAGIC(gr,head);
-gr_head_sptr gr_make_head(size_t sizeof_stream_item, int nitems);
+gr_head_sptr gr_make_head(size_t sizeof_stream_item, unsigned long long nitems);
class gr_head : public gr_block {
gr_head();
diff --git a/gr-msdd6000/src/.gitignore b/gr-msdd6000/src/.gitignore
index 33061d3ab..ca4a54fb0 100644
--- a/gr-msdd6000/src/.gitignore
+++ b/gr-msdd6000/src/.gitignore
@@ -4,3 +4,5 @@
/.deps
/msdd.cc
/msdd.py
+/msdd_rs.cc
+/msdd_rs.py
diff --git a/gr-msdd6000/src/Makefile.am b/gr-msdd6000/src/Makefile.am
index 0865d40de..9ae4efb0a 100644
--- a/gr-msdd6000/src/Makefile.am
+++ b/gr-msdd6000/src/Makefile.am
@@ -28,26 +28,40 @@ AM_CPPFLAGS = $(STD_DEFINES_AND_INCLUDES) $(PYTHON_CPPFLAGS) \
grinclude_HEADERS = \
msdd_source_simple.h \
msdd_buffer_copy_behaviors.h \
- msdd6000.h
+ msdd6000.h \
+ msdd_rs_source_simple.h \
+ msdd6000_rs.h
-lib_LTLIBRARIES = libgnuradio-msdd6000.la
+lib_LTLIBRARIES = libgnuradio-msdd6000.la \
+ libgnuradio-msdd6000_rs.la
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_la_LDFLAGS = \
$(NO_UNDEFINED)
+libgnuradio_msdd6000_rs_la_LIBADD = \
+ $(GNURADIO_CORE_LA)
+
+libgnuradio_msdd6000_rs_la_LDFLAGS = \
+ $(NO_UNDEFINED)
+
if PYTHON
#################################
# SWIG interface and library
TOP_SWIG_IFILES = \
- msdd.i
+ msdd.i msdd_rs.i
# Install so that they end up available as:
# import gnuradio.msdd
@@ -56,10 +70,16 @@ TOP_SWIG_IFILES = \
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
+
include $(top_srcdir)/Makefile.swig
# add some of the variables generated inside the Makefile.swig.gen
diff --git a/gr-msdd6000/src/Makefile.swig.gen b/gr-msdd6000/src/Makefile.swig.gen
index 5c2920230..ced3979f7 100644
--- a/gr-msdd6000/src/Makefile.swig.gen
+++ b/gr-msdd6000/src/Makefile.swig.gen
@@ -33,14 +33,21 @@
## 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)
+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)
+
## SWIG headers are always installed into the same directory.
msdd_swigincludedir = $(swigincludedir)
+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
@@ -63,6 +70,7 @@ msdd_swigincludedir = $(swigincludedir)
## the SWIG-generated files will be removed from the distribution.
STAMPS += $(DEPDIR)/msdd-generate-*
+STAMPS += $(DEPDIR)/msdd_rs-generate-*
## Other cleaned files: dependency files generated by SWIG or this Makefile
@@ -72,27 +80,40 @@ MOSTLYCLEANFILES += $(DEPDIR)/*.S*
## .h file is sometimes built, but not always ... so that one has to
## be added manually by the including Makefile.am .
-swig_built_sources += msdd.py msdd.cc
+swig_built_sources += msdd.py msdd_rs.py msdd.cc msdd_rs.cc
## 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.i \
+ msdd_rs.i \
$(msdd_swiginclude_headers)
msdd_pylib_LTLIBRARIES = \
_msdd.la
+msdd_rs_pylib_LTLIBRARIES = \
+ _msdd_rs.la
+
_msdd_la_SOURCES = \
- msdd.cc \
+ msdd.cc \
$(msdd_la_swig_sources)
+_msdd_rs_la_SOURCES = \
+ msdd_rs.cc \
+ $(msdd_la_swig_sources)
+
+
_msdd_la_LIBADD = \
$(STD_SWIG_LA_LIB_ADD) \
$(msdd_la_swig_libadd)
+_msdd_rs_la_LIBADD = \
+ $(STD_SWIG_LA_LIB_ADD) \
+ $(msdd_rs_la_swig_libadd)
+
_msdd_la_LDFLAGS = \
$(STD_SWIG_LA_LD_FLAGS) \
$(msdd_la_swig_ldflags)
@@ -101,10 +122,22 @@ _msdd_la_CXXFLAGS = \
$(STD_SWIG_CXX_FLAGS) \
$(msdd_la_swig_cxxflags)
+_msdd_rs_la_LDFLAGS = \
+ $(STD_SWIG_LA_LD_FLAGS) \
+ $(msdd_rs_la_swig_ldflags)
+
+_msdd_rs_la_CXXFLAGS = \
+ $(STD_SWIG_CXX_FLAGS) \
+ $(msdd_rs_la_swig_cxxflags)
+
msdd_python_PYTHON = \
- msdd.py \
+ msdd.py \
$(msdd_python)
+msdd_rs_python_PYTHON = \
+ msdd_rs.py \
+ $(msdd_rs_python)
+
## Entry rule for running SWIG
msdd.h msdd.py msdd.cc: msdd.i
@@ -251,9 +284,161 @@ $(DEPDIR)/msdd-generate-stamp:
##
touch $(DEPDIR)/msdd-generate-stamp
+
+
+
+
+
+msdd_rs.h msdd_rs.py msdd_rs.cc: msdd_rs.i
+## This rule will get called only when MAKE decides that one of the
+## targets needs to be created or re-created, because:
+##
+## * The .i file is newer than any or all of the generated files;
+##
+## * Any or all of the .cc, .h, or .py files does not exist and is
+## needed (in the case this file is not needed, the rule for it is
+## ignored); or
+##
+## * Some SWIG-based dependecy of the .cc file isn't met and hence the
+## .cc file needs be be regenerated. Explanation: Because MAKE
+## knows how to handle dependencies for .cc files (regardless of
+## their name or extension), then the .cc file is used as a target
+## instead of the .i file -- but with the dependencies of the .i
+## file. It is this last reason why the line:
+##
+## if test -f $@; then :; else
+##
+## cannot be used in this case: If a .i file dependecy is not met,
+## then the .cc file needs to be rebuilt. But if the stamp is newer
+## than the .cc file, and the .cc file exists, then in the original
+## version (with the 'test' above) the internal MAKE call will not
+## be issued and hence the .cc file will not be rebuilt.
+##
+## Once execution gets to here, it should always proceed no matter the
+## state of a stamp (as discussed in link above). The
+## $(DEPDIR)/msdd-generate stuff is used to allow for parallel
+## builds to "do the right thing". The stamp has no relationship with
+## either the target files or dependency file; it is used solely for
+## the protection of multiple builds during a given call to MAKE.
+##
+## Catch signals SIGHUP (1), SIGINT (2), SIGPIPE (13), and SIGTERM
+## (15). At a caught signal, the quoted command will be issued before
+## exiting. In this case, remove any stamp, whether temporary of not.
+## The trap is valid until the process exits; the process includes all
+## commands appended via "\"s.
+##
+ trap 'rm -rf $(DEPDIR)/msdd_rs-generate-*' 1 2 13 15; \
+##
+## Create a temporary directory, which acts as a lock. The first
+## process to create the directory will succeed and issue the MAKE
+## command to do the actual work, while all subsequent processes will
+## fail -- leading them to wait for the first process to finish.
+##
+ if mkdir $(DEPDIR)/msdd_rs-generate-lock 2>/dev/null; then \
+##
+## This code is being executed by the first process to succeed in
+## creating the directory lock.
+##
+## Remove the stamp associated with this filename.
+##
+ rm -f $(DEPDIR)/msdd_rs-generate-stamp; \
+##
+## Tell MAKE to run the rule for creating this stamp.
+##
+ $(MAKE) $(AM_MAKEFLAGS) $(DEPDIR)/msdd_rs-generate-stamp WHAT=$<; \
+##
+## Now that the .cc, .h, and .py files have been (re)created from the
+## .i file, future checking of this rule during the same MAKE
+## execution will come back that the rule doesn't need to be executed
+## because none of the conditions mentioned at the start of this rule
+## will be positive. Remove the the directory lock, which frees up
+## any waiting process(es) to continue.
+##
+ rmdir $(DEPDIR)/msdd_rs-generate-lock; \
+ else \
+##
+## This code is being executed by any follower processes while the
+## directory lock is in place.
+##
+## Wait until the first process is done, testing once per second.
+##
+ while test -d $(DEPDIR)/msdd_rs-generate-lock; do \
+ sleep 1; \
+ done; \
+##
+## Succeed if and only if the first process succeeded; exit this
+## process returning the status of the generated stamp.
+##
+ test -f $(DEPDIR)/msdd_rs-generate-stamp; \
+ exit $$?; \
+ fi;
+
+$(DEPDIR)/msdd_rs-generate-stamp:
+## This rule will be called only by the first process issuing the
+## above rule to succeed in creating the lock directory, after
+## removing the actual stamp file in order to guarantee that MAKE will
+## execute this rule.
+##
+## Call SWIG to generate the various output files; special
+## post-processing on 'mingw32' host OS for the dependency file.
+##
+ if $(SWIG) $(STD_SWIG_PYTHON_ARGS) $(msdd_rs_swig_args) \
+ -MD -MF $(DEPDIR)/msdd_rs.Std \
+ -module msdd_rs -o msdd_rs.cc $(WHAT); then \
+ if test $(host_os) = mingw32; then \
+ $(RM) $(DEPDIR)/msdd_rs.Sd; \
+ $(SED) 's,\\\\,/,g' < $(DEPDIR)/msdd_rs.Std \
+ > $(DEPDIR)/msdd_rs.Sd; \
+ $(RM) $(DEPDIR)/msdd_rs.Std; \
+ $(MV) $(DEPDIR)/msdd_rs.Sd $(DEPDIR)/msdd_rs.Std; \
+ fi; \
+ else \
+ $(RM) $(DEPDIR)/msdd_rs.S*; exit 1; \
+ fi;
+##
+## Mess with the SWIG output .Std dependency file, to create a
+## dependecy file valid for the input .i file: Basically, simulate the
+## dependency file created for libraries by GNU's libtool for C++,
+## where all of the dependencies for the target are first listed, then
+## each individual dependency is listed as a target with no further
+## dependencies.
+##
+## (1) remove the current dependency file
+##
+ $(RM) $(DEPDIR)/msdd_rs.d
+##
+## (2) Copy the whole SWIG file:
+##
+ cp $(DEPDIR)/msdd_rs.Std $(DEPDIR)/msdd_rs.d
+##
+## (3) all a carriage return to the end of the dependency file.
+##
+ echo "" >> $(DEPDIR)/msdd_rs.d
+##
+## (4) from the SWIG file, remove the first line (the target); remove
+## trailing " \" and " " from each line. Append ":" to each line,
+## followed by 2 carriage returns, then append this to the end of
+## the dependency file.
+##
+ $(SED) -e '1d;s, \\,,g;s, ,,g' < $(DEPDIR)/msdd_rs.Std | \
+ awk '{ printf "%s:\n\n", $$0 }' >> $(DEPDIR)/msdd_rs.d
+##
+## (5) remove the SWIG-generated file
+##
+ $(RM) $(DEPDIR)/msdd_rs.Std
+##
+## Create the stamp for this filename generation, to signal success in
+## executing this rule; allows other threads waiting on this process
+## to continue.
+##
+ touch $(DEPDIR)/msdd_rs-generate-stamp
+
# KLUDGE: Force runtime include of a SWIG dependency file. This is
# not guaranteed to be portable, but will probably work. If it works,
# we have accurate dependencies for our swig stuff, which is good.
+
@am__include@ @am__quote@./$(DEPDIR)/msdd.d@am__quote@
+@am__include@ @am__quote@./$(DEPDIR)/msdd_rs.d@am__quote@
+
diff --git a/gr-msdd6000/src/msdd6000_rs.cc b/gr-msdd6000/src/msdd6000_rs.cc
new file mode 100644
index 000000000..d78f2b4da
--- /dev/null
+++ b/gr-msdd6000/src/msdd6000_rs.cc
@@ -0,0 +1,286 @@
+/* -*- 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
new file mode 100644
index 000000000..4be4624be
--- /dev/null
+++ b/gr-msdd6000/src/msdd6000_rs.h
@@ -0,0 +1,66 @@
+#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_rs.i b/gr-msdd6000/src/msdd_rs.i
new file mode 100644
index 000000000..16a1bec1a
--- /dev/null
+++ b/gr-msdd6000/src/msdd_rs.i
@@ -0,0 +1,93 @@
+/* -*- 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);
+
+
+ };
diff --git a/gr-msdd6000/src/msdd_rs_source_simple.cc b/gr-msdd6000/src/msdd_rs_source_simple.cc
new file mode 100644
index 000000000..36bed316a
--- /dev/null
+++ b/gr-msdd6000/src/msdd_rs_source_simple.cc
@@ -0,0 +1,236 @@
+/* -*- 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 <msdd_rs_source_simple.h>
+#include <gr_io_signature.h>
+#include <string.h>
+
+
+msdd_rs_source_simple_sptr
+msdd_rs_make_source_simple ( const char *src, unsigned short port_src)
+{
+ return msdd_rs_source_simple_sptr (new msdd_rs_source_simple ( src, port_src));
+}
+
+
+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]);
+ 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
new file mode 100644
index 000000000..f320cbb4d
--- /dev/null
+++ b/gr-msdd6000/src/msdd_rs_source_simple.h
@@ -0,0 +1,87 @@
+/* -*- 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/python-examples/msdd_rs_spec_an.py b/gr-msdd6000/src/python-examples/msdd_rs_spec_an.py
new file mode 100755
index 000000000..4855375b8
--- /dev/null
+++ b/gr-msdd6000/src/python-examples/msdd_rs_spec_an.py
@@ -0,0 +1,350 @@
+#!/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/grc/base/Block.py b/grc/base/Block.py
index b2015cc40..42eb6b3fb 100644
--- a/grc/base/Block.py
+++ b/grc/base/Block.py
@@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from . import odict
from Element import Element
-from Param import Param
-from Port import Port
from Cheetah.Template import Template
from UserDict import UserDict
diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py
index 7c51ef42a..b4ac8fc3a 100644
--- a/grc/base/FlowGraph.py
+++ b/grc/base/FlowGraph.py
@@ -19,8 +19,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from . import odict
from Element import Element
-from Block import Block
-from Connection import Connection
from .. gui import Messages
class FlowGraph(Element):
diff --git a/grc/blocks/pad_sink.xml b/grc/blocks/pad_sink.xml
index 734526793..2e9495260 100644
--- a/grc/blocks/pad_sink.xml
+++ b/grc/blocks/pad_sink.xml
@@ -9,10 +9,10 @@
<key>pad_sink</key>
<make></make>
<param>
- <name>Num Inputs</name>
- <key>nports</key>
- <value>1</value>
- <type>int</type>
+ <name>Label</name>
+ <key>label</key>
+ <value>out</value>
+ <type>string</type>
</param>
<param>
<name>Input Type</name>
@@ -51,15 +51,14 @@
<type>int</type>
</param>
<check>$vlen &gt; 0</check>
- <check>0 &lt; $nports</check>
<sink>
<name>in</name>
<type>$type</type>
<vlen>$vlen</vlen>
- <nports>$nports</nports>
</sink>
<doc>
-The inputs of this block will become the outputs to this flow graph when it is instantiated as a hierarchical block. \
-Limit one sink pad block per flow graph.
+The inputs of this block will become the outputs to this flow graph when it is instantiated as a hierarchical block.
+
+Pad sink will be ordered alphabetically by their ids. The first pad sink will have an index of 0.
</doc>
</block>
diff --git a/grc/blocks/pad_source.xml b/grc/blocks/pad_source.xml
index f44d96238..7b2210cbb 100644
--- a/grc/blocks/pad_source.xml
+++ b/grc/blocks/pad_source.xml
@@ -9,10 +9,10 @@
<key>pad_source</key>
<make></make>
<param>
- <name>Num Outputs</name>
- <key>nports</key>
- <value>1</value>
- <type>int</type>
+ <name>Label</name>
+ <key>label</key>
+ <value>in</value>
+ <type>string</type>
</param>
<param>
<name>Output Type</name>
@@ -51,16 +51,14 @@
<type>int</type>
</param>
<check>$vlen &gt; 0</check>
- <check>0 &lt; $nports</check>
<source>
<name>out</name>
<type>$type</type>
<vlen>$vlen</vlen>
- <nports>$nports</nports>
</source>
<doc>
-The outputs of this block will become the inputs to this flow graph when it is instantiated as a hierarchical block. \
-Limit one source pad block per flow graph. \
-The "pad sink id" will be ignored in this mode.
+The outputs of this block will become the inputs to this flow graph when it is instantiated as a hierarchical block.
+
+Pad sources will be ordered alphabetically by their ids. The first pad source will have an index of 0.
</doc>
</block>
diff --git a/grc/grc_gnuradio/usrp/dual_usrp.py b/grc/grc_gnuradio/usrp/dual_usrp.py
index 3692e1760..b26dbddd4 100644
--- a/grc/grc_gnuradio/usrp/dual_usrp.py
+++ b/grc/grc_gnuradio/usrp/dual_usrp.py
@@ -19,7 +19,7 @@
#
import common
-from gnuradio import gr, usrp
+from gnuradio import gr
####################################################################
# Dual USRP Source
diff --git a/grc/grc_gnuradio/usrp/simple_usrp.py b/grc/grc_gnuradio/usrp/simple_usrp.py
index fc4c75bf0..fb7a39570 100644
--- a/grc/grc_gnuradio/usrp/simple_usrp.py
+++ b/grc/grc_gnuradio/usrp/simple_usrp.py
@@ -19,7 +19,7 @@
#
import common
-from gnuradio import gr, usrp
+from gnuradio import gr
####################################################################
# Simple USRP Source
diff --git a/grc/grc_gnuradio/wxgui/top_block_gui.py b/grc/grc_gnuradio/wxgui/top_block_gui.py
index 998575897..333ccf1c1 100644
--- a/grc/grc_gnuradio/wxgui/top_block_gui.py
+++ b/grc/grc_gnuradio/wxgui/top_block_gui.py
@@ -19,7 +19,6 @@
#
import wx
-import sys, os
from gnuradio import gr
import panel
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index ee3e19a6c..108e23a23 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -29,7 +29,6 @@ import Preferences
from threading import Thread
import Messages
from .. base import ParseXML
-import random
from MainWindow import MainWindow
from PropsDialog import PropsDialog
import Dialogs
diff --git a/grc/gui/Block.py b/grc/gui/Block.py
index 8c65bf06f..27143e070 100644
--- a/grc/gui/Block.py
+++ b/grc/gui/Block.py
@@ -29,6 +29,7 @@ from Constants import \
import pygtk
pygtk.require('2.0')
import gtk
+import pango
BLOCK_MARKUP_TMPL="""\
#set $foreground = $block.is_valid() and 'black' or 'red'
@@ -130,8 +131,11 @@ class Block(Element):
layout.set_markup(Utils.parse_template(BLOCK_MARKUP_TMPL, block=self))
self.label_width, self.label_height = layout.get_pixel_size()
#display the params
- for param in filter(lambda p: p.get_hide() not in ('all', 'part'), self.get_params()):
- layout = param.get_layout()
+ markups = [param.get_markup() for param in self.get_params() if param.get_hide() not in ('all', 'part')]
+ if markups:
+ layout = gtk.DrawingArea().create_pango_layout('')
+ layout.set_spacing(LABEL_SEPARATION*pango.SCALE)
+ layout.set_markup('\n'.join(markups))
layouts.append(layout)
w,h = layout.get_pixel_size()
self.label_width = max(w, self.label_width)
@@ -151,12 +155,11 @@ class Block(Element):
else: w_off = 0
pixmap.draw_layout(gc, w_off, h_off, layout)
h_off = h + h_off + LABEL_SEPARATION
- #create vertical and horizontal images
- self.horizontal_label = image = pixmap.get_image(0, 0, width, height)
+ #create vertical and horizontal pixmaps
+ self.horizontal_label = pixmap
if self.is_vertical():
- self.vertical_label = vimage = gtk.gdk.Image(gtk.gdk.IMAGE_NORMAL, pixmap.get_visual(), height, width)
- for i in range(width):
- for j in range(height): vimage.put_pixel(j, width-i-1, image.get_pixel(i, j))
+ self.vertical_label = self.get_parent().new_pixmap(height, width)
+ Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
#calculate width and height needed
self.W = self.label_width + 2*BLOCK_LABEL_PADDING
self.H = max(*(
@@ -179,9 +182,9 @@ class Block(Element):
)
#draw label image
if self.is_horizontal():
- window.draw_image(gc, self.horizontal_label, 0, 0, x+BLOCK_LABEL_PADDING, y+(self.H-self.label_height)/2, -1, -1)
+ window.draw_drawable(gc, self.horizontal_label, 0, 0, x+BLOCK_LABEL_PADDING, y+(self.H-self.label_height)/2, -1, -1)
elif self.is_vertical():
- window.draw_image(gc, self.vertical_label, 0, 0, x+(self.H-self.label_height)/2, y+BLOCK_LABEL_PADDING, -1, -1)
+ window.draw_drawable(gc, self.vertical_label, 0, 0, x+(self.H-self.label_height)/2, y+BLOCK_LABEL_PADDING, -1, -1)
#draw ports
for port in self.get_ports(): port.draw(gc, window)
diff --git a/grc/gui/Dialogs.py b/grc/gui/Dialogs.py
index af40f47c0..473c796af 100644
--- a/grc/gui/Dialogs.py
+++ b/grc/gui/Dialogs.py
@@ -20,7 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import pygtk
pygtk.require('2.0')
import gtk
-import Preferences
import Utils
class TextDisplay(gtk.TextView):
diff --git a/grc/gui/Element.py b/grc/gui/Element.py
index f0518ee12..e020c5caa 100644
--- a/grc/gui/Element.py
+++ b/grc/gui/Element.py
@@ -17,9 +17,6 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-import pygtk
-pygtk.require('2.0')
-import gtk
from Constants import LINE_SELECT_SENSITIVITY
from Constants import POSSIBLE_ROTATIONS
diff --git a/grc/gui/FlowGraph.py b/grc/gui/FlowGraph.py
index 8feb171f1..5adecccc1 100644
--- a/grc/gui/FlowGraph.py
+++ b/grc/gui/FlowGraph.py
@@ -22,7 +22,6 @@ import Actions
import Colors
import Utils
from Element import Element
-from .. base import FlowGraph as _FlowGraph
import pygtk
pygtk.require('2.0')
import gtk
diff --git a/grc/gui/Param.py b/grc/gui/Param.py
index cb8bfdc52..b3018dab2 100644
--- a/grc/gui/Param.py
+++ b/grc/gui/Param.py
@@ -165,11 +165,9 @@ class Param(Element):
if self.get_options(): return EnumEntryParam(self, *args, **kwargs)
return EntryParam(self, *args, **kwargs)
- def get_layout(self):
+ def get_markup(self):
"""
- Create a layout based on the current markup.
- @return the pango layout
+ Get the markup for this param.
+ @return a pango markup string
"""
- layout = gtk.DrawingArea().create_pango_layout('')
- layout.set_markup(Utils.parse_template(PARAM_MARKUP_TMPL, param=self))
- return layout
+ return Utils.parse_template(PARAM_MARKUP_TMPL, param=self)
diff --git a/grc/gui/Port.py b/grc/gui/Port.py
index 6763f6cbd..2896d04c1 100644
--- a/grc/gui/Port.py
+++ b/grc/gui/Port.py
@@ -97,12 +97,11 @@ class Port(Element):
gc.set_foreground(self._bg_color)
pixmap.draw_rectangle(gc, True, 0, 0, self.w, self.h)
pixmap.draw_layout(gc, 0, 0, layout)
- #create the images
- self.horizontal_label = image = pixmap.get_image(0, 0, self.w, self.h)
+ #create vertical and horizontal pixmaps
+ self.horizontal_label = pixmap
if self.is_vertical():
- self.vertical_label = vimage = gtk.gdk.Image(gtk.gdk.IMAGE_NORMAL, pixmap.get_visual(), self.h, self.w)
- for i in range(self.w):
- for j in range(self.h): vimage.put_pixel(j, self.w-i-1, image.get_pixel(i, j))
+ self.vertical_label = self.get_parent().get_parent().new_pixmap(self.h, self.w)
+ Utils.rotate_pixmap(gc, self.horizontal_label, self.vertical_label)
def draw(self, gc, window):
"""
@@ -117,9 +116,9 @@ class Port(Element):
X,Y = self.get_coordinate()
(x,y),(w,h) = self._areas_list[0] #use the first area's sizes to place the labels
if self.is_horizontal():
- window.draw_image(gc, self.horizontal_label, 0, 0, x+X+(self.W-self.w)/2, y+Y+(self.H-self.h)/2, -1, -1)
+ window.draw_drawable(gc, self.horizontal_label, 0, 0, x+X+(self.W-self.w)/2, y+Y+(self.H-self.h)/2, -1, -1)
elif self.is_vertical():
- window.draw_image(gc, self.vertical_label, 0, 0, x+X+(self.H-self.h)/2, y+Y+(self.W-self.w)/2, -1, -1)
+ window.draw_drawable(gc, self.vertical_label, 0, 0, x+X+(self.H-self.h)/2, y+Y+(self.W-self.w)/2, -1, -1)
def get_connector_coordinate(self):
"""
diff --git a/grc/gui/Utils.py b/grc/gui/Utils.py
index 83036a4b8..b5489d56e 100644
--- a/grc/gui/Utils.py
+++ b/grc/gui/Utils.py
@@ -19,8 +19,31 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
from Constants import POSSIBLE_ROTATIONS
from Cheetah.Template import Template
+import pygtk
+pygtk.require('2.0')
+import gtk
import gobject
+def rotate_pixmap(gc, src_pixmap, dst_pixmap, angle=gtk.gdk.PIXBUF_ROTATE_COUNTERCLOCKWISE):
+ """
+ Load the destination pixmap with a rotated version of the source pixmap.
+ The source pixmap will be loaded into a pixbuf, rotated, and drawn to the destination pixmap.
+ The pixbuf is a client-side drawable, where a pixmap is a server-side drawable.
+ @param gc the graphics context
+ @param src_pixmap the source pixmap
+ @param dst_pixmap the destination pixmap
+ @param angle the angle to rotate by
+ """
+ width, height = src_pixmap.get_size()
+ pixbuf = gtk.gdk.Pixbuf(
+ colorspace=gtk.gdk.COLORSPACE_RGB,
+ has_alpha=False, bits_per_sample=8,
+ width=width, height=height,
+ )
+ pixbuf.get_from_drawable(src_pixmap, src_pixmap.get_colormap(), 0, 0, 0, 0, -1, -1)
+ pixbuf = pixbuf.rotate_simple(angle)
+ dst_pixmap.draw_pixbuf(gc, pixbuf, 0, 0, 0, 0)
+
def get_rotated_coordinate(coor, rotation):
"""
Rotate the coordinate by the given rotation.
diff --git a/grc/python/Constants.py b/grc/python/Constants.py
index 439a52420..e661c3927 100644
--- a/grc/python/Constants.py
+++ b/grc/python/Constants.py
@@ -18,7 +18,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
import os
-import sys
import stat
from gnuradio import gr
diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py
index 4dd18a81f..b2d406bbd 100644
--- a/grc/python/FlowGraph.py
+++ b/grc/python/FlowGraph.py
@@ -20,8 +20,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
import expr_utils
from .. base.FlowGraph import FlowGraph as _FlowGraph
from .. gui.FlowGraph import FlowGraph as _GUIFlowGraph
-from Block import Block
-from Connection import Connection
import re
_variable_matcher = re.compile('^(variable\w*)$')
@@ -50,44 +48,36 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
#return from cache
return self._eval_cache[my_hash]
- def _get_io_signature(self, pad_key):
+ def _get_io_signaturev(self, pad_key):
"""
- Get an io signature for this flow graph.
+ Get a list of io signatures for this flow graph.
The pad key determines the directionality of the io signature.
@param pad_key a string of pad_source or pad_sink
- @return a dict with: type, nports, vlen, size
+ @return a list of dicts with: type, label, vlen, size
"""
pads = filter(lambda b: b.get_key() == pad_key, self.get_enabled_blocks())
- if not pads: return {
- 'nports': '0',
- 'type': '',
- 'vlen': '0',
- 'size': '0',
- }
- pad = pads[0] #take only the first, user should not have more than 1
+ sorted_pads = sorted(pads, lambda x, y: cmp(x.get_id(), y.get_id()))
#load io signature
- return {
- 'nports': str(pad.get_param('nports').get_evaluated()),
+ return [{
+ 'label': str(pad.get_param('label').get_evaluated()),
'type': str(pad.get_param('type').get_evaluated()),
'vlen': str(pad.get_param('vlen').get_evaluated()),
'size': pad.get_param('type').get_opt('size'),
- }
+ } for pad in sorted_pads]
- def get_input_signature(self):
+ def get_input_signaturev(self):
"""
Get the io signature for the input side of this flow graph.
- The io signature with be "0", "0" if no pad source is present.
- @return a string tuple of type, num_ports, port_size
+ @return a list of io signature structures
"""
- return self._get_io_signature('pad_source')
+ return self._get_io_signaturev('pad_source')
- def get_output_signature(self):
+ def get_output_signaturev(self):
"""
Get the io signature for the output side of this flow graph.
- The io signature with be "0", "0" if no pad sink is present.
- @return a string tuple of type, num_ports, port_size
+ @return a list of io signature structures
"""
- return self._get_io_signature('pad_sink')
+ return self._get_io_signaturev('pad_sink')
def get_imports(self):
"""
diff --git a/grc/python/Param.py b/grc/python/Param.py
index 81fb6ba7a..febb112ad 100644
--- a/grc/python/Param.py
+++ b/grc/python/Param.py
@@ -17,7 +17,6 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
"""
-import expr_utils
from .. base.Param import Param as _Param
from .. gui.Param import Param as _GUIParam
from .. gui.Param import EntryParam
diff --git a/grc/python/convert_hier.py b/grc/python/convert_hier.py
index bdafbcbc1..befddccea 100644
--- a/grc/python/convert_hier.py
+++ b/grc/python/convert_hier.py
@@ -23,8 +23,8 @@ from .. base import odict
def convert_hier(flow_graph, python_file):
#extract info from the flow graph
- input_sig = flow_graph.get_input_signature()
- output_sig = flow_graph.get_output_signature()
+ input_sigs = flow_graph.get_input_signaturev()
+ output_sigs = flow_graph.get_output_signaturev()
parameters = flow_graph.get_parameters()
block_key = flow_graph.get_option('id')
block_name = flow_graph.get_option('title')
@@ -56,20 +56,18 @@ def convert_hier(flow_graph, python_file):
params_n.append(param_n)
block_n['param'] = params_n
#sink data
- if int(input_sig['nports']):
+ for input_sig in input_sigs:
sink_n = odict()
- sink_n['name'] = 'in'
+ sink_n['name'] = input_sig['label']
sink_n['type'] = input_sig['type']
sink_n['vlen'] = input_sig['vlen']
- sink_n['nports'] = input_sig['nports']
block_n['sink'] = sink_n
#source data
- if int(output_sig['nports']):
+ for output_sig in output_sigs:
source_n = odict()
- source_n['name'] = 'out'
+ source_n['name'] = output_sig['label']
source_n['type'] = output_sig['type']
source_n['vlen'] = output_sig['vlen']
- source_n['nports'] = output_sig['nports']
block_n['source'] = source_n
#doc data
block_n['doc'] = "%s\n%s\n%s"%(block_author, block_desc, python_file)
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index ab764006c..a1a9308aa 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -65,15 +65,25 @@ class $(class_name)(gr.top_block):
def __init__($param_str):
gr.top_block.__init__(self, "$title")
#elif $generate_options == 'hb'
- #set $in_sig = $flow_graph.get_input_signature()
- #set $out_sig = $flow_graph.get_output_signature()
+ #set $in_sigs = $flow_graph.get_input_signaturev()
+ #set $out_sigs = $flow_graph.get_output_signaturev()
class $(class_name)(gr.hier_block2):
+#def make_io_sig($io_sigs)
+ #set $size_strs = ['%s*%s'%(io_sig['size'], io_sig['vlen']) for io_sig in $io_sigs]
+ #if len($io_sigs) == 0
+gr.io_signature(0, 0, 0)#slurp
+ #elif len($io_sigs) == 1
+gr.io_signature(1, 1, $size_strs[0])#slurp
+ #else
+gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])#slurp
+ #end if
+#end def
def __init__($param_str):
gr.hier_block2.__init__(
self, "$title",
- gr.io_signature($in_sig.nports, $in_sig.nports, $in_sig.size*$in_sig.vlen),
- gr.io_signature($out_sig.nports, $out_sig.nports, $out_sig.size*$out_sig.vlen),
+ $make_io_sig($in_sigs),
+ $make_io_sig($out_sigs),
)
#end if
########################################################
diff --git a/usrp/host/lib/db_xcvr2450.cc b/usrp/host/lib/db_xcvr2450.cc
index 72367286c..ce9d1f4e8 100644
--- a/usrp/host/lib/db_xcvr2450.cc
+++ b/usrp/host/lib/db_xcvr2450.cc
@@ -322,8 +322,8 @@ xcvr2450::set_reg_lpf()
{
d_reg_lpf = (
(d_rssi_hbw<<15) |
- (d_txlpf_bw<<10) |
- (d_rxlpf_bw<<9) |
+ (d_txlpf_bw<<9) |
+ (d_rxlpf_bw<<7) |
(d_rxlpf_fine<<4) | 7);
send_reg(d_reg_lpf);
}
diff --git a/usrp/host/lib/usrp_prims_libusb0.cc b/usrp/host/lib/usrp_prims_libusb0.cc
index 4d1fd78c9..4fbfabea9 100644
--- a/usrp/host/lib/usrp_prims_libusb0.cc
+++ b/usrp/host/lib/usrp_prims_libusb0.cc
@@ -83,7 +83,7 @@ _usb_control_transfer (struct usb_dev_handle *udh, int request_type,
ret = usb_control_msg (udh, request_type,request, value, index,
(char*) data, length, (int) timeout);
if (ret < 0)
- fprintf (stderr, "usrp: usb_claim_interface failed: %s\n", usb_strerror());
+ fprintf (stderr, "usrp: usb_control_msg failed: %s\n", usb_strerror());
return ret;
}
diff --git a/usrp2/firmware/lib/db_xcvr2450.c b/usrp2/firmware/lib/db_xcvr2450.c
index ffdf8d660..a48af9035 100644
--- a/usrp2/firmware/lib/db_xcvr2450.c
+++ b/usrp2/firmware/lib/db_xcvr2450.c
@@ -250,8 +250,8 @@ static void
set_reg_lpf(struct db_xcvr2450_dummy *db){
int reg_lpf = (
(db->common->d_rssi_hbw<<15) |
- (db->common->d_txlpf_bw<<10) |
- (db->common->d_rxlpf_bw<<9) |
+ (db->common->d_txlpf_bw<<9) |
+ (db->common->d_rxlpf_bw<<7) |
(db->common->d_rxlpf_fine<<4) | 7);
send_reg(reg_lpf);
}
diff --git a/vrt/lib/expanded_header.cc b/vrt/lib/expanded_header.cc
index 0eb2042d8..bd1d92e53 100644
--- a/vrt/lib/expanded_header.cc
+++ b/vrt/lib/expanded_header.cc
@@ -112,12 +112,6 @@ namespace vrt {
#include "expanded_header_switch_body.h"
}
- /* is this a if context packet? */
- if (h->if_context_p()){
- *payload = p;
- *n32_bit_words_payload = n32_bit_words_packet;
- }
-
return true;
}
diff --git a/vrt/lib/rx.cc b/vrt/lib/rx.cc
index f75db3111..2d741e908 100644
--- a/vrt/lib/rx.cc
+++ b/vrt/lib/rx.cc
@@ -30,7 +30,7 @@
#include <stdexcept>
static void
-print_words(FILE *fp, size_t offset, uint32_t *buf, size_t n)
+print_words(FILE *fp, size_t offset, const uint32_t *buf, size_t n)
{
size_t i;
for (i = 0; i < n; i++){
@@ -85,27 +85,31 @@ namespace vrt {
vrt_data_handler::~vrt_data_handler(){}
+ // N.B., There may be more than 1 VRT packet in a frame (usually IF-Context packets)
data_handler::result
vrt_data_handler::operator()(const void *base, size_t len)
{
-#if 0
- print_words(0, (uint32_t *)base, len/(sizeof(uint32_t)));
- return 0;
-#else
- const uint32_t *payload;
- size_t n32_bit_words;
- expanded_header hdr;
- if (!expanded_header::parse((const uint32_t*) base, len/(sizeof(uint32_t)),
- &hdr, &payload, &n32_bit_words)){
- if (1){
- fprintf(stderr, "vrt_data_handler: malformed VRT packet!\n");
- print_words(stderr, 0, (uint32_t *)base, len/(sizeof(uint32_t)));
+ const uint32_t *word_base = (const uint32_t *) base;
+ size_t word_len = len/(sizeof(uint32_t));
+
+ bool want_more = true;
+ while (word_len > 0 && want_more){
+ const uint32_t *payload;
+ size_t n32_bit_words;
+ expanded_header hdr;
+ if (!expanded_header::parse(word_base, word_len,
+ &hdr, &payload, &n32_bit_words)){
+ if (1){
+ fprintf(stderr, "vrt_data_handler: malformed VRT packet!\n");
+ print_words(stderr, 0, word_base, word_len);
+ }
+ return 0;
}
- return 0;
+ want_more = (*d_handler)(payload, n32_bit_words, &hdr);
+ word_base += hdr.pkt_size();
+ word_len -= hdr.pkt_size();
}
- bool want_more = (*d_handler)(payload, n32_bit_words, &hdr);
return !want_more ? data_handler::DONE : 0;
-#endif
}