2017-05-25 01:17 PM
I've experienced random and unexplainable problems with CDC communication over USB, while using CubeMX-generated code.
The PC was always able to enumerate the COM port, but sometimes it was unable to open it, (Windows reports a ''wrong parameter'' error).
After a thorough research and the use of an USB sniffer, I think I've identified the problem.
The issue comes from a wrong answer to the PC's request GET_CODING_LINE.
When the PC issues this request, it expects a payload containing line speed in bps, parity, stop bits and databits.
CDC_Control_FS() in usbd_cdc_if.c should fill the payload with correct data, but in facts its body is empty. There a switch listing the various CDC messages, but the case statements do nothing.
case CDC_SET_LINE_CODING:
break;
case CDC_GET_LINE_CODING:
break;(...and so on...)
For this reason, the payload contains random data that, in most cases, prevent the communication to work.
Here is an example of a request that the sniffer captured.
The body of the function is classified as ''user code'', but leaving it empty is misleading.
I wasted a lot of time to track down this problem.
I understand that CDC code is provided as an example, yet there is not even a simple &sharpwarning to help developers avoiding this pitfall.
I think this should be fixed as soon as possible.
#usb-cdc #cube-mx2017-05-26 01:57 AM
Hi
Scarpi.Giuseppe.002
,Thank you for your reported issue and your feedback.
Which STM32CubeMX version you are using ?
Iwill forward this issue internally to CubeMx team. S
o, could you pleaseattach your ioc file, it would be very helpful to try to reproduce the same behaviour.
Thanks
Imen
2017-05-27 04:23 AM
Hello Imen, I am using the lastest MXCube.
I upgrade the software 2 days ago.
Giuseppe