diff options
| -rw-r--r-- | class/serial/usbh_serial.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/class/serial/usbh_serial.c b/class/serial/usbh_serial.c index 3e17b12f..2ea09d70 100644 --- a/class/serial/usbh_serial.c +++ b/class/serial/usbh_serial.c @@ -73,6 +73,7 @@ static void usbh_serial_free(struct usbh_serial *serial) static void usbh_serial_callback(void *arg, int nbytes) { struct usbh_serial *serial = (struct usbh_serial *)arg; + uint32_t free_space; int ret; if (nbytes < 0) { @@ -103,6 +104,11 @@ static void usbh_serial_callback(void *arg, int nbytes) return; } + free_space = usb_ringbuffer_get_free(&serial->rx_rb); + if (free_space < (nbytes - serial->driver->ignore_rx_header)) { + USB_LOG_ERR("serial rx ringbuffer overflow, free space: %u, rx size: %u\n", free_space, (nbytes - serial->driver->ignore_rx_header)); + } + usb_ringbuffer_write(&serial->rx_rb, &serial->iobuffer[(serial->rx_buf_index ? USBH_SERIAL_RX2_NOCACHE_OFFSET : USBH_SERIAL_RX_NOCACHE_OFFSET) + serial->driver->ignore_rx_header], (nbytes - serial->driver->ignore_rx_header)); |
