2026-02-13 5:17 AM - last edited on 2026-02-18 3:40 AM by mƎALLEm
To follow up this thread, CTS signal on USB CDC - STMicroelectronics Community
I'm experiencing a similar issue.
USBser.sys have some problem
1. Only DTR Break can control alone
you can set DTR is 1 or 0, but RTS have change,RTS only change with DTR.
2. CDC Serial State
I have test this code, it send from Endpoint 81h successfully, but PC USB Host have no message
CDC_IN_Buf[0] = 0xA1; /* bmRequestType 0xA1 (10100001B) */
CDC_IN_Buf[1] = 0x20; /* 0x21 (SERIAL_STATE) */
CDC_IN_Buf[2] = 0x00; /* wValue LowByte */
CDC_IN_Buf[3] = 0x00; /* wValue HiByte */
CDC_IN_Buf[4] = 0x00; /* wIndex LowByte Default 0 */
CDC_IN_Buf[5] = 0x00; /* wIndex HiByte */
CDC_IN_Buf[6] = 0x02; /* wLength LowByte Serial State Length 0x0002 */
CDC_IN_Buf[7] = 0x00; /* wLength HiByte */
CDC_IN_Buf[8] = 0x14; /* Data LowByte */
CDC_IN_Buf[9] = 0x00; /* Data HiByte */
/*
CDC Serial State bit define (USB CDC 1.1 6.3.5 )
bit0 bRxCarrier 0x01
bit1 bTxCarrier 0x02
bit2 bBreak 0x04
bit3 bRingSignal 0x08
bit4 bFraming 0x10
bit5 bParity 0x20
bit6 bOverRun 0x40
*/
USBD_CDC_SetTxBuffer(&hUsbDeviceFS, CDC_IN_Buf, 10);
USBD_LL_Transmit(&hUsbDeviceFS, CDC_CMD_EP, CDC_IN_Buf, 10);Solved! Go to Solution.
2026-02-18 1:40 AM - edited 2026-02-20 6:21 AM
Hi @wjandsq
An internal ticket is submitted to dedicated team (227474) to check whether it's a bug. Would you provide more details about your HW setup and minimal project to reproduce the issue?
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.
2026-02-18 1:40 AM - edited 2026-02-20 6:21 AM
Hi @wjandsq
An internal ticket is submitted to dedicated team (227474) to check whether it's a bug. Would you provide more details about your HW setup and minimal project to reproduce the issue?
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.
2026-02-18 4:03 AM
Maybe there is some problem with the configuration descriptor.
Last time I checked, the CDC ACM notifications in my USB stack were correctly handled by Windows. The default Windows driver is greatly simplified with regard to notification data handling. I also observed the behavior you describe (RTS/DTR).
2026-02-20 6:09 AM
you can set DTR is 1 or 0, but RTS have no change,RTS only change with DTR. this is a bug.
2026-02-20 6:22 AM
Hi @wjandsq Can you provide an example to reproduce the issue?
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.
2026-03-01 12:44 PM
But is there a real use case/story for DTR & RTS, besides of compatibility with FTDI and CH341? Millions of users seem to be happy with the Windows in-box driver.
2026-03-01 8:20 PM
Millions of users seem to be satisfied with Windows' built-in drivers, but I am not.
Current solutions:
1. Imitate CH340/CH341 devices by using CH340/CH341 drivers.
The current device imitation of CH340N works well and is more stable than the Microsoft CDC Driver. But there are still some problems:
Each packet is only 32 bytes, limiting speed. Authorization from the device manufacturer wch.cn has not been obtained, so it cannot be used compliantly.
2. Imitate FT232RL devices by using FT232RL drivers.
64-byte packets can be used, but it has not been successful yet, and authorization from the device manufacturer FTDI is also required.
3. Use a USB Composite Device, here being a Custom HID CDC_ACM device.
The current problem is:
Once USB FS (PA11 PA12) is in Composite mode, the macro USE_USBD_COMPOSITE is enabled.
Then the USB Device Library used for USB HS (PB14 PB15) also switches to Composite mode.
Therefore, USB FS and USB HS must be in the same Composite mode. The appearance of the macro USE_USBD_COMPOSITE in this USB Device Library is really unfriendly.
2026-03-01 8:42 PM
in USB CDC ACM Device, RTS/DTR Code is here.
case CDC_SET_CONTROL_LINE_STATE: /* 0x22 */
/*
Endpoint 0 Default Control
Generates RS-232/V.24 style control signals
bmRequest 0x21
...00001 Interface
.01..... Class
1....... Device to Host
bRequest 0x22 Set Control Line State
wValue 0x0000
0 DTE ........ .......0 Not Present
1 Carrier Control ........ ......0. Deactivate
15..2 Reserved 00000000 000000..
wIndex 0x0000 Interface
wLength 0x0000
wValue 0x0001 DTR = 1 RTS = 0
wValue 0x0000 DTR = 0 RTS = 0
wValue 0x0003 DTR = 1 RTS = 1
wValue 0x0002 DTR = 0 RTS = 1
*/
if (hUsbDeviceFS.request.bRequest == CDC_SET_CONTROL_LINE_STATE) {
if ((hUsbDeviceFS.request.wValue & 0x0002) == 0x0000) {
/* STM32 CDC RTS Status Control : RTS = 0 */
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_10, GPIO_PIN_SET);
} else if ((hUsbDeviceFS.request.wValue & 0x0002) == 0x0002) {
/* STM32 CDC RTS Status Control : RTS = 1 */
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_10, GPIO_PIN_RESET);
}
if ((hUsbDeviceFS.request.wValue & 0x0001) == 0x0000) {
/* STM32_CDC DTR Status Control DTR = 0 */
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11, GPIO_PIN_SET);
} else if ((hUsbDeviceFS.request.wValue & 0x0001) == 0x0001) {
/* STM32 CDC DTR Status Control DTR = 1 */
HAL_GPIO_WritePin(GPIOE, GPIO_PIN_11, GPIO_PIN_RESET);
}
}
break;
2026-03-01 8:45 PM - edited 2026-03-01 8:57 PM
Thank you for this additional information. So, do you want to use RTS/CTS for flow control? If yes, how these signals are set by the WCH and FT drivers? Do you have host side software that uses RTS/CTS flow control and relies on specific serial drivers or vendor's library, or middleware such as the Qt library?
[ trying to understand if the same can be implemented in the usbser in backward-compatible way, so it won't break existing apps... ]
[ AI suggests to check how this is handled by the TinyUSB library. ]
2026-03-01 8:57 PM
In CH340N Device, PC Software Set RTS , the control Endpoint 0 :
Offset Field Size Value Description
| 0 | bmRequestType | 1 | 40h | |
| 4..0: Recipient | ...00000 | Device | ||
| 6..5: Type | .10..... | Vendor | ||
| 7: Direction | 0....... | Host-to-Device | ||
| 1 | bRequest | 1 | A4h | |
| 2 | wValue | 2 | 00BFh | |
| 4 | wIndex | 2 | 0000h | |
| 6 | wLength | 2 | 0000h |
PC Software Reset RTS , the control Endpoint 0 :
Offset Field Size Value Description
| 0 | bmRequestType | 1 | 40h | |
| 4..0: Recipient | ...00000 | Device | ||
| 6..5: Type | .10..... | Vendor | ||
| 7: Direction | 0....... | Host-to-Device | ||
| 1 | bRequest | 1 | A4h | |
| 2 | wValue | 2 | 00FFh | |
| 4 | wIndex | 2 | 0000h | |
| 6 | wLength | 2 | 0000h |