diff --git a/src/knx/table_object.cpp b/src/knx/table_object.cpp index bf5477b..909337a 100644 --- a/src/knx/table_object.cpp +++ b/src/knx/table_object.cpp @@ -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; }), diff --git a/src/knx/table_object.h b/src/knx/table_object.h index 7ae89fb..28dcb11 100644 --- a/src/knx/table_object.h +++ b/src/knx/table_object.h @@ -68,4 +68,5 @@ class TableObject: public InterfaceObject LoadState _state = LS_UNLOADED; Memory& _memory; uint8_t *_data = 0; + uint32_t _size = 0; };