我正在设置一个 USRP 以 400MHz 记录并正确接收数据。然后我将 USRP 设置为以 400MHz + 18kHz 偏移量进行录制,然后我在 recv() 命令上出现 TIMEOUT 错误。
我使用与先前频率相同的代码设置新频率,因此这是本示例中唯一改变的地方。
是否需要进行一些清理或保持时间超过 2 秒左右才能达到新的频率?
构造接口类时,我们使用以下行进行初始化
uhd::set_thread_priority_safe();
// Setup device addresses and create object
uhd::device_addr_t devAddr;
devAddr["addr0"] = "192.168.10.2";
devAddr["addr1"] = "192.168.20.2";
devAddr["addr2"] = "192.168.30.2";
m_usrp = uhd::usrp::multi_usrp::make(devAddr);
uhd::usrp::subdev_spec_t rxSpec("A:0");
m_usrp->set_rx_subdev_spec(rxSpec);
m_usrp->set_clock_source("external");
m_usrp->set_time_source("external");
m_usrp->set_rx_rate(m_sampleRate); //Sample rate is 500000
我们使用以下几行准备特定的数据捕获。设置和获取匹配的小数点有一点差异。
uhd::stream_args_t streamArgs("fc32");
for (size_t chan = 0; chan < m_usrp->get_rx_num_channels(); chan++)
{
streamArgs.channels.push_back(chan);
}
m_rxStreamer = m_usrp->get_rx_stream(streamArgs);
m_usrp->set_rx_gain(m_gainChannel1, 0); // All gains set to 31.5
m_usrp->set_rx_gain(m_gainChannel2, 1);
m_usrp->set_rx_gain(m_gainChannel3, 2);
uhd::time_spec_t cmdTime = m_usrp->get_time_now() + uhd::time_spec_t(1.0);
m_usrp->set_command_time(cmdTime);
m_usrp->set_rx_freq(m_freqChannel1 - CENTER_FREQ_OFFSET_HZ, 0); // Freq is 400000000 and CENTER_FREQ is 100000
m_usrp->set_rx_freq(m_freqChannel2 - CENTER_FREQ_OFFSET_HZ, 1);
m_usrp->set_rx_freq(m_freqChannel3 - CENTER_FREQ_OFFSET_HZ, 2);
m_usrp->clear_command_time();
sleep(1);
double actualChannel0Freq = m_usrp->get_rx_freq(0);
double actualChannel1Freq = m_usrp->get_rx_freq(1);
double actualChannel2Freq = m_usrp->get_rx_freq(2);
LOG(INFO) << "Acutal tuned USRP frequencies " << std::fixed << actualChannel0Freq << " " << actualChannel1Freq << " " << actualChannel2Freq;
何时开始使用以下方法获取数据:
uhd::rx_metadata_t md;
double timeout = 5.0;
size_t samplesRxThisTime = m_rxStreamer->recv(buffPtrs, sampsThisTime, md, timeout);
// Smaller timeout for subsequent packets
timeout = 0.75;
// Handle any error codes
if (md.error_code == uhd::rx_metadata_t::ERROR_CODE_TIMEOUT)
{
LOG(ERROR) << "Timed out while receiving data from USRPs";
break;
}
我原以为稍微改变频率不会引起问题。原始频率有效……更新后的频率无效。