diff options
Diffstat (limited to 'lib/device_addr.cpp')
-rw-r--r-- | lib/device_addr.cpp | 60 |
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; } |