vfs: usb_serial_jtag: consider O_NONBLOCK flag when reading via driver

Closes https://github.com/espressif/esp-idf/issues/8839
pull/9137/head
Ivan Grokhotkov 2022-05-03 21:29:21 +02:00
rodzic 129cdcc08c
commit cd21a31416
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 1E050E141B280628
1 zmienionych plików z 7 dodań i 3 usunięć

Wyświetl plik

@ -71,8 +71,11 @@ typedef struct {
// Read and write locks, lazily initialized
_lock_t read_lock;
_lock_t write_lock;
// Non-blocking flag. Note: default implementation does not honor this
// flag, all reads are non-blocking. ToDo: implement driver that honours this.
// Non-blocking flag.
// The default implementation does not honor this flag, all reads
// are non-blocking.
// When the driver is used (via esp_vfs_usb_serial_jtag_use_driver),
// reads are either blocking or non-blocking depending on this flag.
bool non_blocking;
// Newline conversion mode when transmitting
esp_line_endings_t tx_mode;
@ -389,7 +392,8 @@ esp_err_t esp_vfs_dev_usb_serial_jtag_register(void)
static int usbjtag_rx_char_via_driver(int fd)
{
uint8_t c;
int n = usb_serial_jtag_read_bytes(&c, 1, portMAX_DELAY);
TickType_t timeout = s_ctx.non_blocking ? 0 : portMAX_DELAY;
int n = usb_serial_jtag_read_bytes(&c, 1, timeout);
if (n <= 0) {
return NONE;
}