diff --git a/src/emsesp.cpp b/src/emsesp.cpp index fd9d6e419..46a44a18e 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -556,7 +556,7 @@ void EMSESP::publish_response(std::shared_ptr telegram) { doc["dest"] = Helpers::hextoa(buffer, telegram->dest); doc["type"] = Helpers::hextoa(buffer, telegram->type_id); doc["offset"] = Helpers::hextoa(buffer, telegram->offset); - strcpy(buffer, Helpers::data_to_hex(telegram->message_data, telegram->message_length).c_str()); + strcpy(buffer, Helpers::data_to_hex(telegram->message_data, telegram->message_length - 1).c_str()); // exclude CRC doc["data"] = buffer; if (telegram->message_length <= 4) { diff --git a/src/telegram.cpp b/src/telegram.cpp index 450a0740e..5792cc4ba 100644 --- a/src/telegram.cpp +++ b/src/telegram.cpp @@ -126,14 +126,6 @@ std::string Telegram::to_string_message() const { // checks if we have an Rx telegram that needs processing void RxService::loop() { - /* - while (!rx_telegrams_.empty()) { - auto telegram = rx_telegrams_.pop().telegram_; - (void)EMSESP::process_telegram(telegram); // further process the telegram - increment_telegram_count(); // increase rx count - } - */ - while (!rx_telegrams_.empty()) { auto telegram = rx_telegrams_.front().telegram_; (void)EMSESP::process_telegram(telegram); // further process the telegram @@ -156,9 +148,9 @@ void RxService::add(uint8_t * data, uint8_t length) { if (data[length - 1] != crc) { if ((data[0] & 0x7F) != ems_bus_id()) { // do not count echos as errors telegram_error_count_++; - LOG_WARNING(F("Incomplete Rx: %s"), Helpers::data_to_hex(data, length).c_str()); + LOG_WARNING(F("Incomplete Rx: %s"), Helpers::data_to_hex(data, length - 1).c_str()); // exclude CRC } else { - LOG_TRACE(F("Incomplete Rx: %s"), Helpers::data_to_hex(data, length).c_str()); + LOG_TRACE(F("Incomplete Rx: %s"), Helpers::data_to_hex(data, length - 1).c_str()); // exclude CRC } return; } @@ -204,6 +196,7 @@ void RxService::add(uint8_t * data, uint8_t length) { } // if we're watching and "raw" print out actual telegram as bytes to the console + // including the CRC at the end if (EMSESP::watch() == EMSESP::Watch::WATCH_RAW) { uint16_t trace_watch_id = EMSESP::watch_id(); if ((trace_watch_id == WATCH_ID_NONE) || (type_id == trace_watch_id) @@ -367,7 +360,7 @@ void TxService::send_telegram(const QueuedTxTelegram & tx_telegram) { LOG_DEBUG(F("Sending %s Tx [#%d], telegram: %s"), (telegram->operation == Telegram::Operation::TX_WRITE) ? F("write") : F("read"), tx_telegram.id_, - Helpers::data_to_hex(telegram_raw, length).c_str()); + Helpers::data_to_hex(telegram_raw, length - 1).c_str()); // exclude the last CRC byte set_post_send_query(tx_telegram.validateid_); // send the telegram to the UART Tx @@ -590,7 +583,7 @@ void TxService::retry_tx(const uint8_t operation, const uint8_t * data, const ui (operation == Telegram::Operation::TX_WRITE) ? F("Write") : F("Read"), retry_count_, telegram_last_->to_string().c_str(), - Helpers::data_to_hex(data, length).c_str()); + Helpers::data_to_hex(data, length - 1).c_str()); #endif // add to the top of the queue