aboutsummaryrefslogtreecommitdiffstats
path: root/host/examples/rx_samples_to_file.cpp
diff options
context:
space:
mode:
authorJason Abele <jason@ettus.com>2011-09-16 10:47:54 -0700
committerJosh Blum <josh@joshknows.com>2011-09-21 16:03:46 -0700
commit539c9b5a5560ea5d79c78954ea8e482846a5e966 (patch)
treea577fc45164ff61f539231cf88c5a2560dc62638 /host/examples/rx_samples_to_file.cpp
parent42c7aaa480548716d211c3dcdd2ced1d3c79b510 (diff)
downloaduhd-539c9b5a5560ea5d79c78954ea8e482846a5e966.tar.gz
uhd-539c9b5a5560ea5d79c78954ea8e482846a5e966.tar.bz2
uhd-539c9b5a5560ea5d79c78954ea8e482846a5e966.zip
Updates to example apps
Add --ref option to specify mboard clock reference source Add check for lock to mboard clock reference (where applicable) Add check of daughterboard LO lock detect (where applicable)
Diffstat (limited to 'host/examples/rx_samples_to_file.cpp')
-rw-r--r--host/examples/rx_samples_to_file.cpp38
1 files changed, 37 insertions, 1 deletions
diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp
index d44315701..05d9b15b7 100644
--- a/host/examples/rx_samples_to_file.cpp
+++ b/host/examples/rx_samples_to_file.cpp
@@ -18,6 +18,7 @@
#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/safe_main.hpp>
#include <uhd/usrp/multi_usrp.hpp>
+#include <uhd/exception.hpp>
#include <boost/program_options.hpp>
#include <boost/format.hpp>
#include <boost/thread.hpp>
@@ -64,7 +65,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
uhd::set_thread_priority_safe();
//variables to be set by po
- std::string args, file, type, ant, subdev;
+ std::string args, file, type, ant, subdev, ref;
size_t total_num_samps, spb;
double rate, freq, gain, bw;
@@ -83,6 +84,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
("ant", po::value<std::string>(&ant), "daughterboard antenna selection")
("subdev", po::value<std::string>(&subdev), "daughterboard subdevice specification")
("bw", po::value<double>(&bw), "daughterboard IF filter bandwidth in Hz")
+ ("ref", po::value<std::string>(&ref)->default_value("INTERNAL"), "waveform type (INTERNAL, EXTERNAL, MIMO)")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
@@ -99,6 +101,20 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl;
uhd::usrp::multi_usrp::sptr usrp = uhd::usrp::multi_usrp::make(args);
+ //Lock mboard clocks
+ if (ref == "MIMO") {
+ uhd::clock_config_t clock_config;
+ clock_config.ref_source = uhd::clock_config_t::REF_MIMO;
+ clock_config.pps_source = uhd::clock_config_t::PPS_MIMO;
+ usrp->set_clock_config(clock_config, 0);
+ }
+ else if (ref == "EXTERNAL") {
+ usrp->set_clock_config(uhd::clock_config_t::external(), 0);
+ }
+ else if (ref == "INTERNAL") {
+ usrp->set_clock_config(uhd::clock_config_t::internal(), 0);
+ }
+
//always select the subdevice first, the channel mapping affects the other settings
if (vm.count("subdev")) usrp->set_rx_subdev_spec(subdev);
@@ -141,6 +157,26 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for some setup time
+ //Check Ref and LO Lock detect
+ std::vector<std::string> sensor_names;
+ sensor_names = usrp->get_rx_sensor_names(0);
+ if (std::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);
+ std::cout << boost::format("Checking RX: %s ...") % lo_locked.to_pp_string() << std::endl;
+ UHD_ASSERT_THROW(lo_locked.to_bool());
+ }
+ sensor_names = usrp->get_mboard_sensor_names(0);
+ if ((ref == "MIMO") and (std::find(sensor_names.begin(), sensor_names.end(), "mimo_locked") != sensor_names.end())) {
+ uhd::sensor_value_t mimo_locked = usrp->get_mboard_sensor("mimo_locked",0);
+ std::cout << boost::format("Checking RX: %s ...") % mimo_locked.to_pp_string() << std::endl;
+ UHD_ASSERT_THROW(mimo_locked.to_bool());
+ }
+ if ((ref == "EXTERNAL") and (std::find(sensor_names.begin(), sensor_names.end(), "ref_locked") != sensor_names.end())) {
+ uhd::sensor_value_t ref_locked = usrp->get_mboard_sensor("ref_locked",0);
+ std::cout << boost::format("Checking RX: %s ...") % ref_locked.to_pp_string() << std::endl;
+ UHD_ASSERT_THROW(ref_locked.to_bool());
+ }
+
//setup streaming
uhd::stream_cmd_t stream_cmd((total_num_samps == 0)?
uhd::stream_cmd_t::STREAM_MODE_START_CONTINUOUS: