AnsweredAssumed Answered

USB CDC CubeMX bug in generated code

Question asked by adib on Feb 6, 2016
Latest reply on Apr 24, 2016 by adib
Hello, in the file usbd_cdc_if.c there is this function:
uint8_t CDC_Transmit_FS(uint8_t* Buf, uint16_t Len)
{
  uint8_t result = USBD_OK;
  /* USER CODE BEGIN 7 */
  USBD_CDC_SetTxBuffer(hUsbDevice_0, Buf, Len);     
  while(result != USBD_OK);
  do {
    result = USBD_CDC_TransmitPacket(hUsbDevice_0);
  }
  while(result != USBD_OK);
  /* USER CODE END 7 */
  return result;
}

those lines:
while(result != USBD_OK);
do {
  result = USBD_CDC_TransmitPacket(hUsbDevice_0);
}
while(result != USBD_OK);
 don't make many sense and might lead to potential deadlock bcs. the situation is not resolved within timeout.
Happyly the function USBD_CDC_TransmitPacket always returns USBD_OK. So in this version it will not lead to deadlock.

Please provide a more professional solution.

Regards, Adib.


Outcomes