Click here to Skip to main content
15,886,799 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I know COM Port settings can be read and set using the Device Manager. However, I need to be able to obtain the BaudRate programmatically.

What I have tried:

I noticed that *some* COM Ports settings are included in the Win32_SerialPortConfiguration but most are not included.
Posted
Updated 28-Mar-22 5:09am

You can't get a baudrate, unless you have set it - it's not a "feature" that is transmitted as part of the communication between two devices unless they actively have a "negotiation phase" which is unbelievably rare and mostly only found in embedded devices, not OSes.

Baudrate is the speed in bits per second at which a device transmits - and the "other end" needs to be set to the same speed (plus or minus 5%) in order to reliably understand what is being sent. It's a "internal" feature that you can set in software but you can only read back the value you set (or the default value set by the port software which for the C# SerialPort class is 9600 baud).
There is no way to "read" the baudrate of the remote device as they can't communicate reliably unless they are both set to the same value!
 
Share this answer
 
If you are talking about a Windows system then you can use GetCommConfig function (winbase.h) - Win32 apps | Microsoft Docs[^].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900