
3-11
IM AQ6370C-17EN
Ethernet Interface
1
2
3
4
5
6
7
8
App
Index
'==================================================
' Sub routine
' Connect OSA via ETHERNET
'
in: strIP IP Address(Ex. "192.168.1.100") or Computer Name
'
intPort port number (Ex. 10001)
'
out:
none
'
ret:
OK/NG true: OK, false: NG
'==================================================
Function ConnectLan(strIP As String, intPort As Integer) As Boolean
Dim sglStart As Single
Dim sglEnd As Single
Dim sglNow As Single
Dim bConnect As Boolean
sglStart = Timer()
sglEnd = sg TIMEOUT
bConnect = True
' === Connect ===
Winsock1.RemoteHost = strIP
' OSA IP address
Winsock1.RemotePort = intPort
' OSA remote port num
Winsock1.Connect
' === Wait to connect complete ===
While ((Winsock1.State <> sckConnected) And (bConnect = True))
DoEvents
' Timeout check
sglNow = Timer()
If (sglNow < sglStart) Then sglNow = 86400
If sglNow >= sglEnd Then bConnect = False
Wend
'----- return value set
ConnectLan = bConnect
End Function
'==================================================
' Sub routine
' Send Remote Command
'==================================================
Sub SendLan(strData As String)
Winsock1.SendData strData & vbCrLf
DoEvents
End Sub
'==================================================
' Sub routine
' Receive query data
'
in:
none
'
out: strData
Receive data
'
ret: Receive data size (Error: -1)
'==================================================
Function ReceiveLan(strData As String) As Long
Dim strData2 As String
Dim sglStart As Single
Dim sglEnd As Single
Dim sglNow As Single
Dim bTimeout As Boolean
sglStart = Timer()
sglEnd = sg TIMEOUT
bTimeout = False
3.3 Sample Program