Merge pull request #251 from OpenKNX/fix_data_property_read_idx0

fixed wrong answers to property read
This commit is contained in:
thelsing 2023-07-13 11:08:46 +02:00 committed by GitHub
commit f7ac39c66f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,15 +5,16 @@
uint8_t DataProperty::read(uint16_t start, uint8_t count, uint8_t* data) const uint8_t DataProperty::read(uint16_t start, uint8_t count, uint8_t* data) const
{ {
if (count == 0 || _currentElements == 0 || start > _currentElements || count > _currentElements - start + 1)
return 0;
if (start == 0) if (start == 0)
{ {
pushWord(_currentElements, data); pushWord(_currentElements, data);
return 1; return 1;
} }
if (count == 0 || _currentElements == 0 || start > _currentElements || count > _currentElements - start + 1)
return 0;
// we start counting with zero // we start counting with zero
start -= 1; start -= 1;