好久没来了,一直都很忙,也无聊,压力也很大,感情也很无赖。。。去OMRON公司散了一下心,学习串口通信,收获较多。。。现把一VB程式,通过VB 访问有HOSTLINK 协议的设备。还有就是超级终端其实是一个很好的东东,不竞可以调试移动设备,也可以调试工业设备等等咯。
Private Sub com1_Click() MSComm1.CommPort = 1 End Sub
Private Sub Command1_Click() Me.Timer1.Enabled = False
End Sub Private Sub Command2_Click() Text1.Text = "" Text2.Text = "" Text3.Text = "" End Sub
Private Sub Form_Load() Text3.Text = "@00RD00000001" End Sub
Private Sub MSComm1_OnComm() Select Case MSComm1.CommEvent Case comEvReceive temp = MSComm1.Input If temp <> "" Then Text1.Text = Text1.Text + temp Me.Refresh End Select
End Sub
Private Sub Option1_Click() If Me.MSComm1.PortOpen = True Then Me.MSComm1.PortOpen = False End If MSComm1.CommPort = 2 End Sub
Private Sub Timer1_Timer() Dim FcsResult As String Dim StrIn As String Dim jytemp As Integer Dim temp As String jytemp = 0 StrIn = Text3.Text Text1.Text = "" '************** 校 验 For i = 1 To Len(StrIn) jytemp = Asc(Mid$(StrIn, i, 1)) Xor jytemp Next i FcsResult = Hex$(jytemp) '************** Text2.Text = FcsResult If (MSComm1.PortOpen = False) Then MSComm1.PortOpen = True MSComm1.Output = Text3.Text + Text2.Text + "*" + Chr(13) End Sub
Private Sub 停止通讯_Click() Me.Timer1.Enabled = False
End Sub
[upload=jpg]UploadFile/2006-9/20069219104919185.jpg[/upload]
|