all parser:

- _raw_data is now filled in configBitstreamParser
- source may be a file or a pipe
- displayHeader become a common method (configBitstreamParser)
- improve/rewrite some parser (efinixHexparser 1s -> 11ms)
This commit is contained in:
Gwenhael Goavec-Merou
2021-02-24 06:36:48 +01:00
parent efbe68c431
commit 16932786db
25 changed files with 370 additions and 341 deletions
+1 -15
View File
@@ -77,14 +77,6 @@ DFUFileParser::DFUFileParser(const string &filename, bool verbose):
_dwCRC(0), _bLength(0)
{}
void DFUFileParser::displayHeader()
{
cout << "bitstream header infos" << endl;
for (auto it = _hdr.begin(); it != _hdr.end(); it++) {
cout << (*it).first << ": " << (*it).second << endl;
}
}
/* USB Device firmware Upgrade Specification, Revision 1.1 B */
/* p.40-47 */
int DFUFileParser::parseHeader()
@@ -140,18 +132,12 @@ int DFUFileParser::parseHeader()
int DFUFileParser::parse()
{
_fd.read((char *)&_raw_data[0], sizeof(char) * _file_size);
if (_fd.gcount() != _file_size) {
printError("Error: fail to read " + _filename);
return EXIT_FAILURE;
}
int ret = parseHeader();
if (ret < 0)
return EXIT_FAILURE;
_bit_data.resize(_file_size - _bLength);
copy(_raw_data.begin(), _raw_data.end() - _bLength, _bit_data.begin());
std::move(_raw_data.begin(), _raw_data.end(), _bit_data.begin());
/* If file contains suffix check CRC */
if (ret != 0) {