mirror of
https://github.com/espressif/esp-idf.git
synced 2025-09-30 19:19:21 +00:00
esp_system, vfs: fix incomplete blocking reads in vfs_cdcacm
Blocking read from cdcacm VFS could return less bytes than requested. This didn’t match the behaviour of other VFS drivers, and higher level code could misbehave.
This commit is contained in:
@@ -386,7 +386,7 @@ ssize_t esp_usb_console_read_buf(char *buf, size_t buf_size)
|
||||
if (s_cdc_acm_device == NULL) {
|
||||
return -1;
|
||||
}
|
||||
if (!esp_usb_console_read_available()) {
|
||||
if (esp_usb_console_available_for_read() == 0) {
|
||||
return 0;
|
||||
}
|
||||
int bytes_read = cdc_acm_fifo_read(s_cdc_acm_device, (uint8_t*) buf, buf_size);
|
||||
@@ -414,12 +414,12 @@ esp_err_t esp_usb_console_set_cb(esp_usb_console_cb_t rx_cb, esp_usb_console_cb_
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
bool esp_usb_console_read_available(void)
|
||||
ssize_t esp_usb_console_available_for_read(void)
|
||||
{
|
||||
if (s_cdc_acm_device == NULL) {
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
return cdc_acm_rx_fifo_cnt(s_cdc_acm_device) > 0;
|
||||
return cdc_acm_rx_fifo_cnt(s_cdc_acm_device);
|
||||
}
|
||||
|
||||
bool esp_usb_console_write_available(void)
|
||||
|
Reference in New Issue
Block a user