From 3285519380ba9ed8b529099ad3b9b008994050b8 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Fri, 10 Oct 2014 23:51:04 +0200 Subject: [PATCH] OP-1536 Send only the available bytes, not the entire buffer, to the USB CDC RX callback function --- flight/pios/stm32f4xx/pios_usbhook.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/flight/pios/stm32f4xx/pios_usbhook.c b/flight/pios/stm32f4xx/pios_usbhook.c index 259861b14..dc276c491 100644 --- a/flight/pios/stm32f4xx/pios_usbhook.c +++ b/flight/pios/stm32f4xx/pios_usbhook.c @@ -418,7 +418,9 @@ static uint8_t PIOS_USBHOOK_CLASS_DataOut(void *pdev, uint8_t epnum) if ((epnum_idx < NELEMENTS(usb_epout_table)) && usb_epout_table[epnum_idx].cb) { struct usb_ep_entry *ep = &(usb_epout_table[epnum_idx]); - if (!ep->cb(ep->context, epnum_idx, ep->max_len)) { + uint16_t len = USBD_GetRxCount(pdev, epnum); + PIOS_Assert(ep->max_len >= len); + if (!ep->cb(ep->context, epnum_idx, len)) { /* NOTE: use real endpoint number including direction bit */ DCD_SetEPStatus(pdev, epnum, USB_OTG_EP_RX_NAK); }