16,721
社区成员




With serialport1
.PortName = comParams(cP.cPort) 'TBD reopen 异常
.BaudRate = CInt(comParams(cP.cBaud))
'demo working with enumerations. get enum value from string
.Parity = DirectCast([Enum].Parse(GetType(Parity), comParams(cP.cParity)), Parity) 'get enum value from string
.DataBits = CInt(comParams(cP.cData))
.StopBits = DirectCast([Enum].Parse(GetType(StopBits), comParams(cP.cStop)), StopBits)
.Handshake = Handshake.None
.RtsEnable = False
'set the set the number of bytes in readbuffer, when event will be fired
.ReceivedBytesThreshold = CInt(comParams(cP.cThreshold))
Me._threshold = .ReceivedBytesThreshold
'i this usage 5000ms will never be reached because we read only bytes present in readbuffer
.ReadTimeout = 5000
'default value. make changes here
.ReadBufferSize = 512
'default value
.WriteBufferSize = 256
'make changes here
'.Encoding = System.Text.Encoding.ASCII
'delay so that event handle can fetch more bytes at once
Me._receiveDelay = CInt(comParams(cP.cDelay))
End With
Me.SerialPort1.ReceivedBytesThreshold ="1"