Mon Sep 5 11:56:00 2016
options
author
Aaron Scher
window_size
category
[GRC Hier Blocks]
comment
description
_enabled
True
_coordinate
(8, 8)
_rotation
0
generate_options
qt_gui
hier_block_src_path
.:
id
top_block
max_nouts
0
qt_qss_theme
realtime_scheduling
run_command
{python} -u {filename}
run_options
prompt
run
True
thread_safe_setters
title
Messaging Example
variable
comment
_enabled
True
_coordinate
(8, 160)
_rotation
0
id
samp_rate
value
32000
blocks_message_debug
alias
comment
affinity
_enabled
True
_coordinate
(656, 160)
_rotation
0
id
blocks_message_debug_0
blocks_null_sink
alias
bus_conns
[[0,],]
comment
affinity
_enabled
True
_coordinate
(576, 24)
_rotation
0
id
blocks_null_sink_0
type
complex
num_inputs
1
vlen
1
blocks_null_source
alias
bus_conns
[[0,],]
comment
affinity
_enabled
True
_coordinate
(168, 24)
_rotation
0
id
blocks_null_source_0
maxoutbuf
0
minoutbuf
0
num_outputs
1
type
complex
vlen
1
blocks_throttle
alias
comment
II inclued this throttle block to avoid the warning about
including throttle blocks (to avoid CPU congestion for
cases with no audio or RF hardware blocks).
affinity
_enabled
True
_coordinate
(304, 20)
_rotation
0
id
blocks_throttle_0
ignoretag
True
maxoutbuf
0
minoutbuf
0
samples_per_second
samp_rate
type
complex
vlen
1
epy_block
alias
_io_cache
('Embedded Python Block', 'msg_block', [], [('msg_in', 'message')], [('msg_out', 'message')], 'This block converts strings from the QT GUI Message Edit Box to uint8 vectors', [])
_source_code
"""
Embedded Python Blocks:
Each time this file is saved, GRC will instantiate the first class it finds
to get ports and parameters of your block. The arguments to __init__ will
be the parameters. All of them are required to have default values!
"""
import numpy as np
import pylab
from gnuradio import gr
import pmt
class msg_block(gr.basic_block): # other base classes are basic_block, decim_block, interp_block
"""This block converts strings from the QT GUI Message Edit Box to uint8 vectors"""
def __init__(self): # only default arguments here
"""arguments to this function show up as parameters in GRC"""
gr.basic_block.__init__(
self,
name='Embedded Python Block', # will show up in GRC
in_sig=None,
out_sig=None
)
self.message_port_register_out(pmt.intern('msg_out'))
self.message_port_register_in(pmt.intern('msg_in'))
self.set_msg_handler(pmt.intern('msg_in'), self.handle_msg)
def handle_msg(self, msg):
nvec = pmt.to_python(msg)
self.message_port_pub(pmt.intern('msg_out'), pmt.cons(pmt.make_dict(), pmt.pmt_to_python.numpy_to_uvector(np.array([ord(c) for c in nvec], np.uint8))))
def work(self, input_items, output_items):
pass
comment
Double click on this block and click on "open in
editor" to see the Python code.
This block converts strings from the QT GUI Message
Edit Box to uint8 vectors
_enabled
1
_coordinate
(368, 160)
_rotation
0
id
epy_block_0
qtgui_edit_box_msg
alias
comment
affinity
_enabled
1
_coordinate
(120, 132)
gui_hint
_rotation
0
id
qtgui_edit_box_msg_0
key
label
maxoutbuf
0
minoutbuf
0
is_pair
False
is_static
False
type
string
value
blocks_null_source_0
blocks_throttle_0
0
0
blocks_throttle_0
blocks_null_sink_0
0
0
epy_block_0
blocks_message_debug_0
msg_out
print
qtgui_edit_box_msg_0
epy_block_0
msg
msg_in