发表于:2006-01-03 11:09:00
3楼
用转换模块将422转换成232后,用VB编程。你可以用控件MSCOMM进行编程。在你的FORM中加入MSCOMM后,在初始化中对MSCOMM进行初始化。完成后添件ONCOMM事件。
Private Sub MainMSComm_OnComm()
On Error Resume Next
If MainMSComm.PortOpen = False Then
AddInfo DebugInfo, "串口没有打开", RunInfoList
Exit Sub
End If
Select Case MainMSComm.CommEvent
' Handle each event or error by placing
' code below each case statement
' Errors
Case comEventBreak ' A Break was received.
Case comEventFrame ' Framing Error
Case comEventOverrun ' Data Lost.
Case comEventRxOver ' Receive buffer overflow.
Case comEventRxParity ' Parity Error.
Case comEventTxFull ' Transmit buffer full.
Case comEventDCB ' Unexpected error retrieving DCB]
' Events
Case comEvCD ' Change in the CD line.
Case comEvCTS ' Change in the CTS line.
Case comEvDSR ' Change in the DSR line.
Case comEvRing ' Change in the Ring Indicator.
Case comEvReceive ' Received RThreshold # of
' chars.
'接收到一个字符产生的消息,判断是否是数据的开始,如果是继续接收168个,如果不是直接退出等待下一个数据
Case comEvSend ' There are SThreshold number of
' characters in the transmit
' buffer.
Case comEvEOF ' An EOF charater was found in
' the input stream
End Select
End Sub