α
2 Simple Application Controllers
The Command String 7
7 - 49
'Wait until the number of 'LenRxData' byte were received or timeout.
Do
DoEvents
Loop Until (MSComm1.InBufferCount >= lenrxdata) Or (timecnt >= 10)
Call StopTimer
If MSComm1.PortOpen = True Then
lenrxdata = MSComm1.InBufferCount
rxdata = MSComm1.Input
Call PortClose
Else
lenrxdata = -1
End If
End Sub
Private Sub Timer1_Timer()
timecnt = timecnt + 1
End Sub
Private Sub StartTimer()
timecnt = 0
Timer1.Enabled = True
End Sub
Private Sub StopTimer()
Timer1.Enabled = False
End Sub
4. Compile the project and run the application
Unless there is no change made to the code above and the MSComm1 default setup is not
changed, the example application communicates by serial port 1 at 9600 bps, 8 bit, no
parity, 1 stopp bit with
α
2 station number 0.