Skip to main content
Associate
March 22, 2025
Question

Received Data length is wrong in usb Communication

  • March 22, 2025
  • 1 reply
  • 908 views

"static uint8_t USBD_CDC_DataOut(USBD_HandleTypeDef *pdev, uint8_t epnum)"

In stm32u575 controller and in this function while I am calling

"uint32_t receivedLength = USBD_LL_GetRxDataSize(pdev, epnum);" it gives me 1 insted of 6 or 5 bytes I am reciving so that I could not get entire data

 

1 reply

TDK
Super User
March 22, 2025

Probably the data is being split up into several packets. What program is sending the data?

"If you feel a post has answered your question, please click ""Accept as Solution""."
Sarathk3kAuthor
Associate
March 24, 2025

It is a company software.We have to communicate with that.

void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd)

In this function ep->xfer_count += (RegVal & USB_OTG_GRXSTSP_BCNT) >> 4;  the xfer_count becomes 1 instead of 6 bytes or 5 bytes we are receiving. If I forcefully put it into 6 .I will get the first entire string.