Hi all,
i try to understand this, which i do not know how to explain. The picture below descript the form that i've done.
Then the code
The input send using serial port is for example 01010111Code:Option Explicit Public bolComOpen As Boolean Private Sub Option1_Click(Index As Integer) 'option to select handsking type Select Case Index Case Option1(0).Value = vbChecked MSComm1.Handshaking = comNone Case Option1(1).Value = vbChecked MSComm1.Handshaking = comRTSXOnXOff Case Option1(2).Value = vbChecked MSComm1.Handshaking = comRTS Case Option1(3).Value = vbChecked MSComm1.Handshaking = comRTSXOnXOff End Select End Sub Private Sub Command1_Click() 'command to start sending data 'Dim inputstring On Error GoTo ErrorHandler Command1.Enabled = False 'command1 = start button Command2.Enabled = True 'command2 = Stop button Command3.Enabled = False 'command3 = close button With MSComm1 .CommPort = Right(Trim(Combo1.Text), 1) 'combo1 = to display port option .Settings = Text1 'text1 = textbox to display parameter .PortOpen = True End With bolComOpen = True Command1.BackColor = vbGreen Text2 = "" 'text2 = text for display incoming data Text3 = "" 'text3 = text for display buffer size Combo1.Enabled = False Text1.Enabled = False Do With MSComm1 If MSComm1.InBufferCount = 256 Then Text3 = .InBufferSize 'size buffer display on the buffer size textbox Text2.Text = Right(Text2.Text & .Input, 100) 'incoming data from serial port with the length of 100 Open "C:\Documents and Settings\ece30966\test program\test.cli" For Output As #1 Print #1, Text2.Text Debug.Print Text2.Text Close #1 End If End With DoEvents Loop Until Not bolComOpen MSComm1.PortOpen = False Command1.Enabled = True Command2.Enabled = False Command3.Enabled = True Exit Sub ErrorHandler: MsgBox Err.Description Command1.Enabled = True Command2.Enabled = False Command3.Enabled = True End Sub Private Sub Command2_Click() bolComOpen = False Command1.BackColor = vbRed Combo1.Enabled = True Text1.Enabled = True Command1.Enabled = True Command2.Enabled = False Command3.Enabled = True End Sub Private Sub Command3_Click() Unload Me End Sub Private Sub Form_load() Combo1.Enabled = True Text1.Enabled = True Command1.Enabled = True Command2.Enabled = False Command3.Enabled = True End Sub Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer) If MSComm1.PortOpen = True Then MsgBox "click stop to close the connection first" Cancel = True End If End Sub
then data read as a character and save in C:\Documents and Settings\ece30966\test program\test.cli.
Since the file in .cli. Then what i do is to open using visual c++. i opened the file as type binary. and display this.
Can anyone please help me how to read this. how to read this data and compare with the input which is 01010111. Thanks.. please guide




Reply With Quote