网上流传两个版本的DCB,经过验证有一个有问题

补充:

测试了一下使用左面的结构定义,使用字符串(baud=1111 parity=E data=8 stop=1)构造DCB只能改变波特率,对校验方式无效

可以用构造后用xDCB.parity=E来解决

右面的结构上面的对校验位有效,但是操作errorchar之类的比较麻烦

----------------------------------------------------------------------------------------------------------------------------------

下面两个DCB结构网上流传很广

其实在XP + VB6环境下右边这个才是准确的

虽然左边这个可以用于设置某些串口参数,但是要进行一些更深入的设置就会出问题,不报错但是设置不起作用

fBitFields:

' The fourteen actual DCB bit-sized data fields within the four bytes of fBitFields can be manipulated by bitwise logical And/Or operations.
' FieldName Bit # Description
' ----------------- ----- ------------------------------
' fBinary 1 1 binary mode,no EOF check
' fParity 2 1 enable parity checking
' fOutxCtsFlow 3 0 CTS output flow control
' fOutxDsrFlow 4 0 DSR output flow control
' fDtrControl 5 0 DTR flow control type (2 bits)
' fDsrSensitivity 7 0 DSR sensitivity
' fTXContinueOnXoff 8 0 XOFF continues Tx
' fOutX 9 0 XON/XOFF out flow control
' fInX 10 0 XON/XOFF in flow control
' fErrorChar 11 1 enable error replacement
' fNull 12 1 enable null stripping
' fRtsControl 13 0 RTS flow control (2 bits)
' fAbortOnError 15 1 abort reads/writes on error
' fDummy2 16 0 reserved

Type DCB Type DCB DCBlength As Long DCBlength As Long Baudrate As Long Baudrate As Long fBinary As Long fBitFields As Long fParity As Long wReserved As Integer fOutxCtsFlow As Long XonLim As Integer fOutxDsrFlow As Long XoffLim As Integer fDtrControl As Long ByteSize As Byte fDsrSensitivity As Long Parity As Byte fTXContinueOnXoff As Long StopBits As Byte fOutX As Long XonChar As Byte fInX As Long XoffChar As Byte fErrorChar As Long ErrorChar As Byte fNull As Long EofChar As Byte fRtsControl As Long EvtChar As Byte fAbortOnError As Long wReserved1 As Integer 'Reserved; Do Not Use fDummy2 As Long End Type wReserved As Integer XonLim As Integer XoffLim As Integer ByteSize As Byte Parity As Byte StopBits As Byte XonChar As Byte XoffChar As Byte ErrorChar As Byte EofChar As Byte EvtChar As Byte End Type

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...