diff options
-rw-r--r-- | cmake/Modules/GrSwig.cmake | 41 | ||||
-rw-r--r-- | docs/doxygen/other/build_guide.dox | 12 | ||||
-rw-r--r-- | docs/doxygen/other/msg_passing.dox | 40 | ||||
-rw-r--r-- | gnuradio-runtime/swig/gr_types.i | 20 | ||||
-rw-r--r-- | gr-blocks/include/gnuradio/blocks/peak_detector2_fb.h | 24 | ||||
-rw-r--r-- | gr-blocks/include/gnuradio/blocks/tagged_stream_align.h | 4 | ||||
-rw-r--r-- | gr-digital/lib/mpsk_snr_est.cc | 1 | ||||
-rw-r--r-- | gr-digital/lib/ofdm_chanest_vcvc_impl.cc | 2 | ||||
-rw-r--r-- | gr-digital/lib/pn_correlator_cc_impl.cc | 3 | ||||
-rw-r--r-- | gr-digital/lib/simple_correlator_impl.cc | 1 | ||||
-rw-r--r-- | gr-fec/include/gnuradio/fec/awgn_bp.h | 11 | ||||
-rw-r--r-- | gr-fec/include/gnuradio/fec/gf2mat.h | 25 | ||||
-rw-r--r-- | gr-uhd/examples/c++/tags_demo.cc | 3 | ||||
-rw-r--r-- | grc/base/Block.py | 5 | ||||
-rw-r--r-- | grc/base/FlowGraph.py | 18 |
15 files changed, 145 insertions, 65 deletions
diff --git a/cmake/Modules/GrSwig.cmake b/cmake/Modules/GrSwig.cmake index abf4dc4612..ef3a76eb4c 100644 --- a/cmake/Modules/GrSwig.cmake +++ b/cmake/Modules/GrSwig.cmake @@ -105,17 +105,36 @@ endfunction(GR_SWIG_MAKE_DOCS) macro(GR_SWIG_MAKE name) set(ifiles ${ARGN}) - # Shimming this in here to take care of a SWIG bug with handling - # vector<size_t> and vector<unsigned int> (on 32-bit machines) and - # vector<long unsigned int> (on 64-bit machines). Use this to test - # the size of size_t, then set SIZE_T_32 if it's a 32-bit machine - # or not if it's 64-bit. The logic in gr_type.i handles the rest. - INCLUDE(CheckTypeSize) - CHECK_TYPE_SIZE("size_t" SIZEOF_SIZE_T) - CHECK_TYPE_SIZE("unsigned int" SIZEOF_UINT) - if(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT}) - list(APPEND GR_SWIG_FLAGS -DSIZE_T_32) - endif(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT}) + # Take care of a SWIG < 3.0 bug with handling std::vector<size_t>, + # by mapping to the correct sized type on the runtime system, one + # of "unsigned int", "unsigned long", or "unsigned long long". + # Compare the sizeof(size_t) with the sizeof the other types, and + # pick the first one in the list with the same sizeof. The logic + # in gnuradio-runtime/swig/gr_types.i handles the rest. It is + # probably not necessary to do this assignment all of the time, + # but it's easier to do it this way than to figure out the + # conditions when it is necessary -- and doing it this way won't + # hurt. This bug seems to have been fixed with SWIG >= 3.0, and + # mostly happens when not doing a native build (e.g., on Mac OS X + # when using a 64-bit CPU but building for 32-bit). + + if(SWIG_VERSION VERSION_LESS "3.0.0") + include(CheckTypeSize) + check_type_size("size_t" SIZEOF_SIZE_T) + check_type_size("unsigned int" SIZEOF_UINT) + check_type_size("unsigned long" SIZEOF_UL) + check_type_size("unsigned long long" SIZEOF_ULL) + + if(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UINT}) + list(APPEND GR_SWIG_FLAGS -DSIZE_T_UINT) + elseif(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_UL}) + list(APPEND GR_SWIG_FLAGS -DSIZE_T_UL) + elseif(${SIZEOF_SIZE_T} EQUAL ${SIZEOF_ULL}) + list(APPEND GR_SWIG_FLAGS -DSIZE_T_ULL) + else() + message(FATAL_ERROR "GrSwig: Unable to find replace for std::vector<size_t>; this should never happen!") + endif() + endif() #do swig doc generation if specified if(GR_SWIG_DOC_FILE) diff --git a/docs/doxygen/other/build_guide.dox b/docs/doxygen/other/build_guide.dox index ebf47dc7e2..8fc3f911fb 100644 --- a/docs/doxygen/other/build_guide.dox +++ b/docs/doxygen/other/build_guide.dox @@ -1,4 +1,4 @@ -/*! \page build_guide Build Instructions and Information + /*! \page build_guide Build Instructions and Information \section dependencies Dependencies @@ -24,11 +24,11 @@ installation tool (apt-get, pkg_install, YaST, yum, urpmi, etc.) first. Most recent systems have these packages available. \subsection dep_global Global Dependencies -\li git http://code.google.com/p/msysgit +\li git http://git-scm.com/downloads \li cmake (>= 2.6.3) http://www.cmake.org/cmake/resources/software.html -\li boost (>= 1.35) http://www.boostpro.com/download -\li cppunit (>= 1.9.14) http://gaiacrtn.free.fr/cppunit/index.html -\li fftw3f (>= 3.0.1) http://www.fftw.org/install/windows.html +\li boost (>= 1.35) http://www.boost.org/users/download/ +\li cppunit (>= 1.9.14) http://freedesktop.org/wiki/Software/cppunit/ +\li fftw3f (>= 3.0.1) http://www.fftw.org/download.html \subsection dep_python Python Wrappers \li python (>= 2.5) http://www.python.org/download/ @@ -176,7 +176,7 @@ If not specified, the "Release" mode is the default. Here are som other potentially helpful CMake flags. These are to help you specifically locate certain dependencies. While the CMake scripts themselves should generally find these for us, we can use these to help direct CMake to specific locations if we have installed a different version elsewhere on the system that CMake doesn't know about. -\li QWT_LIBRARIES: shared library to use for Qwt (in the form <path>/libqwt.so). +\li QWT_LIBRARIES: shared library to use for Qwt (in the form \<path\>/libqwt.so). \li QWT_INCLUDE_DIRS: path to Qwt include files (e.g., /usr/include/qwt). \li PYTHON_EXECUTABLE: Location of the 'python' binary you want to use (e.g., /usr/bin/python2.7). \li PYTHON_INCLUDE_PATH: path to Python include files (e.g., /usr/include/python2.7). diff --git a/docs/doxygen/other/msg_passing.dox b/docs/doxygen/other/msg_passing.dox index df116c2ba1..494ca03921 100644 --- a/docs/doxygen/other/msg_passing.dox +++ b/docs/doxygen/other/msg_passing.dox @@ -311,4 +311,44 @@ 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. + */ diff --git a/gnuradio-runtime/swig/gr_types.i b/gnuradio-runtime/swig/gr_types.i index 8ae953b904..e329a4ce9f 100644 --- a/gnuradio-runtime/swig/gr_types.i +++ b/gnuradio-runtime/swig/gr_types.i @@ -80,15 +80,19 @@ namespace std { %template(gr_vector_vector_complexf) std::vector< std::vector< std::complex<float> > >; %template(gr_vector_vector_complexd) std::vector< std::vector< std::complex<double> > >; -// Fix for Issue #529 -#ifdef SIZE_T_32 - // On 32-bit systems, whenever we see std::vector<size_t>, replace it - // with vector<unsigned int> +// Fix for Issue #529: replace std::vector<size_t> with its equivalent +// in element size, one of "unsigned int", "unsigned long", or +// "unsigned long long". The replacement depends on the sizeof each +// type, as determined in GrSwig.cmake GR_SWIG_MAKE. For SWIG >= +// 3.0.0, none of these will be defined because this issue seems to +// have been fixed. + +#if defined(SIZE_T_UINT) %apply std::vector<unsigned int> { std::vector<size_t> }; -#else - // On 64-bit systems, whenever we see std::vector<size_t>, replace it - // with vector<long unsigned int> - %apply std::vector<long unsigned int> { std::vector<size_t> }; +#elif defined(SIZE_T_UL) + %apply std::vector<unsigned long> { std::vector<size_t> }; +#elif defined(SIZE_T_ULL) + %apply std::vector<unsigned long long> { std::vector<size_t> }; #endif #endif /* SWIG_GR_TYPES_I */ diff --git a/gr-blocks/include/gnuradio/blocks/peak_detector2_fb.h b/gr-blocks/include/gnuradio/blocks/peak_detector2_fb.h index da2d9fc740..541dd8aa09 100644 --- a/gr-blocks/include/gnuradio/blocks/peak_detector2_fb.h +++ b/gr-blocks/include/gnuradio/blocks/peak_detector2_fb.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2007,2013 Free Software Foundation, Inc. + * Copyright 2007,2013,2015 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -36,7 +36,7 @@ namespace gr { * \details * If a peak is detected, this block outputs a 1, or it outputs * 0's. A separate debug output may be connected, to view the - * internal EWMA described below. + * internal estimated mean described below. */ class BLOCKS_API peak_detector2_fb : virtual public sync_block { @@ -47,13 +47,21 @@ namespace gr { /*! * Build a peak detector block with float in, byte out. * - * \param threshold_factor_rise The threshold factor determins - * when a peak is present. An EWMA average of the signal is - * calculated and when the value of the signal goes over - * threshold_factor_rise*average, we call the peak. + * \param threshold_factor_rise The threshold factor determines + * when a peak is present. An average of the input signal + * is calculated (through a single-pole autoregressive + * filter) and when the value of the input signal goes + * over threshold_factor_rise*average, we assume we are + * in the neighborhood of a peak. The block will then + * find the position of the maximum within a window of + * look_ahead samples starting at the point where the + * threshold was crossed upwards. * \param look_ahead The look-ahead value is used when the - * threshold is found to locate the peak within this range. - * \param alpha The gain value of a single-pole moving average filter. + * threshold is crossed upwards to locate the peak within + * this range. + * \param alpha One minus the pole of a single-pole + * autoregressive filter that evaluates the average of + * the input signal. */ static sptr make(float threshold_factor_rise=7, int look_ahead=1000, float alpha=0.001); diff --git a/gr-blocks/include/gnuradio/blocks/tagged_stream_align.h b/gr-blocks/include/gnuradio/blocks/tagged_stream_align.h index 979629317c..ae01198113 100644 --- a/gr-blocks/include/gnuradio/blocks/tagged_stream_align.h +++ b/gr-blocks/include/gnuradio/blocks/tagged_stream_align.h @@ -43,7 +43,8 @@ namespace gr { /*! * Make a tagged stream align * - * \param lengthtagname Length tag key + * \param itemsize The size (in bytes) of the item datatype. + * \param lengthtagname Name of the TSB's length tag key. */ static sptr make(size_t itemsize, const std::string &lengthtagname); }; @@ -52,4 +53,3 @@ namespace gr { } // namespace gr #endif /* INCLUDED_TAGGED_STREAM_ALIGN_H */ - diff --git a/gr-digital/lib/mpsk_snr_est.cc b/gr-digital/lib/mpsk_snr_est.cc index 4e7825b894..098e465b2b 100644 --- a/gr-digital/lib/mpsk_snr_est.cc +++ b/gr-digital/lib/mpsk_snr_est.cc @@ -131,6 +131,7 @@ namespace gr { { d_y1 = 0; d_y2 = 0; + d_y3 = 0; d_counter = 1; } diff --git a/gr-digital/lib/ofdm_chanest_vcvc_impl.cc b/gr-digital/lib/ofdm_chanest_vcvc_impl.cc index 8d2c17ca8b..f27107f2db 100644 --- a/gr-digital/lib/ofdm_chanest_vcvc_impl.cc +++ b/gr-digital/lib/ofdm_chanest_vcvc_impl.cc @@ -63,6 +63,8 @@ namespace gr { d_corr_v(sync_symbol2), d_known_symbol_diffs(0, 0), d_new_symbol_diffs(0, 0), + d_first_active_carrier(0), + d_last_active_carrier(sync_symbol2.size()-1), d_interpolate(false) { // Set index of first and last active carrier diff --git a/gr-digital/lib/pn_correlator_cc_impl.cc b/gr-digital/lib/pn_correlator_cc_impl.cc index 649b73be14..fa86de8cfe 100644 --- a/gr-digital/lib/pn_correlator_cc_impl.cc +++ b/gr-digital/lib/pn_correlator_cc_impl.cc @@ -43,7 +43,8 @@ namespace gr { : sync_decimator("pn_correlator_cc", io_signature::make(1, 1, sizeof(gr_complex)), io_signature::make(1, 1, sizeof(gr_complex)), - (unsigned int)((1ULL << degree)-1)) // PN code length + (unsigned int)((1ULL << degree)-1)), // PN code length + d_pn(0.0f) { d_len = (unsigned int)((1ULL << degree)-1); if(mask == 0) diff --git a/gr-digital/lib/simple_correlator_impl.cc b/gr-digital/lib/simple_correlator_impl.cc index 6524e906a4..0e0b05a9a1 100644 --- a/gr-digital/lib/simple_correlator_impl.cc +++ b/gr-digital/lib/simple_correlator_impl.cc @@ -51,6 +51,7 @@ namespace gr { io_signature::make(1, 1, sizeof(unsigned char))), d_payload_bytesize(payload_bytesize), d_state(ST_LOOKING), d_osi(0), + d_transition_osi(0), d_center_osi(0), d_bblen((payload_bytesize + GRSF_PAYLOAD_OVERHEAD) * GRSF_BITS_PER_BYTE), d_bitbuf(new unsigned char[d_bblen]), d_pktbuf(new unsigned char[d_bblen/GRSF_BITS_PER_BYTE]), diff --git a/gr-fec/include/gnuradio/fec/awgn_bp.h b/gr-fec/include/gnuradio/fec/awgn_bp.h index f420d76394..62fe7e26a4 100644 --- a/gr-fec/include/gnuradio/fec/awgn_bp.h +++ b/gr-fec/include/gnuradio/fec/awgn_bp.h @@ -119,13 +119,14 @@ class FEC_API awgn_bp int get_max_iterations(); /*! - \brief Decodes the given vector rx_word by message passing. - - \param *niterations is the number of message passing iterations - done to decode this codeword + * \brief Decodes the given vector rx_word by message passing. + * + * \param rx_word The received samples for decoding. + * \param niterations The number of message passing iterations + * done to decode this codeword. */ std::vector<char> decode (std::vector<float> rx_word, - int *niterations); + int *niterations); private: //! The number of check nodes in the tanner-graph int M; diff --git a/gr-fec/include/gnuradio/fec/gf2mat.h b/gr-fec/include/gnuradio/fec/gf2mat.h index 963b20830d..51aa310518 100644 --- a/gr-fec/include/gnuradio/fec/gf2mat.h +++ b/gr-fec/include/gnuradio/fec/gf2mat.h @@ -54,7 +54,7 @@ class GF2Mat int get_M(); //! Returns the variable N - int get_N(); + int get_N(); //! Set the element at (i, j) coordinate to val void set_element(int i, int j, char val); @@ -93,17 +93,18 @@ class GF2Mat std::vector<std::vector<char> > get_H(); /*! - \brief Obtains an equivalent representation of H for encoding - - For encoding a G matrix in the form [I P] is obtained from the - parity matrix H, by (a) Column permutations, (b) Row additions - and (c) Row permutations. Details of encoding is given in - section A.1 of the reference given below. - - "Modern Coding Theory", T Richardson and R Urbanke. - - \param p is the column permutation during this operation - \ - */ + * \brief Obtains an equivalent representation of H for encoding + * + * For encoding a G matrix in the form [I P] obtained from the + * parity matrix H, by (a) Column permutations, (b) Row additions + * and (c) Row permutations. Details of encoding is given in + * section A.1 of the reference: + * + * - "Modern Coding Theory", T Richardson and R Urbanke. + * + * \param p The column permutation during this operation. + * \param rank The rank of the matrix. + */ GF2Mat get_G(std::vector<int> & p, int & rank); }; diff --git a/gr-uhd/examples/c++/tags_demo.cc b/gr-uhd/examples/c++/tags_demo.cc index 787e3d2e4b..42cbb46874 100644 --- a/gr-uhd/examples/c++/tags_demo.cc +++ b/gr-uhd/examples/c++/tags_demo.cc @@ -24,6 +24,7 @@ #include <gnuradio/uhd/usrp_sink.h> #include <tag_source_demo.h> #include <tag_sink_demo.h> +#include <uhd/utils/safe_main.hpp> #include <boost/make_shared.hpp> #include <boost/thread/thread.hpp> //sleep #include <boost/program_options.hpp> @@ -41,7 +42,7 @@ void sig_int_handler(int){stop_signal_called = true;} /*********************************************************************** * Main w/ program options **********************************************************************/ -int main(int argc, char *argv[]){ +int UHD_SAFE_MAIN(int argc, char *argv[]){ std::string device_addr, length_tag; double center_freq, samp_rate, burst_dur, idle_dur; diff --git a/grc/base/Block.py b/grc/base/Block.py index cadff12c0a..b367e60e69 100644 --- a/grc/base/Block.py +++ b/grc/base/Block.py @@ -141,8 +141,9 @@ class Block(Element): and (self._key != "virtual_sink") \ and (self._key != "pad_source") \ and (self._key != "pad_sink")) + is_variable = self._key.startswith('variable') - if is_not_virtual_or_pad: + if is_not_virtual_or_pad and not is_variable: self.get_params().append(self.get_parent().get_parent().Param( block=self, n=odict({'name': 'Block Alias', @@ -413,7 +414,7 @@ class Block(Element): """ n = odict() n['key'] = self.get_key() - n['param'] = map(lambda p: p.export_data(), self.get_params()) + n['param'] = map(lambda p: p.export_data(), sorted(self.get_params(), key=str)) if 'bus' in map(lambda a: a.get_type(), self.get_sinks()): n['bus_sink'] = str(1); if 'bus' in map(lambda a: a.get_type(), self.get_sources()): diff --git a/grc/base/FlowGraph.py b/grc/base/FlowGraph.py index fb25b46821..790aed07f6 100644 --- a/grc/base/FlowGraph.py +++ b/grc/base/FlowGraph.py @@ -126,13 +126,13 @@ class FlowGraph(Element): def get_block(self, id): return filter(lambda b: b.get_id() == id, self.get_blocks())[0] def get_blocks_unordered(self): return filter(lambda e: e.is_block(), self.get_elements()) def get_blocks(self): - blocks = self.get_blocks_unordered(); - for i in range(len(blocks)): - if blocks[i].get_key() == 'variable': - blk = blocks[i]; - blocks.remove(blk); - blocks.insert(1, blk); - return blocks; + # refactored the slow, ugly version + # don't know why we need this here, using it for sorted export_data() + return sorted(self.get_blocks_unordered(), key=lambda b: ( + b.get_key() != 'options', # options to the front + not b.get_key().startswith('variable'), # then vars + str(b) + )) def get_connections(self): return filter(lambda e: e.is_connection(), self.get_elements()) def get_children(self): return self.get_elements() def get_elements(self): @@ -250,8 +250,8 @@ class FlowGraph(Element): """ n = odict() n['timestamp'] = self._timestamp - n['block'] = [block.export_data() for block in self.get_blocks()] - n['connection'] = [connection.export_data() for connection in self.get_connections()] + n['block'] = [b.export_data() for b in self.get_blocks()] # already sorted + n['connection'] = [c.export_data() for c in sorted(self.get_connections(), key=str)] instructions = odict({ 'created': self.get_parent().get_version_short(), 'format': FLOW_GRAPH_FILE_FORMAT_VERSION, |