Acuity AP820 Laser Scanners
Rev. 3.3
33
Later, once you’ve established communications with the laser, you can configure the
laser’s working IP address to be another address, if desired.
11.4
Calling EthernetScanner_Connect,
Ethernet_Scanner_Disconnect, and
EthernetScanner_GetConnectStatus.
To prove that the AP820 is connected properly and that we are able to “talk” to it via
Ethernet, we will have to call EthernetScanner_Connect, and then verify that we are
connected by calling EthernetScanner_GetConnectStatus.
The form of the function EthernetScanner_Connect is:
Private Function
EthernetScanner_Connect(
ByVal
IPAddr
As String
,
ByVal
Port
As String
,
ByVal
Timeout
As UInteger
)
As
IntPtr
Where:
IPAddr is a string containing the IP Address (e.g. “192.168.123.222”)
Port as a string containing the TCP Port (default value is “3000”)
Timeout is an unsigned integer containing the number of milliseconds to wait for a
response
If successful, this function returns a pointer to an object representing the AP820. (This
pointer will be required to be passed to other functions in the dll.) If this function is
unsuccessful, this pointer will be a null pointer. First, we declare a pointer for the laser
object:
Public
pScanner
As
IntPtr =
Nothing
Then, we connect to the object with the following code:
pScanner = EthernetScanner_Connect(
"192.168.1.245"
,
"1096"
, 500)
If
pScanner =
Nothing Then
'Failure!
Else
'Success!
End If
If the function does not return a null pointer, we have successfully connected to the laser.
We will disconnect from the AP820 later by calling EthernetScanner_Disconnect and
passing it the pScanner pointer.
We can check the connect status by calling:
Private Sub
EthernetScanner_GetConnectStatus(
ByVal
pScanner
As
IntPtr,
ByRef
Status
As UInteger
)