Skip to main content
Graduate II
December 14, 2023
Question

Can USB CDC_Receive_FS Callback be called more than once

  • December 14, 2023
  • 1 reply
  • 1412 views

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

 

    This topic has been closed for replies.

    1 reply

    Graduate II
    December 14, 2023

    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.

    LMorr.3Author
    Graduate II
    December 14, 2023

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