mode settings, RC35 temperature factor, UART modes

This commit is contained in:
MichaelDvP
2020-07-02 16:46:41 +02:00
parent 1b00a4405b
commit 51e52846f0
7 changed files with 144 additions and 177 deletions

View File

@@ -88,7 +88,7 @@ class Telegram {
// reads a bit value from a given telegram position
void read_bitvalue(uint8_t & value, const uint8_t index, const uint8_t bit) const {
uint8_t abs_index = (index - offset);
if (abs_index >= message_length) {
if (abs_index >= message_length - 1) {
return; // out of bounds
}
@@ -104,7 +104,7 @@ class Telegram {
// s is to override number of bytes read (e.g. use 3 to simulat a uint24_t)
void read_value(Value & value, const uint8_t index, uint8_t s = 0) const {
uint8_t size = (!s) ? sizeof(Value) : s;
int8_t abs_index = ((index - offset + size - 1) >= message_length) ? -1 : (index - offset);
int8_t abs_index = ((index - offset + size - 1) >= message_length - 1) ? -1 : (index - offset);
if (abs_index < 0) {
return; // out of bounds, we don't change the value
}