diff options
author | Nicholas Corgan <nick.corgan@ettus.com> | 2015-03-26 08:54:57 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2015-03-27 14:44:26 -0700 |
commit | 988c597026551dfcfbb60aaf32d291bb90d0ce93 (patch) | |
tree | a6495faf47016d5cdd829ea85bf1320941533c88 /host/lib/usrp/mboard_eeprom.cpp | |
parent | 715f4dd313656f936e40b6415179b7ab6feda128 (diff) | |
download | uhd-988c597026551dfcfbb60aaf32d291bb90d0ce93.tar.gz uhd-988c597026551dfcfbb60aaf32d291bb90d0ce93.tar.bz2 uhd-988c597026551dfcfbb60aaf32d291bb90d0ce93.zip |
Consolidated byte_vector common code into single file
Diffstat (limited to 'host/lib/usrp/mboard_eeprom.cpp')
-rw-r--r-- | host/lib/usrp/mboard_eeprom.cpp | 29 |
1 files changed, 2 insertions, 27 deletions
diff --git a/host/lib/usrp/mboard_eeprom.cpp b/host/lib/usrp/mboard_eeprom.cpp index 68c084589..9c92fe252 100644 --- a/host/lib/usrp/mboard_eeprom.cpp +++ b/host/lib/usrp/mboard_eeprom.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010-2013 Ettus Research LLC +// Copyright 2010-2013,2015 Ettus Research LLC // // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by @@ -16,6 +16,7 @@ // #include <uhd/usrp/mboard_eeprom.hpp> +#include <uhd/types/byte_vector.hpp> #include <uhd/types/mac_addr.hpp> #include <uhd/utils/byteswap.hpp> #include <boost/asio/ip/address_v4.hpp> @@ -39,32 +40,6 @@ 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; - BOOST_FOREACH(boost::uint8_t byte, bytes){ - if (byte < 32 or byte > 127) return out; - out += byte; - } - return out; -} - -//! create a byte vector from a string, null terminate unless max length -static const byte_vector_t string_to_bytes(const std::string &string, size_t max_length){ - byte_vector_t bytes; - for (size_t i = 0; i < std::min(string.size(), max_length); i++){ - bytes.push_back(string[i]); - } - if (bytes.size() < max_length - 1) bytes.push_back('\0'); - return bytes; -} - //! convert a string to a byte vector to write to eeprom static byte_vector_t string_to_uint16_bytes(const std::string &num_str){ const boost::uint16_t num = boost::lexical_cast<boost::uint16_t>(num_str); |