diff options
Diffstat (limited to 'gnuradio-core/src/lib')
-rw-r--r-- | gnuradio-core/src/lib/CMakeLists.txt | 18 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_random_pdu.cc | 83 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_random_pdu.h | 64 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_random_pdu.i | 30 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_tag_debug.cc | 4 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_pdu.cc | 24 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_pdu.h | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_pdu.i | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_socket_pdu.h | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_stream_pdu_base.cc | 6 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_basic_block.h | 8 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_complex.h | 14 | ||||
-rw-r--r-- | gnuradio-core/src/lib/swig/CMakeLists.txt | 8 |
13 files changed, 227 insertions, 38 deletions
diff --git a/gnuradio-core/src/lib/CMakeLists.txt b/gnuradio-core/src/lib/CMakeLists.txt index 9c980157d..89a1bad88 100644 --- a/gnuradio-core/src/lib/CMakeLists.txt +++ b/gnuradio-core/src/lib/CMakeLists.txt @@ -41,14 +41,18 @@ list(APPEND test_gnuradio_core_sources bug_work_around_6.cc) ######################################################################## # Setup the include and linker paths ######################################################################## -include_directories(${GNURADIO_CORE_INCLUDE_DIRS}) -include_directories(${VOLK_INCLUDE_DIRS}) - -include_directories(${Boost_INCLUDE_DIRS}) -link_directories(${Boost_LIBRARY_DIRS}) +include_directories( + ${GNURADIO_CORE_INCLUDE_DIRS} + ${VOLK_INCLUDE_DIRS} + ${GRUEL_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} + ${FFTW3F_INCLUDE_DIRS} +) -include_directories(${FFTW3F_INCLUDE_DIRS}) -link_directories(${FFTW3F_LIBRARY_DIRS}) +link_directories( + ${Boost_LIBRARY_DIRS} + ${FFTW3F_LIBRARY_DIRS} +) ######################################################################## # Setup library diff --git a/gnuradio-core/src/lib/general/gr_random_pdu.cc b/gnuradio-core/src/lib/general/gr_random_pdu.cc new file mode 100644 index 000000000..9f692c72b --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_random_pdu.cc @@ -0,0 +1,83 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include <gr_random_pdu.h> +#include <gr_io_signature.h> +#include <cstdio> +#include <errno.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <stdexcept> +#include <string.h> +#include <iostream> + +// public constructor that returns a shared_ptr + +gr_random_pdu_sptr +gr_make_random_pdu (int items_min, int items_max) +{ + return gnuradio::get_initial_sptr(new gr_random_pdu(items_min, items_max)); +} + +gr_random_pdu::gr_random_pdu (int items_min, int items_max) + : gr_block("random_pdu", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(0, 0, 0)), + urange(items_min, items_max), + brange(0, 255), + rvar(rng, urange), + bvar(rng, brange) +{ + message_port_register_out(pmt::mp("pdus")); + message_port_register_in(pmt::mp("generate")); + set_msg_handler(pmt::mp("generate"), boost::bind(&gr_random_pdu::generate_pdu, this, _1)); +} + +bool gr_random_pdu::start(){ + output_random(); + return true; +} + +void gr_random_pdu::output_random(){ + + // pick a random vector length + int len = rvar(); + + // fill it with random bytes + unsigned char vec[len]; + for(int i=0; i<len; i++){ + vec[i] = (unsigned char) bvar(); + } + + // send the vector + pmt::pmt_t vecpmt( pmt::pmt_make_blob( vec, len ) ); + pmt::pmt_t pdu( pmt::pmt_cons( pmt::PMT_NIL, vecpmt ) ); + message_port_pub( pmt::mp("pdus"), pdu ); + + std::cout << "sending new random vector of length " << len << "\n"; +} + diff --git a/gnuradio-core/src/lib/general/gr_random_pdu.h b/gnuradio-core/src/lib/general/gr_random_pdu.h new file mode 100644 index 000000000..e6457d21b --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_random_pdu.h @@ -0,0 +1,64 @@ +/* -*- c++ -*- */ +/* + * Copyright 2012 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +#ifndef INCLUDED_GR_RANDOM_PDU_H +#define INCLUDED_GR_RANDOM_PDU_H + +#include <gr_core_api.h> +#include <gr_block.h> +#include <gr_message.h> +#include <gr_msg_queue.h> + +#include <boost/random.hpp> +#include <boost/generator_iterator.hpp> + +class gr_random_pdu; +typedef boost::shared_ptr<gr_random_pdu> gr_random_pdu_sptr; + +GR_CORE_API gr_random_pdu_sptr gr_make_random_pdu (int mintime, int maxtime); + +/*! + * \brief Send message at defined interval + * \ingroup msg_blk + */ +class GR_CORE_API gr_random_pdu : public gr_block +{ + private: + friend GR_CORE_API gr_random_pdu_sptr + gr_make_random_pdu(int mintime, int maxtime); + + void output_random(); + + boost::mt19937 rng; + boost::uniform_int<> urange; + boost::uniform_int<> brange; + boost::variate_generator< boost::mt19937, boost::uniform_int<> > rvar; // pdu length + boost::variate_generator< boost::mt19937, boost::uniform_int<> > bvar; // pdu contents + + public: + gr_random_pdu (int, int); + bool start(); + void generate_pdu(pmt::pmt_t msg){ output_random(); } + void generate_pdu(){ output_random(); } +}; + +#endif /* INCLUDED_GR_RANDOM_PDU_H */ diff --git a/gnuradio-core/src/lib/general/gr_random_pdu.i b/gnuradio-core/src/lib/general/gr_random_pdu.i new file mode 100644 index 000000000..045a33060 --- /dev/null +++ b/gnuradio-core/src/lib/general/gr_random_pdu.i @@ -0,0 +1,30 @@ +/* -*- c++ -*- */ +/* + * Copyright 2005 Free Software Foundation, Inc. + * + * This file is part of GNU Radio + * + * GNU Radio is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GNU Radio is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Radio; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, + * Boston, MA 02110-1301, USA. + */ + +GR_SWIG_BLOCK_MAGIC(gr,random_pdu); + +%{ +#include <gr_random_pdu.h> +%} + +%include "gr_random_pdu.h" + diff --git a/gnuradio-core/src/lib/general/gr_tag_debug.cc b/gnuradio-core/src/lib/general/gr_tag_debug.cc index 5833a1891..ecf1b65e1 100644 --- a/gnuradio-core/src/lib/general/gr_tag_debug.cc +++ b/gnuradio-core/src/lib/general/gr_tag_debug.cc @@ -81,10 +81,10 @@ gr_tag_debug::work(int noutput_items, get_tags_in_range(d_tags, i, abs_N, end_N); if(d_display) { - sout << "Input Stream: " << i << std::endl; + sout << "Input Stream: " << std::setw(2) << std::setfill('0') << i << std::setfill(' ') << std::endl; for(d_tags_itr = d_tags.begin(); d_tags_itr != d_tags.end(); d_tags_itr++) { sout << std::setw(10) << "Offset: " << d_tags_itr->offset - << std::setw(10) << "Source: " << pmt::pmt_symbol_to_string(d_tags_itr->srcid) + << std::setw(10) << "Source: " << (pmt::pmt_is_symbol(d_tags_itr->srcid) ? pmt::pmt_symbol_to_string(d_tags_itr->srcid) : "n/a") << std::setw(10) << "Key: " << pmt::pmt_symbol_to_string(d_tags_itr->key) << std::setw(10) << "Value: "; sout << d_tags_itr->value << std::endl; diff --git a/gnuradio-core/src/lib/io/gr_pdu.cc b/gnuradio-core/src/lib/io/gr_pdu.cc index b2757c307..302fd7b9b 100644 --- a/gnuradio-core/src/lib/io/gr_pdu.cc +++ b/gnuradio-core/src/lib/io/gr_pdu.cc @@ -29,11 +29,11 @@ size_t gr_pdu_itemsize(gr_pdu_vector_type type){ switch(type){ - case BYTE: + case pdu_byte: return 1; - case FLOAT: + case pdu_float: return sizeof(float); - case COMPLEX: + case pdu_complex: return sizeof(gr_complex); default: throw std::runtime_error("bad type!"); @@ -43,11 +43,11 @@ gr_pdu_itemsize(gr_pdu_vector_type type){ bool gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v){ switch(type){ - case BYTE: + case pdu_byte: return pmt::pmt_is_u8vector(v); - case FLOAT: + case pdu_float: return pmt::pmt_is_f32vector(v); - case COMPLEX: + case pdu_complex: return pmt::pmt_is_c32vector(v); default: throw std::runtime_error("bad type!"); @@ -57,11 +57,11 @@ gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v){ pmt::pmt_t gr_pdu_make_vector(gr_pdu_vector_type type, const uint8_t* buf, size_t items){ switch(type){ - case BYTE: + case pdu_byte: return pmt::pmt_init_u8vector(items, buf); - case FLOAT: + case pdu_float: return pmt::pmt_init_f32vector(items, (const float*)buf); - case COMPLEX: + case pdu_complex: return pmt::pmt_init_c32vector(items, (const gr_complex*)buf); default: throw std::runtime_error("bad type!"); @@ -70,10 +70,10 @@ gr_pdu_make_vector(gr_pdu_vector_type type, const uint8_t* buf, size_t items){ gr_pdu_vector_type type_from_pmt(pmt::pmt_t vector){ if(pmt_is_u8vector(vector)) - return BYTE; + return pdu_byte; if(pmt_is_f32vector(vector)) - return FLOAT; + return pdu_float; if(pmt_is_c32vector(vector)) - return COMPLEX; + return pdu_complex; throw std::runtime_error("bad type!"); } diff --git a/gnuradio-core/src/lib/io/gr_pdu.h b/gnuradio-core/src/lib/io/gr_pdu.h index 5ed9cdded..a5ae87db7 100644 --- a/gnuradio-core/src/lib/io/gr_pdu.h +++ b/gnuradio-core/src/lib/io/gr_pdu.h @@ -29,7 +29,7 @@ #define pdu_port_id pmt::mp("pdus") #define pdu_length_tag pmt::mp("pdu_length") -enum gr_pdu_vector_type { BYTE, FLOAT, COMPLEX }; +enum gr_pdu_vector_type { pdu_byte, pdu_float, pdu_complex }; size_t gr_pdu_itemsize(gr_pdu_vector_type type); bool gr_pdu_type_matches(gr_pdu_vector_type type, pmt::pmt_t v); diff --git a/gnuradio-core/src/lib/io/gr_pdu.i b/gnuradio-core/src/lib/io/gr_pdu.i index 7cb3c62c7..ada3a63a7 100644 --- a/gnuradio-core/src/lib/io/gr_pdu.i +++ b/gnuradio-core/src/lib/io/gr_pdu.i @@ -24,7 +24,7 @@ #include <gr_pdu.h>
%}
-enum gr_pdu_vector_type { BYTE, FLOAT, COMPLEX };
+enum gr_pdu_vector_type { pdu_byte, pdu_float, pdu_complex };
diff --git a/gnuradio-core/src/lib/io/gr_socket_pdu.h b/gnuradio-core/src/lib/io/gr_socket_pdu.h index f554febdc..2fedb317d 100644 --- a/gnuradio-core/src/lib/io/gr_socket_pdu.h +++ b/gnuradio-core/src/lib/io/gr_socket_pdu.h @@ -28,7 +28,9 @@ #include <gr_message.h> #include <gr_msg_queue.h> #include <gr_stream_pdu_base.h> +#include <boost/array.hpp> #include <boost/asio.hpp> +#include <iostream> class gr_socket_pdu; typedef boost::shared_ptr<gr_socket_pdu> gr_socket_pdu_sptr; diff --git a/gnuradio-core/src/lib/io/gr_stream_pdu_base.cc b/gnuradio-core/src/lib/io/gr_stream_pdu_base.cc index cff7296cb..7250c33e5 100644 --- a/gnuradio-core/src/lib/io/gr_stream_pdu_base.cc +++ b/gnuradio-core/src/lib/io/gr_stream_pdu_base.cc @@ -24,6 +24,7 @@ #include "config.h" #endif +#include <ciso646> #include <gr_stream_pdu_base.h> #include <gr_io_signature.h> #include <cstdio> @@ -35,8 +36,13 @@ #include <string.h> #include <iostream> #include <gr_pdu.h> +#include <boost/asio.hpp> #include <boost/format.hpp> +#ifdef HAVE_IO_H +#include <io.h> +#endif + static const long timeout_us = 100*1000; //100ms gr_stream_pdu_base::gr_stream_pdu_base (int MTU) diff --git a/gnuradio-core/src/lib/runtime/gr_basic_block.h b/gnuradio-core/src/lib/runtime/gr_basic_block.h index f3b7b835b..9cc2ad775 100644 --- a/gnuradio-core/src/lib/runtime/gr_basic_block.h +++ b/gnuradio-core/src/lib/runtime/gr_basic_block.h @@ -142,9 +142,9 @@ class GR_CORE_API gr_basic_block : public gr_msg_accepter, public boost::enable_ 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); - virtual bool message_port_is_hier(pmt::pmt_t port_id) { std::cout << "is_hier\n"; return false; } - virtual bool message_port_is_hier_in(pmt::pmt_t port_id) { std::cout << "is_hier_in\n"; return false; } - virtual bool message_port_is_hier_out(pmt::pmt_t port_id) { std::cout << "is_hier_out\n"; return false; } + virtual bool message_port_is_hier(pmt::pmt_t port_id) { (void) port_id; std::cout << "is_hier\n"; return false; } + virtual bool message_port_is_hier_in(pmt::pmt_t port_id) { (void) port_id; std::cout << "is_hier_in\n"; return false; } + virtual bool message_port_is_hier_out(pmt::pmt_t port_id) { (void) port_id; std::cout << "is_hier_out\n"; return false; } /*! * \brief Get input message port names. @@ -224,7 +224,7 @@ class GR_CORE_API gr_basic_block : public gr_msg_accepter, public boost::enable_ * This check is in addition to the constraints specified by the input * and output gr_io_signatures. */ - virtual bool check_topology(int ninputs, int noutputs) { return true; } + virtual bool check_topology(int ninputs, int noutputs) { (void) ninputs; (void) noutputs; return true; } /*! * \brief Set the callback that is fired when messages are available. diff --git a/gnuradio-core/src/lib/runtime/gr_complex.h b/gnuradio-core/src/lib/runtime/gr_complex.h index 758002106..58d1525b4 100644 --- a/gnuradio-core/src/lib/runtime/gr_complex.h +++ b/gnuradio-core/src/lib/runtime/gr_complex.h @@ -27,13 +27,13 @@ typedef std::complex<float> gr_complex; typedef std::complex<double> gr_complexd; -inline bool is_complex (gr_complex x) { return true;} -inline bool is_complex (gr_complexd x) { return true;} -inline bool is_complex (float x) { return false;} -inline bool is_complex (double x) { return false;} -inline bool is_complex (int x) { return false;} -inline bool is_complex (char x) { return false;} -inline bool is_complex (short x) { return false;} +inline bool is_complex (gr_complex x) { (void) x; return true;} +inline bool is_complex (gr_complexd x) { (void) x; return true;} +inline bool is_complex (float x) { (void) x; return false;} +inline bool is_complex (double x) { (void) x; return false;} +inline bool is_complex (int x) { (void) x; return false;} +inline bool is_complex (char x) { (void) x; return false;} +inline bool is_complex (short x) { (void) x; return false;} // this doesn't really belong here, but there are worse places for it... diff --git a/gnuradio-core/src/lib/swig/CMakeLists.txt b/gnuradio-core/src/lib/swig/CMakeLists.txt index 734547131..d8a64cc0f 100644 --- a/gnuradio-core/src/lib/swig/CMakeLists.txt +++ b/gnuradio-core/src/lib/swig/CMakeLists.txt @@ -21,16 +21,16 @@ include(GrPython) include(GrSwig) -include_directories(${Boost_INCLUDE_DIRS}) -link_directories(${Boost_LIBRARY_DIRS}) - set(GR_SWIG_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR} - ${GRUEL_INCLUDE_DIRS} ${GNURADIO_CORE_SWIG_INCLUDE_DIRS} + ${GRUEL_INCLUDE_DIRS} + ${Boost_INCLUDE_DIRS} ) set(GR_SWIG_LIBRARIES gnuradio-core) +link_directories(${Boost_LIBRARY_DIRS}) + ######################################################################## # Build and install the swig targets ######################################################################## |