cancel
Showing results for 
Search instead for 
Did you mean: 

STM32CDC Windows and OOB data?

TJohn.14
Associate II

I have a STM32F303 acting as a serial port to an industrial control system, but I need a reliable way to set a byte for out-of-band data (I need to set "termination resistor On/Off, Drive Strength, etc -- I'm using the "comm port" for the serial data, but I need to set the interface bits)... it seems Windows is doing a good job of thwarting me:

I tried changing the UBCDdevice... but windows only reads it at plug-in time (even if I do IOCTL on the hub to read the descriptor again).

I tried returning the info in the upper byte of dwBaudRate in the LineCoding, but it seems that Windows does some odd combination of reading/writing to it so the data doesn't pass cleanly through...

What's the best way to handle this kind of out-of-band-data? Is there a good, simple way to get a "byte" back (like RI, CD, DSR, CTS, Foo, bar, baz, squack) using the CDC, or should I make the device show up as 2 com ports (1 for normal communication, one for line status/configuration) -- I only need 1 byte in and one byte out at "config time" (but they must be independent -- I'll send "NoTemination, Invert, Pace", and I want to get back "NoiseLevel0-4, 0-15devices, commgood," not "I'll Read LineCoding, and I'll only write the delta and you're nuts if you think 4MBaud is ok"), but Windows seems to be thwarting me every step of the way...

4 REPLIES 4
Jack Peacock_2
Senior III

You might want to look at the HID class instead of CDC. It works well sending on/off and small value flags plus if set up right it will appear at BIOS boot time on the PC side, so it'll be present by the time the host app starts.

Jack Peacock

Pavel A.
Evangelist III

Without adding another interface and endpoint... Consider switching from "data" mode to "AT commands" like in a modem. Use break or "+++AT" to activate AT commands. ATO command goes back to data mode.

-- pa

Is there a reference/tutorial on a composite device (HID+CDC)?

Some examples are available on github...

https://github.com/IntergatedCircuits/USBDevice

-- pa