|
From: | Elmore Family |
Subject: | Re: Selector error - "IndexError: output_index must be < noutputs" |
Date: | Wed, 6 Sep 2023 13:34:26 -0400 |
Jim,
Thanks for your comments. I think I have been going down the wrong road and
need to refocus on using a callback to resolve my issue.
I have used callbacks all through my project which have been triggered by
an action such as a toggle or a radio button selection. I need to trigger the
callback in this case programmatically based on a time value. How do I do
this?
In your code snippet how do you trigger the set_signal_choice callback from
a program?
I want to set a select_wave variable used in the output_index of a selector
in order to select the appropriate output. I want to set that variable from
within another method. How do I do that?
Jim
From: Jim
Melton
Sent: Tuesday, September 5, 2023 1:02 PM
Subject: RE: Re: Selector error - "IndexError: output_index must be
< noutputs" In your original, import
Receive Receive is a Hier Block
which I import in to my Python file blocks_selector_0
= Receive.blocks.selector(gr.sizeof_float*1,0,0) Instantiation of blocks_selector_0. The
Selector block is in the Receive Hier Block. I questioned the syntax. You said “Receive is a Hier Block”
but then you do a module operation (not an instance operation), so it wasn’t
clear what you are doing. In your simplified example, your graph instantiates a
selector, and your embedded python block instantiates a selector. The EPY block
doesn’t connect the selector to anything, so selecting an output is very likely
to give you an index error. I created a signal generator, where I could mix in different
waveforms with an input waveform, and used the selector to control which signal
was being mixed in. As with a lot of my stuff, I used GRC for the initial
prototype, then make the generated code more production-ready. I have these
lines:
self.source_selector =
blocks.selector(gr.sizeof_gr_complex*1,signal_choice,0)
self.source_selector.set_enabled(True) //
…
self.connect((self.noise_throttle, 0), (self.source_selector,
0))
self.connect((self, 0), (self.source_selector, 1))
self.connect((self.source_selector, 0), (self.live_strength,
0))
self.connect((self.source_selector, 0), (self, 2)) In your attached GRC file, you have flowgraph generated
connections, but you don’t have any connections to the one created in your EPY
block (probably your bug). As Paul suggested, you can use variables and
callbacks to control your selector (which might be simpler than the EPY block).
My hier block (referenced above) has this: def
set_signal_choice(self, signal_choice):
self.signal_choice = signal_choice
self.source_selector.set_input_index(self.signal_choice) and the associated GRC file has: templates: imports: from
gnuradio import inputs make:
"inputs.siggen(\n signal_choice=${ signal_choice
},\n)"
callbacks: -
set_signal_choice(${ signal_choice }) (simplified for illustrative purposes). Hope this helps. --- Jim
Melton
Jim, I have attached a
greatly simplified version of what I am trying to accomplish. I still get the
same error. What am I doing wrong? Jim From: Jim
Melton Sent: Monday,
August 28, 2023 12:01 PM Subject: RE:
Selector error - "IndexError: output_index must be <
noutputs" Don’t you need to instantiate
“Receive”? --- Jim
Melton
From:
discuss-gnuradio-bounces+jim.melton=sncorp.com@gnu.org
<discuss-gnuradio-bounces+jim.melton=sncorp.com@gnu.org> On
Behalf Of Elmore's I am attempting
to use a Selector block with 2 outputs. I want to select the output
programmatically. When I run the flowgraph, I get the subject
error. The following is
my abbreviated code which is pertinent to the question interspersed with
explanatory comments: import
Receive Receive is a Hier Block
which I import in to my Python file blocks_selector_0
= Receive.blocks.selector(gr.sizeof_float*1,0,0) Instantiation of blocks_selector_0. The
Selector block is in the Receive Hier Block. blocks_selector_0.set_output_index(0)
I am trying to select the 0
output. This is where the error occurs. 0 is certainly
less than 2 so what is happening? Jim CONFIDENTIALITY
NOTICE - SNC EMAIL: This email and any attachments are confidential, may contain
proprietary, protected, or export controlled information, and are intended for
the use of the intended recipients only. Any review, reliance, distribution,
disclosure, or forwarding of this email and/or attachments outside of Sierra
Nevada Corporation (SNC) without express written approval of the sender, except
to the extent required to further properly approved SNC business purposes, is
strictly prohibited. If you are not the intended recipient of this email, please
notify the sender immediately, and delete all copies without reading, printing,
or saving in any manner. --- Thank
You. |
[Prev in Thread] | Current Thread | [Next in Thread] |