Custom baud rate

a 夏天 提交于 2019-12-04 07:18:22

Iv'e just had a quick trip to the MSDN documents for this, and here's what is said about the BaudRate property in the DCB struct.

BaudRate The baud rate at which the communications device operates. This member can be an actual baud rate value, or one of the following indexes. CBR_110. CBR_300, CBR_600, CBR_1200, CBR_2400, CBR_4800, CBR_9600, CBR_14400, CBR_19200, CBR_38400, CBR_57600, CBR_115200, CBR_128000, CBR_256000

So in theory at least you should have no problem setting the serial port speed your requesting.

It also states further down that there are some combinations that are invalid (Specifically when programming the 8250 serial chip)

Remarks When a DCB structure is used to configure the 8250, the following restrictions apply to the values specified for the ByteSize and StopBits members: The number of data bits must be 5 to 8 bits. The use of 5 data bits with 2 stop bits is an invalid combination, as is 6, 7, or 8 data bits with 1.5 stop bits.

This makes me wonder if the issue you have is that certain combinations are what's causing things, rather than just setting the baud-rate for example.

Maybe your baudrate is fine, but by selecting that baudrate your invalidating the number of stop bits, or the parity length, which when the baudrate is set back to a standard setting then become valid again.

I don't know the hardware your dealing with so I can't say 100% if this is the case, I only know serial port programming in general, but personally, my next step would be to set the baudrate to what I need then leaving that as is, try all the different combinations of other flags in the block.

The official MSDN page for the DCB structure can be found here:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa363214(v=vs.85).aspx

You may also find the BuildCommDCB function of some help too:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa363143(v=vs.85).aspx

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