Get rid of occsional fails during ETS programming (#200)

- happens just with large applications
- occured mainly on SAMD platform
- new crc16ccitt algorithm without additional buffer
- reorder groupObjTable in memory for less fragmentation

Co-authored-by: Waldemar Porscha <waldemar.porscha@sap.com>
This commit is contained in:
mumpf 2022-04-25 19:27:47 +02:00 committed by GitHub
parent e12a074e07
commit d43703f7bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 15 deletions

View File

@ -23,9 +23,9 @@ BauSystemBDevice::BauSystemBDevice(Platform& platform) :
_transLayer.groupAddressTable(_addrTable);
_memory.addSaveRestore(&_deviceObj);
_memory.addSaveRestore(&_groupObjTable); // changed order for better memory management
_memory.addSaveRestore(&_addrTable);
_memory.addSaveRestore(&_assocTable);
_memory.addSaveRestore(&_groupObjTable);
#ifdef USE_DATASECURE
_memory.addSaveRestore(&_secIfObj);
#endif

View File

@ -125,15 +125,13 @@ uint64_t sixBytesToUInt64(uint8_t* data)
uint16_t crc16Ccitt(uint8_t* input, uint16_t length)
{
uint32_t polynom = 0x1021;
uint8_t padded[length+2];
memcpy(padded, input, length);
memset(padded+length, 0x00, 2);
uint32_t result = 0xffff;
for (uint32_t i = 0; i < 8 * (uint32_t)sizeof(padded); i++) {
for (uint32_t i = 0; i < 8 * ((uint32_t)length + 2); i++)
{
result <<= 1;
uint32_t nextBit = (padded[i / 8] >> (7 - (i % 8))) & 0x1;
uint32_t nextBit;
nextBit = ((i / 8) < length) ? ((input[i / 8] >> (7 - (i % 8))) & 0x1) : 0;
result |= nextBit;
if ((result & 0x10000) != 0)
result ^= polynom;