offset correction for next telegram

This commit is contained in:
MichaelDvP
2024-07-19 19:57:13 +02:00
parent 1a400bfd40
commit c3296ccf97

View File

@@ -638,7 +638,7 @@ void TxService::retry_tx(const uint8_t operation, const uint8_t * data, const ui
uint16_t TxService::read_next_tx(const uint8_t offset, const uint8_t length) { uint16_t TxService::read_next_tx(const uint8_t offset, const uint8_t length) {
uint8_t old_length = telegram_last_->type_id > 0xFF ? length - 7 : length - 5; uint8_t old_length = telegram_last_->type_id > 0xFF ? length - 7 : length - 5;
uint8_t next_length = telegram_last_->type_id > 0xFF ? EMS_MAX_TELEGRAM_MESSAGE_LENGTH - 2 : EMS_MAX_TELEGRAM_MESSAGE_LENGTH; uint8_t next_length = telegram_last_->type_id > 0xFF ? EMS_MAX_TELEGRAM_MESSAGE_LENGTH - 2 : EMS_MAX_TELEGRAM_MESSAGE_LENGTH;
uint8_t next_offset = telegram_last_->offset + old_length; uint8_t next_offset = offset + old_length;
uint8_t message_data = (UINT8_MAX - next_offset) >= next_length ? next_length : UINT8_MAX - next_offset; uint8_t message_data = (UINT8_MAX - next_offset) >= next_length ? next_length : UINT8_MAX - next_offset;
// check telegram, offset and overflow // check telegram, offset and overflow
// some telegrams only reply with one byte less, but have higher offsets (0x10) // some telegrams only reply with one byte less, but have higher offsets (0x10)