summaryrefslogtreecommitdiff
path: root/gnuradio-core/src/lib/general
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-core/src/lib/general')
-rw-r--r--gnuradio-core/src/lib/general/CMakeLists.txt2
-rw-r--r--gnuradio-core/src/lib/general/general.i5
-rw-r--r--gnuradio-core/src/lib/general/gr_block_gateway.cc184
-rw-r--r--gnuradio-core/src/lib/general/gr_block_gateway.h212
-rw-r--r--gnuradio-core/src/lib/general/gr_block_gateway.i46
-rw-r--r--gnuradio-core/src/lib/general/gr_message_strobe.cc75
-rw-r--r--gnuradio-core/src/lib/general/gr_message_strobe.h62
-rw-r--r--gnuradio-core/src/lib/general/gr_message_strobe.i30
-rw-r--r--gnuradio-core/src/lib/general/gr_nop.cc3
-rw-r--r--gnuradio-core/src/lib/general/gr_skiphead.cc4
-rw-r--r--gnuradio-core/src/lib/general/gri_control_loop.cc23
-rw-r--r--gnuradio-core/src/lib/general/gri_control_loop.h39
12 files changed, 675 insertions, 10 deletions
diff --git a/gnuradio-core/src/lib/general/CMakeLists.txt b/gnuradio-core/src/lib/general/CMakeLists.txt
index 3cf7f74e4..4c99acfc3 100644
--- a/gnuradio-core/src/lib/general/CMakeLists.txt
+++ b/gnuradio-core/src/lib/general/CMakeLists.txt
@@ -187,6 +187,7 @@ set(gr_core_general_triple_threats
gr_agc2_ff
gr_align_on_samplenumbers_ss
gr_bin_statistics_f
+ gr_block_gateway
gr_bytes_to_syms
gr_char_to_float
gr_char_to_short
@@ -298,6 +299,7 @@ set(gr_core_general_triple_threats
gr_burst_tagger
gr_correlate_access_code_tag_bb
gr_tag_debug
+ gr_message_strobe
)
foreach(file_tt ${gr_core_general_triple_threats})
diff --git a/gnuradio-core/src/lib/general/general.i b/gnuradio-core/src/lib/general/general.i
index 790549c4d..1446088a2 100644
--- a/gnuradio-core/src/lib/general/general.i
+++ b/gnuradio-core/src/lib/general/general.i
@@ -1,6 +1,6 @@
/* -*- c++ -*- */
/*
- * Copyright 2004,2005,2006,2007,2008,2009,2010 Free Software Foundation, Inc.
+ * Copyright 2004-2012 Free Software Foundation, Inc.
*
* This file is part of GNU Radio
*
@@ -143,6 +143,7 @@
#include <gr_add_ff.h>
#include <gr_vector_map.h>
#include <gr_tag_debug.h>
+#include <gr_message_strobe.h>
%}
%include "gri_control_loop.i"
@@ -266,3 +267,5 @@
%include "gr_add_ff.i"
%include "gr_vector_map.i"
%include "gr_tag_debug.i"
+%include "gr_block_gateway.i"
+%include "gr_message_strobe.i"
diff --git a/gnuradio-core/src/lib/general/gr_block_gateway.cc b/gnuradio-core/src/lib/general/gr_block_gateway.cc
new file mode 100644
index 000000000..79b42803a
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_block_gateway.cc
@@ -0,0 +1,184 @@
+/*
+ * Copyright 2011-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.
+ */
+
+#include <gr_block_gateway.h>
+#include <gr_io_signature.h>
+#include <iostream>
+#include <boost/bind.hpp>
+
+/***********************************************************************
+ * Helper routines
+ **********************************************************************/
+template <typename OutType, typename InType>
+void copy_pointers(OutType &out, const InType &in){
+ out.resize(in.size());
+ for (size_t i = 0; i < in.size(); i++){
+ out[i] = (void *)(in[i]);
+ }
+}
+
+/***********************************************************************
+ * The gr_block gateway implementation class
+ **********************************************************************/
+class gr_block_gateway_impl : public gr_block_gateway{
+public:
+ gr_block_gateway_impl(
+ gr_feval_ll *handler,
+ const std::string &name,
+ gr_io_signature_sptr in_sig,
+ gr_io_signature_sptr out_sig,
+ const gr_block_gw_work_type work_type,
+ const unsigned factor
+ ):
+ gr_block(name, in_sig, out_sig),
+ _handler(handler),
+ _work_type(work_type)
+ {
+ switch(_work_type){
+ case GR_BLOCK_GW_WORK_GENERAL:
+ _decim = 1; //not relevant, but set anyway
+ _interp = 1; //not relevant, but set anyway
+ break;
+
+ case GR_BLOCK_GW_WORK_SYNC:
+ _decim = 1;
+ _interp = 1;
+ this->set_fixed_rate(true);
+ break;
+
+ case GR_BLOCK_GW_WORK_DECIM:
+ _decim = factor;
+ _interp = 1;
+ break;
+
+ case GR_BLOCK_GW_WORK_INTERP:
+ _decim = 1;
+ _interp = factor;
+ this->set_output_multiple(_interp);
+ break;
+ }
+ }
+
+ /*******************************************************************
+ * Overloads for various scheduler-called functions
+ ******************************************************************/
+ void forecast(
+ int noutput_items,
+ gr_vector_int &ninput_items_required
+ ){
+ switch(_work_type){
+ case GR_BLOCK_GW_WORK_GENERAL:
+ _message.action = gr_block_gw_message_type::ACTION_FORECAST;
+ _message.forecast_args_noutput_items = noutput_items;
+ _message.forecast_args_ninput_items_required = ninput_items_required;
+ _handler->calleval(0);
+ ninput_items_required = _message.forecast_args_ninput_items_required;
+ return;
+
+ default:
+ unsigned ninputs = ninput_items_required.size();
+ for (unsigned i = 0; i < ninputs; i++)
+ ninput_items_required[i] = fixed_rate_noutput_to_ninput(noutput_items);
+ return;
+ }
+ }
+
+ int general_work(
+ int noutput_items,
+ gr_vector_int &ninput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items
+ ){
+ switch(_work_type){
+ case GR_BLOCK_GW_WORK_GENERAL:
+ _message.action = gr_block_gw_message_type::ACTION_GENERAL_WORK;
+ _message.general_work_args_noutput_items = noutput_items;
+ _message.general_work_args_ninput_items = ninput_items;
+ copy_pointers(_message.general_work_args_input_items, input_items);
+ _message.general_work_args_output_items = output_items;
+ _handler->calleval(0);
+ return _message.general_work_args_return_value;
+
+ default:
+ int r = work (noutput_items, input_items, output_items);
+ if (r > 0) consume_each(r*_decim/_interp);
+ return r;
+ }
+ }
+
+ int work(
+ int noutput_items,
+ gr_vector_const_void_star &input_items,
+ gr_vector_void_star &output_items
+ ){
+ _message.action = gr_block_gw_message_type::ACTION_WORK;
+ _message.work_args_ninput_items = fixed_rate_noutput_to_ninput(noutput_items);
+ if (_message.work_args_ninput_items == 0) return -1;
+ _message.work_args_noutput_items = noutput_items;
+ copy_pointers(_message.work_args_input_items, input_items);
+ _message.work_args_output_items = output_items;
+ _handler->calleval(0);
+ return _message.work_args_return_value;
+ }
+
+ int fixed_rate_noutput_to_ninput(int noutput_items){
+ return (noutput_items*_decim/_interp) + history() - 1;
+ }
+
+ int fixed_rate_ninput_to_noutput(int ninput_items){
+ return std::max(0, ninput_items - (int)history() + 1)*_interp/_decim;
+ }
+
+ bool start(void){
+ _message.action = gr_block_gw_message_type::ACTION_START;
+ _handler->calleval(0);
+ return _message.start_args_return_value;
+ }
+
+ bool stop(void){
+ _message.action = gr_block_gw_message_type::ACTION_STOP;
+ _handler->calleval(0);
+ return _message.stop_args_return_value;
+ }
+
+ gr_block_gw_message_type &gr_block_message(void){
+ return _message;
+ }
+
+private:
+ gr_feval_ll *_handler;
+ gr_block_gw_message_type _message;
+ const gr_block_gw_work_type _work_type;
+ unsigned _decim, _interp;
+};
+
+boost::shared_ptr<gr_block_gateway> gr_make_block_gateway(
+ gr_feval_ll *handler,
+ const std::string &name,
+ gr_io_signature_sptr in_sig,
+ gr_io_signature_sptr out_sig,
+ const gr_block_gw_work_type work_type,
+ const unsigned factor
+){
+ return boost::shared_ptr<gr_block_gateway>(
+ new gr_block_gateway_impl(handler, name, in_sig, out_sig, work_type, factor)
+ );
+}
diff --git a/gnuradio-core/src/lib/general/gr_block_gateway.h b/gnuradio-core/src/lib/general/gr_block_gateway.h
new file mode 100644
index 000000000..ae91d41b5
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_block_gateway.h
@@ -0,0 +1,212 @@
+/*
+ * Copyright 2011-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_GRBLOCK_GATEWAY_H
+#define INCLUDED_GRBLOCK_GATEWAY_H
+
+#include <gr_core_api.h>
+#include <gr_block.h>
+#include <gr_feval.h>
+
+/*!
+ * The work type enum tells the gateway what kind of block to implement.
+ * The choices are familiar gnuradio block overloads (sync, decim, interp).
+ */
+enum gr_block_gw_work_type{
+ GR_BLOCK_GW_WORK_GENERAL,
+ GR_BLOCK_GW_WORK_SYNC,
+ GR_BLOCK_GW_WORK_DECIM,
+ GR_BLOCK_GW_WORK_INTERP,
+};
+
+/*!
+ * Shared message structure between python and gateway.
+ * Each action type represents a scheduler-called function.
+ */
+struct gr_block_gw_message_type{
+ enum action_type{
+ ACTION_GENERAL_WORK, //dispatch work
+ ACTION_WORK, //dispatch work
+ ACTION_FORECAST, //dispatch forecast
+ ACTION_START, //dispatch start
+ ACTION_STOP, //dispatch stop
+ };
+
+ action_type action;
+
+ int general_work_args_noutput_items;
+ std::vector<int> general_work_args_ninput_items;
+ std::vector<void *> general_work_args_input_items; //TODO this should be const void*, but swig cant int cast it right
+ std::vector<void *> general_work_args_output_items;
+ int general_work_args_return_value;
+
+ int work_args_ninput_items;
+ int work_args_noutput_items;
+ std::vector<void *> work_args_input_items; //TODO this should be const void*, but swig cant int cast it right
+ std::vector<void *> work_args_output_items;
+ int work_args_return_value;
+
+ int forecast_args_noutput_items;
+ std::vector<int> forecast_args_ninput_items_required;
+
+ bool start_args_return_value;
+
+ bool stop_args_return_value;
+};
+
+/*!
+ * The gateway block which performs all the magic.
+ *
+ * The gateway provides access to all the gr_block routines.
+ * The methods prefixed with gr_block__ are renamed
+ * to class methods without the prefix in python.
+ */
+class GR_CORE_API gr_block_gateway : virtual public gr_block{
+public:
+ //! Provide access to the shared message object
+ virtual gr_block_gw_message_type &gr_block_message(void) = 0;
+
+ long gr_block__unique_id(void) const{
+ return gr_block::unique_id();
+ }
+
+ std::string gr_block__name(void) const{
+ return gr_block::name();
+ }
+
+ unsigned gr_block__history(void) const{
+ return gr_block::history();
+ }
+
+ void gr_block__set_history(unsigned history){
+ return gr_block::set_history(history);
+ }
+
+ void gr_block__set_fixed_rate(bool fixed_rate){
+ return gr_block::set_fixed_rate(fixed_rate);
+ }
+
+ bool gr_block__fixed_rate(void) const{
+ return gr_block::fixed_rate();
+ }
+
+ void gr_block__set_output_multiple(int multiple){
+ return gr_block::set_output_multiple(multiple);
+ }
+
+ int gr_block__output_multiple(void) const{
+ return gr_block::output_multiple();
+ }
+
+ void gr_block__consume(int which_input, int how_many_items){
+ return gr_block::consume(which_input, how_many_items);
+ }
+
+ void gr_block__consume_each(int how_many_items){
+ return gr_block::consume_each(how_many_items);
+ }
+
+ void gr_block__produce(int which_output, int how_many_items){
+ return gr_block::produce(which_output, how_many_items);
+ }
+
+ void gr_block__set_relative_rate(double relative_rate){
+ return gr_block::set_relative_rate(relative_rate);
+ }
+
+ double gr_block__relative_rate(void) const{
+ return gr_block::relative_rate();
+ }
+
+ uint64_t gr_block__nitems_read(unsigned int which_input){
+ return gr_block::nitems_read(which_input);
+ }
+
+ uint64_t gr_block__nitems_written(unsigned int which_output){
+ return gr_block::nitems_written(which_output);
+ }
+
+ gr_block::tag_propagation_policy_t gr_block__tag_propagation_policy(void){
+ return gr_block::tag_propagation_policy();
+ }
+
+ void gr_block__set_tag_propagation_policy(gr_block::tag_propagation_policy_t p){
+ return gr_block::set_tag_propagation_policy(p);
+ }
+
+ void gr_block__add_item_tag(
+ unsigned int which_output, const gr_tag_t &tag
+ ){
+ return gr_block::add_item_tag(which_output, tag);
+ }
+
+ void gr_block__add_item_tag(
+ unsigned int which_output,
+ uint64_t abs_offset,
+ const pmt::pmt_t &key,
+ const pmt::pmt_t &value,
+ const pmt::pmt_t &srcid=pmt::PMT_F
+ ){
+ return gr_block::add_item_tag(which_output, abs_offset, key, value, srcid);
+ }
+
+ std::vector<gr_tag_t> gr_block__get_tags_in_range(
+ unsigned int which_input,
+ uint64_t abs_start,
+ uint64_t abs_end
+ ){
+ std::vector<gr_tag_t> tags;
+ gr_block::get_tags_in_range(tags, which_input, abs_start, abs_end);
+ return tags;
+ }
+
+ std::vector<gr_tag_t> gr_block__get_tags_in_range(
+ unsigned int which_input,
+ uint64_t abs_start,
+ uint64_t abs_end,
+ const pmt::pmt_t &key
+ ){
+ std::vector<gr_tag_t> tags;
+ gr_block::get_tags_in_range(tags, which_input, abs_start, abs_end, key);
+ return tags;
+ }
+};
+
+/*!
+ * Make a new gateway block.
+ * \param handler the swig director object with callback
+ * \param name the name of the block (Ex: "Shirley")
+ * \param in_sig the input signature for this block
+ * \param out_sig the output signature for this block
+ * \param work_type the type of block overload to implement
+ * \param factor the decimation or interpolation factor
+ * \return a new gateway block
+ */
+GR_CORE_API boost::shared_ptr<gr_block_gateway> gr_make_block_gateway(
+ gr_feval_ll *handler,
+ const std::string &name,
+ gr_io_signature_sptr in_sig,
+ gr_io_signature_sptr out_sig,
+ const gr_block_gw_work_type work_type,
+ const unsigned factor
+);
+
+#endif /* INCLUDED_GRBLOCK_GATEWAY_H */
diff --git a/gnuradio-core/src/lib/general/gr_block_gateway.i b/gnuradio-core/src/lib/general/gr_block_gateway.i
new file mode 100644
index 000000000..8adafdfea
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_block_gateway.i
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2011-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.
+ */
+
+////////////////////////////////////////////////////////////////////////
+// standard includes
+////////////////////////////////////////////////////////////////////////
+%include <gnuradio.i>
+%include <gr_tags.i>
+%include <gr_feval.i>
+
+////////////////////////////////////////////////////////////////////////
+// block headers
+////////////////////////////////////////////////////////////////////////
+%{
+#include <gr_block_gateway.h>
+%}
+
+////////////////////////////////////////////////////////////////////////
+// data type support
+////////////////////////////////////////////////////////////////////////
+%template(int_vector_t) std::vector<int>;
+%template(void_star_vector_t) std::vector<void *>;
+
+////////////////////////////////////////////////////////////////////////
+// block magic
+////////////////////////////////////////////////////////////////////////
+GR_SWIG_BLOCK_MAGIC(gr,block_gateway);
+%include <gr_block_gateway.h>
diff --git a/gnuradio-core/src/lib/general/gr_message_strobe.cc b/gnuradio-core/src/lib/general/gr_message_strobe.cc
new file mode 100644
index 000000000..6a9f807d1
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_message_strobe.cc
@@ -0,0 +1,75 @@
+/* -*- 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_strobe.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_message_strobe_sptr
+gr_make_message_strobe (pmt::pmt_t msg, float period_ms)
+{
+ return gnuradio::get_initial_sptr(new gr_message_strobe(msg, period_ms));
+}
+
+gr_message_strobe::gr_message_strobe (pmt::pmt_t msg, float period_ms)
+ : gr_block("message_strobe",
+ gr_make_io_signature(0, 0, 0),
+ gr_make_io_signature(0, 0, 0)),
+ d_finished(false),
+ d_period_ms(period_ms),
+ d_msg(msg)
+{
+ message_port_register_out(pmt::mp("strobe"));
+ d_thread = boost::shared_ptr<boost::thread>(new boost::thread(boost::bind(&gr_message_strobe::run, this)));
+
+ message_port_register_in(pmt::mp("set_msg"));
+ set_msg_handler(pmt::mp("set_msg"), boost::bind(&gr_message_strobe::set_msg, this, _1));
+}
+
+gr_message_strobe::~gr_message_strobe()
+{
+ d_finished = true;
+ d_thread->interrupt();
+ d_thread->join();
+}
+
+void gr_message_strobe::run(){
+ while(!d_finished) {
+ boost::this_thread::sleep(boost::posix_time::milliseconds(d_period_ms));
+ if(d_finished){ return; }
+
+ message_port_pub( pmt::mp("strobe"), d_msg );
+ }
+}
diff --git a/gnuradio-core/src/lib/general/gr_message_strobe.h b/gnuradio-core/src/lib/general/gr_message_strobe.h
new file mode 100644
index 000000000..89046ffc0
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_message_strobe.h
@@ -0,0 +1,62 @@
+/* -*- 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_STROBE_H
+#define INCLUDED_GR_MESSAGE_STROBE_H
+
+#include <gr_core_api.h>
+#include <gr_block.h>
+#include <gr_message.h>
+#include <gr_msg_queue.h>
+
+class gr_message_strobe;
+typedef boost::shared_ptr<gr_message_strobe> gr_message_strobe_sptr;
+
+GR_CORE_API gr_message_strobe_sptr gr_make_message_strobe (pmt::pmt_t msg, float period_ms);
+
+/*!
+ * \brief Send message at defined interval
+ * \ingroup msg_blk
+ */
+class GR_CORE_API gr_message_strobe : public gr_block
+{
+ private:
+ friend GR_CORE_API gr_message_strobe_sptr
+ gr_make_message_strobe(pmt::pmt_t msg, float period_ms);
+
+ boost::shared_ptr<boost::thread> d_thread;
+ bool d_finished;
+ float d_period_ms;
+ pmt::pmt_t d_msg;
+
+ void run();
+
+ protected:
+ gr_message_strobe (pmt::pmt_t msg, float period_ms);
+
+ public:
+ ~gr_message_strobe ();
+
+ void set_msg(pmt::pmt_t msg){ d_msg = msg; }
+};
+
+#endif /* INCLUDED_GR_MESSAGE_STROBE_H */
diff --git a/gnuradio-core/src/lib/general/gr_message_strobe.i b/gnuradio-core/src/lib/general/gr_message_strobe.i
new file mode 100644
index 000000000..490aa8e8a
--- /dev/null
+++ b/gnuradio-core/src/lib/general/gr_message_strobe.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,message_strobe);
+
+%{
+#include <gr_message_strobe.h>
+%}
+
+%include "gr_message_strobe.h"
+
diff --git a/gnuradio-core/src/lib/general/gr_nop.cc b/gnuradio-core/src/lib/general/gr_nop.cc
index ca5983c39..edfe1d76d 100644
--- a/gnuradio-core/src/lib/general/gr_nop.cc
+++ b/gnuradio-core/src/lib/general/gr_nop.cc
@@ -40,7 +40,8 @@ gr_nop::gr_nop (size_t sizeof_stream_item)
d_nmsgs_recvd(0)
{
// Arrange to have count_received_msgs called when messages are received.
- set_msg_handler(boost::bind(&gr_nop::count_received_msgs, this, _1));
+ message_port_register_in(pmt::mp("port"));
+ set_msg_handler(pmt::mp("port"), boost::bind(&gr_nop::count_received_msgs, this, _1));
}
// Trivial message handler that just counts them.
diff --git a/gnuradio-core/src/lib/general/gr_skiphead.cc b/gnuradio-core/src/lib/general/gr_skiphead.cc
index c887376e4..7b441bea9 100644
--- a/gnuradio-core/src/lib/general/gr_skiphead.cc
+++ b/gnuradio-core/src/lib/general/gr_skiphead.cc
@@ -43,14 +43,14 @@ gr_make_skiphead (size_t itemsize, uint64_t nitems_to_skip)
int
gr_skiphead::general_work(int noutput_items,
- gr_vector_int &ninput_items_ignored,
+ gr_vector_int &ninput_items_,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const char *in = (const char *) input_items[0];
char *out = (char *) output_items[0];
- int ninput_items = noutput_items; // we've got at least this many input items
+ int ninput_items = std::min(ninput_items_[0], noutput_items);
int ii = 0; // input index
while (ii < ninput_items){
diff --git a/gnuradio-core/src/lib/general/gri_control_loop.cc b/gnuradio-core/src/lib/general/gri_control_loop.cc
index 5a93737f9..bb3c4a326 100644
--- a/gnuradio-core/src/lib/general/gri_control_loop.cc
+++ b/gnuradio-core/src/lib/general/gri_control_loop.cc
@@ -144,6 +144,17 @@ gri_control_loop::set_phase(float phase)
d_phase += M_TWOPI;
}
+void
+gri_control_loop::set_max_freq(float freq)
+{
+ d_max_freq = freq;
+}
+
+void
+gri_control_loop::set_min_freq(float freq)
+{
+ d_min_freq = freq;
+}
/*******************************************************************
GET FUNCTIONS
@@ -185,3 +196,15 @@ gri_control_loop::get_phase() const
{
return d_phase;
}
+
+float
+gri_control_loop::get_max_freq() const
+{
+ return d_max_freq;
+}
+
+float
+gri_control_loop::get_min_freq() const
+{
+ return d_min_freq;
+}
diff --git a/gnuradio-core/src/lib/general/gri_control_loop.h b/gnuradio-core/src/lib/general/gri_control_loop.h
index df260d2cf..304857ac7 100644
--- a/gnuradio-core/src/lib/general/gri_control_loop.h
+++ b/gnuradio-core/src/lib/general/gri_control_loop.h
@@ -141,9 +141,9 @@ class GR_CORE_API gri_control_loop
void set_beta(float beta);
/*!
- * \brief Set the Costas loop's frequency.
+ * \brief Set the control loop's frequency.
*
- * Set's the Costas Loop's frequency. While this is normally updated by the
+ * Set's the control loop's frequency. While this is normally updated by the
* inner loop of the algorithm, it could be useful to manually initialize,
* set, or reset this under certain circumstances.
*
@@ -153,9 +153,9 @@ class GR_CORE_API gri_control_loop
void set_frequency(float freq);
/*!
- * \brief Set the Costas loop's phase.
+ * \brief Set the control loop's phase.
*
- * Set's the Costas Loop's phase. While this is normally updated by the
+ * Set's the control loop's phase. While this is normally updated by the
* inner loop of the algorithm, it could be useful to manually initialize,
* set, or reset this under certain circumstances.
*
@@ -164,6 +164,23 @@ class GR_CORE_API gri_control_loop
*/
void set_phase(float phase);
+ /*!
+ * \brief Set the control loop's maximum frequency.
+ *
+ * Set the maximum frequency the control loop can track.
+ *
+ * \param freq (float) new max frequency
+ */
+ void set_max_freq(float freq);
+
+ /*!
+ * \brief Set the control loop's minimum frequency.
+ *
+ * Set the minimum frequency the control loop can track.
+ *
+ * \param freq (float) new min frequency
+ */
+ void set_min_freq(float freq);
/*******************************************************************
GET FUNCTIONS
@@ -190,14 +207,24 @@ class GR_CORE_API gri_control_loop
float get_beta() const;
/*!
- * \brief Get the Costas loop's frequency estimate
+ * \brief Get the control loop's frequency estimate
*/
float get_frequency() const;
/*!
- * \brief Get the Costas loop's phase estimate
+ * \brief Get the control loop's phase estimate
*/
float get_phase() const;
+
+ /*!
+ * \brief Get the control loop's maximum frequency.
+ */
+ float get_max_freq() const;
+
+ /*!
+ * \brief Get the control loop's minimum frequency.
+ */
+ float get_min_freq() const;
};
#endif /* GRI_CONTROL_LOOP */