[message filter]

- take filter string and substite string
- can now replace key by another key

git-svn-id: http://moon:8086/svn/software/trunk/projects/GnuRadio@529 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
2019-05-31 17:23:52 +00:00
parent d757827ffb
commit 6b03adfed8
2 changed files with 19 additions and 3 deletions
+6 -1
View File
@@ -27,13 +27,14 @@ class message_filter(gr.basic_block):
"""
docstring for block message_filter
"""
def __init__(self, filter='freq'):
def __init__(self, filter, subst=''):
gr.basic_block.__init__(self,
name="message_filter",
in_sig=None,
out_sig=None)
self.filter = filter
self.subst = subst
# Register in / out message ports
self.port_in = pmt.intern("in")
@@ -47,9 +48,13 @@ class message_filter(gr.basic_block):
def delegate_pair(self, pair):
key = pmt.car(pair)
val = pmt.cdr(pair)
key_str = pmt.symbol_to_string(key)
if self.filter in key_str:
if len(self.subst):
pair = pmt.cons(pmt.string_to_symbol(self.subst), val)
self.message_port_pub(self.port_out, pair)
def msg_handler(self, msg):