本文整理汇总了C++中uhd::usrp::multi_usrp::sptr::get_rx_freq方法的典型用法代码示例。如果您正苦于以下问题:C++ sptr::get_rx_freq方法的具体用法?C++ sptr::get_rx_freq怎么用?C++ sptr::get_rx_freq使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uhd::usrp::multi_usrp::sptr
的用法示例。
在下文中一共展示了sptr::get_rx_freq方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 rx_lo_freq, const double tx_offset)
{
//tune the receiver with no cordic
uhd::tune_request_t rx_tune_req(rx_lo_freq);
rx_tune_req.dsp_freq_policy = uhd::tune_request_t::POLICY_MANUAL;
rx_tune_req.dsp_freq = 0;
usrp->set_rx_freq(rx_tune_req);
//tune the transmitter
double tx_freq = usrp->get_rx_freq() + tx_offset;
double min_fe_tx_freq = usrp->get_fe_tx_freq_range().start();
double max_fe_tx_freq = usrp->get_fe_tx_freq_range().stop();
uhd::tune_request_t tx_tune_req(tx_freq);
tx_tune_req.dsp_freq_policy = uhd::tune_request_t::POLICY_MANUAL;
tx_tune_req.dsp_freq = 0;
if (tx_freq < min_fe_tx_freq)
tx_tune_req.dsp_freq = tx_freq - min_fe_tx_freq;
else if (tx_freq > max_fe_tx_freq)
tx_tune_req.dsp_freq = tx_freq - max_fe_tx_freq;
usrp->set_tx_freq(tx_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_rx_freq();
}
示例2: setRxFreq
bool uhd_device::setRxFreq(double wFreq)
{
uhd::tune_result_t tr = usrp_dev->set_rx_freq(wFreq);
LOG(INFO) << "\n" << tr.to_pp_string();
rx_freq = usrp_dev->get_rx_freq();
return true;
}
示例3: set_optimal_rx_gain
/***********************************************************************
* Function to find optimal RX gain setting (for the current frequency)
**********************************************************************/
UHD_INLINE void set_optimal_rx_gain(
uhd::usrp::multi_usrp::sptr usrp,
uhd::rx_streamer::sptr rx_stream,
double wave_freq = 0.0)
{
const double gain_step = 3.0;
const double gain_compression_threshold = gain_step * 0.5;
const double actual_rx_rate = usrp->get_rx_rate();
const double actual_tx_freq = usrp->get_tx_freq();
const double actual_rx_freq = usrp->get_rx_freq();
const double bb_tone_freq = actual_tx_freq - actual_rx_freq + wave_freq;
const size_t nsamps = size_t(actual_rx_rate / default_fft_bin_size);
std::vector<samp_type> buff(nsamps);
uhd::gain_range_t rx_gain_range = usrp->get_rx_gain_range();
double rx_gain = rx_gain_range.start() + gain_step;
double curr_dbrms = 0.0;
double prev_dbrms = 0.0;
double delta = 0.0;
// No sense in setting the gain where this is no gain range
if (rx_gain_range.stop() - rx_gain_range.start() < gain_step)
return;
// The algorithm below cycles through the RX gain range
// looking for the point where the signal begins to get
// clipped and the gain begins to be compressed. It does
// this by looking for the gain setting where the increase
// in the tone is less than the gain step by more than the
// gain compression threshold (curr - prev < gain - threshold).
// Initialize prev_dbrms value
usrp->set_rx_gain(rx_gain);
capture_samples(usrp, rx_stream, buff, nsamps);
prev_dbrms = compute_tone_dbrms(buff, bb_tone_freq/actual_rx_rate);
rx_gain += gain_step;
// Find RX gain where signal begins to clip
while (rx_gain <= rx_gain_range.stop())
{
usrp->set_rx_gain(rx_gain);
capture_samples(usrp, rx_stream, buff, nsamps);
curr_dbrms = compute_tone_dbrms(buff, bb_tone_freq/actual_rx_rate);
delta = curr_dbrms - prev_dbrms;
// check if the gain is compressed beyone the threshold
if (delta < gain_step - gain_compression_threshold)
break; // if so, we are done
prev_dbrms = curr_dbrms;
rx_gain += gain_step;
}
// The rx_gain value at this point is the gain setting where clipping
// occurs or the gain setting that is just beyond the gain range.
// The gain is reduced by 2 steps to make sure it is within the range and
// under the point where it is clipped with enough room to make adjustments.
rx_gain -= 2 * gain_step;
// Make sure the gain is within the range.
rx_gain = rx_gain_range.clip(rx_gain);
// Finally, set the gain.
usrp->set_rx_gain(rx_gain);
}
示例4: 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;
}
示例5: get_rx_parameters
void get_rx_parameters(uhd::usrp::multi_usrp::sptr usrp, size_t mboard , std::ostream & os)
{
using namespace std;
namespace radio = uhd::usrp;
size_t nchan = 0;
// Get sub device specification
os << std::endl << "********** RX Sub Device ***********" << std::endl;
os << std::endl << "-----> Get Rx Subdevice" << std::endl;
radio::subdev_spec_t rx_subdev = usrp->get_rx_subdev_spec(mboard);
os << "RX Subdevice Specification:" << endl;
os << rx_subdev.to_pp_string() << endl;
os << std::endl << "-----> Get number of RX channels" << std::endl;
size_t num_rx = usrp->get_rx_num_channels();
os << "Number of RX channels:" << endl;
os << num_rx << endl;
os << std::endl << "-----> Get RX Subdevice Name" << std::endl;
string rx_name = usrp->get_rx_subdev_name(nchan);
os << "RX Subdevice Name:" << endl;
os << rx_name << endl;
os << std::endl << "********** RX Sample Rate ***********" << std::endl;
os << std::endl << "-----> Get RX Rate" << std::endl;
double rx_rate = usrp->get_rx_rate(nchan);
os << "RX Rate:" << endl;
os << rx_rate << endl;
os << std::endl << "-----> Get RX Rate List" << std::endl;
uhd::meta_range_t rx_rates = usrp->get_rx_rates(nchan);
os << "RX Rate List:" << endl;
os << "Start: " << rx_rates.start() << " Stop: " << rx_rates.stop() << " Step: " << rx_rates.step() << endl;
os << rx_rates.to_pp_string() << endl;
// RX FREQUENCIES
os << std::endl << "********** RX Frequencies ***********" << std::endl;
os << std::endl << "-----> Get RX Center Frequency" << std::endl;
double rx_freq = usrp->get_rx_freq(nchan);
os << "RX Freq:" << endl;
os << rx_freq << endl;
os << std::endl << "-----> Get RX Center Frequency Range" << std::endl;
uhd::freq_range_t rx_freq_range = usrp->get_rx_freq_range(nchan);
os << "RX Frequency Range:" << endl;
os << "Start: " << rx_freq_range.start() << " Stop: " << rx_freq_range.stop() << " Step: " << rx_freq_range.step() << endl;
os << rx_freq_range.to_pp_string() << endl;
// RX Front end frequencies
os << std::endl << "-----> Get RX RF Front End Center Frequency Range" << std::endl;
try
{
os << "RX Front End Frequency Range:" << endl;
uhd::freq_range_t rx_fe_freq_range = usrp->get_fe_rx_freq_range(nchan);
os << "Start: " << rx_fe_freq_range.start() << " Stop: " << rx_fe_freq_range.stop() << " Step: " << rx_fe_freq_range.step() << endl;
os << rx_fe_freq_range.to_pp_string() << endl;
}
catch (uhd::runtime_error &e)
{
os << " Exception occurred : " << e.code() << endl;
}
// RX GAIN
os << std::endl << "********** RX Gain ***********" << std::endl;
// Total combined gain
os << endl << "-----> Get RX Total Gain" << endl;
os << "RX Total Gain: " ;
try
{
double rx_total_gain = usrp->get_rx_gain(nchan);
os << rx_total_gain << endl;
}
catch(uhd::runtime_error &e)
{
os << "Exception code: " << e.code() << endl;
}
// List of all gain elements
os << std::endl << "-----> Get RX gain names" << std::endl;
std::vector<std::string> rx_gain_names = usrp->get_rx_gain_names(nchan);
os << "Rx Gain Names: " << std::endl;
for (int index =0; index < rx_gain_names.size(); index++)
{
// Name
os << "\t" << rx_gain_names[index] << endl;
}
for (int index =0; index < rx_gain_names.size(); index++)
{
// Name
os << "\t" << "Name: " << rx_gain_names[index] << " Value: ";
// Value
try
{
double element_gain = usrp->get_rx_gain(rx_gain_names[index], nchan);
os << element_gain << endl;
}
catch(uhd::runtime_error &e)
//.........这里部分代码省略.........