I want to modify a OOT block to have two outputs, as follow :
Current state :
int
block_impl::general_work (int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_complex *in = (const gr_complex *) input_items[0];
gr_complex *out = (gr_complex *) output_items[0];
// signal processing part
switch (state) {
case SEND: {
// Send one complex vector to "out"
noutput_items = 1;
}
case NOK: {
// Do nothing
noutput_items = 0;
}
}
return noutput_items;
}
And I tried :
int
block_impl::general_work (int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const gr_complex *in = (const gr_complex *) input_items[0];
gr_complex *out = (gr_complex *) output_items[0];
gr_complex *out_all = (gr_complex *) output_items[1];
// signal processing part
switch (state) {
case SEND: {
// Send one complex vector to "out" and "out_all"
noutput_items = 2;
}
case NOK: {
// Send complex vector to "out_all"
noutput_items = 1;
}
}
return noutput_items;
}
However, this solution is not working as the block connected to "out_all" is not receiving anything and the block connected to "out" is not working properly anymore.
I guess my understanding of the "noutput_items" value to return at the end of the work function is not total, can someone explain to me what I'm missing ?
You can use the produce function as follow :
int
block_impl::general_work (int noutput_items,
gr_vector_int &ninput_items,
gr_vector_const_void_star &input_items,
gr_vector_void_star &output_items)
{
const int OUT = 0;
const int OUT_ALL = 1;
const gr_complex *in = (const gr_complex *) input_items[0];
gr_complex *out = (gr_complex *) output_items[OUT];
gr_complex *out_all = (gr_complex *) output_items[OUT_ALL];
// signal processing part
switch (state) {
case SEND: {
// Send one complex vector to "out" and "out_all"
produce(OUT,1);
produce(OUT_ALL,1);
}
case NOK: {
// Send complex vector to "out_all"
produce(OUT,0);
produce(OUT_ALL,1);
}
}
return WORK_CALLED_PRODUCE;
}