Dear EinarT,
I am not sure if this will work for your device. But, this will give you some ideas I believe.
If you're using TCP/IP to connect, you can try below code snippets.
Code:
tcpClient = CREATEOBJECT('MSWinsock.Winsock.1')
tcpClient.RemoteHost = "192.168.100.123" && replace with your IP of the device
tcpClient.RemotePort = 77777 && replace with your PORT (you will get this from device documentation)
tcpClient.Close() && Just to ensure that we are starting afresh. I use like this. Not sure if required.
tcpClient.Connect() && Connect to the device.
If connection is successful, tcpClient.State will have a value 7.
Please note that the connection may take some time in some devices or as per your connectivity setups. So, you may have to wait, after issuing the tcpClient.Connect(), until you get tcpClient.State = 7. While doing this, please ensure you're not getting stuck in an infinite loop (if the device fails to connect forever). So, you may have to setup a max time duration also for your wait. The below code should help in that.
Code:
lnStartSecs = SECONDS()
tcpClient.Connect()
DO WHILE tcpClient.State <> 7
IF (SECONDS() - lnStartSecs) > 5
EXIT
ENDIF
ENDDO
Here it runs for a max of 5 seconds only irrespective of connection is success or not.
Now, if you got State = 7, you can start sending to the device as per your requirement.
Code:
tcpClient.SendData(lcDataToBeSent) && Replace lcDataToBeSent with your command string.
Then you can receive the reply from the device using
Code:
lcResponseStr = SPACE(255)
tcpClient.GetData(@lcResponseStr) && you may have to refer the documentation for how to define/initialise lcResponseStr variable.
And finally when you finish, close it.
Code:
tcpClient.Close()
RELEASE tcpClient
Hope this helps in some way.
Rajesh Karunakaran