aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-01-13 16:02:48 -0800
committerJosh Blum <josh@joshknows.com>2011-01-13 16:02:48 -0800
commitad51739550a6998d9de09460b8d6d8af386ace15 (patch)
treec0b035facc7742e9d6ba6a6a3898dcd09caab162 /host
parent641ab2399a994b6e767985adfbd8f7a916401206 (diff)
downloaduhd-ad51739550a6998d9de09460b8d6d8af386ace15.tar.gz
uhd-ad51739550a6998d9de09460b8d6d8af386ace15.tar.bz2
uhd-ad51739550a6998d9de09460b8d6d8af386ace15.zip
usrp2: use the mac address to determine serial# for older usrp
Diffstat (limited to 'host')
-rw-r--r--host/lib/usrp/mboard_eeprom.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp
index 863a80191..9cc252380 100644
--- a/host/lib/usrp/mboard_eeprom.cpp
+++ b/host/lib/usrp/mboard_eeprom.cpp
@@ -97,8 +97,14 @@ static void load_n100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
N100_EEPROM_ADDR, USRP_N100_OFFSETS["name"], NAME_MAX_LEN
));
- //empty serial correction: use the mac address
- if (mb_eeprom["serial"].empty()) mb_eeprom["serial"] = mb_eeprom["mac-addr"];
+ //Empty serial correction: use the mac address to determine serial.
+ //Older usrp2 models don't have a serial burned into EEPROM.
+ //The lower mac address bits will function as the serial number.
+ if (mb_eeprom["serial"].empty()){
+ byte_vector_t mac_addr_bytes = mac_addr_t::from_string(mb_eeprom["mac-addr"]).to_bytes();
+ unsigned serial = mac_addr_bytes.at(5) | (unsigned(mac_addr_bytes.at(4) & 0x0f) << 8);
+ mb_eeprom["serial"] = boost::lexical_cast<std::string>(serial);
+ }
}
static void store_n100(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){