本文整理汇总了C++中uhd::usrp::multi_usrp::sptr::get_rx_sensor方法的典型用法代码示例。如果您正苦于以下问题:C++ sptr::get_rx_sensor方法的具体用法?C++ sptr::get_rx_sensor怎么用?C++ sptr::get_rx_sensor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uhd::usrp::multi_usrp::sptr
的用法示例。
在下文中一共展示了sptr::get_rx_sensor方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tune_rx_and_tx
/***********************************************************************
* Tune RX and TX routine
**********************************************************************/
static double tune_rx_and_tx(uhd::usrp::multi_usrp::sptr usrp, const double tx_lo_freq, const double rx_offset)
{
//tune the transmitter with no cordic
uhd::tune_request_t tx_tune_req(tx_lo_freq);
tx_tune_req.dsp_freq_policy = uhd::tune_request_t::POLICY_MANUAL;
tx_tune_req.dsp_freq = 0;
usrp->set_tx_freq(tx_tune_req);
//tune the receiver
double rx_freq = usrp->get_tx_freq() - rx_offset;
double min_fe_rx_freq = usrp->get_fe_rx_freq_range().start();
double max_fe_rx_freq = usrp->get_fe_rx_freq_range().stop();
uhd::tune_request_t rx_tune_req(rx_freq);
rx_tune_req.dsp_freq_policy = uhd::tune_request_t::POLICY_MANUAL;
rx_tune_req.dsp_freq = 0;
if (rx_freq < min_fe_rx_freq)
rx_tune_req.dsp_freq = rx_freq - min_fe_rx_freq;
else if (rx_freq > max_fe_rx_freq)
rx_tune_req.dsp_freq = rx_freq - max_fe_rx_freq;
usrp->set_rx_freq(rx_tune_req);
//wait for the LOs to become locked
boost::this_thread::sleep(boost::posix_time::milliseconds(50));
boost::system_time start = boost::get_system_time();
while (not usrp->get_tx_sensor("lo_locked").to_bool() or not usrp->get_rx_sensor("lo_locked").to_bool())
{
if (boost::get_system_time() > start + boost::posix_time::milliseconds(100))
throw std::runtime_error("timed out waiting for TX and/or RX LO to lock");
}
return usrp->get_tx_freq();
}
示例2: wait_for_lo_lock
void wait_for_lo_lock(uhd::usrp::multi_usrp::sptr usrp)
{
std::this_thread::sleep_for(std::chrono::milliseconds(50));
const auto timeout =
std::chrono::steady_clock::now() + std::chrono::milliseconds(100);
while (not usrp->get_tx_sensor("lo_locked").to_bool()
or not usrp->get_rx_sensor("lo_locked").to_bool()) {
if (std::chrono::steady_clock::now() > timeout) {
throw std::runtime_error(
"timed out waiting for TX and/or RX LO to lock");
}
}
}
示例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;
}
示例4: get_rx_parameters
//.........这里部分代码省略.........
try
{
os << endl << "-----> Get RX Total Gain Range" << endl;
uhd::gain_range_t rx_total_gain_range = usrp->get_rx_gain_range(nchan);
os << "RX Total Gain Range: " ;
os << "Start: " << rx_total_gain_range.start() << " End: " << rx_total_gain_range.stop() << " Step: " << rx_total_gain_range.step() << endl;
}
catch(uhd::runtime_error &e)
{
os << "Exception code: " << e.code() <<endl;
}
// ANTENNA FUNCTIONS
os << std::endl << "********** RX ANTENNA ***********" << std::endl;
// Current Rx Antenna
os << std::endl << "-----> Get RX Antenna" << std::endl;
string rx_antenna = usrp->get_rx_antenna(nchan);
os << "RX Antenna: " ;
os << rx_antenna << endl;
// RX Antenna choices
os << std::endl << "-----> Get Rx Antenna List" << std::endl;
std::vector<std::string> rx_antennas = usrp->get_rx_antennas(nchan);
os << "RX Antennas : " << std::endl;
for (int index =0; index < rx_antennas.size(); index++)
os << "\t" << rx_antennas[index] << std::endl;
// RX BANDWIDTH FUNCTIONS
os << std::endl << "********** RX BANDWIDTH ***********" << std::endl;
// Current RX Bandwidth
os << endl << "-----> Get RX Bandwidth" << endl;
try
{
os << "RX Bandwidth " ;
double rx_bandwidth = usrp->get_rx_bandwidth(nchan);
os << rx_bandwidth << endl;
}
catch (uhd::runtime_error &e)
{
os << "Exception occured " << e.code() << endl;
}
// RX Bandwidth Range
os << endl << "-----> Get RX Bandwidth Range" << endl;
try
{
os << "RX Bandwidth Range: " ;
uhd::gain_range_t rx_bandwidth_range = usrp->get_rx_bandwidth_range(nchan);
os << "Start: " << rx_bandwidth_range .start() << " End: " << rx_bandwidth_range .stop() << " Step: " << rx_bandwidth_range .step() << endl;
}
catch(uhd::runtime_error &e)
{
os << "Exception code: " << e.code() <<endl;
}
// RX DBOARD INTERFACE OBJECT
os << std::endl << "********** RX DBOARD INTERFACE ***********" << std::endl;
// RX Dboard Interface
os << endl << "-----> Get rx_dboard_iface()" << endl;
try
{
os << "RX Dboard Interface " ;
uhd::usrp::dboard_iface::sptr rx_dboard_iface = usrp->get_rx_dboard_iface(nchan);
os << rx_dboard_iface << endl;
}
catch (uhd::runtime_error &e)
{
os << "Exception occured " << e.code() << endl;
}
// RX _SENSORS
os << std::endl << "********** RX Sensors ***********" << std::endl;
// List of all available sensors
os << std::endl << "-----> Get RX Sensors Name" << std::endl;
std::vector<std::string> rx_sensor_names = usrp->get_rx_sensor_names(nchan);
os << "Sensor Names: " << std::endl;
for (int index =0; index < rx_sensor_names.size(); index++)
{
// Name
os << "\t" << rx_sensor_names[index] << ": ";
// Value
try
{
uhd::sensor_value_t rx_sensor_value = usrp->get_rx_sensor(rx_sensor_names[index], nchan);
os << rx_sensor_value.to_pp_string()<< std::endl;
}
catch(uhd::runtime_error &e)
{
os << "Exception occured " << e.code() << endl;
}
}
}