为功函数中的每个输出指定 noutput_items
Specify noutput_items for each output in work function
我想修改一个OOT块有两个输出,如下:
当前状态:
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;
}
我试过了:
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;
}
但是,此解决方案不起作用,因为连接到“out_all”的块没有收到任何东西,并且连接到“out”的块不再正常工作。
我想我对功函数末尾 return 的“noutput_items”值的理解并不完整,有人可以向我解释我缺少什么吗?
您可以按如下方式使用 produce function :
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;
}
我想修改一个OOT块有两个输出,如下:
当前状态:
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;
}
我试过了:
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;
}
但是,此解决方案不起作用,因为连接到“out_all”的块没有收到任何东西,并且连接到“out”的块不再正常工作。
我想我对功函数末尾 return 的“noutput_items”值的理解并不完整,有人可以向我解释我缺少什么吗?
您可以按如下方式使用 produce function :
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;
}