Change properties in device manager

ぐ巨炮叔叔 提交于 2020-01-17 08:16:13

问题


i am working with serial device, i want to communicate my computer with microcontroller. In my C# program, i can set the baud rate, stop bits, data bits etc. These just in my C# program.

For example, i set the baud rate 115200 in microcontroller and my C# program, But when i see the properties of my device in device manager, the baud rate is still using default, 9600 bps. I don't know if it is good or no for communication, my C# program and microcontroller using 115200bps, and in the properties using 9600bps, but the communication is working.

How to change the properties of device in device manager?


回答1:


When you set up a serial port in your C# program, it will do so using the Win32 SetCommState API. This is true regardless of the serial communications library that you use. However, the Win32 SetCommState API will never change the baud rate that is shown in Device Manager.

The value that is shown in Device Manager comes from the driver for the device, and it is the default value that is used when you don't set it explicitly within your program. The value is written to the Windows registry when the driver is installed.

As long as you set it in your program, you don't need to worry about the value that is shown in Device Manager.

However, if you really wanted to change the value shown in Device Manager, you could do it by changing the value in the Windows Registry.

The key is typically located here:

"HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Ports"

You would change the value for the key corresponding to the port that you wish to change.

For example, if you wanted to change the COM2 settings, and if the "COM2:" key had a value of "9600,n,8,1" you could change it to "115200,n,8,1"



来源:https://stackoverflow.com/questions/29284404/change-properties-in-device-manager

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!