diff options
Diffstat (limited to 'gr-blocks/lib')
-rw-r--r-- | gr-blocks/lib/CMakeLists.txt | 2 | ||||
-rw-r--r-- | gr-blocks/lib/message_sink_impl.cc | 132 | ||||
-rw-r--r-- | gr-blocks/lib/message_sink_impl.h | 56 | ||||
-rw-r--r-- | gr-blocks/lib/message_source_impl.cc | 151 | ||||
-rw-r--r-- | gr-blocks/lib/message_source_impl.h | 62 |
5 files changed, 0 insertions, 403 deletions
diff --git a/gr-blocks/lib/CMakeLists.txt b/gr-blocks/lib/CMakeLists.txt index da6bc9bf89..96fe7c0258 100644 --- a/gr-blocks/lib/CMakeLists.txt +++ b/gr-blocks/lib/CMakeLists.txt @@ -140,8 +140,6 @@ list(APPEND gr_blocks_sources keep_one_in_n_impl.cc lfsr_32k_source_s_impl.cc message_debug_impl.cc - message_sink_impl.cc - message_source_impl.cc message_strobe_impl.cc message_strobe_random_impl.cc message_burst_source_impl.cc diff --git a/gr-blocks/lib/message_sink_impl.cc b/gr-blocks/lib/message_sink_impl.cc deleted file mode 100644 index 3dc4102c48..0000000000 --- a/gr-blocks/lib/message_sink_impl.cc +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010,2013 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 "message_sink_impl.h" -#include <gnuradio/io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <string.h> - -namespace gr { - namespace blocks { - - message_sink::sptr - message_sink::make(size_t itemsize, msg_queue::sptr msgq, bool dont_block) - { - return gnuradio::get_initial_sptr - (new message_sink_impl(itemsize, msgq, dont_block)); - } - - message_sink::sptr - message_sink::make(size_t itemsize, msg_queue::sptr msgq, bool dont_block, - const std::string& lengthtagname) - { - return gnuradio::get_initial_sptr - (new message_sink_impl(itemsize, msgq, dont_block, lengthtagname)); - } - - message_sink_impl::message_sink_impl(size_t itemsize, msg_queue::sptr msgq, bool dont_block) - : sync_block("message_sink", - io_signature::make(1, 1, itemsize), - io_signature::make(0, 0, 0)), - d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block), - d_tags(false), d_items_read(0) - { - } - - message_sink_impl::message_sink_impl(size_t itemsize, msg_queue::sptr msgq, bool dont_block, - const std::string& lengthtagname) - : sync_block("message_sink", - io_signature::make(1, 1, itemsize), - io_signature::make(0, 0, 0)), - d_itemsize(itemsize), d_msgq(msgq), d_dont_block(dont_block), - d_tags(true), d_lengthtagname(lengthtagname), d_items_read(0) - { - } - - message_sink_impl::~message_sink_impl() - { - } - - int - message_sink_impl::work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) - { - const char *in = (const char *) input_items[0]; - - if (d_tags) { - long packet_length = 0; - std::vector<tag_t> tags; - this->get_tags_in_range(tags, 0, d_items_read, d_items_read+1); - //const size_t ninput_items = noutput_items; //assumption for sync block, this can change - for (unsigned int i = 0; i < tags.size(); i++) { - if (pmt::symbol_to_string(tags[i].key) == d_lengthtagname) { - packet_length = pmt::to_long(tags[i].value); - } - } - assert(packet_length != 0); - - // FIXME run this multiple times if input_items >= N * packet_length - if (noutput_items >= packet_length ) { - // If the message queue is full we drop the packet. - if (!d_msgq->full_p()) { - message::sptr msg = message::make(0, // msg type - d_itemsize, // arg1 for other end - packet_length, // arg2 for other end (redundant) - packet_length * d_itemsize); // len of msg - memcpy(msg->msg(), in, packet_length * d_itemsize); - d_msgq->handle(msg); // send it - } - d_items_read += packet_length; - return packet_length; - } else { - return 0; - } - } else { - // If the queue if full we drop all the data we got. - if (!d_msgq->full_p()) { - // build a message to hold whatever we've got - message::sptr msg = message::make(0, // msg type - d_itemsize, // arg1 for other end - noutput_items, // arg2 for other end (redundant) - noutput_items * d_itemsize); // len of msg - memcpy(msg->msg(), in, noutput_items * d_itemsize); - - d_msgq->handle(msg); // send it - } - - return noutput_items; - } - } - - } /* namespace blocks */ -} /* namespace gr */ - diff --git a/gr-blocks/lib/message_sink_impl.h b/gr-blocks/lib/message_sink_impl.h deleted file mode 100644 index e0ae3d00c0..0000000000 --- a/gr-blocks/lib/message_sink_impl.h +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2013 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_SINK_IMPL_H -#define INCLUDED_GR_MESSAGE_SINK_IMPL_H - -#include <gnuradio/blocks/message_sink.h> - -namespace gr { - namespace blocks { - - class message_sink_impl : public message_sink - { - private: - size_t d_itemsize; - msg_queue::sptr d_msgq; - bool d_dont_block; - bool d_tags; - std::string d_lengthtagname; - uint64_t d_items_read; - - public: - message_sink_impl(size_t itemsize, msg_queue::sptr msgq, bool dont_block); - message_sink_impl(size_t itemsize, msg_queue::sptr msgq, bool dont_block, - const std::string& lengthtagname); - - ~message_sink_impl(); - - int work(int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); - }; - - } /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_GR_MESSAGE_SINK_IMPL_H */ diff --git a/gr-blocks/lib/message_source_impl.cc b/gr-blocks/lib/message_source_impl.cc deleted file mode 100644 index b4e9ba6ed7..0000000000 --- a/gr-blocks/lib/message_source_impl.cc +++ /dev/null @@ -1,151 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2010,2013 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 "message_source_impl.h" -#include <gnuradio/io_signature.h> -#include <cstdio> -#include <errno.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <stdexcept> -#include <string.h> - -namespace gr { - namespace blocks { - - message_source::sptr - message_source::make(size_t itemsize, int msgq_limit) - { - return gnuradio::get_initial_sptr - (new message_source_impl(itemsize, msgq_limit)); - } - - message_source::sptr - message_source::make(size_t itemsize, msg_queue::sptr msgq) - { - return gnuradio::get_initial_sptr - (new message_source_impl(itemsize, msgq)); - } - - message_source::sptr - message_source::make(size_t itemsize, msg_queue::sptr msgq, - const std::string& lengthtagname) - { - return gnuradio::get_initial_sptr - (new message_source_impl(itemsize, msgq, lengthtagname)); - } - - message_source_impl::message_source_impl(size_t itemsize, int msgq_limit) - : sync_block("message_source", - io_signature::make(0, 0, 0), - io_signature::make(1, 1, itemsize)), - d_itemsize(itemsize), d_msgq(msg_queue::make(msgq_limit)), - d_msg_offset(0), d_eof(false), d_tags(false) - { - } - - message_source_impl::message_source_impl(size_t itemsize, msg_queue::sptr msgq) - : sync_block("message_source", - io_signature::make(0, 0, 0), - io_signature::make(1, 1, itemsize)), - d_itemsize(itemsize), d_msgq(msgq), - d_msg_offset(0), d_eof(false), d_tags(false) - { - } - - message_source_impl::message_source_impl(size_t itemsize, msg_queue::sptr msgq, - const std::string& lengthtagname) - : sync_block("message_source", - io_signature::make(0, 0, 0), - io_signature::make(1, 1, itemsize)), - d_itemsize(itemsize), d_msgq(msgq), d_msg_offset(0), d_eof(false), - d_tags(true), d_lengthtagname(lengthtagname) - { - } - - message_source_impl::~message_source_impl() - { - } - - int - message_source_impl::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; - - 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); - - if (d_tags && (d_msg_offset == 0)) { - const uint64_t offset = this->nitems_written(0) + nn; - pmt::pmt_t key = pmt::string_to_symbol(d_lengthtagname); - pmt::pmt_t value = pmt::from_long(d_msg->length()); - this->add_item_tag(0, offset, key, value); - } - 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(); - } - } - 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; - - if ((d_msg->length() % d_itemsize) != 0) - throw std::runtime_error("msg length is not a multiple of d_itemsize"); - } - - } - - return nn; - } - - } /* namespace blocks */ -} /* namespace gr */ diff --git a/gr-blocks/lib/message_source_impl.h b/gr-blocks/lib/message_source_impl.h deleted file mode 100644 index bbc8f728d5..0000000000 --- a/gr-blocks/lib/message_source_impl.h +++ /dev/null @@ -1,62 +0,0 @@ -/* -*- c++ -*- */ -/* - * Copyright 2005,2013 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_SOURCE_IMPL_H -#define INCLUDED_GR_MESSAGE_SOURCE_IMPL_H - -#include <gnuradio/blocks/message_source.h> -#include <gnuradio/message.h> - -namespace gr { - namespace blocks { - - class message_source_impl : public message_source - { - private: - size_t d_itemsize; - msg_queue::sptr d_msgq; - message::sptr d_msg; - unsigned d_msg_offset; - bool d_eof; - bool d_tags; - // FIXME: Is this adequate tagname length. - std::string d_lengthtagname; - - public: - message_source_impl(size_t itemsize, int msgq_limit); - message_source_impl(size_t itemsize, msg_queue::sptr msgq); - message_source_impl(size_t itemsize, msg_queue::sptr msgq, - const std::string& lengthtagname); - - ~message_source_impl(); - - 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); - }; - - } /* namespace blocks */ -} /* namespace gr */ - -#endif /* INCLUDED_GR_MESSAGE_SOURCE_IMPL_H */ |