Title: TCP/IP logger check a checksum in incoming data Post by: jamesant on October 08, 2013, 06:04:49 PM I am receiving data using the Advanced TCP/IP data logger like this:
$25623,25637,49414,25616,44142,54216,-68682,131008150028,0660\r\n The last 4 digit value is a checksum of the previous 8 values. I want to be sure the data is correct before it is put into an sql database, and reply with an OK to indicate that the data can be deleted. If the checksum is wrong, I need to discard the data and reply ERROR to get the data sent again. What is the best way to do this? I can change the format of the checksum if required. Title: Re: TCP/IP logger check a checksum in incoming data Post by: Arthur Grasin on October 08, 2013, 08:46:00 PM In Advanced TCP/IP Data Logger Enterprise (or trial) you can do it using the "Script Execute" plugin. But. of course, you need to write a script that will calculate and verify the checksum.
Title: Re: TCP/IP logger check a checksum in incoming data Post by: jamesant on October 09, 2013, 12:10:42 AM Does the script get executed before the ascii parser and the sql database write ?
If so, I can write a script to reject bad data before it gets any further. If not, will it be too late by the time the checksum is checked in the Script execute plugin? How do I access the incoming data in a script ? Is there some sort of global array of received characters to process ? Title: Re: TCP/IP logger check a checksum in incoming data Post by: Arthur Grasin on October 09, 2013, 07:25:38 AM 1. The Script Execute plugin will be called after the parser and before any data export plugin.
2. You can access parsed data and a whole data packet from a script. Also, you can discard invalid data packet and they will not be exported. Look at the plugin's folder for examples. Title: Re: TCP/IP logger check a checksum in incoming data Post by: jamesant on October 09, 2013, 06:01:57 PM How do you access the whole data packet ?
I can see how to access individual variables, but not the whole packet. Title: Re: TCP/IP logger check a checksum in incoming data Post by: Arthur Grasin on October 09, 2013, 06:15:02 PM Use "DataPacket" function.
Title: Re: TCP/IP logger check a checksum in incoming data Post by: jamesant on October 09, 2013, 06:45:23 PM I get
Undeclared identifier: 'DataPacket' if I try and use DataPacket() as a function. I am using C++ script. I searched for DataPacket in the forum posts and found the answer in another thread : string sName1 = "DATA_PACKET"; string data; { data = GetVariable(sName1); ShowMessage(data); } Thanks for the clue. Title: Re: TCP/IP logger check a checksum in incoming data Post by: Arthur Grasin on October 10, 2013, 07:41:51 AM Sorry, this is my mistake. Also you may use the "FULL_DATA_PACKET" variable, because "DATA_PACKET" does not include beginning and ending characters of a data packet.
|