mirror of
https://github.com/thelsing/knx.git
synced 2025-09-18 17:52:44 +02:00
fix segment size in TableObject()
* save size after TableObject::allocTable() is called. Also change save() and restore() to save _size to flash. Modify saveSize() * use _size to calculate crc value in CallbackProperty
This commit is contained in:
parent
1cadc320a5
commit
0fb3c704dc
@ -31,6 +31,8 @@ uint8_t* TableObject::save(uint8_t* buffer)
|
||||
{
|
||||
buffer = pushByte(_state, buffer);
|
||||
|
||||
buffer = pushInt(_size, buffer);
|
||||
|
||||
if (_data)
|
||||
buffer = pushInt(_memory.toRelative(_data), buffer);
|
||||
else
|
||||
@ -46,6 +48,8 @@ const uint8_t* TableObject::restore(const uint8_t* buffer)
|
||||
buffer = popByte(state, buffer);
|
||||
_state = (LoadState)state;
|
||||
|
||||
buffer = popInt(_size, buffer);
|
||||
|
||||
uint32_t relativeAddress = 0;
|
||||
buffer = popInt(relativeAddress, buffer);
|
||||
|
||||
@ -80,6 +84,8 @@ bool TableObject::allocTable(uint32_t size, bool doFill, uint8_t fillByte)
|
||||
if (doFill)
|
||||
memset(_data, fillByte, size);
|
||||
|
||||
_size = size;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -229,7 +235,7 @@ void TableObject::errorCode(ErrorCode errorCode)
|
||||
|
||||
uint16_t TableObject::saveSize()
|
||||
{
|
||||
return 5 + InterfaceObject::saveSize();
|
||||
return 5 + InterfaceObject::saveSize() + sizeof(_size);
|
||||
}
|
||||
|
||||
void TableObject::initializeProperties(size_t propertiesSize, Property** properties)
|
||||
@ -272,13 +278,13 @@ void TableObject::initializeProperties(size_t propertiesSize, Property** propert
|
||||
if (obj->_state != LS_LOADED)
|
||||
return 0; // need to check return code for invalid
|
||||
|
||||
uint32_t segmentSize = obj->saveSize();
|
||||
uint32_t segmentSize = obj->_size;
|
||||
uint16_t crc16 = crc16Ccitt(obj->data(), segmentSize);
|
||||
|
||||
pushInt(segmentSize, data); // Segment size
|
||||
pushByte(0x00, data + 4); // CRC control byte -> 0: always valid
|
||||
pushByte(0xFF, data + 5); // Read access 4 bits + Write access 4 bits (unknown: value taken from real coupler device)
|
||||
pushWord(crc16, data + 6); // CRC-16 CCITT of filter table
|
||||
pushByte(0xFF, data + 5); // Read access 4 bits + Write access 4 bits
|
||||
pushWord(crc16, data + 6); // CRC-16 CCITT of data
|
||||
|
||||
return 1;
|
||||
}),
|
||||
|
@ -68,4 +68,5 @@ class TableObject: public InterfaceObject
|
||||
LoadState _state = LS_UNLOADED;
|
||||
Memory& _memory;
|
||||
uint8_t *_data = 0;
|
||||
uint32_t _size = 0;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user