aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/mboard_eeprom.cpp
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-02-22 10:19:09 -0800
committerJosh Blum <josh@joshknows.com>2011-02-22 10:19:09 -0800
commit814a5c40c6fbaedba3dafabbe30d00a05af6a274 (patch)
tree79bd05d506e6e0366c729b56cc3b37d734a0aebe /host/lib/usrp/mboard_eeprom.cpp
parenta8bb5ec900d8f2d3d2f274a921d19b564c668323 (diff)
downloaduhd-814a5c40c6fbaedba3dafabbe30d00a05af6a274.tar.gz
uhd-814a5c40c6fbaedba3dafabbe30d00a05af6a274.tar.bz2
uhd-814a5c40c6fbaedba3dafabbe30d00a05af6a274.zip
uhd: added 9 byte serial to dboard eeprom class
Diffstat (limited to 'host/lib/usrp/mboard_eeprom.cpp')
-rw-r--r--host/lib/usrp/mboard_eeprom.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp
index f7f4b2c68..c90f4a2db 100644
--- a/host/lib/usrp/mboard_eeprom.cpp
+++ b/host/lib/usrp/mboard_eeprom.cpp
@@ -17,12 +17,12 @@
#include <uhd/usrp/mboard_eeprom.hpp>
#include <uhd/types/mac_addr.hpp>
-#include <uhd/utils/algorithm.hpp>
#include <uhd/utils/byteswap.hpp>
#include <boost/asio/ip/address_v4.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/foreach.hpp>
+#include <algorithm>
#include <cstddef>
using namespace uhd;
@@ -38,6 +38,12 @@ static const size_t NAME_MAX_LEN = 32 - SERIAL_LEN;
* Utility functions
**********************************************************************/
+//! A wrapper around std::copy that takes ranges instead of iterators.
+template<typename RangeSrc, typename RangeDst> inline
+void byte_copy(const RangeSrc &src, RangeDst &dst){
+ std::copy(boost::begin(src), boost::end(src), boost::begin(dst));
+}
+
//! create a string from a byte vector, return empty if invalid ascii
static const std::string bytes_to_string(const byte_vector_t &bytes){
std::string out;
@@ -84,7 +90,7 @@ static void load_n100(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
)).to_string();
boost::asio::ip::address_v4::bytes_type ip_addr_bytes;
- std::copy(iface.read_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["ip-addr"], 4), ip_addr_bytes);
+ byte_copy(iface.read_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["ip-addr"], 4), ip_addr_bytes);
mb_eeprom["ip-addr"] = boost::asio::ip::address_v4(ip_addr_bytes).to_string();
//extract the serial
@@ -126,7 +132,7 @@ static void store_n100(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
if (mb_eeprom.has_key("ip-addr")){
byte_vector_t ip_addr_bytes(4);
- std::copy(boost::asio::ip::address_v4::from_string(mb_eeprom["ip-addr"]).to_bytes(), ip_addr_bytes);
+ byte_copy(boost::asio::ip::address_v4::from_string(mb_eeprom["ip-addr"]).to_bytes(), ip_addr_bytes);
iface.write_eeprom(N100_EEPROM_ADDR, USRP_N100_OFFSETS["ip-addr"], ip_addr_bytes);
}