Private Sub MSComm_OnComm () Select Case MSComm1.CommEvent ' Handle each event or error by placing ' code below each case statement' 错误 Case comEventBreak ' 收到 Break。 Case comEventCDTO ' CD (RLSD) 超时。 Case comEventCTSTO ' CTS Timeout。 Case comEventDSRTO ' DSR Timeout。 Case comEventFrame ' Framing Error Case comEventOverrun '数据丢失。 Case comEventRxOver'接收缓冲区溢出。 Case comEventRxParity' Parity 错误。 Case comEventTxFull '传输缓冲区已满。 Case comEventDCB '获取 DCB] 时意外错误 ' 事件 Case comEvCD ' CD 线状态变化。 Case comEvCTS ' CTS 线状态变化。 Case comEvDSR ' DSR 线状态变化。 Case comEvRing ' Ring Indicator 变化。 Case comEvReceive ' 收到 RThreshold # of chars. Case comEvSend ' 传输缓冲区有 Sthreshold 个字符 ' ' Case comEvEof ' 输入数据流中发现 EOF 字符 ' End Select End Sub
S D0 D1 D2 D3 D4 D5 D6 D7 P
S—起始位
P—结束位
D0-- D7 数据
二、数据链路:
地址(Address)2bytes 数据长度(Long) 1byte 数据段(Data) 1~256bytes 帧校验和(FCS)1byte
Select Case MSComm1.CommEvent
' Handle each event or error by placing
' code below each case statement' 错误
Case comEventBreak ' 收到 Break。
Case comEventCDTO ' CD (RLSD) 超时。
Case comEventCTSTO ' CTS Timeout。
Case comEventDSRTO ' DSR Timeout。
Case comEventFrame ' Framing Error
Case comEventOverrun '数据丢失。
Case comEventRxOver'接收缓冲区溢出。
Case comEventRxParity' Parity 错误。
Case comEventTxFull '传输缓冲区已满。
Case comEventDCB '获取 DCB] 时意外错误 ' 事件
Case comEvCD ' CD 线状态变化。
Case comEvCTS ' CTS 线状态变化。
Case comEvDSR ' DSR 线状态变化。
Case comEvRing ' Ring Indicator 变化。
Case comEvReceive ' 收到 RThreshold # of
chars.
Case comEvSend ' 传输缓冲区有 Sthreshold 个字符 '
'
Case comEvEof ' 输入数据流中发现 EOF 字符
'
End Select
End Sub