don't show CRC in log (irrelevant to most people)

This commit is contained in:
proddy
2021-07-24 15:02:58 +02:00
parent 008983be26
commit 15c682cd1e
2 changed files with 6 additions and 13 deletions

View File

@@ -556,7 +556,7 @@ void EMSESP::publish_response(std::shared_ptr<const Telegram> telegram) {
doc["dest"] = Helpers::hextoa(buffer, telegram->dest); doc["dest"] = Helpers::hextoa(buffer, telegram->dest);
doc["type"] = Helpers::hextoa(buffer, telegram->type_id); doc["type"] = Helpers::hextoa(buffer, telegram->type_id);
doc["offset"] = Helpers::hextoa(buffer, telegram->offset); 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; doc["data"] = buffer;
if (telegram->message_length <= 4) { if (telegram->message_length <= 4) {

View File

@@ -126,14 +126,6 @@ std::string Telegram::to_string_message() const {
// checks if we have an Rx telegram that needs processing // checks if we have an Rx telegram that needs processing
void RxService::loop() { 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()) { while (!rx_telegrams_.empty()) {
auto telegram = rx_telegrams_.front().telegram_; auto telegram = rx_telegrams_.front().telegram_;
(void)EMSESP::process_telegram(telegram); // further process the 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[length - 1] != crc) {
if ((data[0] & 0x7F) != ems_bus_id()) { // do not count echos as errors if ((data[0] & 0x7F) != ems_bus_id()) { // do not count echos as errors
telegram_error_count_++; 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 { } 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; 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 // 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) { if (EMSESP::watch() == EMSESP::Watch::WATCH_RAW) {
uint16_t trace_watch_id = EMSESP::watch_id(); uint16_t trace_watch_id = EMSESP::watch_id();
if ((trace_watch_id == WATCH_ID_NONE) || (type_id == trace_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"), LOG_DEBUG(F("Sending %s Tx [#%d], telegram: %s"),
(telegram->operation == Telegram::Operation::TX_WRITE) ? F("write") : F("read"), (telegram->operation == Telegram::Operation::TX_WRITE) ? F("write") : F("read"),
tx_telegram.id_, 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_); set_post_send_query(tx_telegram.validateid_);
// send the telegram to the UART Tx // 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"), (operation == Telegram::Operation::TX_WRITE) ? F("Write") : F("Read"),
retry_count_, retry_count_,
telegram_last_->to_string().c_str(), telegram_last_->to_string().c_str(),
Helpers::data_to_hex(data, length).c_str()); Helpers::data_to_hex(data, length - 1).c_str());
#endif #endif
// add to the top of the queue // add to the top of the queue