diff options
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r-- | gnuradio-core/src/lib/filter/CMakeLists.txt | 3 | ||||
-rw-r--r-- | gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c | 2 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_message_burst_source.cc | 144 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_message_burst_source.h | 71 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/gr_message_burst_source.i | 38 | ||||
-rw-r--r-- | gnuradio-core/src/lib/io/io.i | 2 |
8 files changed, 261 insertions, 2 deletions
diff --git a/gnuradio-core/src/lib/filter/CMakeLists.txt b/gnuradio-core/src/lib/filter/CMakeLists.txt index facaff764..088d3376d 100644 --- a/gnuradio-core/src/lib/filter/CMakeLists.txt +++ b/gnuradio-core/src/lib/filter/CMakeLists.txt @@ -210,6 +210,9 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)") ${CMAKE_CURRENT_SOURCE_DIR}/qa_dotprod_powerpc.cc ) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm") + if(have_mfpu_neon) + add_definitions(-DHAVE_MFPU_NEON) + endif() list(APPEND gnuradio_core_sources ${CMAKE_CURRENT_SOURCE_DIR}/sysconfig_armv7_a.cc ${CMAKE_CURRENT_SOURCE_DIR}/gr_fir_sysconfig_armv7_a.cc diff --git a/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c b/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c index e7c6b266e..c125b49b3 100644 --- a/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c +++ b/gnuradio-core/src/lib/filter/dotprod_ccf_armv7_a.c @@ -37,7 +37,7 @@ gr_p2_round_down(size_t x, size_t pow2) } -#if 0 +#ifndef HAVE_MFPU_NEON void dotprod_ccf_armv7_a(const float *a, const float *b, float *res, size_t n) diff --git a/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c b/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c index 68c448b35..23bbef033 100644 --- a/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c +++ b/gnuradio-core/src/lib/filter/dotprod_fff_armv7_a.c @@ -37,7 +37,7 @@ gr_p2_round_down(size_t x, size_t pow2) } -#if 0 +#ifndef HAVE_MFPU_NEON float dotprod_fff_armv7_a(const float *a, const float *b, size_t n) diff --git a/gnuradio-core/src/lib/io/CMakeLists.txt b/gnuradio-core/src/lib/io/CMakeLists.txt index af9d7583c..3dea13396 100644 --- a/gnuradio-core/src/lib/io/CMakeLists.txt +++ b/gnuradio-core/src/lib/io/CMakeLists.txt @@ -87,6 +87,7 @@ set(gr_core_io_triple_threats gr_file_descriptor_source gr_message_sink gr_message_source + gr_message_burst_source microtune_xxxx_eval_board microtune_4702_eval_board microtune_4937_eval_board diff --git a/gnuradio-core/src/lib/io/gr_message_burst_source.cc b/gnuradio-core/src/lib/io/gr_message_burst_source.cc new file mode 100644 index 000000000..e9e2dfd4d --- /dev/null +++ b/gnuradio-core/src/lib/io/gr_message_burst_source.cc @@ -0,0 +1,144 @@ +/* -*- 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_message_burst_source.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 <gr_tags.h> + +// public constructor that returns a shared_ptr + +gr_message_burst_source_sptr +gr_make_message_burst_source(size_t itemsize, int msgq_limit) +{ + return gnuradio::get_initial_sptr(new gr_message_burst_source(itemsize, msgq_limit)); +} + +// public constructor that takes existing message queue +gr_message_burst_source_sptr +gr_make_message_burst_source(size_t itemsize, gr_msg_queue_sptr msgq) +{ + return gnuradio::get_initial_sptr(new gr_message_burst_source(itemsize, msgq)); +} + +gr_message_burst_source::gr_message_burst_source (size_t itemsize, int msgq_limit) + : gr_sync_block("message_burst_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_msgq(gr_make_msg_queue(msgq_limit)), d_msg_offset(0), d_eof(false) +{ + std::stringstream id; + id << name() << unique_id(); + d_me = pmt::pmt_string_to_symbol(id.str()); +} + +gr_message_burst_source::gr_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq) + : gr_sync_block("message_burst_source", + gr_make_io_signature(0, 0, 0), + gr_make_io_signature(1, 1, itemsize)), + d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false) +{ + std::stringstream id; + id << name() << unique_id(); + d_me = pmt::pmt_string_to_symbol(id.str()); +} + +gr_message_burst_source::~gr_message_burst_source() +{ +} + +int +gr_message_burst_source::work(int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) +{ + char *out = (char *) output_items[0]; + int nn = 0; + + uint64_t abs_sample_count = nitems_written(0); + + while (nn < noutput_items){ + if (d_msg){ + // + // Consume whatever we can from the current message + // + + int mm = std::min(noutput_items - nn, (int)((d_msg->length() - d_msg_offset) / d_itemsize)); + memcpy (out, &(d_msg->msg()[d_msg_offset]), mm * d_itemsize); + + nn += mm; + out += mm * d_itemsize; + d_msg_offset += mm * d_itemsize; + assert(d_msg_offset <= d_msg->length()); + + if (d_msg_offset == d_msg->length()){ + if (d_msg->type() == 1) // type == 1 sets EOF + d_eof = true; + d_msg.reset(); + //tag end of burst + add_item_tag(0, //stream ID + abs_sample_count+nn-1, //sample number + pmt::pmt_string_to_symbol("tx_eob"), + pmt::pmt_from_bool(1), + d_me //block src id + ); + } + } + else { + // + // No current message + // + if (d_msgq->empty_p() && nn > 0){ // no more messages in the queue, return what we've got + break; + } + + if (d_eof) + return -1; + + d_msg = d_msgq->delete_head(); // block, waiting for a message + d_msg_offset = 0; + //tag start of burst + add_item_tag(0, //stream ID + abs_sample_count+nn, //sample number + pmt::pmt_string_to_symbol("tx_sob"), + pmt::pmt_from_bool(1), + d_me //block src id + ); + + + if ((d_msg->length() % d_itemsize) != 0) + throw std::runtime_error("msg length is not a multiple of d_itemsize"); + } + } + + return nn; +} diff --git a/gnuradio-core/src/lib/io/gr_message_burst_source.h b/gnuradio-core/src/lib/io/gr_message_burst_source.h new file mode 100644 index 000000000..63e220113 --- /dev/null +++ b/gnuradio-core/src/lib/io/gr_message_burst_source.h @@ -0,0 +1,71 @@ +/* -*- 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_MESSAGE_BURST_SOURCE_H +#define INCLUDED_GR_MESSAGE_BURST_SOURCE_H + +#include <gr_core_api.h> +#include <gr_sync_block.h> +#include <gr_message.h> +#include <gr_msg_queue.h> + +class gr_message_burst_source; +typedef boost::shared_ptr<gr_message_burst_source> gr_message_burst_source_sptr; + +GR_CORE_API gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, int msgq_limit=0); +GR_CORE_API gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq); + +/*! + * \brief Turn received messages into a stream and tag them for UHD to send. + * \ingroup source_blk + */ +class GR_CORE_API gr_message_burst_source : public gr_sync_block +{ + private: + size_t d_itemsize; + gr_msg_queue_sptr d_msgq; + gr_message_sptr d_msg; + unsigned d_msg_offset; + bool d_eof; + + pmt::pmt_t d_me; + + friend GR_CORE_API gr_message_burst_source_sptr + gr_make_message_burst_source(size_t itemsize, int msgq_limit); + friend GR_CORE_API gr_message_burst_source_sptr + gr_make_message_burst_source(size_t itemsize, gr_msg_queue_sptr msgq); + + protected: + gr_message_burst_source (size_t itemsize, int msgq_limit); + gr_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq); + + public: + ~gr_message_burst_source (); + + gr_msg_queue_sptr msgq() const { return d_msgq; } + + int work (int noutput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); +}; + +#endif /* INCLUDED_gr_message_burst_source_H */ diff --git a/gnuradio-core/src/lib/io/gr_message_burst_source.i b/gnuradio-core/src/lib/io/gr_message_burst_source.i new file mode 100644 index 000000000..f7ad840c2 --- /dev/null +++ b/gnuradio-core/src/lib/io/gr_message_burst_source.i @@ -0,0 +1,38 @@ +/* -*- 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. + */ + +GR_SWIG_BLOCK_MAGIC(gr,message_burst_source); + +gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, int msgq_limit=0); +gr_message_burst_source_sptr gr_make_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq); + +class gr_message_burst_source : public gr_sync_block +{ + protected: + gr_message_burst_source (size_t itemsize, int msgq_limit); + gr_message_burst_source (size_t itemsize, gr_msg_queue_sptr msgq); + + public: + ~gr_message_burst_source (); + + gr_msg_queue_sptr msgq() const; +}; diff --git a/gnuradio-core/src/lib/io/io.i b/gnuradio-core/src/lib/io/io.i index eab1346f1..5cd352905 100644 --- a/gnuradio-core/src/lib/io/io.i +++ b/gnuradio-core/src/lib/io/io.i @@ -38,6 +38,7 @@ #include <gr_oscope_sink_f.h> #include <ppio.h> #include <gr_message_source.h> +#include <gr_message_burst_source.h> #include <gr_message_sink.h> #include <gr_udp_sink.h> #include <gr_udp_source.h> @@ -59,6 +60,7 @@ %include "gr_oscope_sink.i" %include "ppio.i" %include "gr_message_source.i" +%include "gr_message_burst_source.i" %include "gr_message_sink.i" %include "gr_udp_sink.i" %include "gr_udp_source.i" |