This commit is contained in:
MichaelDvP
2020-06-15 18:57:09 +02:00
18 changed files with 176 additions and 115 deletions

View File

@@ -304,11 +304,11 @@ void RxService::add(uint8_t * data, uint8_t length) {
return;
}
// if we're in "trace" 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
if (EMSESP::watch() == 2) {
uint16_t trace_watch_id = EMSESP::watch_id();
if ((trace_watch_id == WATCH_NONE) || (src == trace_watch_id) || (dest == trace_watch_id) || (type_id == trace_watch_id)) {
LOG_INFO(F("Rx: %s"), Helpers::data_to_hex(data, length).c_str());
LOG_NOTICE(F("Rx: %s"), Helpers::data_to_hex(data, length).c_str());
}
}
@@ -461,6 +461,20 @@ void TxService::send_telegram(const QueuedTxTelegram & tx_telegram) {
length++; // add one since we want to now include the CRC
#if defined(ESP32)
// This logging causes errors with timer based tx-modes on esp8266!
LOG_DEBUG(F("Sending %s Tx [#%d], telegram: %s"),
(telegram->operation == Telegram::Operation::TX_WRITE) ? F("write") : F("read"),
tx_telegram.id_,
telegram->to_string(telegram_raw, length).c_str());
#ifdef EMSESP_DEBUG
// if watching in 'raw' mode
if (EMSESP::watch() == 2) {
LOG_NOTICE(F("[DEBUG] Tx: %s"), Helpers::data_to_hex(telegram_raw, length).c_str());
}
#endif
#endif
// send the telegram to the UART Tx
uint16_t status = EMSuart::transmit(telegram_raw, length);
@@ -469,11 +483,6 @@ void TxService::send_telegram(const QueuedTxTelegram & tx_telegram) {
increment_telegram_fail_count(); // another Tx fail
tx_waiting(false); // nothing send, tx not in wait state
return;
// } else {
// LOG_DEBUG(F("Send %s Tx [#%d], telegram: %s"),
// (telegram->operation == Telegram::Operation::TX_WRITE) ? F("write") : F("read"),
// tx_telegram.id_,
// telegram->to_string(telegram_raw, length).c_str());
}
tx_waiting(true); // tx now in a wait state
@@ -495,12 +504,9 @@ void TxService::send_telegram(const uint8_t * data, const uint8_t length) {
// send the telegram to the UART Tx
uint16_t status = EMSuart::transmit(telegram_raw, length);
if (status == EMS_TX_STATUS_ERR) {
LOG_ERROR(F("Failed to transmit Tx via UART."));
increment_telegram_fail_count(); // another Tx fail
// } else {
// LOG_DEBUG(F("Send Raw telegram: %s (length=%d)"), Helpers::data_to_hex(telegram_raw, length).c_str(), length);
}
}
@@ -610,7 +616,6 @@ void TxService::remember_tx(const uint8_t * data, const uint8_t length) {
if (ems_mask() != EMS_MASK_UNSET) {
telegram_last_[0] ^= ems_mask();
}
}
// add last Tx to tx queue and increment count