3#ifndef IMT_BASE_LIB_SRECCONVERTER_SRECCONVERTER_H
4#define IMT_BASE_LIB_SRECCONVERTER_SRECCONVERTER_H
16namespace srecconverter {
38 bool convert(std::string
const& fileName);
74 enum class RecordType :
uint8_t {
77 Record_Data_2Byte = 1,
78 Record_Data_3Byte = 2,
79 Record_Data_4Byte = 3,
89 static uint32_t const MAX_PRG_DATA_LEN {16U};
92 struct SingleLineDataRecord {
96 std::array<uint8_t, MAX_PRG_DATA_LEN> m_data;
105 bool readFileAndFillSingleLinesToList(std::string
const& fileName);
112 bool createSingleLineRecord(std::vector<std::string>& fileSingleLineDataList);
119 bool createDataRecords(std::vector<SingleLineDataRecord>& singleLineDataRecordList);
126 void createPageNumberList(
uint32_t const pageSizeKb, std::vector<DataRecord>& dataRecordList);
131 bool isFlashSizeValid()
const;
137 static RecordType getRecordType(std::string
const& line);
142 static void fillProgramData(std::string
const& line,
uint32_t const length,
uint8_t*
const pData);
147 static uint32_t getInt(std::string
const& str);
149 static constexpr uint32_t RECORD_TYPE_INDEX {1U};
150 static constexpr uint32_t RECORD_TYPE_LEN {1U};
151 static constexpr uint32_t DATA_LENGTH_INDEX {RECORD_TYPE_INDEX + RECORD_TYPE_LEN};
152 static constexpr uint32_t DATA_LENGTH_LEN {2U};
153 static constexpr uint32_t ADDRESS_INDEX {DATA_LENGTH_INDEX + DATA_LENGTH_LEN};
154 static constexpr uint32_t ADDRESS_LEN {8U};
155 static constexpr uint32_t DATA_INDEX {ADDRESS_INDEX + ADDRESS_LEN};
156 static constexpr uint32_t ADDRESS_SIZE {4U};
157 static constexpr uint32_t CHECKSUM_SIZE {1U};
159 static constexpr uint32_t FLASH_START_ADDRESS {0x08000000U};
160 static constexpr uint32_t BYTES_PER_KILOBYTE {1024U};
164 std::vector<std::string> m_fileSingleLineDataList;
165 std::vector<SingleLineDataRecord> m_singleLineDataRecordList;
166 std::vector<DataRecord> m_dataRecordList;
167 std::vector<uint8_t> m_pageNumberList;
The SRecConverter is used to read a Motorola srecord binary file.
bool convert(std::string const &fileName)
Converts the srecord.
DataRecord const * getDataRecord(uint32_t const recordNr) const
Gets the data of a single record.
uint32_t getDataSize() const
Returns the data size of program or eeprom data in bytes.
std::vector< uint8_t > getPageNumberList() const
Returns the page number list.
SRecConverter(uint32_t const pageSizeKb, uint32_t const flashSizeKb)
Constructor.
uint32_t getRecordCount() const
Returns the number of records.
uint8_t getPageCount() const
Returns the number of pages (1kB || 2kB) containing in Motorola srecord file.
This is a application specific file which is used to configure Imt.Base.Core.Math.
unsigned __int16 uint16_t
unsigned __int32 uint32_t
static constexpr uint16_t MAX_RECORD_SIZE
Maximal record size in bytes.