2025-04-02 9:54 PM
I have Nucleo-64 board acting as a USB Host connected to a CDC-ACM device. I am trying to receive data from this device, my method is as follows
while (1)
{
/* USER CODE END WHILE */
MX_USB_HOST_Process();
/* USER CODE BEGIN 3 */
if (Appli_state==APPLICATION_READY){
CDC_HandleTypeDef *CDC_Handle = (CDC_HandleTypeDef *) hUsbHostFS.pActiveClass->pData;
memset(USB_Rx_Buffer, 0, USBH_CDC_BUFFER_SIZE);
Status = USBH_CDC_Receive(&hUsbHostFS, USB_Rx_Buffer, USBH_CDC_BUFFER_SIZE);
if (Status == USBH_OK){
URB_Status = USBH_LL_GetURBState(&hUsbHostFS, CDC_Handle->DataItf.InPipe);
if (URB_Status == URB_IDLE){
(void)USBH_BulkReceiveData(&hUsbHostFS,
CDC_Handle->pRxData,
CDC_Handle->DataItf.InEpSize,
CDC_Handle->DataItf.InPipe);
uint16_t length = USBH_CDC_GetLastReceivedDataSize(&hUsbHostFS);
}
if (URB_Status == URB_DONE){
uint16_t length = USBH_CDC_GetLastReceivedDataSize(&hUsbHostFS);
printf("Received Data Size: %d \r\n", length);
}
}
}
For first couple of frames, I get full 64Bytes, but later on I just get 2 or 5 bytes. I am not receiving complete data.
I've made sure that sensor is transmitting data properly
I would really appreciate if someone could help me resolve this issue.
2025-04-10 4:17 AM - edited 2025-04-11 3:12 AM
Hi @KetanP
Did you check this example? STM32CubeF4/Projects/STM324xG_EVAL/Applications/USB_Host/CDC_Standalone/Src/main.c
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.