tachoparser

module
v0.0.0-...-f47db30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 1, 2024 License: AGPL-3.0

README

Tachoparser

Decode and verify tachograph data (VU data and driver card data).

Inpired by ReadESM and Go Tachograph Card / Parse tacho's card file, but developed from scratch based on the specs.

BUILDING and INSTALLATION

Public keys

For proper data verification, the public keys (root ca and member states) are required. The Python scripts pks1/dl_all_pks1.py and pks2/dl_all_pks2.py download and rename all available public keys, first generation (digital tachograph) public keys are expected to be in pks1, second generation (smart tachograph) public keys are expected in pks2.

> cd pks1
pks1> ./dl_all_pks1.py
pks1> cd ..
> cd pks2
pks2> ./dl_all_pks2.py
pks2> cd ..

Alternatively, they can be downloaded manually from ERCA certificates DT and ERCA certificates ST, but have to be renamed to their certificate reference (resp. unzipped in case of the root certificate) in this case.

BUILDING

In the root directory, execute

> ./build-binaries-prod.sh

Alternatively, execute

> go mod vendor

And then change the working directory to cmd/dddparser (or any of the other subdirectories of cmd/) and execute

> go build .

The project aims to have as little external dependencies as possible, currently there are the following external dependencies (most of them are actually not strictly required and could be removed with little effort):

The executables that are build are the following:

  • dddparser is the main executable which parses tachograph / driver card data into a json structure.
  • dddsimple is a very simplified version which only extracts the identification numbers and driver names
  • dddui is a basic UI for dddparser (select an input tacho file, select an output json file, select the file type (VU or card))
  • dddserver is a gRPC server for tachograph file parsing
  • dddclient is a basic gRPC client which connects to the dddserver
Docker build

The Dockerfile in the main directory will create a docker image containing only the dddserver executable.

Testing

There are unit tests for decoding different data types. To run, type

> go test
INSTALLATION

Put the executable cmds/dddparser/dddparser to a location that is in your PATH, f.e.

> sudo cp cmds/dddparser/dddparser /usr/local/bin

USAGE

The executable dddparser reads raw data from STDIN and outputs JSON data to STDOUT, warnings and errors are sent to STDERR.

dddparser requires one parameter option, which has to be either -card or -vu depending on the type of data (-card is for driver card data, -vu is for vehicle unit data).

Example:

> cat tachodata.ddd | ./dddparser -vu

The executable dddsimple reads raw data from STDIN and outputs JSON data to STDOUT, warnings and errors are sent to STDERR.

dddsimple has one optional argument -card which indicates that the input data is driver card data, if not given, it is assumed to be vehicle unit data.

Example:

> cat driverdata.ddd | ./dddsimple -card

The executable dddserver starts a gRPC server which listens on port 50055 for incoming requests. The server can be started with the following command:

> ./dddserver

To change the port, use the -listen option:

> ./dddserver -listen :50056

Tipps and Tricks

For output formatting and further processing, jq is recommended, f.e.:

> cat tachodata.ddd | dddparser -vu | jq . | less

TODO

  • parse 1st generation driver card data
  • parse 2nd generation driver card data
  • parse 2nd generation v2 driver card data
  • parse 1st generation vu data
  • parse 2nd generation vu data
  • parse 2nd generation v2 vu data
  • signature verification 1st generation
  • signature verification 2nd generation
  • complete unit tests for all data types

Directories

Path Synopsis
cmd
internal
pkg

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL