AnsweredAssumed Answered

Why USB CDC_Receive_FS Get Called Multiple times with >64 bytes Packets

Question asked by Nicolas Felipe on Jun 19, 2017
Latest reply on Jun 19, 2017 by Nicolas Felipe

My MCU is receiving from Java different packet lenght calls through USB CDC,

 

When Java Sends 384 bytes the CDC_Receive_FS gets Called 6 times, 384/64 = 6

and its impossible to know when the data has finished because the Java Application send random parameteres and the data lenght is variable,

 

is there any way to have flow control with the HAL CDC Libraries? or will have to implement some flow control from Java sending Heads and Tail messages.

 

I have tried almost every interrupt in the HAL libraries but also get called 6 times, for example :

 

in stm32f1xx_hal_pcd.c there is 

 

/*multi-packet on the NON control OUT endpoint*/
ep->xfer_count+=count;
ep->xfer_buff+=count;

if ((ep->xfer_len == 0) || (count < ep->maxpacket))
{
/* RX COMPLETE */

callBackNumber++;
HAL_PCD_DataOutStageCallback(hpcd, ep->num);
}

but also get called 6 times since the callBackNumber keeps incrementing at that pace.

 

i have seen this question asked lot of times but vague answers, is there a method to know the RX packets real lenght?

 

thanks for any helpful answer.

Outcomes