My project periodically will have the target checking for potential data coming from the host without making a blocking call, though USBD_BULK_ReadAsync() or USBD_BULK_ReadOverlapped() could be used I first tested the API by using the function USBD_BULK_GetNumBytesInBuffer(). This was made by a simple modification to the USB_BULK_Test.c code provided for the NXP 1060 EVK. Is there some kind of initialization missing or should this function return 1 (one) after the corresponding eval code for the host is running and the device has been selected? I always see a 0 (zero) being returned.
USBD_BULK_GetNumBytesInBuffer() always returning 0
This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.
-
-
The function USBD_BULK_GetNumBytesInBuffer() never triggers a read, it only check for bytes in the buffer. If you never call any read function, then the buffer will be always empty.
Please use USBD_BULK_Receive(..., Timeout = -1) instead.Please read the forum rules before posting.
Keep in mind, this is *not* a support forum.
Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
Should you be entitled to support you can contact us via our support system: segger.com/ticket/
Or you can contact us via e-mail. -
Thank you Rainer for the info. I have tried the following an none give me an indication that there is a byte or more available to read:
USBD_BULK_Receive( hInst, NULL, 0, -1 );
USBD_BULK_Receive( hInst, NULL, 1, -1 );
USBD_BULK_Receive( hInst, &c, 0, -1 );
My workaround has been using a 1mS timeout so not to waste too much time with USB_BULK_Read(), but from what I can understand from the manual is that this can cause loss of data if a timeout expires before a transaction has completed..
Still need your help, thanks.The post was edited 1 time, last by adam_sds ().
-
Update, so long as I only call the USBD_BULK_Receive( hInst, NULL, 0, -1 ) once in the loop (till I later receive something) then USBD_BULK_GetNumBytesInBuffer() will actually return the number of bytes in the OUT buffer that are waiting to be read, then I call USBD_BULK_Read() to get them and reset a flag to allow the process to restart..
-
Simply call USBD_BULK_Receive( hInst, &c, 1, -1 );
It returns 1, if you got a byte,
It returns 0 if there is no data.Please read the forum rules before posting.
Keep in mind, this is *not* a support forum.
Our engineers will try to answer your questions between their projects if possible but this can be delayed by longer periods of time.
Should you be entitled to support you can contact us via our support system: segger.com/ticket/
Or you can contact us via e-mail.
-
Share
- Facebook 0
- Twitter 0
- Google Plus 0
- Reddit 0