After further checking, here are the steps to reproduce the issue, and a workaround:
1. Create a flow graph with:
Null Source (short) ->
Throttle(short) ->
Embedded Python Block #1 (short in, short out) ->
Embedded Python Block #2 (short in, float out) ->
Null Sink (float)
For the Embedded Python Blocks, use the code editor to set the types for inputs and outputs:
Block #1
class blk(gr.sync_block):)
def __init__(self, factor=1.0): # only default arguments here
gr.sync_block.__init__(
self,
name='Embedded Python Block',
in_sig=[np.short], # edited this line
out_sig=[np.short] # edited this line
)
self.factor = factor
Block #2
class blk(gr.sync_block):
def __init__(self, factor=1.0): # only default arguments here
gr.sync_block.__init__(
self,
name='Embedded Python Block',
in_sig=[np.short], # edited this line
out_sig=[np.float32] # edited this line
)
self.factor = factor
If you try to run, you get a size mismatch error. The reason is that the editor gives the same default name "blk" to both class definitions; then top_block.py instantiates the same class twice, instead of two unique classes. So in one of the modules, change "blk" to "blk2" and it works fine. Seems obvious now, but not at first. Perhaps the template code could have a comment to that effect, or better would be to automatically set the class name to match the block ID.
Hopefully this post will save someone some time.
Sent: September 5, 2016 8:37 PM
To: Gavin Jacobs
Cc: discuss-gnuradio@gnu.org
Subject: Re: [Discuss-gnuradio] Fw: Signal Source - frequency control
> Now here's the frustrating part, when I tried to use another embedded python block to implement the bit banger, I got confusing runtime errors indicating that the top block was getting the two blocks mixed up(e.g. size mismatch). Is there a limit of one embedded python block?
Not as far as I know.
I haven't used Python blocks significantly because they pose a risk of thread deadlock together with other things I need to do, so I can't comment in detail. Perhaps someone else can help there.
A good thing to do at this point would be to make a copy of your code and modify it into an example that demonstrates the problem without having unnecessary parts. If you show us this code it will be easier to find out where the problem lies, whether it is with GNU Radio or with your code.
No comments:
Post a Comment