C++ GNU无线电是如何确定noutput_项目的?

C++ GNU无线电是如何确定noutput_项目的?,c++,gnuradio,C++,Gnuradio,我正在看GrOsmoSdr的源代码,这是一个GNU无线电源,它从TCP读取交错I/Q数据 work函数如下所示: int rtl_tcp_source_f::work (int noutput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { flo

我正在看GrOsmoSdr的源代码,这是一个GNU无线电源,它从TCP读取交错I/Q数据

work函数如下所示:

int rtl_tcp_source_f::work (int noutput_items,
                            gr_vector_const_void_star &input_items,
                            gr_vector_void_star &output_items)
{
  float *out = (float *) output_items[0];
  ssize_t r = 0;

  int bytesleft = noutput_items;
  int index = 0;
  int receivedbytes = 0;
  while(bytesleft > 0) {
    receivedbytes = recv(d_socket, (char*)&d_temp_buff[index], bytesleft, 0);

    if(receivedbytes == -1 && !is_error(EAGAIN)){
      fprintf(stderr, "socket error\n");
      return -1;
    }
    bytesleft -= receivedbytes;
    index += receivedbytes;
  }
  r = noutput_items;

  for(int i=0; i<r; ++i)
    out[i]=d_LUT[*(d_temp_buff+d_temp_offset+i)];

  return r;
}
其中
d_payload_size
是一个构造函数参数,由配置传入


work函数准确地将
noutput\u项目读入
d\u temp\u buff
。Gnuradio通常如何选择
noutput_items
,此工作函数如何确保
noutput_items默认情况下,流图的最大输出项数的上限是一个很大的数字,这取决于Gnuradio版本,当前主存储库中设置的值为

这是通过调用流图的顶部块(未指定参数)来设置的,并使用默认参数。覆盖此全局值可以通过向top_块的start调用传递不同的参数来完成,或者通过调用set_max_noutput_项在top块上或在特定块上调用set_max_noutput_项来完成

在以如此高的值进行初始化之后,调度程序将基于最小可用输出空间将其设置为较低的值,该最小可用输出空间使用块详细信息构造函数中设置的noutput_项的值,以及块的output_multiple和min_noutput_项。看到和

在您的模块中发生的工作函数的子分类似乎没有基于负载大小(默认设置为)或作为参数传入的MTU/数据包长度对max_noutput_项的任何约束

在使用之前或在构造函数中,需要修改代码以添加此类检查,或者需要根据数据包长度为给定块设置set_max_noutput_项,它当前默认为继承自块的同步块的rtl_tcp_source_f块的继承值0,值标志设置为false

d_temp_buff = new unsigned char[d_payload_size];