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.
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.
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 ?
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.
How do you access the whole data packet ?
I can see how to access individual variables, but not the whole packet.
Use "DataPacket" function.
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.
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.