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
Non-Sensitive
From: Elmore's <[email protected]>
Sent: Friday, September 1, 2023 20:28
To: [email protected]
Subject: [EXTERNAL] Re: Selector error - "IndexError: output_index must be <
noutputs"
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
To: [email protected]<mailto:[email protected]>
Subject: RE: Selector error - "IndexError: output_index must be < noutputs"
Don’t you need to instantiate “Receive”?
---
Jim Melton
Non-Sensitive
From:
[email protected]<mailto:[email protected]>
<[email protected]<mailto:[email protected]>>
On Behalf Of Elmore's
Sent: Monday, August 28, 2023 09:15
To: [email protected]<mailto:[email protected]>
Subject: [EXTERNAL] Selector error - "IndexError: output_index must be <
noutputs"
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
[Image removed by
sender.]<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
Virus-free.www.avg.com<http://www.avg.com/email-signature?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient>
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.