
3-13
IM AQ6370C-17EN
Ethernet Interface
1
2
3
4
5
6
7
8
App
Index
'------------------------------
' Recieve binary data block
'------------------------------
lngPos = 0
lngTempPos = 0
ReDim byteDummy(lngDataLength)
Winsock1.GetData byteDummy, vbArray + vbByte, lngDataLength
' Receive binary data
Do
DoEvents
If (lngTempPos > UBound(byteDummy)) Then
Winsock1.GetData byteDummy, v vbByte, lngDataLength
' Continue to receive
lngTempPos
=
0
Else
byteArray(lngPos)
=
byteDummy(lngTempPos)
lngPos = 1
lngTempPos = lngT 1
End
If
'Timeout
check
sglNow = Timer()
If (sglNow < sglStart) Then sglNow = 86400
If sglNow >= sglEnd Then bTimeout = True
Loop Until ((lngPos = lngDataLength) Or (bTimeout = True))
End If
' return value set
If bTimeout = True Then
ReceiveBinaryLan = -1
Else
ReceiveBinaryLan = lngDataLength
End If
End Function
'====================================================================
' Read binary data(1byte)
'====================================================================
Sub ReadIPBin(byteData As Byte)
Dim sglStart As Single
Dim sglEnd As Single
Dim sglNow As Single
Dim bTimeout As Boolean
sglStart = Timer()
sglEnd = sg TIMEOUT
bTimeout = False
'----- wait until data received or timeout
Do
DoEvents
'Timeout check
sglNow = Timer()
If (sglNow < sglStart) Then sglNow = 86400
If sglNow >= sglEnd Then bTimeout = True
Loop Until ((Winsock1.BytesReceived > 1) Or (bTimeout = True))
Winsock1.GetData byteData, vbByte, 1
' 1byte read
End Sub
3.3 Sample Program