aboutsummaryrefslogtreecommitdiffstats
path: root/lib/device_addr.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2010-02-12 18:07:55 -0800
committerJosh Blum <josh@joshknows.com>2010-02-12 18:07:55 -0800
commit9fff25f4e5da179ea29ff44278e0415a337870cb (patch)
treecfbee4cf2921fd4bd415e3af1c1d466f79bab3d7 /lib/device_addr.cpp
parent350f5c5decca20a54132867283448fd32226bbc2 (diff)
downloaduhd-9fff25f4e5da179ea29ff44278e0415a337870cb.tar.gz
uhd-9fff25f4e5da179ea29ff44278e0415a337870cb.tar.bz2
uhd-9fff25f4e5da179ea29ff44278e0415a337870cb.zip
Added a templated dictionary class because its more useful than map.
Made the device addrs into a string:string dict. If its all strings we dont have to change the top level caller for new product. Created shared_iovec class to manage memory for device recvs. Work on the bro/dude control protocol for usrp2.
Diffstat (limited to 'lib/device_addr.cpp')
-rw-r--r--lib/device_addr.cpp60
1 files changed, 9 insertions, 51 deletions
diff --git a/lib/device_addr.cpp b/lib/device_addr.cpp
index ee6dbbbc8..ffd511f92 100644
--- a/lib/device_addr.cpp
+++ b/lib/device_addr.cpp
@@ -21,6 +21,7 @@
#include <stdexcept>
#include <boost/format.hpp>
#include <boost/algorithm/string.hpp>
+#include <boost/foreach.hpp>
//----------------------- u2 mac addr wrapper ------------------------//
uhd::mac_addr_t::mac_addr_t(const std::string &mac_addr_str_){
@@ -71,58 +72,15 @@ std::ostream& operator<<(std::ostream &os, const uhd::mac_addr_t &x){
}
//----------------------- usrp device_addr_t wrapper -------------------------//
-uhd::device_addr_t::device_addr_t(device_addr_type_t device_addr_type){
- type = device_addr_type;
- virtual_args.num_rx_dsps = 0;
- virtual_args.num_tx_dsps = 0;
- virtual_args.num_dboards = 0;
- usb_args.vendor_id = 0xffff;
- usb_args.product_id = 0xffff;
- eth_args.ifc = "eth0";
- eth_args.mac_addr = "";
- udp_args.addr = "";
- discovery_args.mboard_id = ~0;
-}
-
-std::string uhd::device_addr_t::to_string(void) const{
- std::ostringstream out;
- out << "USRP Type: ";
- switch(type){
- case DEVICE_ADDR_TYPE_AUTO:
- out << "Automatic" << std::endl;
- break;
- case DEVICE_ADDR_TYPE_VIRTUAL:
- out << "Virtual" << std::endl;
- out << "Num RX DSPs: " << virtual_args.num_rx_dsps << std::endl;
- out << "Num TX DSPs: " << virtual_args.num_rx_dsps << std::endl;
- out << "Num dboards: " << virtual_args.num_dboards << std::endl;
- break;
- case DEVICE_ADDR_TYPE_USB:
- out << "USB Port" << std::endl;
- out << "Vendor ID: 0x" << std::hex << usb_args.vendor_id << std::endl;
- out << "Product ID: 0x" << std::hex << usb_args.product_id << std::endl;
- break;
- case DEVICE_ADDR_TYPE_ETH:
- out << "Raw Ethernet" << std::endl;
- out << "Interface: " << eth_args.ifc << std::endl;
- out << "MAC Addr: " << eth_args.mac_addr << std::endl;
- break;
- case DEVICE_ADDR_TYPE_UDP:
- out << "UDP Socket" << std::endl;
- out << "Address: " << udp_args.addr << std::endl;
- break;
- case DEVICE_ADDR_TYPE_GPMC:
- out << "GPMC" << std::endl;
- break;
- default:
- out << "Unknown" << std::endl;
+std::string uhd::device_addr_to_string(const uhd::device_addr_t &device_addr){
+ std::stringstream ss;
+ BOOST_FOREACH(std::string key, device_addr.get_keys()){
+ ss << boost::format("%s: %s") % key % device_addr[key] << std::endl;
}
- out << std::endl;
- return out.str();
+ return ss.str();
}
-std::ostream& operator<<(std::ostream &os, const uhd::device_addr_t &x)
-{
- os << x.to_string();
- return os;
+std::ostream& operator<<(std::ostream &os, const uhd::device_addr_t &device_addr){
+ os << uhd::device_addr_to_string(device_addr);
+ return os;
}