Skip to content

Commit

Permalink
fix UART buffer (#82)
Browse files Browse the repository at this point in the history
* fix

* revert change

* revert asyncio event_loop

* Update main/modules/serial.cpp

---------

Co-authored-by: Falko Schindler <[email protected]>
  • Loading branch information
Johannes-Thiel and falkoschindler authored Oct 21, 2024
1 parent b097d3f commit 0fd4e41
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions main/modules/serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@
#include <cstring>
#include <stdexcept>

#define RX_BUF_SIZE 1024
#define TX_BUF_SIZE 1024
#define RX_BUF_SIZE 2048
#define TX_BUF_SIZE 2048
#define UART_PATTERN_QUEUE_SIZE 20

Serial::Serial(const std::string name,
const gpio_num_t rx_pin, const gpio_num_t tx_pin, const long baud_rate, const uart_port_t uart_num)
Expand All @@ -25,12 +26,12 @@ Serial::Serial(const std::string name,
};
uart_param_config(uart_num, &uart_config);
uart_set_pin(uart_num, tx_pin, rx_pin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
uart_driver_install(uart_num, RX_BUF_SIZE, TX_BUF_SIZE, 0, NULL, 0);
uart_driver_install(uart_num, RX_BUF_SIZE, TX_BUF_SIZE, UART_PATTERN_QUEUE_SIZE, NULL, 0);
}

void Serial::enable_line_detection() const {
uart_enable_pattern_det_baud_intr(this->uart_num, '\n', 1, 9, 0, 0);
uart_pattern_queue_reset(this->uart_num, 100);
uart_pattern_queue_reset(this->uart_num, UART_PATTERN_QUEUE_SIZE);
}

void Serial::deinstall() const {
Expand Down

0 comments on commit 0fd4e41

Please sign in to comment.