Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

Help decoding TCP Datatable sent via SendData() function


Alex Tower Oct 25, 2018 12:41 PM

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


Vim Oct 26, 2018 01:18 PM

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.


JDavis Oct 26, 2018 04:52 PM

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.

Log in or register to post/reply in the forum.