如何在GNU无线电中确定noutput_items

How is noutput_items determined in GNU Radio?

本文关键字:noutput items GNU 无线电      更新时间:2023-10-16

我正在查看Grosmosdr的rtl_tcp_source_f.cc的源代码,这是GNU无线电源,它读取TCP的交织I/Q数据。

工作功能看起来像这样:

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 errorn");
      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_temp_buff

d_temp_buff = new unsigned char[d_payload_size]; 

其中 d_payload_size是通过配置传递的构造函数参数。

工作功能将noutput_items读取到d_temp_buff中。Gnuradio一般如何选择noutput_items,该工作功能如何确保noutput_items <= d_payload_size

默认情况下,流程图的最大输出项数量的上限是一个大数字,取决于gnuradio版本,当前主存储库中设置的值为100000000

这是通过调用启动流程图的顶部块来设置的,没有指定参数,并且使用默认参数。可以通过将不同的参数传递给top_block的启动调用或在顶部块上或在特定块上调用set_max_noutput_items。

以如此高的值初始化后,根据调度程序将其设置为较低的值,基于最小可用的输出空间,该空间使用block_detail构造函数中设置的noutput_items的值,以及uppute_multiple和min_noutput_items。请参阅single_threaded_scheduler.cc和block_executor.cc

基于有效载荷大小,在您的模块中发生的工作函数的子分类似乎在MAX_NOUTPUT_ITEMS上没有任何限制,该级别默认设置为16384,或者以参数传递的MTU/数据包长度。

需要修改代码以添加此类检查或SET_MAX_NOUTPUT_ITEMS需要基于数据包长度为给定块设置给定块,无论是在使用之前还是在构造函数中,当前默认为默认值为0和0值设置为false的rtl_tcp_source_f block的标志,该块从sync_block继承,该块从块中继承。