fixed wrong answers to property read:

with start = 0 (read the number of current elements) and current elements = 0 (empty property) 0 was returned which results in an error message when reading this property.
This commit is contained in:
John Doe 2023-06-26 10:15:51 +02:00
parent 48000b25aa
commit a5ba7bcd5e

View File

@ -5,15 +5,16 @@
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)
{
pushWord(_currentElements, data);
return 1;
}
if (count == 0 || _currentElements == 0 || start > _currentElements || count > _currentElements - start + 1)
return 0;
// we start counting with zero
start -= 1;