summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/examples/rx_ascii_art_dft.cpp53
-rw-r--r--host/lib/device.cpp7
-rw-r--r--host/lib/usrp/dboard/db_xcvr2450.cpp2
-rw-r--r--host/utils/usrp1_init_eeprom.cpp6
4 files changed, 55 insertions, 13 deletions
diff --git a/host/examples/rx_ascii_art_dft.cpp b/host/examples/rx_ascii_art_dft.cpp
index c407ecf91..fa8c4d4a4 100644
--- a/host/examples/rx_ascii_art_dft.cpp
+++ b/host/examples/rx_ascii_art_dft.cpp
@@ -32,9 +32,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
uhd::set_thread_priority_safe();
//variables to be set by po
- std::string args;
+ std::string args, ant, subdev;
size_t num_bins;
- double rate, freq, gain, frame_rate;
+ double rate, freq, gain, bw, frame_rate;
float ref_lvl, dyn_rng;
//setup the program options
@@ -44,8 +44,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
("args", po::value<std::string>(&args)->default_value(""), "multi uhd device address args")
// hardware parameters
("rate", po::value<double>(&rate), "rate of incoming samples (sps)")
- ("freq", po::value<double>(&freq)->default_value(0), "RF center frequency in Hz")
- ("gain", po::value<double>(&gain)->default_value(0), "gain for the RF chain")
+ ("freq", po::value<double>(&freq), "RF center frequency in Hz")
+ ("gain", po::value<double>(&gain), "gain for the RF chain")
+ ("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")
// display parameters
("num-bins", po::value<size_t>(&num_bins)->default_value(512), "the number of bins in the DFT")
("frame-rate", po::value<double>(&frame_rate)->default_value(5), "frame rate of the display (fps)")
@@ -66,22 +69,48 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
std::cout << std::endl;
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);
+
+ //always select the subdevice first, the channel mapping affects the other settings
+ if (vm.count("subdev")) usrp->set_rx_subdev_spec(subdev);
+
std::cout << boost::format("Using Device: %s") % usrp->get_pp_string() << std::endl;
- //set the rx sample rate
+ //set the sample rate
+ if (not vm.count("rate")){
+ std::cerr << "Please specify the sample rate with --rate" << std::endl;
+ return ~0;
+ }
std::cout << boost::format("Setting RX Rate: %f Msps...") % (rate/1e6) << std::endl;
usrp->set_rx_rate(rate);
std::cout << boost::format("Actual RX Rate: %f Msps...") % (usrp->get_rx_rate()/1e6) << std::endl << std::endl;
- //set the rx center frequency
- std::cout << boost::format("Setting RX Freq: %f Mhz...") % (freq/1e6) << std::endl;
+ //set the center frequency
+ if (not vm.count("freq")){
+ std::cerr << "Please specify the center frequency with --freq" << std::endl;
+ return ~0;
+ }
+ std::cout << boost::format("Setting RX Freq: %f MHz...") % (freq/1e6) << std::endl;
usrp->set_rx_freq(freq);
- std::cout << boost::format("Actual RX Freq: %f Mhz...") % (usrp->get_rx_freq()/1e6) << std::endl << std::endl;
+ std::cout << boost::format("Actual RX Freq: %f MHz...") % (usrp->get_rx_freq()/1e6) << std::endl << std::endl;
+
+ //set the rf gain
+ if (vm.count("gain")){
+ std::cout << boost::format("Setting RX Gain: %f dB...") % gain << std::endl;
+ usrp->set_rx_gain(gain);
+ std::cout << boost::format("Actual RX Gain: %f dB...") % usrp->get_rx_gain() << std::endl << std::endl;
+ }
+
+ //set the IF filter bandwidth
+ if (vm.count("bw")){
+ std::cout << boost::format("Setting RX Bandwidth: %f MHz...") % bw << std::endl;
+ usrp->set_rx_bandwidth(bw);
+ std::cout << boost::format("Actual RX Bandwidth: %f MHz...") % usrp->get_rx_bandwidth() << std::endl << std::endl;
+ }
+
+ //set the antenna
+ if (vm.count("ant")) usrp->set_rx_antenna(ant);
- //set the rx rf gain
- std::cout << boost::format("Setting RX Gain: %f dB...") % gain << std::endl;
- usrp->set_rx_gain(gain);
- std::cout << boost::format("Actual RX Gain: %f dB...") % usrp->get_rx_gain() << std::endl << std::endl;
+ boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for some setup time
//allocate recv buffer and metatdata
uhd::rx_metadata_t md;
diff --git a/host/lib/device.cpp b/host/lib/device.cpp
index 1b3daa103..b2b0238d2 100644
--- a/host/lib/device.cpp
+++ b/host/lib/device.cpp
@@ -25,10 +25,13 @@
#include <boost/weak_ptr.hpp>
#include <boost/functional/hash.hpp>
#include <boost/tuple/tuple.hpp>
+#include <boost/thread/mutex.hpp>
#include <iostream>
using namespace uhd;
+static boost::mutex _device_mutex;
+
/***********************************************************************
* Helper Functions
**********************************************************************/
@@ -70,6 +73,8 @@ void device::register_device(
* Discover
**********************************************************************/
device_addrs_t device::find(const device_addr_t &hint){
+ boost::mutex::scoped_lock lock(_device_mutex);
+
device_addrs_t device_addrs;
BOOST_FOREACH(const dev_fcn_reg_t &fcn, get_dev_fcn_regs()){
@@ -93,6 +98,8 @@ device_addrs_t device::find(const device_addr_t &hint){
* Make
**********************************************************************/
device::sptr device::make(const device_addr_t &hint, size_t which){
+ boost::mutex::scoped_lock lock(_device_mutex);
+
typedef boost::tuple<device_addr_t, make_t> dev_addr_make_t;
std::vector<dev_addr_make_t> dev_addr_makers;
diff --git a/host/lib/usrp/dboard/db_xcvr2450.cpp b/host/lib/usrp/dboard/db_xcvr2450.cpp
index 70b0bbabd..45f600569 100644
--- a/host/lib/usrp/dboard/db_xcvr2450.cpp
+++ b/host/lib/usrp/dboard/db_xcvr2450.cpp
@@ -153,7 +153,7 @@ private:
*/
double get_rssi(void){
//*FIXME* RSSI depends on LNA Gain Setting (datasheet pg 16 top middle chart)
- double max_power;
+ double max_power = 0.0;
switch(_max2829_regs.rx_lna_gain){
case 0:
case 1: max_power = 0; break;
diff --git a/host/utils/usrp1_init_eeprom.cpp b/host/utils/usrp1_init_eeprom.cpp
index b05e400b1..39f091af4 100644
--- a/host/utils/usrp1_init_eeprom.cpp
+++ b/host/utils/usrp1_init_eeprom.cpp
@@ -21,6 +21,7 @@
#include <boost/program_options.hpp>
#include <boost/format.hpp>
#include <iostream>
+#include <cstdlib>
namespace po = boost::program_options;
@@ -41,6 +42,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
return ~0;
}
+ //cant find a uninitialized usrp with this mystery module in the way...
+ if (std::system("/sbin/rmmod usbtest") != 0){
+ std::cerr << "Did not rmmod usbtest, this may be ok..." << std::endl;
+ }
+
//load the options into the address
uhd::device_addr_t device_addr;
device_addr["type"] = "usrp1";