118142-001 Rev B
Page 34 of 104
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
Summary of Contents for DXM100 Series
Page 11: ...DXM100 MANUAL 5 118147 001 Rev D Figure 2 1 Unit Dimensions ...
Page 16: ...DXM100 MANUAL 10 118147 001 Rev D Figure 3 3 Local Programming Via External Voltage Source ...
Page 17: ...DXM100 MANUAL 11 118147 001 Rev D Figure 3 4 Remote Monitoring ...
Page 18: ...DXM100 MANUAL 12 118147 001 Rev D RELAY Figure 3 5 Enable Interlock Logic Control ...
Page 37: ...118142 001 Rev B Page 13 of 104 Figure 9 Web Page 1 Contact Information ...