From 354096a9730611e2af046273e5758c6504cac79e Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 25 Mar 2018 15:10:41 +0000 Subject: Fixed bug #930. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11855 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/hal/src/hal_serial_usb.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'os/hal/src') diff --git a/os/hal/src/hal_serial_usb.c b/os/hal/src/hal_serial_usb.c index ec1f1c4fe..246360ebc 100644 --- a/os/hal/src/hal_serial_usb.c +++ b/os/hal/src/hal_serial_usb.c @@ -484,20 +484,25 @@ void sduDataTransmitted(USBDriver *usbp, usbep_t ep) { * @param[in] ep OUT endpoint number */ void sduDataReceived(USBDriver *usbp, usbep_t ep) { + size_t size; SerialUSBDriver *sdup = usbp->out_params[ep - 1U]; + if (sdup == NULL) { return; } osalSysLockFromISR(); - /* Signaling that data is available in the input queue.*/ - chnAddFlagsI(sdup, CHN_INPUT_AVAILABLE); + /* Checking for zero-size transactions.*/ + size = usbGetReceiveTransactionSizeX(sdup->config->usbp, + sdup->config->bulk_out); + if (size > (size_t)0) { + /* Signaling that data is available in the input queue.*/ + chnAddFlagsI(sdup, CHN_INPUT_AVAILABLE); - /* Posting the filled buffer in the queue.*/ - ibqPostFullBufferI(&sdup->ibqueue, - usbGetReceiveTransactionSizeX(sdup->config->usbp, - sdup->config->bulk_out)); + /* Posting the filled buffer in the queue.*/ + ibqPostFullBufferI(&sdup->ibqueue, size); + } /* The endpoint cannot be busy, we are in the context of the callback, so a packet is in the buffer for sure. Trying to get a free buffer -- cgit v1.2.3