Improve firmware parser and tool robustness

closes #241
This commit is contained in:
joevt 2021-10-07 18:51:39 +03:00 committed by vit9696
parent e14547c497
commit f9c35f77a6
41 changed files with 415 additions and 324 deletions

View file

@ -64,7 +64,7 @@ public:
}
UByteArray left(int32_t len) const { return d.substr(0, len); }
UByteArray right(int32_t len) const { return d.substr(d.size() - 1 - len, len); }
UByteArray right(int32_t len) const { return d.substr(d.size() - len, len); }
UByteArray mid(int32_t pos, int32_t len = -1) const { return d.substr(pos, len); }
UByteArray & operator=(const UByteArray & ba) { d = ba.d; return *this; }
@ -77,12 +77,11 @@ public:
for (int32_t i = 0; i < size(); i++) {
uint8_t low = d[i] & 0x0F;
uint8_t high = (d[i] & 0xF0) >> 4;
low += (low < 10 ? '0' : 'a');
high += (high < 10 ? '0' : 'a');
hex[2*i] = low;
hex[2*i + 1] = high;
low += (low < 10 ? '0' : 'a' - 10);
high += (high < 10 ? '0' : 'a' - 10);
hex[2*i] = high;
hex[2*i + 1] = low;
}
std::reverse(hex.begin(), hex.end());
return UByteArray(hex);
}