
4.3.5.2
Retrieve data only if it exists
1: Do
2: DoEvents
3:
If MSComm1.InBufferCount > 0 Then
4:
str = str & MSComm1.Input
5: End
If
6:
Loop Until InStr(str, Chr(3)) Or Timer - t1 > 1
7:
'str = str & MSComm1.Input
8:
If InStr(str, Chr(3)) > 0 Then
9:
tmrOpenClose.Enabled = False
10: End
If
Notice that in line 3 we check for the existence of data before we
extract data from the USB port. Normally, if there is no data, line 4
would append an empty string. However, during a noise event,
retrieving data without first checking the existence of data could
hang.
4.3.5.3
Example Output Routine
Notice that on line 13 we register an error handler in case the port
is invalid because we have closed it in another routine. Notice that
on line 16 we start a timer. When we output data on the port we
start a timer to keep track of incoming data. If we get no incoming
data it means that communications have been interrupted.
1: Private Sub outputOutputString(outputString As String)
2: Dim str As String
3: str = ProcessOutputString(outputString)
4: StatusBar1.Panels(4).Text = "TX: " & str
5: 'StatusBar1.Panels(3).Text = "RX: Waiting"
6: If (portType = "ethernet") Then
7: tcpClient.SendData (str)
8: ElseIf (portType = "USB") Then
9: usb.WriteReport (str)
10: Else
11: MSComm1.InBufferCount = 0
12:
13: On Error GoTo done
14: MSComm1.Output = str
15: done:
16: tmrOpenClose.Enabled = True
17: End If
18: End Sub
118080-001 REV A
Page 32 of 95
Summary of Contents for SLM SERIES
Page 15: ...SLM MANUAL 6 118073 001 Rev C Figure 2 2 Unit Dimensions 1200W ...
Page 19: ...SLM MANUAL 10 118073 001 Rev C Figure 3 3 Local Programming via External Voltage Source ...
Page 20: ...SLM MANUAL 11 118073 001 Rev C Figure 3 4 Remote Monitoring ...
Page 40: ...Figure 9 Web Page 1 Contact Information 118080 001 REV A Page 13 of 95 ...
Page 98: ...Request Faults 68 20 ASCII 118080 001 REV A Page 71 of 95 ...