work around with uart_driver_delete

This commit is contained in:
folkert van heusden 2024-05-20 20:41:43 +02:00
parent f6d8927d23
commit ed85d9717a
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
2 changed files with 12 additions and 5 deletions

View file

@ -19,7 +19,8 @@ comm_esp32_hardwareserial::comm_esp32_hardwareserial(const int uart_nr, const in
comm_esp32_hardwareserial::~comm_esp32_hardwareserial()
{
ESP_ERROR_CHECK(uart_driver_delete(uart_nr));
if (initialized)
ESP_ERROR_CHECK(uart_driver_delete(uart_nr));
}
bool comm_esp32_hardwareserial::begin()
@ -44,6 +45,9 @@ bool comm_esp32_hardwareserial::begin()
return false;
}
// it already was at this point?!
uart_driver_delete(uart_nr);
// Setup UART buffered IO with event queue
const int uart_buffer_size = 1024 * 2;
static QueueHandle_t uart_queue;
@ -53,6 +57,8 @@ bool comm_esp32_hardwareserial::begin()
return false;
}
initialized = true;
return true;
}

View file

@ -9,10 +9,11 @@
class comm_esp32_hardwareserial: public comm
{
private:
const int uart_nr { 1 };
const int rx_pin { -1 };
const int tx_pin { -1 };
const int bitrate { 38400 };
const int uart_nr { 1 };
const int rx_pin { -1 };
const int tx_pin { -1 };
const int bitrate { 38400 };
bool initialized { false };
public:
comm_esp32_hardwareserial(const int uart_nr, const int rx_pin, const int tx_pin, const int bps);