prevent multiple reading of long messages with no offset

This commit is contained in:
MichaelDvP
2021-05-10 13:40:11 +02:00
parent 37bee39cea
commit 312fd85469
3 changed files with 8 additions and 3 deletions

View File

@@ -1061,6 +1061,8 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) {
// get_uptime is only updated once per loop, does not give the right time // get_uptime is only updated once per loop, does not give the right time
LOG_TRACE(F("[UART_DEBUG] Echo after %d ms: %s"), ::millis() - rx_time_, Helpers::data_to_hex(data, length).c_str()); LOG_TRACE(F("[UART_DEBUG] Echo after %d ms: %s"), ::millis() - rx_time_, Helpers::data_to_hex(data, length).c_str());
#endif #endif
// add to RxQueue for log/watch
rxservice_.add(data, length);
return; // it's an echo return; // it's an echo
} }
@@ -1096,7 +1098,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) {
tx_successful = true; tx_successful = true;
// if telegram is longer read next part with offset + 25 for ems+ // if telegram is longer read next part with offset + 25 for ems+
if (length == 32) { if (length == 32) {
if (txservice_.read_next_tx() == read_id_) { if (txservice_.read_next_tx(data[3]) == read_id_) {
read_next_ = true; read_next_ = true;
} }
} }

View File

@@ -590,9 +590,12 @@ void TxService::retry_tx(const uint8_t operation, const uint8_t * data, const ui
tx_telegrams_.emplace_front(tx_telegram_id_++, std::move(telegram_last_), true, get_post_send_query()); tx_telegrams_.emplace_front(tx_telegram_id_++, std::move(telegram_last_), true, get_post_send_query());
} }
uint16_t TxService::read_next_tx() { uint16_t TxService::read_next_tx(uint8_t offset) {
// add to the top/front of the queue // add to the top/front of the queue
uint8_t message_data[1] = {EMS_MAX_TELEGRAM_LENGTH}; // request all data, 32 bytes uint8_t message_data[1] = {EMS_MAX_TELEGRAM_LENGTH}; // request all data, 32 bytes
if (telegram_last_->offset != offset) {
return 0;
}
add(Telegram::Operation::TX_READ, telegram_last_->dest, telegram_last_->type_id, telegram_last_->offset + 25, message_data, 1, 0, true); add(Telegram::Operation::TX_READ, telegram_last_->dest, telegram_last_->type_id, telegram_last_->offset + 25, message_data, 1, 0, true);
return telegram_last_->type_id; return telegram_last_->type_id;
} }

View File

@@ -283,7 +283,7 @@ class TxService : public EMSbus {
void retry_tx(const uint8_t operation, const uint8_t * data, const uint8_t length); void retry_tx(const uint8_t operation, const uint8_t * data, const uint8_t length);
bool is_last_tx(const uint8_t src, const uint8_t dest) const; bool is_last_tx(const uint8_t src, const uint8_t dest) const;
uint16_t post_send_query(); uint16_t post_send_query();
uint16_t read_next_tx(); uint16_t read_next_tx(uint8_t offset);
uint8_t retry_count() const { uint8_t retry_count() const {
return retry_count_; return retry_count_;