diff --git a/README.md b/README.md index e537c5c0..6ab446db 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,10 @@ See the examples for basic usage options ## Changelog +### v2.3.1 - 2026-03-04 + +- Hotfix: DPT16 was not correctly handled for uninitialized KOs + ### v2.3.0 - 2026-01-28 - Fix Define for 'DPT_FlowRate_m3/h' - Enhance multicast initialization logging diff --git a/library.json b/library.json index 9aa1f542..de6f5c3b 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "knx", - "version": "2.2.2", + "version": "2.3.1", "description": "knx stack", "homepage": "https://openknx.de", "authors": [ diff --git a/src/knx/dpt.cpp b/src/knx/dpt.cpp index 1a0dec05..56a959aa 100644 --- a/src/knx/dpt.cpp +++ b/src/knx/dpt.cpp @@ -22,7 +22,7 @@ bool Dpt::operator!=(const Dpt& other) const return !(other == *this); } -unsigned char Dpt::sizeInMemory() const +unsigned char Dpt::dataLength() const { switch (mainGroup) { @@ -72,7 +72,7 @@ unsigned char Dpt::sizeInMemory() const case 275: return 8; case 16: - return 15; // terminating with 0x00 char + return 14; case 285: return 16; default: diff --git a/src/knx/dpt.h b/src/knx/dpt.h index 97fdc797..327ef127 100644 --- a/src/knx/dpt.h +++ b/src/knx/dpt.h @@ -370,5 +370,5 @@ class Dpt unsigned short index; bool operator==(const Dpt& other) const; bool operator!=(const Dpt& other) const; - unsigned char sizeInMemory() const; + unsigned char dataLength() const; }; diff --git a/src/knx/group_object.cpp b/src/knx/group_object.cpp index 1c7d2916..7f5247df 100644 --- a/src/knx/group_object.cpp +++ b/src/knx/group_object.cpp @@ -287,14 +287,15 @@ bool GroupObject::valueNoSend(const KNXValue& value) void GroupObject::recalculateDataLength(const Dpt& type) { - uint8_t sizeInMemory = type.sizeInMemory(); - if (_commFlagEx.uninitialized && sizeInMemory > _dataLength) + uint8_t dataLength = type.dataLength(); + if (_commFlagEx.uninitialized && dataLength > _dataLength) { - _dataLength = sizeInMemory; + _dataLength = dataLength; if (_data) delete[] _data; - _data = new uint8_t[_dataLength]; - memset(_data, 0, _dataLength); + uint8_t sizeInMemory = (type.mainGroup == 16) ? dataLength + 1 : dataLength; + _data = new uint8_t[sizeInMemory]; + memset(_data, 0, sizeInMemory); } }