Hi,
I would like to ask for some help in decoding the TCP data I sent from a Datalogger to a TCP Socket Agent (custom coded in Node JS).
Please find below the code for the communication part (I used SendData function)
SlowSequence Scan(30,Sec,3,0) TCPOpen ("37.157.156.91",9095,0,5000,Handle,1) TCP_socket_open = TCP_socket_open + 1 SendData(Handle,0,1,Test) If Result = 0 Then 'SendVariables returns -1 if successful TCP_variable_sent = TCP_variable_sent + 1 'Increment counter if message send is successful EndIf TCPClose(Handle) TCP_socket_closed = TCP_socket_closed + 1 NextScan SlowSequence
The Test Datatable contains the following data:
Record No 829
Time Stamp 25/10/2018 12:33:45
batt_volt_Min 12,29
PTemp 27,42
SMS_Send_Res 0
And the data I receive in the socket are:
10/25/2018 2:36:32 PMNew client: 10.42.20.96:48222
10/25/2018 2:36:32 PM10.42.20.96 said (hex): bdefff10010fff00010e00ddf0bd
10/25/2018 2:36:32 PM10.42.20.96 said (hex): bd8001800110010001143900026dbcdc00000348000136331b4e0000000044cd4aa500000000f6c2bd
10/25/2018 2:36:32 PMconnection from 10.42.20.96 closed
Could you please help me decoding the stream and extracting the info?
Kind regards,
Alessandro Dalla Torre
The SendData command is used for propriety CS communications.
The recommendation would be to use something like the SerialOut or SerialOutBlock commands to send your data.
To get content for SerialOut, you can use GetRecord with a string variable for a destination. That will give you a line of data in ASCII.
The HTTPPost command is another option. You can use the optional parameters of the instruction for data streaming. One of the options will output JSON formatted data, which should work well with Node JS.