Embedded Python Blocks:
Each 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 sys
from gnuradio import gr
class blk(gr.sync_block):
def __init__(self, enabler=False): # only default arguments here
gr.sync_block.__init__(
self,
name='Embedded Python Block',
in_sig=[np.float32],
out_sig=[np.float32]
)
self.enabler = enabler
def work(self, input_items, output_items):
key = sys.stdin.read(1)
if key==' ':
self.enabler=True
if self.enabler == True:
output_items[0][:] = input_items[0]
return len(output_items[0])
"""Created by Abdul Samad Usman"""
I am trying to make a python block that would act as an enabler between audio source and audio sink such that whenever I hit space from my keyboard the transmission begins and should stop after re hitting again. For starters I tried to start the transmission using just only one space hit but even this seems to be failing.I am using python block module from gnuradio. I get the following errors on my report panel. The source code of the block and the GRC screenshot is also attached.
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/gnuradio/gr/gateway.py", line 55, in eval
try: self._callback()
File "/usr/lib/python2.7/dist-packages/gnuradio/gr/gateway.py", line 160, in __gr_block_handle
) for i in self.__out_indexes],
TypeError: in method 'block_gw_message_type_work_args_return_value_set', argument 2 of type 'int'
thread[thread-per-block[1]: <block Embedded Python Block (1)>]: SWIG director method error. Error detected when calling 'feval_ll.eval'
If anybody figure out the problem or its probable solution please let me know
Regards
Abdul Samad

This comment has been removed by the author.
ReplyDeleteI have the same problem in 3.7.11, but not in later versions. Seems this was a bug but they fixed it.
ReplyDelete