diff options
Diffstat (limited to 'host/lib/usrp')
-rw-r--r-- | host/lib/usrp/dboard_eeprom.cpp | 21 | ||||
-rw-r--r-- | host/lib/usrp/dboard_manager.cpp | 5 | ||||
-rw-r--r-- | host/lib/usrp/usrp2/dboard_impl.cpp | 2 |
3 files changed, 21 insertions, 7 deletions
diff --git a/host/lib/usrp/dboard_eeprom.cpp b/host/lib/usrp/dboard_eeprom.cpp index 5ce0b2328..00236c337 100644 --- a/host/lib/usrp/dboard_eeprom.cpp +++ b/host/lib/usrp/dboard_eeprom.cpp @@ -17,10 +17,14 @@ #include <uhd/usrp/dboard_eeprom.hpp> #include <uhd/utils/assert.hpp> +#include <boost/format.hpp> +#include <iostream> using namespace uhd; using namespace uhd::usrp; +static const bool _dboard_eeprom_debug = false; + //////////////////////////////////////////////////////////////////////// // format of daughterboard EEPROM // 00: 0xDB code for ``I'm a daughterboard'' @@ -55,14 +59,23 @@ using namespace uhd::usrp; //negative sum of bytes excluding checksum byte static boost::uint8_t checksum(const byte_vector_t &bytes){ - int sum; - for (size_t i = 0; i < DB_EEPROM_CHKSUM; i++){ - sum += int(bytes.at(i)); + int sum = 0; + for (size_t i = 0; i < std::min(bytes.size(), size_t(DB_EEPROM_CHKSUM)); i++){ + sum -= int(bytes.at(i)); } - return (-sum) & 0xff; + if (_dboard_eeprom_debug) + std::cout << boost::format("sum: 0x%02x") % sum << std::endl; + return boost::uint8_t(sum); } dboard_eeprom_t::dboard_eeprom_t(const byte_vector_t &bytes){ + if (_dboard_eeprom_debug){ + for (size_t i = 0; i < bytes.size(); i++){ + std::cout << boost::format( + "eeprom byte[0x%02x] = 0x%02x") % i % int(bytes.at(i) + ) << std::endl; + } + } try{ ASSERT_THROW(bytes.size() >= DB_EEPROM_CLEN); ASSERT_THROW(bytes[DB_EEPROM_MAGIC] == DB_EEPROM_MAGIC_VALUE); diff --git a/host/lib/usrp/dboard_manager.cpp b/host/lib/usrp/dboard_manager.cpp index 06f8c55b6..34b635934 100644 --- a/host/lib/usrp/dboard_manager.cpp +++ b/host/lib/usrp/dboard_manager.cpp @@ -177,10 +177,11 @@ static args_t get_dboard_args( //verify that there is a registered constructor for this id if (not get_id_to_args_map().has_key(dboard_id)){ - throw std::runtime_error(str( + /*throw std::runtime_error(str( boost::format("Unregistered %s dboard id: %s") % xx_type % dboard_id::to_string(dboard_id) - )); + ));*/ + return get_dboard_args(dboard_id::NONE, xx_type); } //return the dboard args for this id diff --git a/host/lib/usrp/usrp2/dboard_impl.cpp b/host/lib/usrp/usrp2/dboard_impl.cpp index 043609458..a68ae240e 100644 --- a/host/lib/usrp/usrp2/dboard_impl.cpp +++ b/host/lib/usrp/usrp2/dboard_impl.cpp @@ -136,7 +136,7 @@ void usrp2_impl::rx_dboard_set(const wax::obj &key, const wax::obj &val){ case DBOARD_PROP_DBOARD_ID: _rx_db_eeprom.id = val.as<dboard_id_t>(); - _iface->write_eeprom(I2C_ADDR_RX_DB, 0, _tx_db_eeprom.get_eeprom_bytes()); + _iface->write_eeprom(I2C_ADDR_RX_DB, 0, _rx_db_eeprom.get_eeprom_bytes()); return; default: UHD_THROW_PROP_READ_ONLY(); |