α
2 Simple Application Controllers
The Command String 7
7 - 48
Private Sub ShowRxData(rxdata As Variant, rxdatalen As Integer)
Dim DataStr As String
Dim j As Integer
Dim Re As String
If rxdatalen > 0 Then
For j = 0 To rxdatalen - 1
Re = rxdata(j)
DataStr = DataStr + Right$("00" + Hex$(Re), 2) & " "
Next
ElseIf rxdatalen = 0 Then
DataStr = "No data received"
Else
DataStr = "Communication Reset"
End If
txtRxText.Text = DataStr
End Sub
Private Function PortOpen() As Boolean
Dim message As Variant
On Error GoTo ErrorHandler
If MSComm1.PortOpen = True Then
PortOpen = False
Else
With MSComm1
.InputLen = 0
.InputMode = comInputModeBinary
.PortOpen = True
End With
Call StartTimer
Do
DoEvents
Loop Until timecnt > 1
Call StopTimer
PortOpen = True
End If
Exit Function
ErrorHandler:
txtRxText.Text = "Error! Wrong Port Setup or Port in use."
PortOpen = False
End Function
Private Sub PortClose()
MSComm1.PortOpen = False
End Sub
Private Sub SendCmnd()
MSComm1.Output = cmdstr
End Sub
Private Sub RecResponse(ByRef rxdata As Variant, ByRef lenrxdata As Integer)
Call StartTimer