[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 01/07: blocks: pdu_filter, add option for f
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 01/07: blocks: pdu_filter, add option for filter match inversion |
Date: |
Fri, 16 May 2014 23:49:30 +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 d165f27dd41d34400bac89220f219b9ba6f7438e
Author: Tim O'Shea <address@hidden>
Date: Sun May 11 16:04:24 2014 -0400
blocks: pdu_filter, add option for filter match inversion
---
gr-blocks/grc/blocks_pdu_filter.xml | 16 +++++++++++++-
gr-blocks/include/gnuradio/blocks/pdu_filter.h | 2 +-
gr-blocks/lib/pdu_filter_impl.cc | 30 ++++++++++++--------------
gr-blocks/lib/pdu_filter_impl.h | 3 ++-
4 files changed, 32 insertions(+), 19 deletions(-)
diff --git a/gr-blocks/grc/blocks_pdu_filter.xml
b/gr-blocks/grc/blocks_pdu_filter.xml
index a9565c9..1fb7209 100644
--- a/gr-blocks/grc/blocks_pdu_filter.xml
+++ b/gr-blocks/grc/blocks_pdu_filter.xml
@@ -9,7 +9,7 @@
<key>blocks_pdu_filter</key>
<import>from gnuradio import blocks</import>
<import>import pmt</import>
- <make>blocks.pdu_filter($k, $v)</make>
+ <make>blocks.pdu_filter($k, $v, $invert)</make>
<param>
<name>Key</name>
<key>k</key>
@@ -22,6 +22,20 @@
<value>pmt.intern("value")</value>
<type>raw</type>
</param>
+ <param>
+ <name>Invert Filter</name>
+ <key>invert</key>
+ <value>False</value>
+ <type>enum</type>
+ <option>
+ <name>No</name>
+ <key>False</key>
+ </option>
+ <option>
+ <name>Yes</name>
+ <key>True</key>
+ </option>
+ </param>
<sink>
<name>pdus</name>
<type>message</type>
diff --git a/gr-blocks/include/gnuradio/blocks/pdu_filter.h
b/gr-blocks/include/gnuradio/blocks/pdu_filter.h
index 5d0d2ed..1483731 100644
--- a/gr-blocks/include/gnuradio/blocks/pdu_filter.h
+++ b/gr-blocks/include/gnuradio/blocks/pdu_filter.h
@@ -43,7 +43,7 @@ namespace gr {
/*!
* \brief Construct a PDU filter
*/
- static sptr make(pmt::pmt_t k, pmt::pmt_t v);
+ static sptr make(pmt::pmt_t k, pmt::pmt_t v, bool invert = false);
};
} /* namespace blocks */
diff --git a/gr-blocks/lib/pdu_filter_impl.cc b/gr-blocks/lib/pdu_filter_impl.cc
index 455c6c8..5db8915 100644
--- a/gr-blocks/lib/pdu_filter_impl.cc
+++ b/gr-blocks/lib/pdu_filter_impl.cc
@@ -32,16 +32,16 @@ namespace gr {
namespace blocks {
pdu_filter::sptr
- pdu_filter::make(pmt::pmt_t k, pmt::pmt_t v)
+ pdu_filter::make(pmt::pmt_t k, pmt::pmt_t v, bool invert)
{
- return gnuradio::get_initial_sptr(new pdu_filter_impl(k,v));
+ return gnuradio::get_initial_sptr(new pdu_filter_impl(k,v,invert));
}
- pdu_filter_impl::pdu_filter_impl(pmt::pmt_t k, pmt::pmt_t v)
+ pdu_filter_impl::pdu_filter_impl(pmt::pmt_t k, pmt::pmt_t v, bool invert)
: block("pdu_filter",
io_signature::make (0, 0, 0),
io_signature::make (0, 0, 0)),
- d_k(k), d_v(v)
+ d_k(k), d_v(v), d_invert(invert)
{
message_port_register_out(pmt::mp("pdus"));
message_port_register_in(pmt::mp("pdus"));
@@ -52,21 +52,19 @@ namespace gr {
pdu_filter_impl::handle_msg(pmt::pmt_t pdu)
{
pmt::pmt_t meta = pmt::car(pdu);
+ bool output = d_invert;
- // discard if meta is not a dict
- if(!pmt::is_dict(meta))
- return;
-
- // make sure the dict has the target key
- if(!dict_has_key(meta, d_k))
- return;
-
- // validate the value matches
- if(!pmt::eqv(pmt::dict_ref(meta,d_k,pmt::PMT_NIL), d_v))
- return;
+ // check base type
+ // key exists
+ // value matches
+ if(pmt::is_dict(meta) && dict_has_key(meta, d_k) &&
pmt::eqv(pmt::dict_ref(meta,d_k,pmt::PMT_NIL), d_v)){
+ output = !d_invert;
+ }
// if all tests pass, propagate the pdu
- message_port_pub(pmt::mp("pdus"), pdu);
+ if(output){
+ message_port_pub(pmt::mp("pdus"), pdu);
+ }
}
} /* namespace blocks */
diff --git a/gr-blocks/lib/pdu_filter_impl.h b/gr-blocks/lib/pdu_filter_impl.h
index 86fa648..66440ee 100644
--- a/gr-blocks/lib/pdu_filter_impl.h
+++ b/gr-blocks/lib/pdu_filter_impl.h
@@ -33,9 +33,10 @@ namespace gr {
private:
pmt::pmt_t d_k;
pmt::pmt_t d_v;
+ bool d_invert;
public:
- pdu_filter_impl(pmt::pmt_t k, pmt::pmt_t v);
+ pdu_filter_impl(pmt::pmt_t k, pmt::pmt_t v, bool invert);
void handle_msg(pmt::pmt_t msg);
};
- [Commit-gnuradio] [gnuradio] branch master updated (5974a3e -> cb0bc7f), git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 03/07: pmt: adding pmt.uniform_vector_itemsize(pmt_t vector), returns the size per item in bytes within a uniform vector for any kind of uniform vector, git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 07/07: Merge remote-tracking branch 'osh/pdu_uvector_itemsize', git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 06/07: Merge remote-tracking branch 'bistromath/hdlc_fix', git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 05/07: Merge remote-tracking branch 'osh/pdu_filter_inversion', git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 01/07: blocks: pdu_filter, add option for filter match inversion,
git <=
- [Commit-gnuradio] [gnuradio] 02/07: digital: Fix alloc bug in HDLC deframer and make Coverity happy., git, 2014/05/16
- [Commit-gnuradio] [gnuradio] 04/07: Merge branch 'maint', git, 2014/05/16