diff --git a/platformio.ini b/platformio.ini index 64c31f698..1ba931070 100644 --- a/platformio.ini +++ b/platformio.ini @@ -20,7 +20,7 @@ extra_configs = pio_local.ini ;debug_flags = -DDEBUG_ESP_PORT=Serial -DDEBUG_ESP_CORE -DDEBUG_ESP_SSL -DDEBUG_ESP_WIFI -DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_HTTP_UPDATE -DDEBUG_ESP_HTTP_SERVER -DDEBUG_ESP_UPDATER -DDEBUG_ESP_OTA -DDEBUG_TLS_MEM debug_flags = - ; -D EMSESP_DEBUG + -D EMSESP_DEBUG ; -D EMSESP_SAFE_MODE ; -D ENABLE_CORS -D CORS_ORIGIN=\"http://localhost:3000\" diff --git a/src/emsesp.cpp b/src/emsesp.cpp index 4af4a1fa9..f86b4dddc 100644 --- a/src/emsesp.cpp +++ b/src/emsesp.cpp @@ -162,7 +162,12 @@ void EMSESP::show_emsbus(uuid::console::Shell & shell) { } else if ((it.telegram_->operation) == Telegram::Operation::TX_WRITE) { op = read_flash_string(F("WRITE")); } - shell.printfln(F(" [%02d] %s %s (offset %d)"), it.id_, op.c_str(), pretty_telegram(it.telegram_).c_str(), it.telegram_->offset); + shell.printfln(F(" [%02d%c] %s %s (offset %d)"), + it.id_, + ((it.retry_) ? '*' : ' '), + op.c_str(), + pretty_telegram(it.telegram_).c_str(), + it.telegram_->offset); } } @@ -559,6 +564,7 @@ void EMSESP::send_write_request(const uint16_t type_id, const uint8_t message_length, const uint16_t validate_typeid) { txservice_.add(Telegram::Operation::TX_WRITE, dest, type_id, offset, message_data, message_length); + txservice_.set_post_send_query(validate_typeid); // store which type_id to send Tx read after a write } @@ -584,6 +590,7 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) { if (op != Telegram::Operation::NONE) { bool tx_successful = false; EMSbus::tx_waiting(Telegram::Operation::NONE); // reset Tx wait state + // txservice_.print_last_tx(); // if we're waiting on a Write operation, we want a single byte 1 or 4 if ((op == Telegram::Operation::TX_WRITE) && (length == 1)) { @@ -612,23 +619,9 @@ void EMSESP::incoming_telegram(uint8_t * data, const uint8_t length) { } } - // if Tx wasn't successful, retry or give up + // if Tx wasn't successful, retry or just give up if (!tx_successful) { - // the telegram we got wasn't what we had requested, so re-send the last Tx and increment retry count - uint8_t retries = txservice_.retry_tx(); // returns 0 if exceeded count -#ifdef EMSESP_DEBUG - LOG_DEBUG(F("[DEBUG] Last Tx %s operation failed. Retry #%d. Sent: %s, received: %s"), - (op == Telegram::Operation::TX_WRITE) ? F("Write") : F("Read"), - retries, - txservice_.last_tx_to_string().c_str(), - Helpers::data_to_hex(data, length).c_str()); -#endif - if (!retries) { - LOG_ERROR(F("Last Tx %s operation failed after %d retries. Ignoring request."), - (op == Telegram::Operation::TX_WRITE) ? F("Write") : F("Read"), - txservice_.MAXIMUM_TX_RETRIES); - } - + txservice_.retry_tx(op, data, length); return; } } diff --git a/src/uart/emsuart_esp32.cpp b/src/uart/emsuart_esp32.cpp index c93e4b2ad..668ba2504 100644 --- a/src/uart/emsuart_esp32.cpp +++ b/src/uart/emsuart_esp32.cpp @@ -53,6 +53,7 @@ void EMSuart::emsuart_recvTask(void * para) { } } } + /* * UART interrupt, on break read the fifo and put the whole telegram to ringbuffer */ @@ -83,7 +84,6 @@ void IRAM_ATTR EMSuart::emsuart_rx_intr_handler(void * para) { } } - void IRAM_ATTR EMSuart::emsuart_tx_timer_intr_handler() { if (emsTxBufIdx > EMS_MAXBUFFERSIZE) { return; @@ -104,6 +104,9 @@ void IRAM_ATTR EMSuart::emsuart_tx_timer_intr_handler() { * init UART driver */ void EMSuart::start(uint8_t tx_mode) { + + return; + emsTxWait = EMSUART_TX_BIT_TIME * (tx_mode + 10); if (tx_mode_ != 0xFF) { // uart already initialized tx_mode_ = tx_mode;