diff options
author | Nicholas Corgan <nick.corgan@ettus.com> | 2015-12-14 07:27:38 -0800 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2015-12-14 13:26:45 -0800 |
commit | 373fec2fb177c50b40733445633a10b01fe62cc5 (patch) | |
tree | 6b5a4fdd025b08a66ad4d673d34137ef330e1125 /host/lib/usrp_clock/octoclock | |
parent | 87860fc3226c8915cb45a4fc39d5e64bf667470d (diff) | |
download | uhd-373fec2fb177c50b40733445633a10b01fe62cc5.tar.gz uhd-373fec2fb177c50b40733445633a10b01fe62cc5.tar.bz2 uhd-373fec2fb177c50b40733445633a10b01fe62cc5.zip |
ihex: Windows fixes
Diffstat (limited to 'host/lib/usrp_clock/octoclock')
-rw-r--r-- | host/lib/usrp_clock/octoclock/octoclock_image_loader.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/host/lib/usrp_clock/octoclock/octoclock_image_loader.cpp b/host/lib/usrp_clock/octoclock/octoclock_image_loader.cpp index 1d4699f54..fdb254024 100644 --- a/host/lib/usrp_clock/octoclock/octoclock_image_loader.cpp +++ b/host/lib/usrp_clock/octoclock/octoclock_image_loader.cpp @@ -79,20 +79,18 @@ static void octoclock_calculate_crc(octoclock_session_t &session){ static void octoclock_read_bin(octoclock_session_t &session) { - std::ifstream bin_file(session.image_filepath.c_str()); + std::ifstream bin_file(session.image_filepath.c_str(), std::ios::in | std::ios::binary); if (not bin_file.is_open()) { throw uhd::io_error("Could not read image file."); } size_t filesize = fs::file_size(session.image_filepath); session.image.clear(); - session.image.reserve(filesize); - - std::copy( - std::istream_iterator<boost::uint8_t>(bin_file), - std::istream_iterator<boost::uint8_t>(), - std::back_inserter(session.image) - ); + session.image.resize(filesize); + bin_file.read((char*)&session.image[0], filesize); + if(size_t(bin_file.gcount()) != filesize) { + throw uhd::io_error("Failed to read firmware image."); + } bin_file.close(); } @@ -111,7 +109,8 @@ static void octoclock_validate_firmware_image(octoclock_session_t &session){ ihex_reader hex_reader(session.image_filepath); session.image = hex_reader.to_vector(OCTOCLOCK_FIRMWARE_MAX_SIZE_BYTES); } - else throw uhd::runtime_error(str(boost::format("Invalid extension \"%s\". Extension must be .hex or .bin."))); + else throw uhd::runtime_error(str(boost::format("Invalid extension \"%s\". Extension must be .hex or .bin.") + % extension)); if(session.image.size() > OCTOCLOCK_FIRMWARE_MAX_SIZE_BYTES){ throw uhd::runtime_error(str(boost::format("The specified firmware image is too large: %d vs. %d") |