Skip to main content
mailforspam
Associate
July 3, 2014
Question

Problem with USB Host CDC class

  • July 3, 2014
  • 11 replies
  • 4342 views
Posted on July 03, 2014 at 12:01

Hello,

I'm using STM32CubeMX to generate a project for STM32F207 that uses USB Host. The project compiles without problems. I have a custom USB device that uses CDC to send and receive serial data. When the device is attached to the USB host, it is detected correctly and the CDC class is being started. The functions for writing to and reading from the USB device are USBH_CDC_Transmit and USBH_CDC_Receive. These functions are non-blocking, and there are 2 callback functions that are called when the data have been transferred - USBH_CDC_TransmitCallback and USBH_CDC_ReceiveCallback. I have made some tests reading and writing the device and discovered, that I have to wait the last operation to finish before calling again the functions for reading or writing. The problem is that if I call USBH_CDC_Receive and the device is not sending anything at the moment, I cannot use the USB device anymore, I can call USBH_CDC_Transmit or USBH_CDC_Receive as much as I want, they won't block, but they just won't work. The detaching and attaching again of the device won't be detected by the USB Host Library. How can I find a workaround of that issue? I want to be able to read the USB device, but I don't know how much data I'm expecting, otherwise I would stop calling USBH_CDC_Receive.

#stm32cubemx #cdc #usb-host
This topic has been closed for replies.

11 replies

christo
Associate II
September 24, 2015