HI there,
We have a case where our sensor (RS232 connected to a MOXA serial server on port, says 1000) will be sending data randomly or could says every 20 minutes or so.
The data will be sending from the sensor as ASCII, it looks similar to those GPS NMEA sentences but will be a series of 30 sentences of individual parameters, in total of around 3000-4000 bytes.
What should be the best way to write a CRBasic code to standby for the incoming data? Should we constantly open the TCP connection and monitor for the SerialInChk <>0 ? I was not sure if the Scan loop might miss the data.
Appreciated all ideas and suggestions.
Use TCPOpen() with the buffer set greater than 4000, and it can catch data between scans. Use instructions such as SerialInRecord() to read the data from the buffer.
man thanks for your kind reply.
at what scan interval should we set for the slowsequence? just cusious how we do a loop for getting responses without effect the other loop.
Currently we are using
IPSocket = TCPOpen("192.168.0.100",10002,4096,1500)
If IPSocket <> 0 Then
SerialInBlock(IPSocket,IncomingTCPString,4096)
a = InStr(1,IncomingTCPString,CHR(02),2)
b = InStr(a,IncomingTCPString,CHR(03),2)
MidWSStr = Mid(IncomingTCPString,a+1,b-2)
Call SaveToTable
End If
But it didn't seem to pick up the data successfully and we got zero reading.