How do I (programmatically) retrieve all the baudrates for a serial port (native, USB or otherwise) ?
How do I (programmatically) retrieve all the baudrates for a serial port
(native, USB or otherwise) ?
Not possible, since the serial port controller doesn't store such
information in the first place. See RBIL's port list.
:-) This time my question is Windows related, not DOS.
But if thats so, where does "GetCommProperties" get its permissable
baudrates data from ? Mind you, that "dwSettableBaud" bitmask returns different results for both ports (AFAIKS correctly so for the CP2102).
Where does that bitmask come from ?.
Besides, if it can't why does it exist to begin with ?
Also, the CP2102 isn't a UART, but a microcontroller acting as a bridge between an USB port and a few serial lines. It also needs to have some device driver software installed to be able to use it. IOW, /both/ could contain the list I'm looking for.
Don't get me wrong: I can imagine that there might be reasons why they never put such a shortlist in either the microcontroller or the device driver.
But if the list exists I want to know how to get at it, or get an
explanation to why its (still) not implemented (its existence sounds like a no-brainer to me...). I mean, its not 1987 anymore (the date of the 16550 UART). :-)
Hardware ports are platform independent.
Device drivers for standard serial port controllers brute force the
clock divisor configuration in order to detect the acceptable baud
rates against standard baud rates.
Yes, USB based serial port controllers could. But it won't be part of
either Windows API or the serial port standards. Everything will have
to be implemented as vendor-specific. e.g. custom IOCTLs.
Serial port is part of the old ISA-era PC components. There's no Plug
'n Play yet in that PC era.
JJ,
Hardware ports are platform independent.
Indeed.
So, how do I get that baudrate bitmask onder DOS ? the RBIL doesn't mention it, even though I can easily get it under Windows. :-P
Also, most of those hardware ports seem to need device drivers, which is ofcourse software and as such again platform specific.
IOW, for my question the targetted platform does seem to matter.
Device drivers for standard serial port controllers brute force the
clock divisor configuration in order to detect the acceptable baud
rates against standard baud rates.
Possible, but I've got no information supporting it.
The thing is that above 128K there do not seem to be any "standard baudrates". Just do a Google for them and see what you (not) get ... :-(
I did find a list with some 128k+ baudrates. It shows four in the 128K+ ... 921600 range, where the CP2102 hardware docs shows eight. :-\
And it gets even "funnier" when you would take a look at the newer CP2104,
as that thing goes upto 2Mbps, and I've seen ones going upto 3Mbps. As of yet I've still have to encounter a list with standard baudrates above 921600 bps ...
Yes, USB based serial port controllers could. But it won't be part of
either Windows API or the serial port standards. Everything will have
to be implemented as vendor-specific. e.g. custom IOCTLs.
Pray tell, how do you know it would need to be a *custom* IOCTL ?
Also, if you have a list of standard IOCTLs for serial devices I sure would like to have a copy of it, as my search for "NTIoControlDeviceFile 1B0074" (as executed by GetCommProperties) doesn't even return anything in regard to that specific commandcode.
Having names for the different command codes would make my current disassembling of the CP2102's "silabser.sys" device driver (and recognising the function of each part) a lot easier.
But yes, thats pretty-much what I'm after: A way to ask the device-driver / microcontroller what its extended capablilities are. Just like NTIoControlDeviceFile with the commandcode 0x1B0074 does for its basic capabilities (yes, I took a peek into the GetCommProperties functions code).
Serial port is part of the old ISA-era PC components. There's no Plug
'n Play yet in that PC era.
From my POV thats not a problem. Just ask the device-driver/hardware if it has extended capabilities, and if it responds with an "unknow request" error it doesn't have any. Simples. :-)
Regards,
Rudy Wieser
Bottom line is, what you're looking for is vendor-specific
Windows API doesn't directly provide it.
JJ,
I've disassembled the silabser.sys device drive far enough to be able to
find the code handling the IoCtrl requests. It helped that the driver also converted such request codes into strings for debugging purposes*, making it so much easier to figure out which request was what. :-)
* but seem to have changed the actual Debug Output code into just a RET ...
I did not see any IOCTL_SERIAL_* request which could be related to a list baudrates, neither did any of the vendor-specific Cp210x_* requests turn anything up.
IOW, I'm out of luck and you happened to be right, and its not available
Now thats answered I've got something else I do not get, at all : GetCommProperties returns a COMMPROP structure containing a dwMaxBaud field.
https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-commprop
All three serial ports (over two 'puters) I've checked show 0x10000000.
I don't think that that translates to 268435456 baud, but if I consider it
to be a bitflag it doesn't make much sense either : there can be only a single maximum baudrate, so why use a bitflag ?
Also, the above value (bitflag) translates to BAUD_USER, which tells me absolutily nothing. Other perhaps than that its not one of the common baudrates mentioned in the table - but than they could just have used 0x0.
IOW, do you have any idea why they used a saying-nothing bitflag there instead of just a straight-forward value ?
Yeah, I know thats asking for something that possibly unanswerable. Its
just that it bothers me to see such non-informational data being returned.
It's not a coincidence. It's based on experience.
Try getting a different USB-to-serial device. There's a high chance
that the case would be the same.
It roughly means: user specified. IOTW: any.
But no device has no limit. It has to have a limit. At least for
this specific case. Thus it means: unspecified. IOTW: unknown.
There's no guarantee that a device provides the information via vendor-specific method.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 714 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 140:11:11 |
| Calls: | 12,087 |
| Files: | 14,998 |
| Messages: | 6,517,423 |