diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-01-17 10:00:47 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-01-17 10:00:47 -0800 |
commit | 52ca2e0b8045c254c2be1911e77e8bd3d94ceeab (patch) | |
tree | c7e1a93eeadd65bb13db1aa68974da495114f046 /host/lib/usrp/mboard_eeprom.cpp | |
parent | 46febf986ae5e89ebb0c350fd9aa42aaa6383997 (diff) | |
parent | 95ff7e859d57829e428d41d7746e28c228b983ba (diff) | |
download | uhd-52ca2e0b8045c254c2be1911e77e8bd3d94ceeab.tar.gz uhd-52ca2e0b8045c254c2be1911e77e8bd3d94ceeab.tar.bz2 uhd-52ca2e0b8045c254c2be1911e77e8bd3d94ceeab.zip |
Merge branch 'maint'
Diffstat (limited to 'host/lib/usrp/mboard_eeprom.cpp')
-rw-r--r-- | host/lib/usrp/mboard_eeprom.cpp | 72 |
1 files changed, 54 insertions, 18 deletions
diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp index 5c0014a89..0e6cb8574 100644 --- a/host/lib/usrp/mboard_eeprom.cpp +++ b/host/lib/usrp/mboard_eeprom.cpp @@ -235,52 +235,88 @@ struct x300_eeprom_map static void load_x300(mboard_eeprom_t &mb_eeprom, i2c_iface &iface) { + byte_vector_t bytes = iface.read_eeprom(X300_EEPROM_ADDR, 0, sizeof (struct x300_eeprom_map)); + + if (bytes.size() == 0) + { + return; + } + //extract the revision number mb_eeprom["revision"] = uint16_bytes_to_string( - iface.read_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, revision), 2) + byte_vector_t( + bytes.begin() + offsetof(x300_eeprom_map, revision), + bytes.begin() + (offsetof(x300_eeprom_map, revision)+2)) ); //extract the revision compat number mb_eeprom["revision_compat"] = uint16_bytes_to_string( - iface.read_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, revision_compat), 2) + byte_vector_t( + bytes.begin() + offsetof(x300_eeprom_map, revision_compat), + bytes.begin() + (offsetof(x300_eeprom_map, revision_compat)+2)) ); //extract the product code mb_eeprom["product"] = uint16_bytes_to_string( - iface.read_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, product), 2) + byte_vector_t( + bytes.begin() + offsetof(x300_eeprom_map, product), + bytes.begin() + (offsetof(x300_eeprom_map, product)+2)) ); //extract the mac addresses - mb_eeprom["mac-addr0"] = mac_addr_t::from_bytes(iface.read_eeprom( - X300_EEPROM_ADDR, offsetof(x300_eeprom_map, mac_addr0), 6 - )).to_string(); - mb_eeprom["mac-addr1"] = mac_addr_t::from_bytes(iface.read_eeprom( - X300_EEPROM_ADDR, offsetof(x300_eeprom_map, mac_addr1), 6 - )).to_string(); + mb_eeprom["mac-addr0"] = mac_addr_t::from_bytes( + byte_vector_t( + bytes.begin() + offsetof(x300_eeprom_map, mac_addr0), + bytes.begin() + (offsetof(x300_eeprom_map, mac_addr0)+6)) + ).to_string(); + mb_eeprom["mac-addr1"] = mac_addr_t::from_bytes( + byte_vector_t( + bytes.begin() + offsetof(x300_eeprom_map, mac_addr1), + bytes.begin() + (offsetof(x300_eeprom_map, mac_addr1)+6)) + ).to_string(); //extract the ip addresses boost::asio::ip::address_v4::bytes_type ip_addr_bytes; - byte_copy(iface.read_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, gateway), 4), ip_addr_bytes); + byte_copy( + byte_vector_t( + bytes.begin() + offsetof(x300_eeprom_map, gateway), + bytes.begin() + (offsetof(x300_eeprom_map, gateway)+4)), + ip_addr_bytes + ); mb_eeprom["gateway"] = boost::asio::ip::address_v4(ip_addr_bytes).to_string(); for (size_t i = 0; i < 4; i++) { const std::string n(1, i+'0'); - byte_copy(iface.read_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, ip_addr)+(i*4), 4), ip_addr_bytes); + byte_copy( + byte_vector_t( + bytes.begin() + (offsetof(x300_eeprom_map, ip_addr)+(i*4)), + bytes.begin() + (offsetof(x300_eeprom_map, ip_addr)+(i*4)+4)), + ip_addr_bytes + ); mb_eeprom["ip-addr"+n] = boost::asio::ip::address_v4(ip_addr_bytes).to_string(); - byte_copy(iface.read_eeprom(X300_EEPROM_ADDR, offsetof(x300_eeprom_map, subnet)+(i*4), 4), ip_addr_bytes); + byte_copy( + byte_vector_t( + bytes.begin() + (offsetof(x300_eeprom_map, subnet)+(i*4)), + bytes.begin() + (offsetof(x300_eeprom_map, subnet)+(i*4)+4)), + ip_addr_bytes + ); mb_eeprom["subnet"+n] = boost::asio::ip::address_v4(ip_addr_bytes).to_string(); } //extract the serial - mb_eeprom["serial"] = bytes_to_string(iface.read_eeprom( - X300_EEPROM_ADDR, offsetof(x300_eeprom_map, serial), SERIAL_LEN - )); + mb_eeprom["serial"] = bytes_to_string( + byte_vector_t( + bytes.begin() + offsetof(x300_eeprom_map, serial), + bytes.begin() + (offsetof(x300_eeprom_map, serial)+SERIAL_LEN)) + ); //extract the name - mb_eeprom["name"] = bytes_to_string(iface.read_eeprom( - X300_EEPROM_ADDR, offsetof(x300_eeprom_map, name), NAME_MAX_LEN - )); + mb_eeprom["name"] = bytes_to_string( + byte_vector_t( + bytes.begin() + offsetof(x300_eeprom_map, name), + bytes.begin() + (offsetof(x300_eeprom_map, name)+NAME_MAX_LEN)) + ); } static void store_x300(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface) |