diff options
46 files changed, 908 insertions, 1240 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 4de54d674a..a832cf20ed 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -131,32 +131,31 @@ ELSE() MESSAGE(status "Skipping compiler version check.") ENDIF() -# Configure C++ and C standards -IF(CMAKE_VERSION VERSION_LESS "3.1") - IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98") - ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98") - ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") - SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98") - ELSE() - MESSAGE(warning "C++ standard could not be set because compiler is not GNU, Clang or MSVC.") - ENDIF() +# Configure C++ standard if not externally specified (will actually be +# set after CppUnit check below). Use the variable CMAKE_CXX_STANDARD +# since it will actually be used for this purposes starting in CMake 3.1. - IF(CMAKE_C_COMPILER_ID STREQUAL "GNU") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") - ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") - ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "MSVC") - SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") - ELSE() - MESSAGE(warning "C standard could not be set because compiler is not GNU, Clang or MSVC.") - ENDIF() -ELSE() - SET(CMAKE_C_STANDARD 90) +IF(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") SET(CMAKE_CXX_STANDARD 98) +ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + SET(CMAKE_CXX_STANDARD 98) +ELSEIF(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + SET(CMAKE_CXX_STANDARD 98) +ELSE() + message(warning "C++ standard could not be set because compiler is not GNU, Clang or MSVC.") +ENDIF() + +IF(CMAKE_C_COMPILER_ID STREQUAL "GNU") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") +ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "Clang") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") +ELSEIF(CMAKE_C_COMPILER_ID STREQUAL "MSVC") + SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11") +ELSE() + message(warning "C standard could not be set because compiler is not GNU, Clang or MSVC.") ENDIF() + ######################################################################## # Environment setup ######################################################################## @@ -177,6 +176,12 @@ set(EXPORT_FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake) file(WRITE ${EXPORT_FILE}) #blank the file (subdirs will append) ######################################################################## +# Incorporate CMake function/macros overloading. +######################################################################## + +include(CMakeOverloads) + +######################################################################## # Compiler specific setup ######################################################################## include(GrMiscUtils) #compiler flag check @@ -369,6 +374,19 @@ GR_REGISTER_COMPONENT("testing-support" ENABLE_TESTING CPPUNIT_FOUND ) +# check if CppUnit version is 1.14.0 or greater; requires c++11 ... + +if(CPPUNIT_FOUND AND NOT "${CPPUNIT_VERSION}" VERSION_LESS "1.14.0") + message(WARNING "\nWarning: CppUnit version is ${CPPUNIT_VERSION} which requires C++11 for building. Trying to set CMake internally to use C++11 ...") + SET(CMAKE_CXX_STANDARD 11) +endif() + +# if cmake version is < 3.1, explicitly set C++ standard to use. + +if(${CMAKE_VERSION} VERSION_LESS "3.1") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CMAKE_CXX_STANDARD}") +endif() + ######################################################################## # Add optional dlls specified in DLL_PATHS ######################################################################## diff --git a/cmake/Modules/CMakeOverloads.cmake b/cmake/Modules/CMakeOverloads.cmake new file mode 100644 index 0000000000..450d44c95a --- /dev/null +++ b/cmake/Modules/CMakeOverloads.cmake @@ -0,0 +1,69 @@ +# Copyright 2017 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. + +######################################################################## +# This file contains functions that override those provided by CMake. +# We do this to allow for more generic use of these functions than as +# provided by CMake. +######################################################################## + +if(DEFINED __INCLUDED_CMAKE_OVERLOADS) + return() +endif() +set(__INCLUDED_CMAKE_OVERLOADS TRUE) + +# overload INCLUDE_DIRECTORIES to be a little smarter +# +# NOTE: moving all include directories to either BEFORE (internal to +# source or build) or AFTER (external to source or build) will work in +# general. The primary time it could fail is when include ordering is +# required to find a specific version of a header when multiple of the +# same name are available in the various include directories. This +# situation seems like it's unlikely, so we ignore it here. + +macro(INCLUDE_DIRECTORIES) + # for each provided include directory ... + foreach(inc_dir ${ARGN}) + + # is this dir the literal string "BEFORE" or "AFTER"? + string(FIND ${inc_dir} BEFORE IS_BEFORE) + string(FIND ${inc_dir} AFTER IS_AFTER) + if(NOT ${IS_BEFORE} EQUAL 0 AND NOT ${IS_AFTER} EQUAL 0) + + # not "BEFORE" or "AFTER"; a real directory. + # get absolute path of this include directory + get_filename_component(inc_dir_abs ${inc_dir} ABSOLUTE) + + # is this include directory located within the SOURCE or BUILD? + string(FIND ${inc_dir_abs} ${CMAKE_SOURCE_DIR} IS_IN_SOURCE) + string(FIND ${inc_dir_abs} ${CMAKE_BINARY_DIR} IS_IN_BINARY) + if(${IS_IN_SOURCE} EQUAL 0 OR ${IS_IN_BINARY} EQUAL 0) + # yes: local SOURCE or BINARY; internal. + # call the overloaded INCLUDE_DIRECTORIES, + # prepending this internal directory. + _include_directories(BEFORE ${inc_dir_abs}) + else() + # no: not SOURCE or BUILD; must be external. + # call the overloaded INCLUDE_DIRECTORIES, + # appending this external directory. + _include_directories(AFTER ${inc_dir_abs}) + endif() + endif() + endforeach() +endmacro(INCLUDE_DIRECTORIES) diff --git a/cmake/Modules/FindCppUnit.cmake b/cmake/Modules/FindCppUnit.cmake index f93ade3412..4e9469f9f6 100644 --- a/cmake/Modules/FindCppUnit.cmake +++ b/cmake/Modules/FindCppUnit.cmake @@ -37,3 +37,10 @@ LIST(APPEND CPPUNIT_LIBRARIES ${CMAKE_DL_LIBS}) INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(CPPUNIT DEFAULT_MSG CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS) MARK_AS_ADVANCED(CPPUNIT_LIBRARIES CPPUNIT_INCLUDE_DIRS) + + +# set version to be useable by calling script + +IF(CPPUNIT_FOUND) + set(CPPUNIT_VERSION ${PC_CPPUNIT_VERSION} CACHE INTERNAL "CppUnit Version" FORCE) +ENDIF() diff --git a/docs/doxygen/other/msg_passing.dox b/docs/doxygen/other/msg_passing.dox index 827ad4ee62..14de7bae4c 100644 --- a/docs/doxygen/other/msg_passing.dox +++ b/docs/doxygen/other/msg_passing.dox @@ -14,7 +14,7 @@ GNU Radio was originally a streaming system with no other mechanism to pass data between blocks. Streams of data are a model that work well for samples, bits, etc., but are not really the right mechanism for -control data, metadata, and, often, packet structures (at least at +control data, metadata, or packet structures (at least at some point in the processing chain). We solved part of this problem by introducing the tag stream (see \ref @@ -32,7 +32,7 @@ We want a more general message passing system for a couple of reasons. The first is to allow blocks downstream to communicate back to blocks upstream. The second is to allow an easier way for us to communicate back and forth between external applications and GNU -Radio. The new message passing interface handles these cases, although +Radio. GNU Radio's message passing interface handles these cases, although it does so on an asynchronous basis. The message passing interface heavily relies on Polymorphic Types @@ -57,20 +57,33 @@ to register a new port are: void message_port_register_out(pmt::pmt_t port_id) \endcode +In Python: + +\code + self.message_port_register_in(pmt.intern("port name")) + self.message_port_register_out(pmt.intern("port name")) +\endcode + The ports are now identifiable by that port name. Other blocks who may want to post or receive messages on a port must subscribe to it. When a block has a message to send, they are published on a particular -port. The subscribe and publish API looks like: +port using the following API: \code - void message_port_pub(pmt::pmt_t port_id, - pmt::pmt_t msg); - void message_port_sub(pmt::pmt_t port_id, - pmt::pmt_t target); - void message_port_unsub(pmt::pmt_t port_id, - pmt::pmt_t target); + void message_port_pub(pmt::pmt_t port_id, pmt::pmt_t msg); \endcode +In Python: + +\code + self.message_port_pub(pmt.intern("port name"), <pmt message>) +\endcode + +Subscribing is usually done in the form of connecting message ports +as part of the flowgraph, as discussed later. Internally, when message +ports are connected, the gr::basic_block::message_port_sub method is +called. + Any block that has a subscription to another block's output message port will receive the message when it is published. Internally, when a block publishes a message, it simply iterates through all blocks that @@ -91,6 +104,14 @@ Boost's 'bind' function: boost::bind(&block_class::message_handler_function, this, _1)); \endcode +In Python: + +\code + self.set_msg_handler(pmt.intern("port name"), <msg handler function>) +\endcode + +When a new message is pushed onto a port's message queue, +it is this function that is used to process the message. The 'port_id' is the same PMT as used when registering the input port. The 'block_class::message_handler_function' is the member function of the class designated to handle messages to this port. The @@ -104,16 +125,22 @@ is: void block_class::message_handler_function(pmt::pmt_t msg); \endcode -We give an example of using this below. +In Python the equivalent function would be: + +\code + def handle_msg(self, msg): +\endcode + +We give examples of using this below. \subsection msg_passing_fg_connect Connecting Messages through the Flowgraph From the flowgraph level, we have instrumented a gr::hier_block2::msg_connect method to make it easy to subscribe blocks to other blocks' -messages. The message connection method looks like the following -code. Assume that the block \b src has an output message port named -\a pdus and the block \b dbg has an input port named \a print. +messages. Assume that the block \b src has an output message port named +\a pdus and the block \b dbg has an input port named \a print. The message +connection in the flowgraph (in Python) looks like the following: \code self.tb.msg_connect(src, "pdus", dbg, "print") @@ -144,24 +171,92 @@ gr::basic_block::_post method of the blocks as the way to access the message queue. So the message queue of the right name will have a new message. Posting messages also has the benefit of waking up the block's thread if it is in a wait state. So if idle, as soon as a -message is posted, it will wake up and and call the message handler. +message is posted, it will wake up and call the message handler. -The other side of the action in a block is in the message -handler. When a block has an input message port, it needs a callback -function to handle messages received on that port. We use a Boost bind -operator to bind the message port to the message handling -function. When a new message is pushed onto a port's message queue, -it is this function that is used to process the message. +\section msg_passing_posting Posting from External Sources -\section msg_passing_python Message Passing in Python Blocks +An important feature of the message passing architecture +is how it can be used to take in messages from an external source. We +can call a block's gr::basic_block::_post method directly and pass it a +message. So any block with an input message port can receive messages +from the outside in this way. + +The following example uses a gr::blocks::pdu_to_tagged_stream block +as the source block to a flowgraph. Its purpose is to wait for +messages as PDUs posted to it and convert them to a normal stream. The +payload will be sent on as a normal stream while the meta data will be +decoded into tags and sent on the tagged stream. + +So if we have created a \b src block as a PDU to stream, it has a \a +pdus input port, which is how we will inject PDU messages into the +flowgraph. These PDUs could come from another block or flowgraph, but +here, we will create and insert them by hand. + +\code + port = pmt.intern("pdus") + msg = pmt.cons(pmt.PMT_NIL, pmt.make_u8vector(16, 0xFF)) + src.to_basic_block()._post(port, msg) +\endcode + +The PDU's metadata section is empty, hence the pmt::PMT_NIL +object. The payload is now just a simple vector of 16 bytes of all +1's. To post the message, we have to access the block's gr::basic_block +class, which we do using the gr::basic_block::to_basic_block method and +then call the gr::basic_block::_post method to pass the PDU to the +right port. + +All of these mechanisms are explored and tested in the QA code of the +file qa_pdu.py. + +There are some examples of using the message passing infrastructure +through GRC in gr-blocks/examples/msg_passing. + + +\section msg_passing_commands Using messages as commands + +One important use of messages is to send commands to blocks. Examples for this include: + +- gr::qtgui::freq_sink_c: The scaling of the frequency axis can be changed by messages +- gr::uhd::usrp_source and gr::uhd::usrp_sink: Many transceiver-related settings can + be manipulated through command messages, such as frequency, gain and LO offset +- gr::digital::header_payload_demux, which receives an acknowledgement from a header parser + block on how many payload items there are to process + +There is no special PMT type to encode commands, however, it is strongly recommended +to use one of the following formats: + +- pmt::cons(KEY, VALUE): This format is useful for commands that take a single value. + Think of KEY and VALUE as the argument name and value, respectively. For the case of + the QT GUI Frequency Sink, KEY would be "freq" and VALUE would be the new center frequency + in Hz. +- pmt::dict((KEY1: VALUE1), (KEY2: VALUE2), ...): This is basically the same as the + previous format, but you can provide multiple key/value pairs. This is particularly + useful when a single command takes multiple arguments which can't be broken into + multiple command messages (e.g., the USRP blocks might have both a timestamp and a + center frequency in a command message, which are closely associated). + +In both cases, all KEYs should be pmt::symbols (i.e. strings). VALUEs can be +whatever the block requires. + +It might be tempting to deviate from this format, e.g. the QT Frequency sink could +simply take a float value as a command message, and it would still work fine. +However, there are some very good reasons to stick to this format: -ADD STUFF HERE +- Interoperability: The more people use the standard format, the more likely it + is that blocks from different sources can work together +- Inspectability: A message debug block will display more useful information about + a message if it's containing both a value and a key +- Intuition: This format is pretty versatile and unlikely to create situations + where it is not sufficient (especially considering that values are PMTs themselves). + As a counterexample, using positional arguments (something like "the first argument + is the frequency, the second the gain") is easily forgotten, or changed in one place + and not another, etc. \section msg_passing_examples Code Examples -The following is snippets of code from blocks current in GNU Radio +The following is snippets of code from blocks currently in GNU Radio that take advantage of message passing. We will be using gr::blocks::message_debug and gr::blocks::tagged_stream_to_pdu below to show setting up both input and output message passing capabilities. @@ -193,10 +288,10 @@ The constructor of this block looks like this: } \endcode -So the three ports are registered by their respective names. We then -use the gr::basic_block::set_msg_handler function to identify this -particular port name with a callback function. The Boost \a bind -function (<a target="_blank" +The three message input ports are registered by their respective +names. We then use the gr::basic_block::set_msg_handler function to +identify this particular port name with a callback function. The +Boost \a bind function (<a target="_blank" href="http://www.boost.org/doc/libs/1_52_0/libs/bind/bind.html">Boost::bind</a>) here binds the callback to a function of this block's class. So now the functions in the block's private implementation class, @@ -217,7 +312,7 @@ message_debug_impl::print(pmt::pmt_t msg) The function simply takes in the PMT message and prints it. The method pmt::print is a function in the PMT library to print the -PMT in a friendly, (mostly) pretty manner. +PMT in a friendly and (mostly) pretty manner. The gr::blocks::tagged_stream_to_pdu block only defines a single output message port. In this case, its constructor contains the line: @@ -231,8 +326,8 @@ output message port. In this case, its constructor contains the line: So we are only creating a single output port where \a pdu_port_id is defined in the file pdu.h as \a pdus. -This blocks purpose is to take in a stream of samples along with -stream tags and construct a predefined PDU message from this. In GNU +This block's purpose is to take in a stream of samples along with +stream tags and construct a predefined PDU message from it. In GNU Radio, we define a PDU as a PMT pair of (metadata, data). The metadata describes the samples found in the data portion of the pair. Specifically, the metadata can contain the length of the data @@ -266,7 +361,7 @@ tagged_stream_to_pdu_impl::send_message() } \endcode -This function does a bit of checking to make sure the PDU is ok as +This function does a bit of checking to make sure the PDU is OK as well as some cleanup in the end. But it is the line where the message is published that is important to this discussion. Here, the block posts the PDU message to any subscribers by calling @@ -281,83 +376,6 @@ them. The data is then converted into an output stream of items and passed along. The next section describes how PDUs can be passed into a flowgraph using the gr::blocks::pdu_to_tagged_stream block. -\section msg_passing_posting Posting from External Sources - -The last feature of the message passing architecture to discuss here -is how it can be used to take in messages from an external source. We -can call a block's gr::basic_block::_post method directly and pass it a -message. So any block with an input message port can receive messages -from the outside in this way. - -The following example uses a gr::blocks::pdu_to_tagged_stream block -as the source block to a flowgraph. Its purpose is to wait for -messages as PDUs posted to it and convert them to a normal stream. The -payload will be sent on as a normal stream while the meta data will be -decoded into tags and sent on the tagged stream. - -So if we have created a \b src block as a PDU to stream, it has a \a -pdus input port, which is how we will inject PDU messages to the -flowgraph. These PDUs could come from another block or flowgraph, but -here, we will create and insert them by hand. - -\code - port = pmt.intern("pdus") - msg = pmt.cons(pmt.PMT_NIL, - pmt.make_u8vector(16, 0xFF)) - src.to_basic_block()._post(port, msg) -\endcode - -The PDU's metadata section is empty, hence the pmt::PMT_NIL -object. The payload is now just a simple vector of 16 bytes of all -1's. To post the message, we have to access the block's gr::basic_block -class, which we do using the gr::basic_block::to_basic_block method and -then call the gr::basic_block::_post method to pass the PDU to the -right port. - -All of these mechanisms are explored and tested in the QA code of the -file qa_pdu.py. - -There are some examples of using the message passing infrastructure -through GRC in gr-blocks/examples/msg_passing. - -\section msg_passing_commands Using messages as commands - -Messages can be used to send commands to blocks. Examples for this include: - -- gr::qtgui::freq_sink_c: The scaling of the frequency axis can be changed by messages -- gr::uhd::usrp_source and gr::uhd::usrp_sink: Many transceiver-related settings can - be manipulated through command messages, such as frequency, gain and LO offset -- gr::digital::header_payload_demux, which receives an acknowledgement from a header parser - block on how many payload items there are to process - -There is no special PMT type to encode commands, however, it is strongly recommended -to use one of the following formats: - -- pmt::cons(KEY, VALUE): This format is useful for commands that take a single value. - Think of KEY and VALUE as the argument name and value, respectively. For the case of - the QT GUI Frequency Sink, KEY would be "freq" and VALUE would be the new center frequency - in Hz. -- pmt::dict((KEY1: VALUE1), (KEY2: VALUE2), ...): This is basically the same as the - previous format, but you can provide multiple key/value pairs. This is particularly - useful when a single command takes multiple arguments which can't be broken into - multiple command messages (e.g., the USRP blocks might have both a timestamp and a - center frequency in a command message, which are closely associated). - -In both cases, all KEYs should be pmt::symbols (i.e. strings). VALUEs can be -whatever the block requires. - -It might be tempting to deviate from this format, e.g. the QT Frequency sink could -simply take a float value as a command message, and it would still work fine. -However, there are some very good reasons to stick to this format: - -- Interoperability: The more people use the standard format, the more likely it - is that blocks from different sources can work together -- Inspectability: A message debug block will display more useful information about - a message if its containing both a value and a key -- Intuition: This format is pretty versatile and unlikely to create situations - where it is not sufficient (especially considering that values are PMTs themselves). - As a counterexample, using positional arguments (something like "the first argument - is the frequency, the second the gain") is easily forgotten, or changed in one place - and not another, etc. +For a Python block example, see \ref pyblocks_msgs. */ diff --git a/gnuradio-runtime/include/gnuradio/logger.h.in b/gnuradio-runtime/include/gnuradio/logger.h.in index 13fda6f6c4..ec3c347f9e 100644 --- a/gnuradio-runtime/include/gnuradio/logger.h.in +++ b/gnuradio-runtime/include/gnuradio/logger.h.in @@ -111,7 +111,7 @@ typedef unsigned short mode_t; namespace gr { //#warning GR logging Enabled and using std::cout - typedef std::string logger_ptr; + typedef void* logger_ptr; } /* namespace gr */ #define GR_LOG_DECLARE_LOGPTR(logger) diff --git a/gr-blocks/lib/socket_pdu_impl.h b/gr-blocks/lib/socket_pdu_impl.h index e45f6d4463..1df99fdeff 100644 --- a/gr-blocks/lib/socket_pdu_impl.h +++ b/gr-blocks/lib/socket_pdu_impl.h @@ -24,7 +24,6 @@ #define INCLUDED_BLOCKS_SOCKET_PDU_IMPL_H #include <gnuradio/blocks/socket_pdu.h> -#include "stream_pdu_base.h" #include "tcp_connection.h" namespace gr { diff --git a/gr-blocks/lib/tags_strobe_impl.cc b/gr-blocks/lib/tags_strobe_impl.cc index ddae7fe21f..f821cefccd 100644 --- a/gr-blocks/lib/tags_strobe_impl.cc +++ b/gr-blocks/lib/tags_strobe_impl.cc @@ -60,6 +60,7 @@ namespace gr { set_value(value); set_key(key); set_nsamps(nsamps); + d_offset = 0; } tags_strobe_impl::~tags_strobe_impl() @@ -82,7 +83,6 @@ namespace gr { tags_strobe_impl::set_nsamps(uint64_t nsamps) { d_nsamps = nsamps; - d_offset = 0; } int diff --git a/gr-blocks/lib/tcp_connection.cc b/gr-blocks/lib/tcp_connection.cc index 3b0afa13fc..b28accccf7 100644 --- a/gr-blocks/lib/tcp_connection.cc +++ b/gr-blocks/lib/tcp_connection.cc @@ -54,16 +54,24 @@ namespace gr { tcp_connection::send(pmt::pmt_t vector) { size_t len = pmt::blob_length(vector); + + // Asio async_write() requires the buffer to remain valid until the handler is called. + boost::shared_ptr<char[]> txbuf(new char[len]); + + size_t temp = 0; + memcpy(txbuf.get(), pmt::uniform_vector_elements(vector, temp), len); + size_t offset = 0; - std::vector<char> txbuf(std::min(len, d_buf.size())); while (offset < len) { - size_t send_len = std::min((len - offset), txbuf.size()); - memcpy(&txbuf[0], pmt::uniform_vector_elements(vector, offset), send_len); + // Limit the size of each write() to the MTU. + // FIXME: Note that this has the effect of breaking a large PDU into several smaller PDUs, each + // containing <= MTU bytes. Is this the desired behavior? + size_t send_len = std::min((len - offset), d_buf.size()); + boost::asio::async_write(d_socket, boost::asio::buffer(txbuf.get() + offset, send_len), + boost::bind(&tcp_connection::handle_write, this, txbuf, + boost::asio::placeholders::error, + boost::asio::placeholders::bytes_transferred)); offset += send_len; - boost::asio::async_write(d_socket, boost::asio::buffer(txbuf, send_len), - boost::bind(&tcp_connection::handle_write, this, - boost::asio::placeholders::error, - boost::asio::placeholders::bytes_transferred)); } } diff --git a/gr-blocks/lib/tcp_connection.h b/gr-blocks/lib/tcp_connection.h index 6eeb64e54f..eb4c0df285 100644 --- a/gr-blocks/lib/tcp_connection.h +++ b/gr-blocks/lib/tcp_connection.h @@ -25,6 +25,7 @@ #include <boost/array.hpp> #include <boost/asio.hpp> +#include <boost/shared_ptr.hpp> #include <pmt/pmt.h> namespace gr { @@ -53,7 +54,8 @@ namespace gr { void start(gr::basic_block *block); void send(pmt::pmt_t vector); void handle_read(const boost::system::error_code& error, size_t bytes_transferred); - void handle_write(const boost::system::error_code& error, size_t bytes_transferred) { } + void handle_write(boost::shared_ptr<char[]> txbuf, const boost::system::error_code& error, + size_t bytes_transferred) { } }; } /* namespace blocks */ diff --git a/gr-blocks/lib/tuntap_pdu_impl.cc b/gr-blocks/lib/tuntap_pdu_impl.cc index 391b33937a..7bd0889d5e 100644 --- a/gr-blocks/lib/tuntap_pdu_impl.cc +++ b/gr-blocks/lib/tuntap_pdu_impl.cc @@ -57,7 +57,7 @@ namespace gr { : block("tuntap_pdu", io_signature::make (0, 0, 0), io_signature::make (0, 0, 0)), - stream_pdu_base(MTU), + stream_pdu_base(istunflag ? MTU : MTU + 14), d_dev(dev), d_istunflag(istunflag) { diff --git a/gr-blocks/lib/vector_sink_X_impl.cc.t b/gr-blocks/lib/vector_sink_X_impl.cc.t index 62c6d17dc7..3155c0cb67 100644 --- a/gr-blocks/lib/vector_sink_X_impl.cc.t +++ b/gr-blocks/lib/vector_sink_X_impl.cc.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008,2010,2013 Free Software Foundation, Inc. + * Copyright 2004,2008,2010,2013,2017 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -28,6 +28,7 @@ #include <@NAME_IMPL@.h> #include <gnuradio/io_signature.h> +#include <gnuradio/thread/thread.h> #include <algorithm> #include <iostream> @@ -55,15 +56,26 @@ namespace gr { std::vector<@TYPE@> @NAME_IMPL@::data() const { + gr::thread::scoped_lock guard(d_data_mutex); return d_data; } std::vector<tag_t> @NAME_IMPL@::tags() const { + gr::thread::scoped_lock guard(d_data_mutex); return d_tags; } + + void + @NAME_IMPL@::reset() + { + gr::thread::scoped_lock guard(d_data_mutex); + d_tags.clear(); + d_data.clear(); + } + int @NAME_IMPL@::work(int noutput_items, gr_vector_const_void_star &input_items, @@ -71,6 +83,9 @@ namespace gr { { @TYPE@ *iptr = (@TYPE@*)input_items[0]; + // can't touch this (as long as work() is working, the accessors shall not + // read the data + gr::thread::scoped_lock guard(d_data_mutex); for(int i = 0; i < noutput_items * d_vlen; i++) d_data.push_back (iptr[i]); std::vector<tag_t> tags; diff --git a/gr-blocks/lib/vector_sink_X_impl.h.t b/gr-blocks/lib/vector_sink_X_impl.h.t index 86f0e8773c..bf4811dfde 100644 --- a/gr-blocks/lib/vector_sink_X_impl.h.t +++ b/gr-blocks/lib/vector_sink_X_impl.h.t @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2004,2008,2009,2013 Free Software Foundation, Inc. + * Copyright 2004,2008,2009,2013,2017 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -26,6 +26,7 @@ #define @GUARD_NAME_IMPL@ #include <gnuradio/blocks/@NAME@.h> +#include <gnuradio/thread/thread.h> namespace gr { namespace blocks { @@ -35,13 +36,14 @@ namespace gr { private: std::vector<@TYPE@> d_data; std::vector<tag_t> d_tags; + mutable gr::thread::mutex d_data_mutex; // protects internal data access. int d_vlen; public: @NAME_IMPL@(int vlen); ~@NAME_IMPL@(); - void reset() { d_data.clear(); d_tags.clear(); } + void reset(); std::vector<@TYPE@> data() const; std::vector<tag_t> tags() const; diff --git a/gr-blocks/python/blocks/qa_socket_pdu.py b/gr-blocks/python/blocks/qa_socket_pdu.py index db9f53c71e..5285585340 100755 --- a/gr-blocks/python/blocks/qa_socket_pdu.py +++ b/gr-blocks/python/blocks/qa_socket_pdu.py @@ -100,6 +100,34 @@ class qa_socket_pdu (gr_unittest.TestCase): #self.tb.connect(pdu_to_ts, head, sink) self.tb.run() + def test_004 (self): + # Test that the TCP server can stream PDUs <= the MTU size. + port = str(random.Random().randint(0, 30000) + 10000) + mtu = 10000 + srcdata = tuple([x % 256 for x in xrange(mtu)]) + data = pmt.init_u8vector(srcdata.__len__(), srcdata) + pdu_msg = pmt.cons(pmt.PMT_NIL, data) + + self.pdu_source = blocks.message_strobe(pdu_msg, 500) + self.pdu_send = blocks.socket_pdu("TCP_SERVER", "localhost", port, mtu) + self.pdu_recv = blocks.socket_pdu("TCP_CLIENT", "localhost", port, mtu) + self.pdu_sink = blocks.message_debug() + + self.tb.msg_connect(self.pdu_source, "strobe", self.pdu_send, "pdus") + self.tb.msg_connect(self.pdu_recv, "pdus", self.pdu_sink, "store") + + self.tb.start() + time.sleep(1) + self.tb.stop() + self.tb.wait() + + received = self.pdu_sink.get_message(0) + received_data = pmt.cdr(received) + msg_data = [] + for i in xrange(mtu): + msg_data.append(pmt.u8vector_ref(received_data, i)) + self.assertEqual(srcdata, tuple(msg_data)) + if __name__ == '__main__': gr_unittest.run(qa_socket_pdu, "qa_socket_pdu.xml") diff --git a/gr-digital/examples/demod/symbol_sync_test_complex.grc b/gr-digital/examples/demod/symbol_sync_test_complex.grc index 77bacdeb12..28812e20cd 100644 --- a/gr-digital/examples/demod/symbol_sync_test_complex.grc +++ b/gr-digital/examples/demod/symbol_sync_test_complex.grc @@ -1,25 +1,5 @@ <?xml version='1.0' encoding='utf-8'?> <?grc format='1' created='3.7.12'?> -<!-- - Copyright (C) 2017 Free Software Foundation - - 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. ---> <flow_graph> <timestamp>Mon Jan 12 16:38:01 2015</timestamp> <block> @@ -50,7 +30,7 @@ </param> <param> <key>_coordinate</key> - <value>(10, 10)</value> + <value>(0, 0)</value> </param> <param> <key>_rotation</key> @@ -66,7 +46,7 @@ </param> <param> <key>id</key> - <value>symbol_sync_test_complex</value> + <value>symbol_sync_test_float</value> </param> <param> <key>max_nouts</key> @@ -98,7 +78,7 @@ </param> <param> <key>title</key> - <value>Symbol Sync Test (Complex)</value> + <value>Symbol Sync Test (Float)</value> </param> </block> <block> @@ -136,7 +116,7 @@ </param> <param> <key>value</key> - <value>4</value> + <value>(0,0,0,0,1)</value> </param> <param> <key>_enabled</key> @@ -144,7 +124,7 @@ </param> <param> <key>_coordinate</key> - <value>(392, 48)</value> + <value>(344, 0)</value> </param> <param> <key>gui_hint</key> @@ -180,7 +160,7 @@ </param> <param> <key>label</key> - <value></value> + <value>Data Source</value> </param> <param> <key>labels</key> @@ -192,23 +172,23 @@ </param> <param> <key>option0</key> - <value>0</value> + <value>(1,0,0,0,0)</value> </param> <param> <key>option1</key> - <value>1</value> + <value>(0,1,0,0,0)</value> </param> <param> <key>option2</key> - <value>2</value> + <value>(0,0,1,0,0)</value> </param> <param> <key>option3</key> - <value>3</value> + <value>(0,0,0,1,0)</value> </param> <param> <key>option4</key> - <value>4</value> + <value>(0,0,0,0,1)</value> </param> <param> <key>options</key> @@ -220,7 +200,7 @@ </param> <param> <key>type</key> - <value>int</value> + <value>raw</value> </param> <param> <key>widget</key> @@ -239,7 +219,7 @@ </param> <param> <key>_coordinate</key> - <value>(2288, 588)</value> + <value>(1488, 556)</value> </param> <param> <key>_rotation</key> @@ -274,7 +254,7 @@ </param> <param> <key>_coordinate</key> - <value>(2760, 484)</value> + <value>(1984, 460)</value> </param> <param> <key>gui_hint</key> @@ -309,7 +289,7 @@ </param> <param> <key>_coordinate</key> - <value>(2288, 460)</value> + <value>(1488, 428)</value> </param> <param> <key>_rotation</key> @@ -332,7 +312,7 @@ </param> <param> <key>value</key> - <value>0.25</value> + <value>0.125</value> </param> <param> <key>_enabled</key> @@ -340,7 +320,7 @@ </param> <param> <key>_coordinate</key> - <value>(2440, 568)</value> + <value>(1632, 424)</value> </param> <param> <key>gui_hint</key> @@ -399,7 +379,7 @@ </param> <param> <key>_coordinate</key> - <value>(2608, 212)</value> + <value>(2128, 196)</value> </param> <param> <key>_rotation</key> @@ -426,7 +406,7 @@ </param> <param> <key>_coordinate</key> - <value>(8, 600)</value> + <value>(0, 544)</value> </param> <param> <key>_rotation</key> @@ -465,7 +445,7 @@ </param> <param> <key>_coordinate</key> - <value>(2288, 524)</value> + <value>(1488, 492)</value> </param> <param> <key>_rotation</key> @@ -500,7 +480,7 @@ </param> <param> <key>_coordinate</key> - <value>(2760, 564)</value> + <value>(1984, 540)</value> </param> <param> <key>gui_hint</key> @@ -535,7 +515,7 @@ </param> <param> <key>_coordinate</key> - <value>(1336, 236)</value> + <value>(1280, 228)</value> </param> <param> <key>_rotation</key> @@ -558,7 +538,7 @@ </param> <param> <key>value</key> - <value>1.0</value> + <value>0.28365</value> </param> <param> <key>_enabled</key> @@ -566,7 +546,7 @@ </param> <param> <key>_coordinate</key> - <value>(2608, 568)</value> + <value>(1808, 544)</value> </param> <param> <key>gui_hint</key> @@ -629,7 +609,7 @@ </param> <param> <key>_coordinate</key> - <value>(2440, 448)</value> + <value>(1632, 544)</value> </param> <param> <key>gui_hint</key> @@ -696,7 +676,7 @@ </param> <param> <key>_coordinate</key> - <value>(8, 192)</value> + <value>(0, 128)</value> </param> <param> <key>_rotation</key> @@ -736,151 +716,6 @@ </param> </block> <block> - <key>blocks_add_xx</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(448, 264)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>blocks_add_xx_0</value> - </param> - <param> - <key>type</key> - <value>short</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>num_inputs</key> - <value>5</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - </block> - <block> - <key>blocks_char_to_float</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(1160, 324)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>blocks_char_to_float_2</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>scale</key> - <value>1</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - </block> - <block> - <key>blocks_float_to_char</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(872, 324)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>blocks_float_to_char_0</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>scale</key> - <value>1</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - </block> - <block> <key>blocks_float_to_complex</key> <param> <key>alias</key> @@ -900,7 +735,7 @@ </param> <param> <key>_coordinate</key> - <value>(2752, 328)</value> + <value>(2248, 328)</value> </param> <param> <key>_rotation</key> @@ -943,7 +778,7 @@ </param> <param> <key>_coordinate</key> - <value>(2752, 392)</value> + <value>(2248, 392)</value> </param> <param> <key>_rotation</key> @@ -986,7 +821,7 @@ </param> <param> <key>_coordinate</key> - <value>(1936, 328)</value> + <value>(1512, 328)</value> </param> <param> <key>_rotation</key> @@ -1021,160 +856,7 @@ </param> <param> <key>const</key> - <value>1 if data_src == 4 else 0</value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(224, 540)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>blocks_multiply_const_vxx_0</value> - </param> - <param> - <key>type</key> - <value>short</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - </block> - <block> - <key>blocks_multiply_const_vxx</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>const</key> - <value>1 if data_src == 3 else 0</value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(216, 460)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>blocks_multiply_const_vxx_0_0</value> - </param> - <param> - <key>type</key> - <value>short</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - </block> - <block> - <key>blocks_multiply_const_vxx</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>const</key> - <value>1 if data_src == 2 else 0</value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(216, 380)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>blocks_multiply_const_vxx_0_0_0</value> - </param> - <param> - <key>type</key> - <value>short</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - </block> - <block> - <key>blocks_multiply_const_vxx</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>const</key> - <value>1 if data_src == 1 else 0</value> + <value>0.707+0.707j</value> </param> <param> <key>affinity</key> @@ -1186,7 +868,7 @@ </param> <param> <key>_coordinate</key> - <value>(216, 308)</value> + <value>(1696, 340)</value> </param> <param> <key>_rotation</key> @@ -1194,11 +876,11 @@ </param> <param> <key>id</key> - <value>blocks_multiply_const_vxx_0_0_0_0</value> + <value>blocks_multiply_const_vxx_1</value> </param> <param> <key>type</key> - <value>short</value> + <value>complex</value> </param> <param> <key>maxoutbuf</key> @@ -1214,7 +896,7 @@ </param> </block> <block> - <key>blocks_multiply_const_vxx</key> + <key>blocks_multiply_matrix_xx</key> <param> <key>alias</key> <value></value> @@ -1224,10 +906,6 @@ <value></value> </param> <param> - <key>const</key> - <value>1 if data_src == 0 else 0</value> - </param> - <param> <key>affinity</key> <value></value> </param> @@ -1237,7 +915,7 @@ </param> <param> <key>_coordinate</key> - <value>(208, 212)</value> + <value>(360, 248)</value> </param> <param> <key>_rotation</key> @@ -1245,62 +923,15 @@ </param> <param> <key>id</key> - <value>blocks_multiply_const_vxx_0_0_0_0_0</value> + <value>blocks_multiply_matrix_xx_0</value> </param> <param> <key>type</key> - <value>short</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - </block> - <block> - <key>blocks_multiply_const_vxx</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>const</key> - <value>0.707+0.707j</value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(2128, 340)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>blocks_multiply_const_vxx_1</value> + <value>float</value> </param> <param> - <key>type</key> - <value>complex</value> + <key>A</key> + <value>(data_src,)</value> </param> <param> <key>maxoutbuf</key> @@ -1311,8 +942,8 @@ <value>0</value> </param> <param> - <key>vlen</key> - <value>1</value> + <key>tag_propagation_policy</key> + <value>gr.TPP_ALL_TO_ALL</value> </param> </block> <block> @@ -1323,7 +954,7 @@ </param> <param> <key>comment</key> - <value></value> + <value>Pulse Shaping</value> </param> <param> <key>affinity</key> @@ -1335,7 +966,7 @@ </param> <param> <key>_coordinate</key> - <value>(1312, 324)</value> + <value>(912, 332)</value> </param> <param> <key>_rotation</key> @@ -1343,7 +974,7 @@ </param> <param> <key>id</key> - <value>blocks_repeat_0</value> + <value>blocks_repeat_0_0</value> </param> <param> <key>interp</key> @@ -1386,7 +1017,7 @@ </param> <param> <key>_coordinate</key> - <value>(712, 324)</value> + <value>(192, 148)</value> </param> <param> <key>_rotation</key> @@ -1394,7 +1025,7 @@ </param> <param> <key>id</key> - <value>blocks_short_to_float_0</value> + <value>blocks_short_to_float_1</value> </param> <param> <key>maxoutbuf</key> @@ -1461,7 +1092,7 @@ </param> <param> <key>type</key> - <value>short</value> + <value>float</value> </param> <param> <key>vlen</key> @@ -1488,7 +1119,7 @@ </param> <param> <key>_coordinate</key> - <value>(8, 364)</value> + <value>(0, 300)</value> </param> <param> <key>_rotation</key> @@ -1508,7 +1139,7 @@ </param> <param> <key>type</key> - <value>short</value> + <value>float</value> </param> <param> <key>repeat</key> @@ -1547,7 +1178,7 @@ </param> <param> <key>_coordinate</key> - <value>(8, 284)</value> + <value>(0, 220)</value> </param> <param> <key>_rotation</key> @@ -1567,7 +1198,7 @@ </param> <param> <key>type</key> - <value>short</value> + <value>float</value> </param> <param> <key>repeat</key> @@ -1606,7 +1237,7 @@ </param> <param> <key>_coordinate</key> - <value>(8, 444)</value> + <value>(0, 380)</value> </param> <param> <key>_rotation</key> @@ -1626,7 +1257,7 @@ </param> <param> <key>type</key> - <value>short</value> + <value>float</value> </param> <param> <key>repeat</key> @@ -1665,7 +1296,7 @@ </param> <param> <key>_coordinate</key> - <value>(8, 524)</value> + <value>(0, 460)</value> </param> <param> <key>_rotation</key> @@ -1685,7 +1316,7 @@ </param> <param> <key>type</key> - <value>short</value> + <value>float</value> </param> <param> <key>repeat</key> @@ -1705,49 +1336,6 @@ </param> </block> <block> - <key>digital_map_bb</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(1024, 324)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>digital_map_bb_0</value> - </param> - <param> - <key>map</key> - <value>[-1, 1,0]</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - </block> - <block> <key>digital_symbol_sync_xx</key> <param> <key>alias</key> @@ -1779,7 +1367,7 @@ </param> <param> <key>_coordinate</key> - <value>(2376, 292)</value> + <value>(1920, 292)</value> </param> <param> <key>_rotation</key> @@ -1827,7 +1415,7 @@ </param> <param> <key>constellation</key> - <value>digital.constellation_qpsk().base()</value> + <value>digital.constellation_bpsk().base()</value> </param> <param> <key>ted_type</key> @@ -1835,16 +1423,83 @@ </param> </block> <block> - <key>fir_filter_xxx</key> + <key>epy_block</key> <param> <key>alias</key> <value></value> </param> <param> + <key>_io_cache</key> + <value>('Bit -> Symbol Map', 'ConstMap', [], [('0', 'float', 1)], [('0', 'float', 1)], '\n Map 0, 1 to -1, 1\n ', [])</value> + </param> + <param> + <key>_source_code</key> + <value>""" +Embedded Python Blocks: + +Each time this file is saved, GRC will instantiate the first class it finds +to get ports and parameters of your block. The arguments to __init__ will +be the parameters. All of them are required to have default values! +""" + +import numpy as np +from gnuradio import gr + +class ConstMap(gr.sync_block): + """ + Map 0, 1 to -1, 1 + """ + def __init__(self): + gr.sync_block.__init__( + self, + name='Bit -> Symbol Map', + in_sig=[np.float32], + out_sig=[np.float32] + ) + + def work(self, input_items, output_items): + """ + map + """ + sym_map = {0.0: -1.0, 1.0: 1.0, 2.0: 0.0} + output_items[0][:] = [sym_map[x] for x in input_items[0]] + return len(output_items[0]) +</value> + </param> + <param> <key>comment</key> + <value>BPSK Modulation</value> + </param> + <param> + <key>_enabled</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(696, 328)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>epy_block_0_0</value> + </param> + </block> + <block> + <key>fir_filter_xxx</key> + <param> + <key>alias</key> <value></value> </param> <param> + <key>comment</key> + <value>Matched Filter (almost). +Because the input stream has 6 2/3 +samples per symbol, this incurs a slight ISI.</value> + </param> + <param> <key>affinity</key> <value></value> </param> @@ -1858,7 +1513,7 @@ </param> <param> <key>_coordinate</key> - <value>(1688, 316)</value> + <value>(1264, 324)</value> </param> <param> <key>_rotation</key> @@ -1866,7 +1521,7 @@ </param> <param> <key>id</key> - <value>fir_filter_xxx_0_1_0_0_0</value> + <value>fir_filter_xxx_0_1_0_0_0_0</value> </param> <param> <key>maxoutbuf</key> @@ -1905,7 +1560,7 @@ </param> <param> <key>_coordinate</key> - <value>(184, 12)</value> + <value>(184, 4)</value> </param> <param> <key>_rotation</key> @@ -1921,6 +1576,68 @@ </param> </block> <block> + <key>import</key> + <param> + <key>alias</key> + <value></value> + </param> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(184, 52)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>import_0_0</value> + </param> + <param> + <key>import</key> + <value>from gnuradio import digital</value> + </param> + </block> + <block> + <key>note</key> + <param> + <key>alias</key> + <value></value> + </param> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(320, 316)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>note_0</value> + </param> + <param> + <key>note</key> + <value>Bit Pattern Generation</value> + </param> + </block> + <block> <key>qtgui_time_sink_x</key> <param> <key>autoscale</key> @@ -1956,7 +1673,7 @@ </param> <param> <key>_coordinate</key> - <value>(2992, 296)</value> + <value>(2472, 296)</value> </param> <param> <key>gui_hint</key> @@ -1972,7 +1689,7 @@ </param> <param> <key>id</key> - <value>qtgui_time_sink_x_0_0_0_0_0</value> + <value>qtgui_time_sink_x_0_0_0_0_0_0</value> </param> <param> <key>legend</key> @@ -2319,7 +2036,7 @@ </param> <param> <key>_coordinate</key> - <value>(2376, 204)</value> + <value>(1920, 196)</value> </param> <param> <key>gui_hint</key> @@ -2351,7 +2068,7 @@ </param> <param> <key>label1</key> - <value>Re</value> + <value></value> </param> <param> <key>marker1</key> @@ -2399,7 +2116,7 @@ </param> <param> <key>label2</key> - <value>Im</value> + <value></value> </param> <param> <key>marker2</key> @@ -2654,7 +2371,8 @@ </param> <param> <key>comment</key> - <value></value> + <value>Resampling to 6 2/3 samples +per symbol ("clock desync")</value> </param> <param> <key>affinity</key> @@ -2674,7 +2392,7 @@ </param> <param> <key>_coordinate</key> - <value>(1480, 304)</value> + <value>(1080, 312)</value> </param> <param> <key>_rotation</key> @@ -2707,37 +2425,19 @@ </block> <connection> <source_block_id>analog_random_source_x_0</source_block_id> - <sink_block_id>blocks_multiply_const_vxx_0_0_0_0_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>blocks_add_xx_0</source_block_id> - <sink_block_id>blocks_throttle_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>blocks_char_to_float_2</source_block_id> - <sink_block_id>blocks_repeat_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>blocks_float_to_char_0</source_block_id> - <sink_block_id>digital_map_bb_0</sink_block_id> + <sink_block_id>blocks_short_to_float_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>blocks_float_to_complex_0_0</source_block_id> - <sink_block_id>qtgui_time_sink_x_0_0_0_0_0</sink_block_id> + <sink_block_id>qtgui_time_sink_x_0_0_0_0_0_0</sink_block_id> <source_key>0</source_key> <sink_key>1</sink_key> </connection> <connection> <source_block_id>blocks_float_to_complex_1_0</source_block_id> - <sink_block_id>qtgui_time_sink_x_0_0_0_0_0</sink_block_id> + <sink_block_id>qtgui_time_sink_x_0_0_0_0_0_0</sink_block_id> <source_key>0</source_key> <sink_key>2</sink_key> </connection> @@ -2748,94 +2448,64 @@ <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blocks_multiply_const_vxx_0</source_block_id> - <sink_block_id>blocks_add_xx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>4</sink_key> - </connection> - <connection> - <source_block_id>blocks_multiply_const_vxx_0_0</source_block_id> - <sink_block_id>blocks_add_xx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>3</sink_key> - </connection> - <connection> - <source_block_id>blocks_multiply_const_vxx_0_0_0</source_block_id> - <sink_block_id>blocks_add_xx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>2</sink_key> - </connection> - <connection> - <source_block_id>blocks_multiply_const_vxx_0_0_0_0</source_block_id> - <sink_block_id>blocks_add_xx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>1</sink_key> - </connection> - <connection> - <source_block_id>blocks_multiply_const_vxx_0_0_0_0_0</source_block_id> - <sink_block_id>blocks_add_xx_0</sink_block_id> + <source_block_id>blocks_multiply_const_vxx_1</source_block_id> + <sink_block_id>digital_symbol_sync_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>blocks_multiply_const_vxx_1</source_block_id> - <sink_block_id>digital_symbol_sync_xx_0</sink_block_id> + <sink_block_id>qtgui_time_sink_x_0_1_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blocks_multiply_const_vxx_1</source_block_id> - <sink_block_id>qtgui_time_sink_x_0_1_0</sink_block_id> + <source_block_id>blocks_multiply_matrix_xx_0</source_block_id> + <sink_block_id>blocks_throttle_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blocks_repeat_0</source_block_id> + <source_block_id>blocks_repeat_0_0</source_block_id> <sink_block_id>rational_resampler_xxx_0_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blocks_short_to_float_0</source_block_id> - <sink_block_id>blocks_float_to_char_0</sink_block_id> + <source_block_id>blocks_short_to_float_1</source_block_id> + <sink_block_id>blocks_multiply_matrix_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>blocks_throttle_0</source_block_id> - <sink_block_id>blocks_short_to_float_0</sink_block_id> + <sink_block_id>epy_block_0_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>blocks_vector_source_x_0_0</source_block_id> - <sink_block_id>blocks_multiply_const_vxx_0_0_0</sink_block_id> + <sink_block_id>blocks_multiply_matrix_xx_0</sink_block_id> <source_key>0</source_key> - <sink_key>0</sink_key> + <sink_key>2</sink_key> </connection> <connection> <source_block_id>blocks_vector_source_x_0_0_0</source_block_id> - <sink_block_id>blocks_multiply_const_vxx_0_0_0_0</sink_block_id> + <sink_block_id>blocks_multiply_matrix_xx_0</sink_block_id> <source_key>0</source_key> - <sink_key>0</sink_key> + <sink_key>1</sink_key> </connection> <connection> <source_block_id>blocks_vector_source_x_0_0_1</source_block_id> - <sink_block_id>blocks_multiply_const_vxx_0_0</sink_block_id> + <sink_block_id>blocks_multiply_matrix_xx_0</sink_block_id> <source_key>0</source_key> - <sink_key>0</sink_key> + <sink_key>3</sink_key> </connection> <connection> <source_block_id>blocks_vector_source_x_0_0_1_0</source_block_id> - <sink_block_id>blocks_multiply_const_vxx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>digital_map_bb_0</source_block_id> - <sink_block_id>blocks_char_to_float_2</sink_block_id> + <sink_block_id>blocks_multiply_matrix_xx_0</sink_block_id> <source_key>0</source_key> - <sink_key>0</sink_key> + <sink_key>4</sink_key> </connection> <connection> <source_block_id>digital_symbol_sync_xx_0</source_block_id> @@ -2857,19 +2527,25 @@ </connection> <connection> <source_block_id>digital_symbol_sync_xx_0</source_block_id> - <sink_block_id>qtgui_time_sink_x_0_0_0_0_0</sink_block_id> + <sink_block_id>qtgui_time_sink_x_0_0_0_0_0_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> + <source_block_id>epy_block_0_0</source_block_id> + <sink_block_id>blocks_repeat_0_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>fir_filter_xxx_0_1_0_0_0</source_block_id> + <source_block_id>fir_filter_xxx_0_1_0_0_0_0</source_block_id> <sink_block_id>blocks_float_to_complex_3</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>rational_resampler_xxx_0_0</source_block_id> - <sink_block_id>fir_filter_xxx_0_1_0_0_0</sink_block_id> + <sink_block_id>fir_filter_xxx_0_1_0_0_0_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> diff --git a/gr-digital/examples/demod/symbol_sync_test_float.grc b/gr-digital/examples/demod/symbol_sync_test_float.grc index ce1b24ba4b..f072b1cd89 100644 --- a/gr-digital/examples/demod/symbol_sync_test_float.grc +++ b/gr-digital/examples/demod/symbol_sync_test_float.grc @@ -1,25 +1,5 @@ <?xml version='1.0' encoding='utf-8'?> <?grc format='1' created='3.7.12'?> -<!-- - Copyright (C) 2017 Free Software Foundation - - 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. ---> <flow_graph> <timestamp>Mon Jan 12 16:38:01 2015</timestamp> <block> @@ -50,7 +30,7 @@ </param> <param> <key>_coordinate</key> - <value>(10, 10)</value> + <value>(0, 0)</value> </param> <param> <key>_rotation</key> @@ -136,7 +116,7 @@ </param> <param> <key>value</key> - <value>4</value> + <value>(0,0,0,0,1)</value> </param> <param> <key>_enabled</key> @@ -144,7 +124,7 @@ </param> <param> <key>_coordinate</key> - <value>(392, 48)</value> + <value>(344, 0)</value> </param> <param> <key>gui_hint</key> @@ -180,7 +160,7 @@ </param> <param> <key>label</key> - <value></value> + <value>Data Source</value> </param> <param> <key>labels</key> @@ -192,23 +172,23 @@ </param> <param> <key>option0</key> - <value>0</value> + <value>(1,0,0,0,0)</value> </param> <param> <key>option1</key> - <value>1</value> + <value>(0,1,0,0,0)</value> </param> <param> <key>option2</key> - <value>2</value> + <value>(0,0,1,0,0)</value> </param> <param> <key>option3</key> - <value>3</value> + <value>(0,0,0,1,0)</value> </param> <param> <key>option4</key> - <value>4</value> + <value>(0,0,0,0,1)</value> </param> <param> <key>options</key> @@ -220,7 +200,7 @@ </param> <param> <key>type</key> - <value>int</value> + <value>raw</value> </param> <param> <key>widget</key> @@ -239,7 +219,7 @@ </param> <param> <key>_coordinate</key> - <value>(1800, 548)</value> + <value>(1488, 556)</value> </param> <param> <key>_rotation</key> @@ -274,7 +254,7 @@ </param> <param> <key>_coordinate</key> - <value>(2296, 420)</value> + <value>(1984, 428)</value> </param> <param> <key>gui_hint</key> @@ -309,7 +289,7 @@ </param> <param> <key>_coordinate</key> - <value>(1800, 420)</value> + <value>(1488, 428)</value> </param> <param> <key>_rotation</key> @@ -340,7 +320,7 @@ </param> <param> <key>_coordinate</key> - <value>(1944, 416)</value> + <value>(1632, 424)</value> </param> <param> <key>gui_hint</key> @@ -399,7 +379,7 @@ </param> <param> <key>_coordinate</key> - <value>(2192, 196)</value> + <value>(1848, 196)</value> </param> <param> <key>_rotation</key> @@ -426,7 +406,7 @@ </param> <param> <key>_coordinate</key> - <value>(8, 600)</value> + <value>(0, 544)</value> </param> <param> <key>_rotation</key> @@ -465,7 +445,7 @@ </param> <param> <key>_coordinate</key> - <value>(1800, 484)</value> + <value>(1488, 492)</value> </param> <param> <key>_rotation</key> @@ -500,7 +480,7 @@ </param> <param> <key>_coordinate</key> - <value>(2296, 500)</value> + <value>(1984, 508)</value> </param> <param> <key>gui_hint</key> @@ -566,7 +546,7 @@ </param> <param> <key>_coordinate</key> - <value>(2120, 536)</value> + <value>(1808, 544)</value> </param> <param> <key>gui_hint</key> @@ -629,7 +609,7 @@ </param> <param> <key>_coordinate</key> - <value>(1944, 536)</value> + <value>(1632, 544)</value> </param> <param> <key>gui_hint</key> @@ -696,7 +676,7 @@ </param> <param> <key>_coordinate</key> - <value>(8, 192)</value> + <value>(0, 128)</value> </param> <param> <key>_rotation</key> @@ -736,254 +716,7 @@ </param> </block> <block> - <key>blocks_add_xx</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(448, 264)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>blocks_add_xx_0</value> - </param> - <param> - <key>type</key> - <value>short</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>num_inputs</key> - <value>5</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - </block> - <block> - <key>blocks_char_to_float</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(1160, 324)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>blocks_char_to_float_2</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>scale</key> - <value>1</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - </block> - <block> - <key>blocks_float_to_char</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(872, 324)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>blocks_float_to_char_0</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>scale</key> - <value>1</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - </block> - <block> - <key>blocks_multiply_const_vxx</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>const</key> - <value>1 if data_src == 4 else 0</value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(224, 540)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>blocks_multiply_const_vxx_0</value> - </param> - <param> - <key>type</key> - <value>short</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - </block> - <block> - <key>blocks_multiply_const_vxx</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>const</key> - <value>1 if data_src == 3 else 0</value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(216, 460)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>blocks_multiply_const_vxx_0_0</value> - </param> - <param> - <key>type</key> - <value>short</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - </block> - <block> - <key>blocks_multiply_const_vxx</key> + <key>blocks_multiply_matrix_xx</key> <param> <key>alias</key> <value></value> @@ -993,10 +726,6 @@ <value></value> </param> <param> - <key>const</key> - <value>1 if data_src == 2 else 0</value> - </param> - <param> <key>affinity</key> <value></value> </param> @@ -1006,7 +735,7 @@ </param> <param> <key>_coordinate</key> - <value>(216, 380)</value> + <value>(360, 248)</value> </param> <param> <key>_rotation</key> @@ -1014,113 +743,15 @@ </param> <param> <key>id</key> - <value>blocks_multiply_const_vxx_0_0_0</value> + <value>blocks_multiply_matrix_xx_0</value> </param> <param> <key>type</key> - <value>short</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - </block> - <block> - <key>blocks_multiply_const_vxx</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>const</key> - <value>1 if data_src == 1 else 0</value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(216, 308)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>blocks_multiply_const_vxx_0_0_0_0</value> - </param> - <param> - <key>type</key> - <value>short</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - <param> - <key>vlen</key> - <value>1</value> - </param> - </block> - <block> - <key>blocks_multiply_const_vxx</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>const</key> - <value>1 if data_src == 0 else 0</value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(208, 212)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> + <value>float</value> </param> <param> - <key>id</key> - <value>blocks_multiply_const_vxx_0_0_0_0_0</value> - </param> - <param> - <key>type</key> - <value>short</value> + <key>A</key> + <value>(data_src,)</value> </param> <param> <key>maxoutbuf</key> @@ -1131,8 +762,8 @@ <value>0</value> </param> <param> - <key>vlen</key> - <value>1</value> + <key>tag_propagation_policy</key> + <value>gr.TPP_ALL_TO_ALL</value> </param> </block> <block> @@ -1143,7 +774,7 @@ </param> <param> <key>comment</key> - <value></value> + <value>Pulse Shaping</value> </param> <param> <key>affinity</key> @@ -1155,7 +786,7 @@ </param> <param> <key>_coordinate</key> - <value>(1312, 324)</value> + <value>(928, 324)</value> </param> <param> <key>_rotation</key> @@ -1206,7 +837,7 @@ </param> <param> <key>_coordinate</key> - <value>(712, 324)</value> + <value>(192, 148)</value> </param> <param> <key>_rotation</key> @@ -1214,7 +845,7 @@ </param> <param> <key>id</key> - <value>blocks_short_to_float_0</value> + <value>blocks_short_to_float_1</value> </param> <param> <key>maxoutbuf</key> @@ -1281,7 +912,7 @@ </param> <param> <key>type</key> - <value>short</value> + <value>float</value> </param> <param> <key>vlen</key> @@ -1308,7 +939,7 @@ </param> <param> <key>_coordinate</key> - <value>(8, 364)</value> + <value>(0, 300)</value> </param> <param> <key>_rotation</key> @@ -1328,7 +959,7 @@ </param> <param> <key>type</key> - <value>short</value> + <value>float</value> </param> <param> <key>repeat</key> @@ -1367,7 +998,7 @@ </param> <param> <key>_coordinate</key> - <value>(8, 284)</value> + <value>(0, 220)</value> </param> <param> <key>_rotation</key> @@ -1387,7 +1018,7 @@ </param> <param> <key>type</key> - <value>short</value> + <value>float</value> </param> <param> <key>repeat</key> @@ -1426,7 +1057,7 @@ </param> <param> <key>_coordinate</key> - <value>(8, 444)</value> + <value>(0, 380)</value> </param> <param> <key>_rotation</key> @@ -1446,7 +1077,7 @@ </param> <param> <key>type</key> - <value>short</value> + <value>float</value> </param> <param> <key>repeat</key> @@ -1485,7 +1116,7 @@ </param> <param> <key>_coordinate</key> - <value>(8, 524)</value> + <value>(0, 460)</value> </param> <param> <key>_rotation</key> @@ -1505,7 +1136,7 @@ </param> <param> <key>type</key> - <value>short</value> + <value>float</value> </param> <param> <key>repeat</key> @@ -1525,49 +1156,6 @@ </param> </block> <block> - <key>digital_map_bb</key> - <param> - <key>alias</key> - <value></value> - </param> - <param> - <key>comment</key> - <value></value> - </param> - <param> - <key>affinity</key> - <value></value> - </param> - <param> - <key>_enabled</key> - <value>True</value> - </param> - <param> - <key>_coordinate</key> - <value>(1024, 324)</value> - </param> - <param> - <key>_rotation</key> - <value>0</value> - </param> - <param> - <key>id</key> - <value>digital_map_bb_0</value> - </param> - <param> - <key>map</key> - <value>[-1, 1,0]</value> - </param> - <param> - <key>maxoutbuf</key> - <value>0</value> - </param> - <param> - <key>minoutbuf</key> - <value>0</value> - </param> - </block> - <block> <key>digital_symbol_sync_xx</key> <param> <key>alias</key> @@ -1599,7 +1187,7 @@ </param> <param> <key>_coordinate</key> - <value>(1944, 276)</value> + <value>(1600, 276)</value> </param> <param> <key>_rotation</key> @@ -1655,16 +1243,83 @@ </param> </block> <block> - <key>fir_filter_xxx</key> + <key>epy_block</key> <param> <key>alias</key> <value></value> </param> <param> + <key>_io_cache</key> + <value>('Bit -> Symbol Map', 'ConstMap', [], [('0', 'float', 1)], [('0', 'float', 1)], '\n Map 0, 1 to -1, 1\n ', [])</value> + </param> + <param> + <key>_source_code</key> + <value>""" +Embedded Python Blocks: + +Each time this file is saved, GRC will instantiate the first class it finds +to get ports and parameters of your block. The arguments to __init__ will +be the parameters. All of them are required to have default values! +""" + +import numpy as np +from gnuradio import gr + +class ConstMap(gr.sync_block): + """ + Map 0, 1 to -1, 1 + """ + def __init__(self): + gr.sync_block.__init__( + self, + name='Bit -> Symbol Map', + in_sig=[np.float32], + out_sig=[np.float32] + ) + + def work(self, input_items, output_items): + """ + map + """ + sym_map = {0.0: -1.0, 1.0: 1.0, 2.0: 0.0} + output_items[0][:] = [sym_map[x] for x in input_items[0]] + return len(output_items[0]) +</value> + </param> + <param> <key>comment</key> + <value>BPSK Modulation</value> + </param> + <param> + <key>_enabled</key> + <value>1</value> + </param> + <param> + <key>_coordinate</key> + <value>(712, 328)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>epy_block_0</value> + </param> + </block> + <block> + <key>fir_filter_xxx</key> + <param> + <key>alias</key> <value></value> </param> <param> + <key>comment</key> + <value>Matched Filter (almost). +Because the input stream has 6 2/3 +samples per symbol, this incurs a slight ISI.</value> + </param> + <param> <key>affinity</key> <value></value> </param> @@ -1678,7 +1333,7 @@ </param> <param> <key>_coordinate</key> - <value>(1672, 316)</value> + <value>(1336, 316)</value> </param> <param> <key>_rotation</key> @@ -1725,7 +1380,7 @@ </param> <param> <key>_coordinate</key> - <value>(184, 12)</value> + <value>(184, 4)</value> </param> <param> <key>_rotation</key> @@ -1756,7 +1411,7 @@ </param> <param> <key>_coordinate</key> - <value>(184, 60)</value> + <value>(184, 52)</value> </param> <param> <key>_rotation</key> @@ -1772,6 +1427,37 @@ </param> </block> <block> + <key>note</key> + <param> + <key>alias</key> + <value></value> + </param> + <param> + <key>comment</key> + <value></value> + </param> + <param> + <key>_enabled</key> + <value>True</value> + </param> + <param> + <key>_coordinate</key> + <value>(320, 316)</value> + </param> + <param> + <key>_rotation</key> + <value>0</value> + </param> + <param> + <key>id</key> + <value>note_0</value> + </param> + <param> + <key>note</key> + <value>Bit Pattern Generation</value> + </param> + </block> + <block> <key>qtgui_time_sink_x</key> <param> <key>autoscale</key> @@ -1807,7 +1493,7 @@ </param> <param> <key>_coordinate</key> - <value>(2296, 280)</value> + <value>(1952, 280)</value> </param> <param> <key>gui_hint</key> @@ -2170,7 +1856,7 @@ </param> <param> <key>_coordinate</key> - <value>(1976, 172)</value> + <value>(1632, 172)</value> </param> <param> <key>gui_hint</key> @@ -2505,7 +2191,8 @@ </param> <param> <key>comment</key> - <value></value> + <value>Resampling to 6 2/3 samples +per symbol ("clock desync")</value> </param> <param> <key>affinity</key> @@ -2525,7 +2212,7 @@ </param> <param> <key>_coordinate</key> - <value>(1472, 304)</value> + <value>(1120, 304)</value> </param> <param> <key>_rotation</key> @@ -2558,105 +2245,57 @@ </block> <connection> <source_block_id>analog_random_source_x_0</source_block_id> - <sink_block_id>blocks_multiply_const_vxx_0_0_0_0_0</sink_block_id> + <sink_block_id>blocks_short_to_float_1</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blocks_add_xx_0</source_block_id> + <source_block_id>blocks_multiply_matrix_xx_0</source_block_id> <sink_block_id>blocks_throttle_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blocks_char_to_float_2</source_block_id> - <sink_block_id>blocks_repeat_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>blocks_float_to_char_0</source_block_id> - <sink_block_id>digital_map_bb_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>blocks_multiply_const_vxx_0</source_block_id> - <sink_block_id>blocks_add_xx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>4</sink_key> - </connection> - <connection> - <source_block_id>blocks_multiply_const_vxx_0_0</source_block_id> - <sink_block_id>blocks_add_xx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>3</sink_key> - </connection> - <connection> - <source_block_id>blocks_multiply_const_vxx_0_0_0</source_block_id> - <sink_block_id>blocks_add_xx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>2</sink_key> - </connection> - <connection> - <source_block_id>blocks_multiply_const_vxx_0_0_0_0</source_block_id> - <sink_block_id>blocks_add_xx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>1</sink_key> - </connection> - <connection> - <source_block_id>blocks_multiply_const_vxx_0_0_0_0_0</source_block_id> - <sink_block_id>blocks_add_xx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> <source_block_id>blocks_repeat_0</source_block_id> <sink_block_id>rational_resampler_xxx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> - <source_block_id>blocks_short_to_float_0</source_block_id> - <sink_block_id>blocks_float_to_char_0</sink_block_id> + <source_block_id>blocks_short_to_float_1</source_block_id> + <sink_block_id>blocks_multiply_matrix_xx_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>blocks_throttle_0</source_block_id> - <sink_block_id>blocks_short_to_float_0</sink_block_id> + <sink_block_id>epy_block_0</sink_block_id> <source_key>0</source_key> <sink_key>0</sink_key> </connection> <connection> <source_block_id>blocks_vector_source_x_0_0</source_block_id> - <sink_block_id>blocks_multiply_const_vxx_0_0_0</sink_block_id> + <sink_block_id>blocks_multiply_matrix_xx_0</sink_block_id> <source_key>0</source_key> - <sink_key>0</sink_key> + <sink_key>2</sink_key> </connection> <connection> <source_block_id>blocks_vector_source_x_0_0_0</source_block_id> - <sink_block_id>blocks_multiply_const_vxx_0_0_0_0</sink_block_id> + <sink_block_id>blocks_multiply_matrix_xx_0</sink_block_id> <source_key>0</source_key> - <sink_key>0</sink_key> + <sink_key>1</sink_key> </connection> <connection> <source_block_id>blocks_vector_source_x_0_0_1</source_block_id> - <sink_block_id>blocks_multiply_const_vxx_0_0</sink_block_id> + <sink_block_id>blocks_multiply_matrix_xx_0</sink_block_id> <source_key>0</source_key> - <sink_key>0</sink_key> + <sink_key>3</sink_key> </connection> <connection> <source_block_id>blocks_vector_source_x_0_0_1_0</source_block_id> - <sink_block_id>blocks_multiply_const_vxx_0</sink_block_id> - <source_key>0</source_key> - <sink_key>0</sink_key> - </connection> - <connection> - <source_block_id>digital_map_bb_0</source_block_id> - <sink_block_id>blocks_char_to_float_2</sink_block_id> + <sink_block_id>blocks_multiply_matrix_xx_0</sink_block_id> <source_key>0</source_key> - <sink_key>0</sink_key> + <sink_key>4</sink_key> </connection> <connection> <source_block_id>digital_symbol_sync_xx_0</source_block_id> @@ -2683,6 +2322,12 @@ <sink_key>0</sink_key> </connection> <connection> + <source_block_id>epy_block_0</source_block_id> + <sink_block_id>blocks_repeat_0</sink_block_id> + <source_key>0</source_key> + <sink_key>0</sink_key> + </connection> + <connection> <source_block_id>fir_filter_xxx_0_1_0_0_0</source_block_id> <sink_block_id>digital_symbol_sync_xx_0</sink_block_id> <source_key>0</source_key> diff --git a/gr-digital/grc/digital_correlate_access_code_tag_xx.xml b/gr-digital/grc/digital_correlate_access_code_tag_xx.xml index 83ccb422ea..c7c137187f 100644 --- a/gr-digital/grc/digital_correlate_access_code_tag_xx.xml +++ b/gr-digital/grc/digital_correlate_access_code_tag_xx.xml @@ -9,6 +9,10 @@ <key>digital_correlate_access_code_tag_xx</key> <import>from gnuradio import digital</import> <make>digital.correlate_access_code_tag_$(type.fcn)($access_code, $threshold, $tagname)</make> + <callback>set_access_code($access_code)</callback> + <callback>set_threshold($threshold)</callback> + <callback>set_tagname($tagname)</callback> + <param> <name>IO Type</name> <key>type</key> diff --git a/gr-digital/include/gnuradio/digital/correlate_access_code_tag_bb.h b/gr-digital/include/gnuradio/digital/correlate_access_code_tag_bb.h index 475c038dc7..d064c45709 100644 --- a/gr-digital/include/gnuradio/digital/correlate_access_code_tag_bb.h +++ b/gr-digital/include/gnuradio/digital/correlate_access_code_tag_bb.h @@ -63,6 +63,8 @@ namespace gr { * e.g., "010101010111000100" */ virtual bool set_access_code(const std::string &access_code) = 0; + virtual void set_threshold(int threshold) = 0; + virtual void set_tagname(const std::string &tagname) = 0; }; } /* namespace digital */ diff --git a/gr-digital/include/gnuradio/digital/correlate_access_code_tag_ff.h b/gr-digital/include/gnuradio/digital/correlate_access_code_tag_ff.h index 93e89d6a6e..9eaad08c69 100644 --- a/gr-digital/include/gnuradio/digital/correlate_access_code_tag_ff.h +++ b/gr-digital/include/gnuradio/digital/correlate_access_code_tag_ff.h @@ -64,6 +64,8 @@ namespace gr { * e.g., "010101010111000100" */ virtual bool set_access_code(const std::string &access_code) = 0; + virtual void set_threshold(int threshold) = 0; + virtual void set_tagname(const std::string &tagname) = 0; }; } /* namespace digital */ diff --git a/gr-digital/lib/correlate_access_code_tag_bb_impl.cc b/gr-digital/lib/correlate_access_code_tag_bb_impl.cc index 753efa7a51..b7e93719fc 100644 --- a/gr-digital/lib/correlate_access_code_tag_bb_impl.cc +++ b/gr-digital/lib/correlate_access_code_tag_bb_impl.cc @@ -73,6 +73,8 @@ namespace gr { correlate_access_code_tag_bb_impl::set_access_code( const std::string &access_code) { + gr::thread::scoped_lock l(d_mutex_access_code); + d_len = access_code.length(); // # of bytes in string if(d_len > 64) return false; @@ -96,6 +98,8 @@ namespace gr { gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { + gr::thread::scoped_lock l(d_mutex_access_code); + const unsigned char *in = (const unsigned char*)input_items[0]; unsigned char *out = (unsigned char*)output_items[0]; diff --git a/gr-digital/lib/correlate_access_code_tag_bb_impl.h b/gr-digital/lib/correlate_access_code_tag_bb_impl.h index df558dd17e..7f6d58b5fc 100644 --- a/gr-digital/lib/correlate_access_code_tag_bb_impl.h +++ b/gr-digital/lib/correlate_access_code_tag_bb_impl.h @@ -42,6 +42,8 @@ namespace gr { pmt::pmt_t d_key, d_me; //d_key is the tag name, d_me is the block name + unique ID + gr::thread::mutex d_mutex_access_code; + public: correlate_access_code_tag_bb_impl(const std::string &access_code, int threshold, @@ -53,6 +55,8 @@ namespace gr { gr_vector_void_star &output_items); bool set_access_code(const std::string &access_code); + void set_threshold(int threshold) { d_threshold = threshold; }; + void set_tagname(const std::string &tag_name) { d_key = pmt::string_to_symbol(tag_name); }; }; } /* namespace digital */ diff --git a/gr-digital/lib/correlate_access_code_tag_ff_impl.cc b/gr-digital/lib/correlate_access_code_tag_ff_impl.cc index 6efacbb08b..1aa3d5aca9 100644 --- a/gr-digital/lib/correlate_access_code_tag_ff_impl.cc +++ b/gr-digital/lib/correlate_access_code_tag_ff_impl.cc @@ -74,6 +74,8 @@ namespace gr { correlate_access_code_tag_ff_impl::set_access_code( const std::string &access_code) { + gr::thread::scoped_lock l(d_mutex_access_code); + d_len = access_code.length(); // # of bytes in string if(d_len > 64) return false; @@ -97,6 +99,8 @@ namespace gr { gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { + gr::thread::scoped_lock l(d_mutex_access_code); + const float *in = (const float*)input_items[0]; float *out = (float*)output_items[0]; diff --git a/gr-digital/lib/correlate_access_code_tag_ff_impl.h b/gr-digital/lib/correlate_access_code_tag_ff_impl.h index 67d3ba2d6d..3b5946228a 100644 --- a/gr-digital/lib/correlate_access_code_tag_ff_impl.h +++ b/gr-digital/lib/correlate_access_code_tag_ff_impl.h @@ -42,6 +42,8 @@ namespace gr { pmt::pmt_t d_key, d_me; //d_key is the tag name, d_me is the block name + unique ID + gr::thread::mutex d_mutex_access_code; + public: correlate_access_code_tag_ff_impl(const std::string &access_code, int threshold, @@ -53,6 +55,8 @@ namespace gr { gr_vector_void_star &output_items); bool set_access_code(const std::string &access_code); + void set_threshold(int threshold) { d_threshold = threshold; }; + void set_tagname(const std::string &tag_name) { d_key = pmt::string_to_symbol(tag_name); }; }; } /* namespace digital */ diff --git a/gr-dtv/lib/catv/catv_reed_solomon_enc_bb_impl.cc b/gr-dtv/lib/catv/catv_reed_solomon_enc_bb_impl.cc index 06a1f12c3e..b2b529c0a5 100644 --- a/gr-dtv/lib/catv/catv_reed_solomon_enc_bb_impl.cc +++ b/gr-dtv/lib/catv/catv_reed_solomon_enc_bb_impl.cc @@ -116,7 +116,7 @@ namespace gr { output[i] = message[i]; } - output[127] = gf_poly_eval(output, 128, gf_exp[6]); + output[127] = gf_poly_eval(output, 127, gf_exp[6]); } void diff --git a/gr-dtv/lib/dvbt/dvbt_reference_signals_impl.cc b/gr-dtv/lib/dvbt/dvbt_reference_signals_impl.cc index aa581aeda8..f92f9fa6d8 100644 --- a/gr-dtv/lib/dvbt/dvbt_reference_signals_impl.cc +++ b/gr-dtv/lib/dvbt/dvbt_reference_signals_impl.cc @@ -908,7 +908,12 @@ namespace gr { //Clause 4.6.2.9 set_tps_bits(39, 38, config.d_transmission_mode); //Clause 4.6.2.10 - set_tps_bits(47, 40, config.d_cell_id); + if (d_frame_index % 2) { + set_tps_bits(47, 40, config.d_cell_id & 0xff); + } + else { + set_tps_bits(47, 40, (config.d_cell_id >> 8) & 0xff); + } //These bits are set to zero set_tps_bits(53, 48, 0); //Clause 4.6.2.11 diff --git a/gr-qtgui/grc/qtgui_time_sink_x.xml b/gr-qtgui/grc/qtgui_time_sink_x.xml index fbee4ca483..144cba60eb 100644 --- a/gr-qtgui/grc/qtgui_time_sink_x.xml +++ b/gr-qtgui/grc/qtgui_time_sink_x.xml @@ -931,6 +931,8 @@ $(gui_hint()($win))</make> <hide>#if ((int($nconnections()) >= 10 or ($type() == "complex" and int($nconnections()) >= 5)) and not $type.t == "message") then 'part' else 'all'#</hide> </param> + <check>$nconnections <= #if $type() == "complex" then 5 else 10#</check> + <sink> <name>in</name> <type>$type.t</type> diff --git a/gr-qtgui/lib/TimeDomainDisplayPlot.cc b/gr-qtgui/lib/TimeDomainDisplayPlot.cc index 51a1989a9a..e1e8482369 100644 --- a/gr-qtgui/lib/TimeDomainDisplayPlot.cc +++ b/gr-qtgui/lib/TimeDomainDisplayPlot.cc @@ -170,8 +170,14 @@ TimeDomainDisplayPlot::TimeDomainDisplayPlot(int nplots, QWidget* parent) colors << QColor(Qt::blue) << QColor(Qt::red) << QColor(Qt::green) << QColor(Qt::black) << QColor(Qt::cyan) << QColor(Qt::magenta) << QColor(Qt::yellow) << QColor(Qt::gray) << QColor(Qt::darkRed) + << QColor(Qt::darkGreen) << QColor(Qt::darkBlue) << QColor(Qt::darkGray) + // cycle through all colors again to increase time_sink_f input limit + // from 12 to 24, otherwise you get a segfault + << QColor(Qt::blue) << QColor(Qt::red) << QColor(Qt::green) + << QColor(Qt::black) << QColor(Qt::cyan) << QColor(Qt::magenta) + << QColor(Qt::yellow) << QColor(Qt::gray) << QColor(Qt::darkRed) << QColor(Qt::darkGreen) << QColor(Qt::darkBlue) << QColor(Qt::darkGray); - + // Setup dataPoints and plot vectors // Automatically deleted when parent is deleted for(int i = 0; i < d_nplots; i++) { diff --git a/gr-qtgui/lib/time_sink_c_impl.cc b/gr-qtgui/lib/time_sink_c_impl.cc index 06d0c78e9c..6fe06b74a0 100644 --- a/gr-qtgui/lib/time_sink_c_impl.cc +++ b/gr-qtgui/lib/time_sink_c_impl.cc @@ -55,6 +55,9 @@ namespace gr { d_size(size), d_buffer_size(2*size), d_samp_rate(samp_rate), d_name(name), d_nconnections(2*nconnections), d_parent(parent) { + if(nconnections > 12) + throw std::runtime_error("time_sink_c only supports up to 12 inputs"); + // Required now for Qt; argc must be greater than 0 and argv // must have at least one valid character. Must be valid through // life of the qApplication: diff --git a/gr-qtgui/lib/time_sink_f_impl.cc b/gr-qtgui/lib/time_sink_f_impl.cc index dc88a0add0..1298c6c422 100644 --- a/gr-qtgui/lib/time_sink_f_impl.cc +++ b/gr-qtgui/lib/time_sink_f_impl.cc @@ -57,6 +57,9 @@ namespace gr { d_size(size), d_buffer_size(2*size), d_samp_rate(samp_rate), d_name(name), d_nconnections(nconnections), d_parent(parent) { + if(nconnections > 24) + throw std::runtime_error("time_sink_f only supports up to 24 inputs"); + // Required now for Qt; argc must be greater than 0 and argv // must have at least one valid character. Must be valid through // life of the qApplication: diff --git a/gr-uhd/grc/gen_uhd_usrp_blocks.py b/gr-uhd/grc/gen_uhd_usrp_blocks.py index e99de0d7d0..8b7c58682a 100644 --- a/gr-uhd/grc/gen_uhd_usrp_blocks.py +++ b/gr-uhd/grc/gen_uhd_usrp_blocks.py @@ -517,6 +517,10 @@ PARAMS_TMPL = """ <param> <name>RX2</name> <key>RX2</key> </option> + <option> + <name>RX1</name> + <key>RX1</key> + </option> #end if <tab>RF Options</tab> </param> diff --git a/gr-zeromq/include/gnuradio/zeromq/pub_msg_sink.h b/gr-zeromq/include/gnuradio/zeromq/pub_msg_sink.h index 8cf4bcfab4..fb046ca84b 100644 --- a/gr-zeromq/include/gnuradio/zeromq/pub_msg_sink.h +++ b/gr-zeromq/include/gnuradio/zeromq/pub_msg_sink.h @@ -49,7 +49,7 @@ namespace gr { * \brief Return a shared_ptr to a new instance of zeromq::pub_msg_sink. * * \param address ZMQ socket address specifier - * \param timeout Receive timeout in seconds, default is 100ms, 1us increments + * \param timeout Receive timeout in milliseconds, default is 100ms, 1us increments */ static sptr make(char *address, int timeout=100); }; diff --git a/gr-zeromq/include/gnuradio/zeromq/pub_sink.h b/gr-zeromq/include/gnuradio/zeromq/pub_sink.h index e87c5522f9..3fecc10b59 100644 --- a/gr-zeromq/include/gnuradio/zeromq/pub_sink.h +++ b/gr-zeromq/include/gnuradio/zeromq/pub_sink.h @@ -51,7 +51,7 @@ namespace gr { * \param itemsize Size of a stream item in bytes. * \param vlen Vector length of the input items. Note that one vector is one item. * \param address ZMQ socket address specifier. - * \param timeout Receive timeout in seconds, default is 100ms, 1us increments. + * \param timeout Receive timeout in milliseconds, default is 100ms, 1us increments. * \param pass_tags Whether sink will serialize and pass tags over the link. * \param hwm High Watermark to configure the socket to (-1 => zmq's default) */ diff --git a/gr-zeromq/include/gnuradio/zeromq/pull_msg_source.h b/gr-zeromq/include/gnuradio/zeromq/pull_msg_source.h index 17495152b8..13857ead5f 100644 --- a/gr-zeromq/include/gnuradio/zeromq/pull_msg_source.h +++ b/gr-zeromq/include/gnuradio/zeromq/pull_msg_source.h @@ -46,7 +46,7 @@ namespace gr { * \brief Return a shared_ptr to a new instance of gr::zeromq::pull_msg_source. * * \param address ZMQ socket address specifier - * \param timeout Receive timeout in seconds, default is 100ms, 1us increments + * \param timeout Receive timeout in milliseconds, default is 100ms, 1us increments * */ static sptr make(char *address, int timeout=100); diff --git a/gr-zeromq/include/gnuradio/zeromq/pull_source.h b/gr-zeromq/include/gnuradio/zeromq/pull_source.h index 07cf6af128..ecfe508b0a 100644 --- a/gr-zeromq/include/gnuradio/zeromq/pull_source.h +++ b/gr-zeromq/include/gnuradio/zeromq/pull_source.h @@ -48,7 +48,7 @@ namespace gr { * \param itemsize Size of a stream item in bytes. * \param vlen Vector length of the input items. Note that one vector is one item. * \param address ZMQ socket address specifier. - * \param timeout Receive timeout in seconds, default is 100ms, 1us increments. + * \param timeout Receive timeout in milliseconds, default is 100ms, 1us increments. * \param pass_tags Whether source will look for and deserialize tags. * \param hwm High Watermark to configure the socket to (-1 => zmq's default) */ diff --git a/gr-zeromq/include/gnuradio/zeromq/push_msg_sink.h b/gr-zeromq/include/gnuradio/zeromq/push_msg_sink.h index 3ce6ebbdc0..941ad549f5 100644 --- a/gr-zeromq/include/gnuradio/zeromq/push_msg_sink.h +++ b/gr-zeromq/include/gnuradio/zeromq/push_msg_sink.h @@ -48,7 +48,7 @@ namespace gr { * \brief Return a shared_ptr to a new instance of gr::zeromq::push_msg_sink * * \param address ZMQ socket address specifier - * \param timeout Receive timeout in seconds, default is 100ms, 1us increments + * \param timeout Receive timeout in milliseconds, default is 100ms, 1us increments * */ static sptr make(char *address, int timeout=100); diff --git a/gr-zeromq/include/gnuradio/zeromq/push_sink.h b/gr-zeromq/include/gnuradio/zeromq/push_sink.h index e2260aa3f6..f81dcaa941 100644 --- a/gr-zeromq/include/gnuradio/zeromq/push_sink.h +++ b/gr-zeromq/include/gnuradio/zeromq/push_sink.h @@ -52,7 +52,7 @@ namespace gr { * \param itemsize Size of a stream item in bytes. * \param vlen Vector length of the input items. Note that one vector is one item. * \param address ZMQ socket address specifier. - * \param timeout Receive timeout in seconds, default is 100ms, 1us increments. + * \param timeout Receive timeout in milliseconds, default is 100ms, 1us increments. * \param pass_tags Whether sink will serialize and pass tags over the link. * \param hwm High Watermark to configure the socket to (-1 => zmq's default) */ diff --git a/gr-zeromq/include/gnuradio/zeromq/rep_msg_sink.h b/gr-zeromq/include/gnuradio/zeromq/rep_msg_sink.h index 97f3d831ad..d11550d149 100644 --- a/gr-zeromq/include/gnuradio/zeromq/rep_msg_sink.h +++ b/gr-zeromq/include/gnuradio/zeromq/rep_msg_sink.h @@ -48,7 +48,7 @@ namespace gr { * \brief Return a shared_ptr to a new instance of zeromq::rep_msg_sink. * * \param address ZMQ socket address specifier - * \param timeout Receive timeout in seconds, default is 100ms, 1us increments + * \param timeout Receive timeout in milliseconds, default is 100ms, 1us increments * */ static sptr make(char *address, int timeout=100); diff --git a/gr-zeromq/include/gnuradio/zeromq/rep_sink.h b/gr-zeromq/include/gnuradio/zeromq/rep_sink.h index 220bd34416..c1d2d370fc 100644 --- a/gr-zeromq/include/gnuradio/zeromq/rep_sink.h +++ b/gr-zeromq/include/gnuradio/zeromq/rep_sink.h @@ -50,7 +50,7 @@ namespace gr { * \param itemsize Size of a stream item in bytes. * \param vlen Vector length of the input items. Note that one vector is one item. * \param address ZMQ socket address specifier. - * \param timeout Receive timeout in seconds, default is 100ms, 1us increments. + * \param timeout Receive timeout in milliseconds, default is 100ms, 1us increments. * \param pass_tags Whether sink will serialize and pass tags over the link. * \param hwm High Watermark to configure the socket to (-1 => zmq's default) */ diff --git a/gr-zeromq/include/gnuradio/zeromq/req_msg_source.h b/gr-zeromq/include/gnuradio/zeromq/req_msg_source.h index 05d80b8e7f..28ac9f84f3 100644 --- a/gr-zeromq/include/gnuradio/zeromq/req_msg_source.h +++ b/gr-zeromq/include/gnuradio/zeromq/req_msg_source.h @@ -46,7 +46,7 @@ namespace gr { * \brief Return a shared_ptr to a new instance of zeromq::req_msg_source. * * \param address ZMQ socket address specifier - * \param timeout Receive timeout in seconds, default is 100ms, 1us increments + * \param timeout Receive timeout in milliseconds, default is 100ms, 1us increments * */ static sptr make(char *address, int timeout=100); diff --git a/gr-zeromq/include/gnuradio/zeromq/req_source.h b/gr-zeromq/include/gnuradio/zeromq/req_source.h index 461f653b43..103da90f71 100644 --- a/gr-zeromq/include/gnuradio/zeromq/req_source.h +++ b/gr-zeromq/include/gnuradio/zeromq/req_source.h @@ -48,7 +48,7 @@ namespace gr { * \param itemsize Size of a stream item in bytes. * \param vlen Vector length of the input items. Note that one vector is one item. * \param address ZMQ socket address specifier. - * \param timeout Receive timeout in seconds, default is 100ms, 1us increments. + * \param timeout Receive timeout in milliseconds, default is 100ms, 1us increments. * \param pass_tags Whether source will look for and deserialize tags. * \param hwm High Watermark to configure the socket to (-1 => zmq's default) */ diff --git a/gr-zeromq/include/gnuradio/zeromq/sub_msg_source.h b/gr-zeromq/include/gnuradio/zeromq/sub_msg_source.h index d06a83c1fd..5c91d1e1ed 100644 --- a/gr-zeromq/include/gnuradio/zeromq/sub_msg_source.h +++ b/gr-zeromq/include/gnuradio/zeromq/sub_msg_source.h @@ -46,7 +46,7 @@ namespace gr { * \brief Return a shared_ptr to a new instance of gr::zeromq::sub_msg_source. * * \param address ZMQ socket address specifier - * \param timeout Receive timeout in seconds, default is 100ms, 1us increments + * \param timeout Receive timeout in milliseconds, default is 100ms, 1us increments * */ static sptr make(char *address, int timeout=100); diff --git a/gr-zeromq/include/gnuradio/zeromq/sub_source.h b/gr-zeromq/include/gnuradio/zeromq/sub_source.h index def3a703e6..990c74cabd 100644 --- a/gr-zeromq/include/gnuradio/zeromq/sub_source.h +++ b/gr-zeromq/include/gnuradio/zeromq/sub_source.h @@ -48,7 +48,7 @@ namespace gr { * \param itemsize Size of a stream item in bytes. * \param vlen Vector length of the input items. Note that one vector is one item. * \param address ZMQ socket address specifier. - * \param timeout Receive timeout in seconds, default is 100ms, 1us increments. + * \param timeout Receive timeout in milliseconds, default is 100ms, 1us increments. * \param pass_tags Whether source will look for and deserialize tags. * \param hwm High Watermark to configure the socket to (-1 => zmq's default) */ diff --git a/grc/blocks/options.xml b/grc/blocks/options.xml index 1dee986c5c..6f3c8d5cf0 100644 --- a/grc/blocks/options.xml +++ b/grc/blocks/options.xml @@ -19,6 +19,13 @@ import wx from PyQt4 import Qt import sys #end if +#if $generate_options() == 'bokeh_gui' +import time +import signal +import functools +from bokeh.client import push_session +from bokeh.plotting import curdoc +#end if #if not $generate_options().startswith('hb') from optparse import OptionParser from gnuradio.eng_option import eng_option @@ -61,6 +68,10 @@ else: self.stop(); self.wait()</callback> <value>qt_gui</value> <type>enum</type> <option> + <name>Bokeh GUI</name> + <key>bokeh_gui</key> + </option> + <option> <name>QT GUI</name> <key>qt_gui</key> </option> @@ -104,12 +115,46 @@ else: self.stop(); self.wait()</callback> </option> </param> <param> + <name>Widget Placement</name> + <key>placement</key> + <value>(0,0)</value> + <type>int_vector</type> + <hide>#if $generate_options() == 'bokeh_gui' then 'part' else 'all'#</hide> + </param> + <param> + <name>Sizing Mode</name> + <key>sizing_mode</key> + <value>fixed</value> + <type>enum</type> + <hide>#if $generate_options() == 'bokeh_gui' then 'part' else 'all'#</hide> + <option> + <name>Fixed</name> + <key>fixed</key> + </option> + <option> + <name>Stretch Both</name> + <key>stretch_both</key> + </option> + <option> + <name>Scale Width</name> + <key>scale_width</key> + </option> + <option> + <name>Scale Height</name> + <key>scale_height</key> + </option> + <option> + <name>Scale Both</name> + <key>scale_both</key> + </option> + </param> + <param> <name>Run</name> <key>run</key> <value>True</value> <type>bool</type> <hide> -#if $generate_options() in ('qt_gui', 'wx_gui') +#if $generate_options() in ('qt_gui', 'wx_gui', 'bokeh_gui') #if $run() part #else @@ -218,7 +263,9 @@ part#slurp <check>not $window_size or len($window_size) == 2</check> <check>not $window_size or 300 <= $(window_size)[0] <= 4096</check> <check>not $window_size or 300 <= $(window_size)[1] <= 4096</check> - <doc> + <check>len($placement) == 4 or len($placement) == 2</check> + <check>all(i >= 0 for i in $(placement))</check> + <doc> The options block sets special parameters for the flow graph. \ Only one option block is allowed per flow graph. diff --git a/grc/core/Platform.py b/grc/core/Platform.py index 297e8b0ae5..258f38cc62 100644 --- a/grc/core/Platform.py +++ b/grc/core/Platform.py @@ -31,7 +31,7 @@ from .Block import Block from .Port import Port from .Param import Param -from .utils import odict, extract_docs +from .utils import odict, extract_docs, hide_bokeh_gui_options_if_not_installed class Platform(Element): @@ -172,6 +172,8 @@ class Platform(Element): self._docstring_extractor.finish() # self._docstring_extractor.wait() + hide_bokeh_gui_options_if_not_installed(self.blocks['options']) + def iter_xml_files(self): """Iterator for block descriptions and category trees""" for block_path in self.config.block_paths: diff --git a/grc/core/generator/flow_graph.tmpl b/grc/core/generator/flow_graph.tmpl index 1ef251c46b..5550dca823 100644 --- a/grc/core/generator/flow_graph.tmpl +++ b/grc/core/generator/flow_graph.tmpl @@ -38,7 +38,7 @@ import threading ## Call XInitThreads as the _very_ first thing. ## After some Qt import, it's too late -#if $generate_options in ('wx_gui', 'qt_gui') +#if $generate_options in ('wx_gui', 'qt_gui', 'bokeh_gui') if __name__ == '__main__': import ctypes import sys @@ -119,6 +119,15 @@ class $(class_name)(gr.top_block, Qt.QWidget): self.settings = Qt.QSettings("GNU Radio", "$class_name") self.restoreGeometry(self.settings.value("geometry").toByteArray()) + +#elif $generate_options == 'bokeh_gui' + +class $(class_name)(gr.top_block): + def __init__(self, doc): + gr.top_block.__init__(self, "$title") + self.doc = doc + self.plot_lst = [] + self.widget_lst = [] #elif $generate_options == 'no_gui' @@ -237,6 +246,22 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))]) #end if #end if #end for + +########################################################## +## Create a layout entry if not manually done for BokehGUI +########################################################## +#if $generate_options == 'bokeh_gui' + if self.widget_lst: + input_t = bokehgui.BokehLayout.widgetbox(self.widget_lst) + widgetbox = bokehgui.BokehLayout.WidgetLayout(input_t) + widgetbox.set_layout(*($flow_graph.get_option('placement'))) + list_obj = [widgetbox] + self.plot_lst + else: + list_obj = self.plot_lst + layout_t = bokehgui.BokehLayout.create_layout(list_obj, "$flow_graph.get_option('sizing_mode')") + self.doc.add_root(layout_t) +#end if + ######################################################## ##Create Connections ## The port name should be the id of the parent block. @@ -378,6 +403,37 @@ def main(top_block_cls=$(class_name), options=None): #end for tb.Wait() #end if + #elif $generate_options == 'bokeh_gui' + serverProc, port = bokehgui.utils.create_server() + def killProc(signum, frame, tb): + tb.stop() + tb.wait() + serverProc.terminate() + serverProc.kill() + time.sleep(1) + try: + \# Define the document instance + doc = curdoc() + #if $flow_graph.get_option('author') + doc.title = "$title - $flow_graph.get_option('author')" + #else + doc.title = "$title" + #end if + session = push_session(doc, session_id="$flow_graph.get_option('id')", + url = "http://localhost:" + port + "/bokehgui") + \# Create Top Block instance + tb = top_block_cls(doc) + try: + tb.start() + signal.signal(signal.SIGTERM, functools.partial(killProc, tb=tb)) + session.loop_until_closed() + finally: + print "Exiting the simulation. Stopping Bokeh Server" + tb.stop() + tb.wait() + finally: + serverProc.terminate() + serverProc.kill() #elif $generate_options == 'qt_gui' from distutils.version import StrictVersion if StrictVersion(Qt.qVersion()) >= StrictVersion("4.5.0"): diff --git a/grc/core/utils/__init__.py b/grc/core/utils/__init__.py index 6b23da2723..2aed42d762 100644 --- a/grc/core/utils/__init__.py +++ b/grc/core/utils/__init__.py @@ -20,3 +20,4 @@ import epy_block_io import extract_docs from odict import odict +from hide_bokeh_gui_options_if_not_installed import hide_bokeh_gui_options_if_not_installed diff --git a/grc/core/utils/hide_bokeh_gui_options_if_not_installed.py b/grc/core/utils/hide_bokeh_gui_options_if_not_installed.py new file mode 100644 index 0000000000..fc0141851a --- /dev/null +++ b/grc/core/utils/hide_bokeh_gui_options_if_not_installed.py @@ -0,0 +1,28 @@ +# Copyright 2008-2017 Free Software Foundation, Inc. +# This file is part of GNU Radio +# +# GNU Radio Companion is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# GNU Radio Companion is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA + + +def hide_bokeh_gui_options_if_not_installed(options): + try: + import bokehgui + except ImportError: + generate_option = options.get_param('generate_options') + list_generate_option = generate_option.get_options() + for option in list_generate_option: + if option.get_key() == 'bokeh_gui': + list_generate_option.remove(option) + return |