[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/03: filter: add msg param set port for f
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/03: filter: add msg param set port for frac resampler |
Date: |
Sat, 6 Aug 2016 22:28:33 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch master
in repository gnuradio.
commit c7e146d454cb38d3ac417ddc75630af009991f04
Author: Sebastian Müller <address@hidden>
Date: Sat Aug 6 19:44:35 2016 +0200
filter: add msg param set port for frac resampler
---
gr-filter/grc/filter_fractional_resampler_xx.xml | 7 +++++-
.../gnuradio/filter/fractional_resampler_cc.h | 5 ++++
.../gnuradio/filter/fractional_resampler_ff.h | 6 +++++
gr-filter/lib/fractional_resampler_cc_impl.cc | 26 +++++++++++++++++++++
gr-filter/lib/fractional_resampler_cc_impl.h | 2 ++
gr-filter/lib/fractional_resampler_ff_impl.cc | 27 ++++++++++++++++++++++
gr-filter/lib/fractional_resampler_ff_impl.h | 2 ++
7 files changed, 74 insertions(+), 1 deletion(-)
diff --git a/gr-filter/grc/filter_fractional_resampler_xx.xml
b/gr-filter/grc/filter_fractional_resampler_xx.xml
index 40957b8..b2b4b10 100644
--- a/gr-filter/grc/filter_fractional_resampler_xx.xml
+++ b/gr-filter/grc/filter_fractional_resampler_xx.xml
@@ -42,7 +42,12 @@
<sink>
<name>rate</name>
<type>float</type>
- <optional>1</optional>
+ <optional>1</optional>
+ </sink>
+ <sink>
+ <name>msg_in</name>
+ <type>message</type>
+ <optional>1</optional>
</sink>
<source>
<name>out</name>
diff --git a/gr-filter/include/gnuradio/filter/fractional_resampler_cc.h
b/gr-filter/include/gnuradio/filter/fractional_resampler_cc.h
index 6fde6dd..65e53e2 100644
--- a/gr-filter/include/gnuradio/filter/fractional_resampler_cc.h
+++ b/gr-filter/include/gnuradio/filter/fractional_resampler_cc.h
@@ -32,6 +32,11 @@ namespace gr {
/*!
* \brief resampling MMSE filter with complex input, complex output
* \ingroup resamplers_blk
+ *
+ * \details
+ * The resampling ratio and mu parameters can be set with a pmt dict
+ * message. Keys are pmt symbols with the strings "resamp_ratio" and "mu"
+ * and values are pmt floats.
*/
class FILTER_API fractional_resampler_cc : virtual public block
{
diff --git a/gr-filter/include/gnuradio/filter/fractional_resampler_ff.h
b/gr-filter/include/gnuradio/filter/fractional_resampler_ff.h
index 9836010..f8d207d 100644
--- a/gr-filter/include/gnuradio/filter/fractional_resampler_ff.h
+++ b/gr-filter/include/gnuradio/filter/fractional_resampler_ff.h
@@ -32,7 +32,13 @@ namespace gr {
/*!
* \brief Resampling MMSE filter with float input, float output
* \ingroup resamplers_blk
+ *
+ * \details
+ * The resampling ratio and mu parameters can be set with a pmt dict
+ * message. Keys are pmt symbols with the strings "resamp_ratio" and "mu"
+ * and values are pmt floats.
*/
+
class FILTER_API fractional_resampler_ff : virtual public block
{
public:
diff --git a/gr-filter/lib/fractional_resampler_cc_impl.cc
b/gr-filter/lib/fractional_resampler_cc_impl.cc
index 72a2262..4d8def7 100644
--- a/gr-filter/lib/fractional_resampler_cc_impl.cc
+++ b/gr-filter/lib/fractional_resampler_cc_impl.cc
@@ -52,6 +52,9 @@ namespace gr {
throw std::out_of_range("phase shift ratio must be > 0 and < 1");
set_relative_rate(1.0 / resamp_ratio);
+ message_port_register_in(pmt::intern("msg_in"));
+ set_msg_handler(pmt::intern("msg_in"), boost::bind(
+ &fractional_resampler_cc_impl::handle_msg, this, _1));
}
fractional_resampler_cc_impl::~fractional_resampler_cc_impl()
@@ -60,6 +63,29 @@ namespace gr {
}
void
+ fractional_resampler_cc_impl::handle_msg(pmt::pmt_t msg) {
+ if(!pmt::is_dict(msg))
+ return;
+ // set resamp_ratio or mu by message dict
+ if(pmt::dict_has_key(msg, pmt::intern("resamp_ratio"))) {
+ set_resamp_ratio(
+ pmt::to_float(
+ pmt::dict_ref(msg, pmt::intern("resamp_ratio"),
+ pmt::from_float(resamp_ratio()))
+ )
+ );
+ }
+ if(pmt::dict_has_key(msg, pmt::intern("mu"))) {
+ set_mu(
+ pmt::to_float(
+ pmt::dict_ref(msg, pmt::intern("mu"),
+ pmt::from_float(mu()))
+ )
+ );
+ }
+ }
+
+ void
fractional_resampler_cc_impl::forecast(int noutput_items,
gr_vector_int
&ninput_items_required)
{
diff --git a/gr-filter/lib/fractional_resampler_cc_impl.h
b/gr-filter/lib/fractional_resampler_cc_impl.h
index d88d595..8b7d9de 100644
--- a/gr-filter/lib/fractional_resampler_cc_impl.h
+++ b/gr-filter/lib/fractional_resampler_cc_impl.h
@@ -42,6 +42,8 @@ namespace gr {
float resamp_ratio);
~fractional_resampler_cc_impl();
+ void handle_msg(pmt::pmt_t msg);
+
void forecast(int noutput_items,
gr_vector_int &ninput_items_required);
int general_work(int noutput_items,
diff --git a/gr-filter/lib/fractional_resampler_ff_impl.cc
b/gr-filter/lib/fractional_resampler_ff_impl.cc
index 2ffccf5..6fcd7e5 100644
--- a/gr-filter/lib/fractional_resampler_ff_impl.cc
+++ b/gr-filter/lib/fractional_resampler_ff_impl.cc
@@ -52,6 +52,10 @@ namespace gr {
throw std::out_of_range("phase shift ratio must be > 0 and < 1");
set_relative_rate(1.0 / resamp_ratio);
+
+ message_port_register_in(pmt::intern("msg_in"));
+ set_msg_handler(pmt::intern("msg_in"), boost::bind(
+ &fractional_resampler_ff_impl::handle_msg, this, _1));
}
fractional_resampler_ff_impl::~fractional_resampler_ff_impl()
@@ -60,6 +64,29 @@ namespace gr {
}
void
+ fractional_resampler_ff_impl::handle_msg(pmt::pmt_t msg) {
+ if(!pmt::is_dict(msg))
+ return;
+ // set resamp_ratio or mu by message dict
+ if(pmt::dict_has_key(msg, pmt::intern("resamp_ratio"))) {
+ set_resamp_ratio(
+ pmt::to_float(
+ pmt::dict_ref(msg, pmt::intern("resamp_ratio"),
+ pmt::from_float(resamp_ratio()))
+ )
+ );
+ }
+ if(pmt::dict_has_key(msg, pmt::intern("mu"))) {
+ set_mu(
+ pmt::to_float(
+ pmt::dict_ref(msg, pmt::intern("mu"),
+ pmt::from_float(mu()))
+ )
+ );
+ }
+ }
+
+ void
fractional_resampler_ff_impl::forecast(int noutput_items,
gr_vector_int
&ninput_items_required)
{
diff --git a/gr-filter/lib/fractional_resampler_ff_impl.h
b/gr-filter/lib/fractional_resampler_ff_impl.h
index 11c9886..cccc1be 100644
--- a/gr-filter/lib/fractional_resampler_ff_impl.h
+++ b/gr-filter/lib/fractional_resampler_ff_impl.h
@@ -42,6 +42,8 @@ namespace gr {
float resamp_ratio);
~fractional_resampler_ff_impl();
+ void handle_msg(pmt::pmt_t msg);
+
void forecast(int noutput_items,
gr_vector_int &ninput_items_required);
int general_work(int noutput_items,