AGG Software Forums
November 24, 2024, 02:18:49 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome on our forum!
 
   Home   Help Search Login Register  

Pages: [1]
  Print  
Author Topic: TCP/IP logger check a checksum in incoming data  (Read 21918 times)
jamesant
Jr. Member
**

Karma: +0/-0
Posts: 7


View Profile
« 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.
Logged
Arthur Grasin
Tech. Support
Administrator
Hero Member
*****

Karma: +0/-0
Posts: 806



View Profile WWW
« Reply #1 on: November 12, 2024, 02:00: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.
Logged
jamesant
Jr. Member
**

Karma: +0/-0
Posts: 7


View Profile
« Reply #2 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 ?
Logged
Arthur Grasin
Tech. Support
Administrator
Hero Member
*****

Karma: +0/-0
Posts: 806



View Profile WWW
« Reply #3 on: November 15, 2024, 02:00:00 PM »

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.
Logged
jamesant
Jr. Member
**

Karma: +0/-0
Posts: 7


View Profile
« Reply #4 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.

Logged
Arthur Grasin
Tech. Support
Administrator
Hero Member
*****

Karma: +0/-0
Posts: 806



View Profile WWW
« Reply #5 on: October 09, 2013, 06:15:02 PM »

Use "DataPacket" function.
Logged
jamesant
Jr. Member
**

Karma: +0/-0
Posts: 7


View Profile
« Reply #6 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.
Logged
Arthur Grasin
Tech. Support
Administrator
Hero Member
*****

Karma: +0/-0
Posts: 806



View Profile WWW
« Reply #7 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.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines