Skip to content

Commit

Permalink
fix: fix usb serial communication for esp32s3
Browse files Browse the repository at this point in the history
  • Loading branch information
LynnL4 committed Apr 16, 2024
1 parent dd57e1c commit 1267a52
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions porting/espressif/el_serial_esp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,13 @@

#include <driver/usb_serial_jtag.h>

#include <unistd.h>
#include <cctype>

namespace edgelab {

SerialEsp::SerialEsp(usb_serial_jtag_driver_config_t driver_config)
: _driver_config(driver_config),
_send_lock(),
_size(driver_config.rx_buffer_size),
_rb_rx(nullptr) {}
: _driver_config(driver_config), _send_lock(), _size(driver_config.rx_buffer_size), _rb_rx(nullptr) {}

SerialEsp::~SerialEsp() { deinit(); }

Expand Down Expand Up @@ -85,8 +83,8 @@ char SerialEsp::get_char() {
std::size_t SerialEsp::get_line(char* buffer, size_t size, const char delim) {
if (!this->_is_present) return 0;

size_t rlen = 0;
char rbuf[32] = {0}; // Most commands are less than 32 bytes long
size_t rlen = 0;
char rbuf[32] = {0}; // Most commands are less than 32 bytes long
do {
rlen = usb_serial_jtag_read_bytes(rbuf, sizeof(rbuf), 1 / portTICK_PERIOD_MS);
this->_rb_rx->put(rbuf, rlen);
Expand Down Expand Up @@ -127,6 +125,9 @@ std::size_t SerialEsp::send_bytes(const char* buffer, size_t size) {
size -= bytes_to_send;
}

// ! https://github.com/espressif/esp-idf/issues/13162
fsync(fileno(stdout));

return sent;
}

Expand Down

0 comments on commit 1267a52

Please sign in to comment.