discuss-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Index Error: output_index < noutputs


From: Vasil Velichkov
Subject: Re: Index Error: output_index < noutputs
Date: Thu, 28 Sep 2023 15:49:07 +0300
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0

Hi Marcus,

Thanks for your kind words! Thank you and thanks to all other current and past 
gnuradio maintainers and contributors for all the effort put in this great 
project!

Regards,
Vasil

On 28/09/2023 14.46, Marcus Müller wrote:
> Hi Vasil,
> 
> just wanted to express my appreciation for the detail of investigation you're 
> doing there. Thanks!
> 
> Marcus
> 
> On 27.09.23 19:55, Vasil Velichkov wrote:
>> Hi Elmore,
>>
>> On 27/09/2023 03.17, Elmore Family wrote:
>>> I am using a gnu radio flowgraph to attempt to select the appropriate 
>>> Selector Block output as explained below. The following error occurs when I 
>>> run the flowgraph: Index Error: output_index must be < noutputs.
>>
>>> I forgot to include the version: 3.9.4.0.
>>
>> Lets try analyzing the source code where this error is thrown.
>>
>> $ git checkout v3.9.4.0
>>
>> $ grep "output_index must be < noutputs" . -R
>> ./gr-blocks/lib/selector_impl.cc:        throw 
>> std::out_of_range("output_index must be < noutputs");
>>
>> https://github.com/gnuradio/gnuradio/blob/v3.9.4.0/gr-blocks/lib/selector_impl.cc#L66-L73
>>
>>   66 void selector_impl::set_output_index(unsigned int output_index)
>>   67 {
>>   68     gr::thread::scoped_lock l(d_mutex);
>>   69     if (output_index < d_num_outputs)
>>   70         d_output_index = output_index;
>>   71     else
>>   72         throw std::out_of_range("output_index must be < noutputs");
>>   73 }
>>
>> The code is pretty simple, the only possible case is the value of 
>> output_index variable to be greater or equal to d_num_outputs variable. You 
>> are calling set_output_index with 1 so d_num_outputs must be either 0 or 1.
>>
>> Now let's check where d_num_outputs gets its value.
>>
>> $ grep -n d_num_outputs ./gr-blocks/lib/selector_impl.cc
>> 40:      d_num_outputs(0)
>> 69:    if (output_index < d_num_outputs)
>> 100:        if (new_port < d_num_outputs)
>> 138:        d_num_outputs = (unsigned int)noutputs;
>>
>> It is initialized to 0 in the constructor on line 40 and get assigned in 
>> selector_impl::check_topology function on line 138.
>>
>> https://github.com/gnuradio/gnuradio/blob/v3.9.4.0/gr-blocks/lib/selector_impl.cc#L134-L145
>>
>> So it looks that you are calling set set_output_index(1) before 
>> check_topology() has been called, before the flowgraph is started.
>>
>> Looks like you need to start the flowgraph first and then call 
>> set_output_index(1)
>>
>> Hope this helps.
>>
>> Regards,
>> Vasil
>>
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]