cancel
Showing results for 
Search instead for 
Did you mean: 

Can USB CDC_Receive_FS Callback be called more than once

LMorr.3
Senior II

Hello,

I've enabled a USB virtual com port on an STM32F373 successfully.  The CDC_Receive_FS function in usbd_cdc_if.c gets called when data is received.  I never expect to never receive a 'packet' greater than 64 bytes and have created my USB buffer[64] variable accordingly.

My questions is can I ever expect CDC_Receive_FS to be called more than once in some cases, even if the sender is always transmitting a 'packet' less than 64 bytes?   I know my UART RX callback sometimes gets called more than once, with the 'packet' split into 2 callbacks.  Will CDC_Receive_FS act the same way or can I rest assured *Len will always equal the exact number of bytes transmitted by the sender in 1 'packet'?  

I currently consider anything sent between 'idle' times of 1 byte or more to be a 'packet'.

Thank you

 

2 REPLIES 2
Piranha
Chief II

I already explained this there:

https://community.st.com/t5/stm32-mcus-products/usb-virtual-port-com-as-usb-gt-serial-converter/m-p/613630/highlight/true#M228389

And now you also explained it yourself:

I currently consider anything sent between 'idle' times of 1 byte or more to be a 'packet'.


So can you understand yourself - what an "anything ... of 1 byte or more" means? It's a stream of bytes, not messages. The callback can be called even after every single byte! And it doesn't matter what packets the sender is sending, because the stream interfaces have no concept of messages at API level and therefore the sender application also doesn't have a control over what sized packets the system will send.

I do see your previous post, thank you for confirming.