summaryrefslogtreecommitdiff
path: root/grc
diff options
context:
space:
mode:
Diffstat (limited to 'grc')
-rw-r--r--grc/blocks/block_tree.xml2
-rw-r--r--grc/blocks/gr_message_debug.xml5
-rw-r--r--grc/blocks/gr_socket_pdu.xml62
-rw-r--r--grc/blocks/gr_tuntap_pdu.xml34
-rw-r--r--grc/blocks/pad_sink.xml9
-rw-r--r--grc/blocks/pad_source.xml9
-rw-r--r--grc/python/FlowGraph.py10
-rw-r--r--grc/python/convert_hier.py20
-rw-r--r--grc/python/flow_graph.tmpl17
9 files changed, 163 insertions, 5 deletions
diff --git a/grc/blocks/block_tree.xml b/grc/blocks/block_tree.xml
index 95bd7bb3c..183883959 100644
--- a/grc/blocks/block_tree.xml
+++ b/grc/blocks/block_tree.xml
@@ -43,6 +43,8 @@
<block>gr_message_strobe</block>
<block>gr_pdu_to_tagged_stream</block>
<block>gr_tagged_stream_to_pdu</block>
+ <block>gr_tuntap_pdu</block>
+ <block>gr_socket_pdu</block>
</cat>
<cat>
<name>Operators</name>
diff --git a/grc/blocks/gr_message_debug.xml b/grc/blocks/gr_message_debug.xml
index 705a7cc5f..4d73fbd9c 100644
--- a/grc/blocks/gr_message_debug.xml
+++ b/grc/blocks/gr_message_debug.xml
@@ -19,4 +19,9 @@
<type>message</type>
<optional>1</optional>
</sink>
+ <sink>
+ <name>print_pdu_verbose</name>
+ <type>message</type>
+ <optional>1</optional>
+ </sink>
</block>
diff --git a/grc/blocks/gr_socket_pdu.xml b/grc/blocks/gr_socket_pdu.xml
new file mode 100644
index 000000000..a175c3699
--- /dev/null
+++ b/grc/blocks/gr_socket_pdu.xml
@@ -0,0 +1,62 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## Socket PDU Message source/sink
+###################################################
+ -->
+<block>
+ <name>Socket PDU</name>
+ <key>gr_socket_pdu</key>
+ <import>from gnuradio import gr</import>
+ <make>gr.socket_pdu($type, $host, $port, $mtu)</make>
+ <param>
+ <name>Type</name>
+ <key>type</key>
+ <value>TCP_SERVER</value>
+ <type>enum</type>
+ <option>
+ <name>TCP Server</name>
+ <key>"TCP_SERVER"</key>
+ </option>
+ <option>
+ <name>TCP Client</name>
+ <key>"TCP_CLIENT"</key>
+ </option>
+ <option>
+ <name>UDP Server</name>
+ <key>"UDP_SERVER"</key>
+ </option>
+ <option>
+ <name>UDP Client</name>
+ <key>"UDP_CLIENT"</key>
+ </option>
+ </param>
+ <param>
+ <name>Host</name>
+ <key>host</key>
+ <value></value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>Port</name>
+ <key>port</key>
+ <value>52001</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>MTU</name>
+ <key>mtu</key>
+ <value>10000</value>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>pdus</name>
+ <type>message</type>
+ <optional>1</optional>
+ </sink>
+ <source>
+ <name>pdus</name>
+ <type>message</type>
+ <optional>1</optional>
+ </source>
+</block>
diff --git a/grc/blocks/gr_tuntap_pdu.xml b/grc/blocks/gr_tuntap_pdu.xml
new file mode 100644
index 000000000..f169345af
--- /dev/null
+++ b/grc/blocks/gr_tuntap_pdu.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0"?>
+<!--
+###################################################
+## Tuntap PDU Message source/sink
+###################################################
+ -->
+<block>
+ <name>TunTap PDU</name>
+ <key>gr_tuntap_pdu</key>
+ <import>from gnuradio import gr</import>
+ <make>gr.tuntap_pdu($ifn, $mtu)</make>
+ <param>
+ <name>Interface Name</name>
+ <key>ifn</key>
+ <value>tun0</value>
+ <type>string</type>
+ </param>
+ <param>
+ <name>MTU</name>
+ <key>mtu</key>
+ <value>10000</value>
+ <type>int</type>
+ </param>
+ <sink>
+ <name>pdus</name>
+ <type>message</type>
+ <optional>1</optional>
+ </sink>
+ <source>
+ <name>pdus</name>
+ <type>message</type>
+ <optional>1</optional>
+ </source>
+</block>
diff --git a/grc/blocks/pad_sink.xml b/grc/blocks/pad_sink.xml
index f89eaa53c..f0e10a339 100644
--- a/grc/blocks/pad_sink.xml
+++ b/grc/blocks/pad_sink.xml
@@ -7,7 +7,9 @@
<block>
<name>Pad Sink</name>
<key>pad_sink</key>
- <make></make>
+ <make>#if str($type) == "message"
+None;self.message_port_register_hier_in($label)
+#end if</make>
<param>
<name>Label</name>
<key>label</key>
@@ -44,6 +46,11 @@
<opt>size:gr.sizeof_char</opt>
</option>
<option>
+ <name>Message</name>
+ <key>message</key>
+ <opt>size:0</opt>
+ </option>
+ <option>
<name>Wildcard</name>
<key></key>
<opt>size:0</opt>
diff --git a/grc/blocks/pad_source.xml b/grc/blocks/pad_source.xml
index cbf38eb39..a56a65dcc 100644
--- a/grc/blocks/pad_source.xml
+++ b/grc/blocks/pad_source.xml
@@ -7,7 +7,9 @@
<block>
<name>Pad Source</name>
<key>pad_source</key>
- <make></make>
+ <make>#if str($type) == "message"
+None;self.message_port_register_hier_out($label)
+#end if</make>
<param>
<name>Label</name>
<key>label</key>
@@ -44,6 +46,11 @@
<opt>size:gr.sizeof_char</opt>
</option>
<option>
+ <name>Message</name>
+ <key>message</key>
+ <opt>size:0</opt>
+ </option>
+ <option>
<name>Wildcard</name>
<key></key>
<opt>size:0</opt>
diff --git a/grc/python/FlowGraph.py b/grc/python/FlowGraph.py
index efe362760..376c2e337 100644
--- a/grc/python/FlowGraph.py
+++ b/grc/python/FlowGraph.py
@@ -58,6 +58,8 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
'in': self.get_pad_sources(),
'out': self.get_pad_sinks(),
}[direction]
+ # we only want stream ports
+ sorted_pads = filter(lambda b: b.get_param('type').get_evaluated() != 'message', sorted_pads);
#load io signature
return [{
'label': str(pad.get_param('label').get_evaluated()),
@@ -83,6 +85,14 @@ class FlowGraph(_FlowGraph, _GUIFlowGraph):
pads = filter(lambda b: b.get_key() == 'pad_sink', self.get_enabled_blocks())
return sorted(pads, lambda x, y: cmp(x.get_id(), y.get_id()))
+ def get_msg_pad_sources(self):
+ ps = self.get_pad_sources();
+ return filter(lambda b: b.get_param('type').get_evaluated() == 'message', ps);
+
+ def get_msg_pad_sinks(self):
+ ps = self.get_pad_sinks();
+ return filter(lambda b: b.get_param('type').get_evaluated() == 'message', ps);
+
def get_imports(self):
"""
Get a set of all import statments in this flow graph namespace.
diff --git a/grc/python/convert_hier.py b/grc/python/convert_hier.py
index b609af24a..508ec63b2 100644
--- a/grc/python/convert_hier.py
+++ b/grc/python/convert_hier.py
@@ -25,6 +25,8 @@ def convert_hier(flow_graph, python_file):
#extract info from the flow graph
input_sigs = flow_graph.get_io_signaturev('in')
output_sigs = flow_graph.get_io_signaturev('out')
+ input_msgp = flow_graph.get_msg_pad_sources();
+ output_msgp = flow_graph.get_msg_pad_sinks();
parameters = flow_graph.get_parameters()
block_key = flow_graph.get_option('id')
block_name = flow_graph.get_option('title') or flow_graph.get_option('id').replace('_', ' ').title()
@@ -55,7 +57,7 @@ def convert_hier(flow_graph, python_file):
param_n['type'] = 'raw'
params_n.append(param_n)
block_n['param'] = params_n
- #sink data
+ #sink data stream ports
block_n['sink'] = list()
for input_sig in input_sigs:
sink_n = odict()
@@ -64,7 +66,14 @@ def convert_hier(flow_graph, python_file):
sink_n['vlen'] = input_sig['vlen']
if input_sig['optional']: sink_n['optional'] = '1'
block_n['sink'].append(sink_n)
- #source data
+ #sink data msg ports
+ for input_sig in input_msgp:
+ sink_n = odict()
+ sink_n['name'] = input_sig.get_param("label").get_value();
+ sink_n['type'] = "message"
+ sink_n['optional'] = input_sig.get_param("optional").get_value();
+ block_n['sink'].append(sink_n)
+ #source data stream ports
block_n['source'] = list()
for output_sig in output_sigs:
source_n = odict()
@@ -73,6 +82,13 @@ def convert_hier(flow_graph, python_file):
source_n['vlen'] = output_sig['vlen']
if output_sig['optional']: source_n['optional'] = '1'
block_n['source'].append(source_n)
+ #source data msg ports
+ for output_sig in output_msgp:
+ source_n = odict()
+ source_n['name'] = output_sig.get_param("label").get_value();
+ source_n['type'] = "message"
+ source_n['optional'] = output_sig.get_param("optional").get_value();
+ block_n['source'].append(source_n)
#doc data
block_n['doc'] = "%s\n%s\n%s"%(block_author, block_desc, python_file)
block_n['grc_source'] = "%s"%(flow_graph.grc_file_path)
diff --git a/grc/python/flow_graph.tmpl b/grc/python/flow_graph.tmpl
index af55ad641..163e7f76a 100644
--- a/grc/python/flow_graph.tmpl
+++ b/grc/python/flow_graph.tmpl
@@ -189,6 +189,7 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])
self.connect($make_port_sig($source), $make_port_sig($sink))
#end if
#end for
+
########################################################
##Create Asynch Message Connections
########################################################
@@ -198,7 +199,21 @@ gr.io_signaturev($(len($io_sigs)), $(len($io_sigs)), [$(', '.join($size_strs))])
$DIVIDER
#end if
#for $msg in $messages2
- self.msg_connect(self.$msg.get_source().get_parent().get_id(), "$msg.get_source().get_name()", self.$msg.get_sink().get_parent().get_id(), "$msg.get_sink().get_name()")
+ #set $sr = $msg.get_source()
+ #set $source = "self.%s"%($sr.get_parent().get_id())
+ #set $source_port = $sr.get_name();
+ #if $sr.get_parent().get_key() == "pad_source"
+ #set $source = "self"
+ #set $source_port = $sr.get_parent().get_param("label").get_value();
+ #end if
+ #set $sk = $msg.get_sink()
+ #set $sink = "self.%s"%($sk.get_parent().get_id())
+ #set $sink_port = $sk.get_name();
+ #if $sk.get_parent().get_key() == "pad_sink"
+ #set $sink = "self"
+ #set $sink_port = $sk.get_parent().get_param("label").get_value();
+ #end if
+ self.msg_connect($source, "$source_port", $sink, "$sink_port")
#end for
########################################################