本文整理汇总了C++中uhd::usrp::multi_usrp::sptr::set_clock_source方法的典型用法代码示例。如果您正苦于以下问题:C++ sptr::set_clock_source方法的具体用法?C++ sptr::set_clock_source怎么用?C++ sptr::set_clock_source使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uhd::usrp::multi_usrp::sptr
的用法示例。
在下文中一共展示了sptr::set_clock_source方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set_ref_clk
void uhd_device::set_ref_clk(bool ext_clk)
{
if (ext_clk)
usrp_dev->set_clock_source("external");
return;
}
示例2: Uhd
Uhd(const std::vector<size_t> channels, const double tx_rate, const double tx_center_freq, const double tx_gain)
{
uhd::set_thread_priority_safe();
for(const auto ch : channels)
{
usrp = uhd::usrp::multi_usrp::make(std::string(""));
usrp->set_clock_source("internal");
usrp->set_tx_rate(tx_rate, ch);
usrp->set_tx_freq(uhd::tune_request_t(tx_center_freq), ch);
usrp->set_tx_gain(tx_gain, ch);
}
usrp->set_time_now(uhd::time_spec_t(0.0));
}
示例3: setupUSRP
int setupUSRP( uhd::usrp::multi_usrp::sptr& usrp,
const float center_freq,
const float sample_rate,
const int rx_gain,
const char* dev_addr)
{
//Initialize the USRP to the specified address
usrp = uhd::usrp::multi_usrp::make(string(dev_addr));
//Define the clock reference
usrp->set_clock_source(__USRP_CLK_SRC);
//Output some useful information
cout << "Using the following USRP device: " << endl
<< usrp->get_pp_string() << endl;
//Try setting the sample rate. If the rate we get is not the same as the
//requested rate, we will return with a warning to ensure the user is aware
//of the actual sample rate
usrp->set_rx_rate( sample_rate );
if( usrp->get_rx_rate() != sample_rate )
{
ios_base::fmtflags originalFlags = cout.flags();
cout.setf(ios_base::left,ios_base::floatfield);
cout.precision(15);
cout << "WARNING! Requested rate = " << sample_rate << endl
<< "WARNING! Actual rate = " << usrp->get_rx_rate() << endl;
cout.setf(originalFlags);
}
//Try setting the center frequency. Like above, if we get a different
//frequency than the one we're requesting, we will spit out a warning for the
//user
usrp->set_rx_freq( center_freq );
if( usrp->get_rx_freq() != center_freq )
{
ios_base::fmtflags originalFlags = cout.flags();
cout.setf(ios_base::left,ios_base::floatfield);
cout.precision(15);
cout << "WARNING! Requested frequency = " << center_freq << endl
<< "WARNING! Actual frequency = " << usrp->get_rx_freq() << endl;
cout.setf(originalFlags);
}
//Set the RX gain. There really shouldn't be any problems here, but the user
//might request something silly like 50dB of gain when the module can't
//accomodate. So we'll perform a similar check here.
usrp->set_rx_gain( rx_gain );
if( usrp->get_rx_gain() != rx_gain )
{
cout << "WARNING! Requested gain = " << rx_gain << endl
<< "WARNING! Actual gain = " << usrp->get_rx_gain() << endl;
}
//Ensure the LO locked
vector<string> sensor_names;
sensor_names = usrp->get_rx_sensor_names(0);
if( find(sensor_names.begin(), sensor_names.end(), "lo_locked")
!= sensor_names.end() )
{
uhd::sensor_value_t lo_locked = usrp->get_rx_sensor("lo_locked",0);
cout << "Checking RX: " << endl
<< lo_locked.to_pp_string() << endl;
UHD_ASSERT_THROW(lo_locked.to_bool()); //We should probably catch this
}
return 1;
}