diff options
author | Ashish Chaudhari <ashish@ettus.com> | 2015-12-15 15:17:36 -0800 |
---|---|---|
committer | Ashish Chaudhari <ashish@ettus.com> | 2015-12-15 15:17:36 -0800 |
commit | f44f7f2ca7dbbd1a72f5b3d239856a1954569884 (patch) | |
tree | 310055d734a28063359b26f7cdc4d4704c517b9e /host/lib/utils/ihex.hpp | |
parent | 75ea07bd6d19494e018cd5c3109e1f85969b7ac6 (diff) | |
parent | 10178875a154e58af6c14774621776d13e7e3daa (diff) | |
download | uhd-f44f7f2ca7dbbd1a72f5b3d239856a1954569884.tar.gz uhd-f44f7f2ca7dbbd1a72f5b3d239856a1954569884.tar.bz2 uhd-f44f7f2ca7dbbd1a72f5b3d239856a1954569884.zip |
Merge branch 'maint'
Conflicts:
host/lib/usrp/b200/b200_impl.hpp
host/lib/usrp/e300/e300_fpga_defs.hpp
host/lib/usrp/x300/x300_fw_common.h
Diffstat (limited to 'host/lib/utils/ihex.hpp')
-rw-r--r-- | host/lib/utils/ihex.hpp | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/host/lib/utils/ihex.hpp b/host/lib/utils/ihex.hpp new file mode 100644 index 000000000..9df1fcbc3 --- /dev/null +++ b/host/lib/utils/ihex.hpp @@ -0,0 +1,79 @@ +// +// Copyright 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 +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see <http://www.gnu.org/licenses/>. +// + +#ifndef INCLUDED_IHEX_READER_HPP +#define INCLUDED_IHEX_READER_HPP + +#include <boost/bind.hpp> +#include <boost/function.hpp> +#include <boost/cstdint.hpp> +#include <string> +#include <vector> + +namespace uhd { + +class ihex_reader +{ +public: + // Arguments are: lower address bits, upper address bits, buff, length + typedef boost::function<int(boost::uint16_t,boost::uint16_t,unsigned char*,boost::uint16_t)> record_handle_type; + + /* + * \param ihex_filename Path to the *.ihx file + */ + ihex_reader(const std::string &ihex_filename); + + /*! Read an Intel HEX file and handle it record by record. + * + * Every record is individually passed off to a record handler function. + * + * \param record_handler The functor that will handle the records. + * + * \throws uhd::io_error if the HEX file is corrupted or unreadable. + */ + void read(record_handle_type record_handler); + + /* Convert the ihex file to a bin file. + * + * *Note:* This function makes the assumption that the hex file is + * contiguous, and starts at address zero. + * + * \param bin_filename Output filename. + * + * \throws uhd::io_error if the HEX file is corrupted or unreadable. + */ + void to_bin_file(const std::string &bin_filename); + + /*! Copy the ihex file into a buffer. + * + * Very similar functionality as to_bin_file(). + * + * *Note:* This function makes the assumption that the hex file is + * contiguous, and starts at address zero. + * + * \throws uhd::io_error if the HEX file is corrupted or unreadable. + */ + std::vector<boost::uint8_t> to_vector(const size_t size_estimate = 0); + +private: + const std::string _ihex_filename; +}; + +}; /* namespace uhd */ + +#endif /* INCLUDED_IHEX_READER_HPP */ + |