esp32 uart: Build the read binary from the bytes read · atomvm/AtomVM@e06bba2 · GitHub
Skip to content

Commit e06bba2

Browse files
esp32 uart: Build the read binary from the bytes read
With a 0 tick timeout uart_read_bytes can return -1 (rx mutex busy) or fewer bytes than counted (the other scheduler drained the buffer), and the result was dropped: {ok, Bin} went out with uninitialized bytes. uart:read/2 had the same race with portMAX_DELAY: after counting the buffered bytes, the listener on the other scheduler could take some, and the read then waited for the peer to send more. Both paths now read into a temporary buffer without waiting, build the binary from the returned length, and keep the reader registered when nothing was read. The UART and USB-Serial/JTAG branches share it. Signed-off-by: Gabriel Mancini <gabriel.mancini@gmail.com>
1 parent d326239 commit e06bba2

2 files changed

Lines changed: 75 additions & 108 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 1 deletion

‎src/platforms/esp32/components/avm_builtins/uart_driver.c‎

Lines changed: 73 additions & 107 deletions

0 commit comments

Comments
 (0)