aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib')
-rw-r--r--host/lib/usrp/mboard_eeprom.cpp17
-rw-r--r--host/lib/usrp/usrp1/mboard_impl.cpp10
-rw-r--r--host/lib/usrp/usrp1/usrp1_iface.cpp4
-rw-r--r--host/lib/usrp/usrp1/usrp1_iface.hpp3
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.cpp13
-rw-r--r--host/lib/usrp/usrp1/usrp1_impl.hpp2
-rw-r--r--host/lib/usrp/usrp2/usrp2_impl.cpp18
7 files changed, 52 insertions, 15 deletions
diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp
index 81dc6f194..89e83bd56 100644
--- a/host/lib/usrp/mboard_eeprom.cpp
+++ b/host/lib/usrp/mboard_eeprom.cpp
@@ -132,13 +132,20 @@ static void store_nxxx(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
* Implementation of BXXX load/store
**********************************************************************/
static const boost::uint8_t BXXX_EEPROM_ADDR = 0x50;
+static const size_t USB_SERIAL_LEN = 16;
static const uhd::dict<std::string, boost::uint8_t> USRP_BXXX_OFFSETS = boost::assign::map_list_of
- ("serial", 0xf8)
- ("name", 0xf8 + SERIAL_LEN)
+ ("usb-serial", 0xf8)
+ ("serial", 0xf8 + USB_SERIAL_LEN)
+ ("name", 0xf8 + USB_SERIAL_LEN + SERIAL_LEN)
;
static void load_bxxx(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
+ //extract the usb serial
+ mb_eeprom["usb-serial"] = bytes_to_string(iface.read_eeprom(
+ BXXX_EEPROM_ADDR, USRP_BXXX_OFFSETS["usb-serial"], USB_SERIAL_LEN
+ ));
+
//extract the serial
mb_eeprom["serial"] = bytes_to_string(iface.read_eeprom(
BXXX_EEPROM_ADDR, USRP_BXXX_OFFSETS["serial"], SERIAL_LEN
@@ -151,6 +158,12 @@ static void load_bxxx(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
}
static void store_bxxx(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
+ //store the usb serial
+ iface.write_eeprom(
+ BXXX_EEPROM_ADDR, USRP_BXXX_OFFSETS["usb-serial"],
+ string_to_bytes(mb_eeprom["usb-serial"], USB_SERIAL_LEN)
+ );
+
//store the serial
iface.write_eeprom(
BXXX_EEPROM_ADDR, USRP_BXXX_OFFSETS["serial"],
diff --git a/host/lib/usrp/usrp1/mboard_impl.cpp b/host/lib/usrp/usrp1/mboard_impl.cpp
index d7ab46eb1..86f78a7a9 100644
--- a/host/lib/usrp/usrp1/mboard_impl.cpp
+++ b/host/lib/usrp/usrp1/mboard_impl.cpp
@@ -208,8 +208,6 @@ bool usrp1_impl::has_tx_halfband(void){
**********************************************************************/
void usrp1_impl::mboard_init(void)
{
- _mb_eeprom = mboard_eeprom_t(*_iface, mboard_eeprom_t::MAP_BXXX);
-
_mboard_proxy = wax_obj_proxy::make(
boost::bind(&usrp1_impl::mboard_get, this, _1, _2),
boost::bind(&usrp1_impl::mboard_set, this, _1, _2));
@@ -267,7 +265,7 @@ void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val)
//handle the get request conditioned on the key
switch(key.as<mboard_prop_t>()){
case MBOARD_PROP_NAME:
- val = std::string("usrp1 mboard - " + _mb_eeprom["serial"]);
+ val = std::string("usrp1 mboard - " + _iface->mb_eeprom["serial"]);
return;
case MBOARD_PROP_OTHERS:
@@ -325,7 +323,7 @@ void usrp1_impl::mboard_get(const wax::obj &key_, wax::obj &val)
return;
case MBOARD_PROP_EEPROM_MAP:
- val = _mb_eeprom;
+ val = _iface->mb_eeprom;
return;
default: UHD_THROW_PROP_GET_ERROR();
@@ -380,8 +378,8 @@ void usrp1_impl::mboard_set(const wax::obj &key, const wax::obj &val)
return;
case MBOARD_PROP_EEPROM_MAP:
- _mb_eeprom = val.as<mboard_eeprom_t>();
- _mb_eeprom.commit(*_iface, mboard_eeprom_t::MAP_BXXX);
+ _iface->mb_eeprom = val.as<mboard_eeprom_t>();
+ _iface->mb_eeprom.commit(*_iface, mboard_eeprom_t::MAP_BXXX);
return;
default: UHD_THROW_PROP_SET_ERROR();
diff --git a/host/lib/usrp/usrp1/usrp1_iface.cpp b/host/lib/usrp/usrp1/usrp1_iface.cpp
index 64ced2905..dcba3e819 100644
--- a/host/lib/usrp/usrp1/usrp1_iface.cpp
+++ b/host/lib/usrp/usrp1/usrp1_iface.cpp
@@ -25,6 +25,7 @@
#include <iomanip>
using namespace uhd;
+using namespace uhd::usrp;
using namespace uhd::transport;
static const bool iface_debug = false;
@@ -36,7 +37,8 @@ public:
******************************************************************/
usrp1_iface_impl(usrp_ctrl::sptr ctrl_transport)
{
- _ctrl_transport = ctrl_transport;
+ _ctrl_transport = ctrl_transport;
+ mb_eeprom = mboard_eeprom_t(*this, mboard_eeprom_t::MAP_BXXX);
}
~usrp1_iface_impl(void)
diff --git a/host/lib/usrp/usrp1/usrp1_iface.hpp b/host/lib/usrp/usrp1/usrp1_iface.hpp
index 3f608584a..34a2330b5 100644
--- a/host/lib/usrp/usrp1/usrp1_iface.hpp
+++ b/host/lib/usrp/usrp1/usrp1_iface.hpp
@@ -18,6 +18,7 @@
#ifndef INCLUDED_USRP1_IFACE_HPP
#define INCLUDED_USRP1_IFACE_HPP
+#include <uhd/usrp/mboard_eeprom.hpp>
#include <uhd/types/serial.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/utility.hpp>
@@ -81,6 +82,8 @@ public:
boost::uint16_t index,
unsigned char* buff,
boost::uint16_t length) = 0;
+
+ uhd::usrp::mboard_eeprom_t mb_eeprom;
};
#endif /* INCLUDED_USRP1_IFACE_HPP */
diff --git a/host/lib/usrp/usrp1/usrp1_impl.cpp b/host/lib/usrp/usrp1/usrp1_impl.cpp
index bc478c7fb..6016b0979 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.cpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.cpp
@@ -56,6 +56,10 @@ static device_addrs_t usrp1_find(const device_addr_t &hint)
//return an empty list of addresses when type is set to non-usrp1
if (hint.has_key("type") and hint["type"] != "usrp1") return usrp1_addrs;
+ //Return an empty list of addresses when an address is specified,
+ //since an address is intended for a different, non-USB, device.
+ if (hint.has_key("addr")) return usrp1_addrs;
+
//extract the firmware path for the USRP1
std::string usrp1_fw_image;
try{
@@ -89,11 +93,16 @@ static device_addrs_t usrp1_find(const device_addr_t &hint)
pid = USRP1_PRODUCT_ID;
BOOST_FOREACH(usb_device_handle::sptr handle, usb_device_handle::get_device_list(vid, pid)) {
+ usrp1_iface::sptr iface = usrp1_iface::make(usrp_ctrl::make(usb_control::make(handle)));
device_addr_t new_addr;
new_addr["type"] = "usrp1";
+ new_addr["name"] = iface->mb_eeprom["name"];
new_addr["serial"] = handle->get_serial();
- //this is a found usrp1 when a hint serial is not specified or it matches
- if (not hint.has_key("serial") or hint["serial"] == new_addr["serial"]){
+ //this is a found usrp1 when the hint serial and name match or blank
+ if (
+ (not hint.has_key("name") or hint["name"] == new_addr["name"]) and
+ (not hint.has_key("serial") or hint["serial"] == new_addr["serial"])
+ ){
usrp1_addrs.push_back(new_addr);
}
}
diff --git a/host/lib/usrp/usrp1/usrp1_impl.hpp b/host/lib/usrp/usrp1/usrp1_impl.hpp
index 3eb221a52..ff4d40762 100644
--- a/host/lib/usrp/usrp1/usrp1_impl.hpp
+++ b/host/lib/usrp/usrp1/usrp1_impl.hpp
@@ -26,7 +26,6 @@
#include <uhd/types/clock_config.hpp>
#include <uhd/types/stream_cmd.hpp>
#include <uhd/usrp/dboard_id.hpp>
-#include <uhd/usrp/mboard_eeprom.hpp>
#include <uhd/usrp/subdev_spec.hpp>
#include <uhd/usrp/dboard_eeprom.hpp>
#include <uhd/usrp/dboard_manager.hpp>
@@ -159,7 +158,6 @@ private:
void mboard_get(const wax::obj &, wax::obj &);
void mboard_set(const wax::obj &, const wax::obj &);
wax_obj_proxy::sptr _mboard_proxy;
- uhd::usrp::mboard_eeprom_t _mb_eeprom;
//xx dboard functions and settings
void dboard_init(void);
diff --git a/host/lib/usrp/usrp2/usrp2_impl.cpp b/host/lib/usrp/usrp2/usrp2_impl.cpp
index a680708ad..d94a8606e 100644
--- a/host/lib/usrp/usrp2/usrp2_impl.cpp
+++ b/host/lib/usrp/usrp2/usrp2_impl.cpp
@@ -61,7 +61,7 @@ static uhd::device_addrs_t usrp2_find(const device_addr_t &hint){
if (if_addrs.inet == asio::ip::address_v4::loopback().to_string()) continue;
//create a new hint with this broadcast address
- device_addr_t new_hint;
+ device_addr_t new_hint = hint;
new_hint["addr"] = if_addrs.bcast;
//call discover with the new hint and append results
@@ -110,7 +110,21 @@ static uhd::device_addrs_t usrp2_find(const device_addr_t &hint){
device_addr_t new_addr;
new_addr["type"] = "usrp2";
new_addr["addr"] = ip_addr.to_string();
- usrp2_addrs.push_back(new_addr);
+ //Attempt to read the name from the EEPROM and perform filtering.
+ //This operation can throw due to COMPAT mismatch. That is OK.
+ //We will allow the device to be found and the COMPAT mismatch
+ //will be thrown as an exception in the factory function.
+ try{
+ new_addr["name"] = usrp2_iface::make(udp_simple::make_connected(
+ new_addr["addr"], num2str(USRP2_UDP_CTRL_PORT))
+ )->mb_eeprom["name"];
+ if (not hint.has_key("name") or hint["name"] == new_addr["name"]){
+ usrp2_addrs.push_back(new_addr);
+ }
+ }
+ catch(const std::exception &){
+ usrp2_addrs.push_back(new_addr);
+ }
//dont break here, it will exit the while loop
//just continue on to the next loop iteration
}