GPS tracker: Redirecting data from a GPS tracker to another server, changing the format into ASCII
It is necessary to receive data packets from the vehicle GPS tracker and send them to another server for further processing. The other server (other software) supports only one data format, and it is impossible to connect other trackers to it directly. It means that GPS Tracker Data Logger will run as a converter in this case. The other server can receive information packets in the ASCII format and does not require authentication. Sample information packet:
- IMEI - device ID.
- Year month date hours minutes seconds.
- Longitude and latitude in degrees and their decimals.
- Velocity (kph).
- Direction (degrees).
- Altitude (m).
- Number of satellites.
- Unknown parameter RID.
- 1+2+4+8-bit digital input.
- Digital outputs.
- Two analog inputs (voltage in volts).
- All that ends with a carriage return and a new line.
- GPS Tracker Data Logger Enterprise or the trial version.
- Parser for any tracker.
- Script Execute plugin for Data Logger.
- Data Redirecting plugin for the logger.
- DDE server plugin for the logger (optional, for testing purposes).
It is assumed that:
- You have configured the parameters of connecting to the device and the parser for the vehicle GPS tracker the way it is described in this article;
- You have configured the TCP/IP connection with the other server the way it is described in this article.
After you configure and test the parser with the help of DDE, you can get down to configuration.
1. It is necessary to generate a new data packet for redirecting. You can do it with the filtering "Script Execute" plugin. This plugin allows you to specify the script that will be called for every data packet the parser single out and processes. The parser for Teltonika trackers is used in this example. This parser has a set of variables it splits a data packet into. These variables will be used in the script.
2. Enable the "Data Redirecting" plugin. The "Data Redirecting" plugin must be below the "Script Execute" plugin in the list (fig. 1).
Note: The program can redirect only that data from the GPS tracker that the parser supports and processes. For example, if the tracker sends several types of packets and the parser processes only one of them, you will be able to redirect only that one packet.
Fig.1. GPS tracker. "Data Redirecting" plugin configuration.
Writing the script
The "Script Execute" plugin allows you to write the script in several scripting languages. The script in the Pascal language will be used in this tutorial (fig. 2).
Fig.2. GPS tracker. Script.
Full script source:
This script uses the GetVariable variables to get the values of the variables prepared by the parser, formats them and generates a new data packet. The new data packet in the ASCII format ready to be redirected is added to existing parser variables with the help of the SetVariable function under the name ASCII_DATA_PACKET. Values absent in the parser variables are replaced with their default values. If there are no device ID or date values among the parser variables, this data packet is ignored.
It is easy to see that script variables of the sDate_Name:string = 'TIMESTAMP_UTC'; type are used to specify the name of a parser variable that will be later used in the script body.
Redirecting the data
To configure the "Data Redirecting" plugin (fig.3), select it in the list and click the "Configure" button under the list.
Fig.3. GPS tracker. "Data Redirecting" plugin configuration.
- Specify the name of the variable data from which will be redirected;
- Specify the destination IP address and port the way it is displayed in the program's main window.
Now you have to save all the changes. To do it, close all dialog boxes by clicking the "OK" button.
After data is received from the GPS tracker, you will see information about the data being redirected in the message log of the program (fig. 3).
Fig.3. GPS tracker. Data redirection message.
If you switch to the TCP client configuration (fig. 4) in the program's main window, you will be able to see the data being redirected.
Fig.4. GPS tracker. Data being redirected.