aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--host/examples/rx_timed_samples.cpp9
-rw-r--r--host/include/uhd/types/device_addr.hpp20
-rw-r--r--host/include/uhd/usrp/simple_usrp.hpp47
-rw-r--r--host/lib/types.cpp46
-rw-r--r--host/lib/usrp/simple_usrp.cpp39
-rw-r--r--host/test/addr_test.cpp2
-rw-r--r--host/utils/uhd_find_devices.cpp14
7 files changed, 116 insertions, 61 deletions
diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp
index d49f7d182..4b8774036 100644
--- a/host/examples/rx_timed_samples.cpp
+++ b/host/examples/rx_timed_samples.cpp
@@ -26,7 +26,7 @@ namespace po = boost::program_options;
int UHD_SAFE_MAIN(int argc, char *argv[]){
//variables to be set by po
- std::string transport_args;
+ std::string args;
int seconds_in_future;
size_t total_num_samps;
double rx_rate;
@@ -35,7 +35,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
po::options_description desc("Allowed options");
desc.add_options()
("help", "help message")
- ("args", po::value<std::string>(&transport_args)->default_value(""), "simple uhd transport args")
+ ("args", po::value<std::string>(&args)->default_value(""), "simple uhd device address args")
("secs", po::value<int>(&seconds_in_future)->default_value(3), "number of seconds in the future to receive")
("nsamps", po::value<size_t>(&total_num_samps)->default_value(1000), "total number of samples to receive")
("rxrate", po::value<double>(&rx_rate)->default_value(100e6/16), "rate of incoming samples")
@@ -52,9 +52,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
//create a usrp device
std::cout << std::endl;
- std::cout << boost::format("Creating the usrp device with: %s...")
- % transport_args << std::endl;
- uhd::usrp::simple_usrp::sptr sdev = uhd::usrp::simple_usrp::make(transport_args);
+ std::cout << boost::format("Creating the usrp device with: %s...") % args << std::endl;
+ uhd::usrp::simple_usrp::sptr sdev = uhd::usrp::simple_usrp::make(args);
uhd::device::sptr dev = sdev->get_device();
std::cout << boost::format("Using Device: %s") % sdev->get_name() << std::endl;
diff --git a/host/include/uhd/types/device_addr.hpp b/host/include/uhd/types/device_addr.hpp
index f5dd9371c..e8da2a1ab 100644
--- a/host/include/uhd/types/device_addr.hpp
+++ b/host/include/uhd/types/device_addr.hpp
@@ -32,13 +32,23 @@ namespace uhd{
*
* To narrow down the discovery process to a particular device,
* specify a transport key/value pair specific to your device.
- * Ex, to find a usrp2: my_dev_addr["addr"] = [resolvable_hostname_or_ip]
+ * - Ex, to find a usrp2: my_dev_addr["addr"] = [resolvable_hostname_or_ip]
*
* The device address can also be used to pass arguments into
* the transport layer control to set (for example) buffer sizes.
+ *
+ * An arguments string, is a way to represent a device address
+ * using a single string with delimiter characters.
+ * - Ex: addr=192.168.10.2
+ * - Ex: addr=192.168.10.2, rx_buff_size=1e6
*/
class UHD_API device_addr_t : public dict<std::string, std::string>{
public:
+ /*!
+ * Create a device address from an args string.
+ * \param args the arguments string
+ */
+ device_addr_t(const std::string &args = "");
/*!
* Convert a device address into a printable string.
@@ -52,14 +62,6 @@ namespace uhd{
* \return a string with delimiter markup
*/
std::string to_args_str(void) const;
-
- /*!
- * Make a device address from an args string.
- * The args string contains delimiter symbols.
- * \param args_str the arguments string
- * \return the new device address
- */
- static device_addr_t from_args_str(const std::string &args_str);
};
//handy typedef for a vector of device addresses
diff --git a/host/include/uhd/usrp/simple_usrp.hpp b/host/include/uhd/usrp/simple_usrp.hpp
index c4e0338f7..e3f181ec3 100644
--- a/host/include/uhd/usrp/simple_usrp.hpp
+++ b/host/include/uhd/usrp/simple_usrp.hpp
@@ -39,18 +39,63 @@ namespace uhd{ namespace usrp{
class UHD_API simple_usrp : boost::noncopyable{
public:
typedef boost::shared_ptr<simple_usrp> sptr;
- static sptr make(const std::string &args);
+ /*!
+ * Make a new simple usrp from the device address.
+ * \param dev_addr the device address
+ * \return a new simple usrp object
+ */
+ static sptr make(const device_addr_t &dev_addr);
+
+ /*!
+ * Get the underlying device object.
+ * This is needed to get access to the streaming API and properties.
+ * \return the device object within this simple usrp
+ */
virtual device::sptr get_device(void) = 0;
+ /*!
+ * Get a printable name for this simple usrp.
+ * \return a printable string
+ */
virtual std::string get_name(void) = 0;
/*******************************************************************
* Misc
******************************************************************/
+ /*!
+ * Sets the time registers on the usrp immediately.
+ * \param time_spec the time to latch into the usrp device
+ */
virtual void set_time_now(const time_spec_t &time_spec) = 0;
+
+ /*!
+ * Set the time registers on the usrp at the next pps tick.
+ * The values will not be latched in until the pulse occurs.
+ * It is recommended that the user sleep(1) after calling to ensure
+ * that the time registers will be in a known state prior to use.
+ *
+ * Note: Because this call sets the time on the "next" pps,
+ * the seconds in the time spec should be current seconds + 1.
+ *
+ * \param time_spec the time to latch into the usrp device
+ */
virtual void set_time_next_pps(const time_spec_t &time_spec) = 0;
+
+ /*!
+ * Issue a stream command to the usrp device.
+ * This tells the usrp to send samples into the host.
+ * See the documentation for stream_cmd_t for more info.
+ * \param stream_cmd the stream command to issue
+ */
virtual void issue_stream_cmd(const stream_cmd_t &stream_cmd) = 0;
+
+ /*!
+ * Set the clock configuration for the usrp device.
+ * This tells the usrp how to get a 10Mhz reference and PPS clock.
+ * See the documentation for clock_config_t for more info.
+ * \param clock_config the clock configuration to set
+ */
virtual void set_clock_config(const clock_config_t &clock_config) = 0;
/*******************************************************************
diff --git a/host/lib/types.cpp b/host/lib/types.cpp
index 2a687f34f..91887840c 100644
--- a/host/lib/types.cpp
+++ b/host/lib/types.cpp
@@ -119,46 +119,44 @@ void time_spec_t::set_ticks(boost::uint32_t ticks, double tick_rate){
/***********************************************************************
* device addr
**********************************************************************/
-std::string device_addr_t::to_string(void) const{
- std::stringstream ss;
- BOOST_FOREACH(std::string key, this->keys()){
- ss << boost::format("%s: %s") % key % (*this)[key] << std::endl;
- }
- return ss.str();
-}
-
-static const std::string arg_delim = ";";
+static const std::string arg_delim = ",";
static const std::string pair_delim = "=";
static std::string trim(const std::string &in){
return boost::algorithm::trim_copy(in);
}
-std::string device_addr_t::to_args_str(void) const{
- std::string args_str;
- BOOST_FOREACH(const std::string &key, this->keys()){
- args_str += key + pair_delim + (*this)[key] + arg_delim;
- }
- return args_str;
-}
-
-device_addr_t device_addr_t::from_args_str(const std::string &args_str){
- device_addr_t addr;
-
+device_addr_t::device_addr_t(const std::string &args){
//split the args at the semi-colons
std::vector<std::string> pairs;
- boost::split(pairs, args_str, boost::is_any_of(arg_delim));
+ boost::split(pairs, args, boost::is_any_of(arg_delim));
BOOST_FOREACH(const std::string &pair, pairs){
if (trim(pair) == "") continue;
//split the key value pairs at the equals
std::vector<std::string> key_val;
boost::split(key_val, pair, boost::is_any_of(pair_delim));
- if (key_val.size() != 2) throw std::runtime_error("invalid args string: "+args_str);
- addr[trim(key_val[0])] = trim(key_val[1]);
+ if (key_val.size() != 2) throw std::runtime_error("invalid args string: "+args);
+ (*this)[trim(key_val[0])] = trim(key_val[1]);
}
+}
+
+std::string device_addr_t::to_string(void) const{
+ if (this->size() == 0) return "Empty Device Address";
+
+ std::stringstream ss;
+ BOOST_FOREACH(std::string key, this->keys()){
+ ss << boost::format("%s: %s") % key % (*this)[key] << std::endl;
+ }
+ return ss.str();
+}
- return addr;
+std::string device_addr_t::to_args_str(void) const{
+ std::string args_str;
+ BOOST_FOREACH(const std::string &key, this->keys()){
+ args_str += key + pair_delim + (*this)[key] + arg_delim;
+ }
+ return args_str;
}
/***********************************************************************
diff --git a/host/lib/usrp/simple_usrp.cpp b/host/lib/usrp/simple_usrp.cpp
index 11ee3a798..321d66a4a 100644
--- a/host/lib/usrp/simple_usrp.cpp
+++ b/host/lib/usrp/simple_usrp.cpp
@@ -42,14 +42,14 @@ public:
_tx_dsp = _mboard[MBOARD_PROP_TX_DSP];
//extract rx subdevice
- wax::obj rx_dboard = _mboard[MBOARD_PROP_RX_DBOARD];
- std::string rx_subdev_in_use = rx_dboard[DBOARD_PROP_USED_SUBDEVS].as<prop_names_t>().at(0);
- _rx_subdev = rx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, rx_subdev_in_use)];
+ _rx_dboard = _mboard[MBOARD_PROP_RX_DBOARD];
+ std::string rx_subdev_in_use = _rx_dboard[DBOARD_PROP_USED_SUBDEVS].as<prop_names_t>().at(0);
+ _rx_subdev = _rx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, rx_subdev_in_use)];
//extract tx subdevice
- wax::obj tx_dboard = _mboard[MBOARD_PROP_TX_DBOARD];
- std::string tx_subdev_in_use = tx_dboard[DBOARD_PROP_USED_SUBDEVS].as<prop_names_t>().at(0);
- _tx_subdev = tx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, tx_subdev_in_use)];
+ _tx_dboard = _mboard[MBOARD_PROP_TX_DBOARD];
+ std::string tx_subdev_in_use = _tx_dboard[DBOARD_PROP_USED_SUBDEVS].as<prop_names_t>().at(0);
+ _tx_subdev = _tx_dboard[named_prop_t(DBOARD_PROP_SUBDEV, tx_subdev_in_use)];
}
~simple_usrp_impl(void){
@@ -61,7 +61,26 @@ public:
}
std::string get_name(void){
- return _mboard[MBOARD_PROP_NAME].as<std::string>();
+ return str(boost::format(
+ "Simple USRP:\n"
+ " Device: %s\n"
+ " Mboard: %s\n"
+ " RX DSP: %s\n"
+ " RX Dboard: %s\n"
+ " RX Subdev: %s\n"
+ " TX DSP: %s\n"
+ " TX Dboard: %s\n"
+ " TX Subdev: %s\n"
+ )
+ % (*_dev)[DEVICE_PROP_NAME].as<std::string>()
+ % _mboard[MBOARD_PROP_NAME].as<std::string>()
+ % _rx_dsp[DSP_PROP_NAME].as<std::string>()
+ % _rx_dboard[DBOARD_PROP_NAME].as<std::string>()
+ % _rx_subdev[SUBDEV_PROP_NAME].as<std::string>()
+ % _tx_dsp[DSP_PROP_NAME].as<std::string>()
+ % _tx_dboard[DBOARD_PROP_NAME].as<std::string>()
+ % _tx_subdev[SUBDEV_PROP_NAME].as<std::string>()
+ );
}
/*******************************************************************
@@ -174,6 +193,8 @@ private:
wax::obj _mboard;
wax::obj _rx_dsp;
wax::obj _tx_dsp;
+ wax::obj _rx_dboard;
+ wax::obj _tx_dboard;
wax::obj _rx_subdev;
wax::obj _tx_subdev;
};
@@ -181,6 +202,6 @@ private:
/***********************************************************************
* The Make Function
**********************************************************************/
-simple_usrp::sptr simple_usrp::make(const std::string &args){
- return sptr(new simple_usrp_impl(device_addr_t::from_args_str(args)));
+simple_usrp::sptr simple_usrp::make(const device_addr_t &dev_addr){
+ return sptr(new simple_usrp_impl(dev_addr));
}
diff --git a/host/test/addr_test.cpp b/host/test/addr_test.cpp
index 2ec6de14b..93b7cc0df 100644
--- a/host/test/addr_test.cpp
+++ b/host/test/addr_test.cpp
@@ -44,7 +44,7 @@ BOOST_AUTO_TEST_CASE(test_device_addr){
std::cout << "Pretty Print: " << std::endl << dev_addr.to_string();
std::string args_str = dev_addr.to_args_str();
std::cout << "Args String: " << args_str << std::endl;
- uhd::device_addr_t new_dev_addr = uhd::device_addr_t::from_args_str(args_str);
+ uhd::device_addr_t new_dev_addr(args_str);
//they should be the same size
BOOST_CHECK_EQUAL(dev_addr.size(), new_dev_addr.size());
diff --git a/host/utils/uhd_find_devices.cpp b/host/utils/uhd_find_devices.cpp
index 6c945cbca..8222dc1f4 100644
--- a/host/utils/uhd_find_devices.cpp
+++ b/host/utils/uhd_find_devices.cpp
@@ -27,8 +27,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
po::options_description desc("Allowed options");
desc.add_options()
("help", "help message")
- ("addr", po::value<std::string>(), "resolvable network address")
- ("node", po::value<std::string>(), "path to linux device node")
+ ("args", po::value<std::string>()->default_value(""), "device address args")
;
po::variables_map vm;
@@ -41,17 +40,8 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
return ~0;
}
- //load the options into the address
- uhd::device_addr_t device_addr;
- if (vm.count("addr")){
- device_addr["addr"] = vm["addr"].as<std::string>();
- }
- if (vm.count("node")){
- device_addr["node"] = vm["node"].as<std::string>();
- }
-
//discover the usrps and print the results
- uhd::device_addrs_t device_addrs = uhd::device::find(device_addr);
+ uhd::device_addrs_t device_addrs = uhd::device::find(vm["args"].as<std::string>());
if (device_addrs.size() == 0){
std::cerr << "No UHD Devices Found" << std::endl;