Dim z_star As Boolean
Dim in_data (2) the As Byte
Dim ovt As an Integer type 'BYTE is BYTE Integer is an Integer STRING is a STRING type
Private Sub Form_Load ()
Timer1. Enabled=False
MSComm1. InBufferSize=40
MSComm1. InBufferCount=0
MSComm1. An InputMode=comInputModeBinary
MPort=10
MSComm1.ComMSComm1. Settings="57600, N, 8, 1", "
MSComm1. RThreshold=1
MSComm1. InputLen=0
If MSComm1. PortOpen=False Then
MSComm1. PortOpen=1
End the If
End Sub
Private Sub Check3_Click (Index As an Integer) 'check control button
Dim dat (3) As Byte
If Check3 (Index)=1 Then
Check3 (Index). Caption="light" & amp; The Index + 1 & amp; "Open"
Dat (0)=& amp; H0
Dat (1)=& amp; The H2
The Else
Check3 (Index). Caption="light" & amp; The Index + 1 & amp; "Closed"
Dat (0)=& amp; H1
Dat (1)=& amp; H3
End the If
MSComm1. The Output=dat
End Sub
Private Sub Command1_Click () 'send button
MSComm1. The Output=Text2. Text
End Sub
Private Sub Command2_Click () 'delete button
Text1. Text=""
End Sub
Private Sub dispose_data frame processing
() 'For I=0 To ovt
Text1. Text=Text1. Text & amp; Hex (in_data (I)) & amp; "
"
Next
If in_data (2)=1 Then
Shape1 (in_data (1) - 1) BackColor=& amp; HFF00 & amp; Green
'The Else
Shape1 (in_data (1) - 1) BackColor=& amp; H8000000F
End the If
End Sub
Private Sub MSComm1_OnComm ()
Select Case mEvent MSComm1.Com
Case comEvReceive 'received RThreshold # of
Xv: Dim hk As the Variant
Hk=MSComm1. Input
If Check2. Value=https://bbs.csdn.net/topics/1 Then hexadecimal collection
'If Check1. Value=https://bbs.csdn.net/topics/0 Then frame processing
'
If hk (0)=& amp; HFA Then 'frame head
Z_star=True
Ovt=0
End the If
If hk (0)=& amp; HFB Then 'tail frame
Z_star=False
Hk (in_data (ovt)=0)
Call dispose_data 'after receiving the complete a frame to invoke the data processing program
End the If
If z_star=True Then
Hk (in_data (ovt)=0)
Ovt=ovt + 1
End the If
The Else
Text1. Text=Text1. Text & amp; Hex (hk (0)) & amp; "
"
End the If
The Else
Text1. Text=Text1. Text & amp; Hk
End the If
If MSComm1. InBufferCount & lt;> 0 Then
GoTo xv
End the If
End the Select
End Sub
This is my software interface
Have not received the data problem is single chip microcomputer, master program where there is a problem
CodePudding user response:
Come and someone to help me,,,,,,,CodePudding user response:
For help!CodePudding user response:
How no one!!!!!!CodePudding user response:
Please post microcontroller program, in order to check where you are wrong!CodePudding user response:
Here to estimate the original poster is receives numeric 0 s and 1 s on the single chip microcomputer, and the upper machine PC sends data type is a string of "0" and "1", because there is no posted on the single chip microcomputer program, the original poster can't check, so the landlord to check whether there are wrong,CodePudding user response:
PC sends is the binary 1 s and 0 s:MSComm1. An InputMode=comInputModeBinary
Private Sub Check3_Click (Index As an Integer) 'check control button
Dim dat (3) As Byte
If Check3 (Index)=1 Then
Check3 (Index). Caption="light" & amp; The Index + 1 & amp; "Open"
Dat (0)=& amp; H0
Dat (1)=& amp; The H2
The Else
Check3 (Index). Caption="light" & amp; The Index + 1 & amp; "Closed"
Dat (0)=& amp; H1
Dat (1)=& amp; H3
End the If
MSComm1. The Output=dat
End Sub
CodePudding user response:
The building Lord, you confirm that you are using a serial port?MPort=10
MSComm1.Com
Entire virtual serial port using a piece of string is a U turn? U series chips have many, some with all sorts of problems on their use,
CodePudding user response:
Beginners serial port development, it is best to use a real serial desktops, experienced, and using the U turn bunch,