Tachograph parser integration¶
1. Scope¶
FLEET Mira parses driver-card C files and vehicle-unit M files through one TachographImportService. The original compressed archive object remains the evidence source; parsed tables are replaceable derived data.
2. Import pipeline¶
flowchart TD
A[Archive ID] --> B[Read and verify GZIP/hash]
B --> C[Classify binary content]
C --> D[Parse C or M structure]
D --> E[Verify certificates and signed sections]
E --> F{Result}
F -->|Valid| G[Atomically replace derived rows]
F -->|Invalid/unverifiable| H[Persist quarantine results]
F -->|Technical failure| I[Keep previous valid details]
G --> J[Links, deadlines, UI cache invalidation]
H --> J
Public integration points:
TachographImportService(db_path, logger).import_archive_id(archive_id)
DriverCardFullParser.parse_bytes(data)
VehicleUnitParser.parse(path)
DriverCardSignatureVerificationService.verify(parsed, trust_store, reference_time)
SignatureVerificationService.verify_sections(parsed, trust_store)
3. Classification¶
Classification uses protocol/file identifiers in the binary content, never the filename alone. Result values are DRIVER_CARD, VEHICLE_UNIT and UNKNOWN. C/M filename prefixes are validated only for readout-date and plausibility functions.
4. Driver-card data¶
The C parser preserves block kind, application/file ID, generation, order, raw data bytes and following signature bytes. It maps identity, card validity, authorities, driving-licence number, activities, events, faults, vehicles and positions.
Important identity mapping:
| Parser value | Business use |
|---|---|
| holder surname/first names | person conflict check and display |
| birth date | optional person value |
| card number/generation | card link and C/M matching |
| card issue/valid-from/expiry | card record and expiry deadline |
| driving-licence number/authority | person licence data |
| preferred language/country | card metadata |
No guessed values are generated from unrelated byte ranges. Text fields strip encoding indicators/control bytes and normalise whitespace without changing meaningful characters.
5. Vehicle-unit data¶
Supported download groups are G1 TREP 01–05, G2 v1 21–25 and G2 v2 31–35. Derived tables include overview/identity, card sessions, slot activities, events, faults, overspeed, second-by-second speed, technical/calibration records and position/border/loading data.
Unknown bounded optional records are retained as warnings. Invalid length/protocol sequences produce parse failure. Driver/workshop names use the same normalisation rules as C text.
6. Signature verification¶
C files¶
- G1:
EF.Card_Certificate,EF.CA_Certificate, RSA PKCS#1 and SHA-1 over exact data-block bytes. - G2/G2V2:
Card_Sign,MSCA_Card, optional link certificate and ECDSA over exact signed EFs.
M files¶
Every available signed VU download section is verified separately against the applicable ERCA/MSCA/VU chain. Trust and certificate validity use the best plausible signed file time, otherwise archive/download time with warning.
Overall priority: INVALID, then UNVERIFIABLE, then VALID. cryptography missing, signature/certificate missing or trust anchor missing produces UNVERIFIABLE, not VALID.
7. Parser and quarantine status¶
| Status | Meaning |
|---|---|
PARSED_VERIFIED |
parse and all required verification valid |
PARSED_VERIFIED_WITH_WARNINGS |
valid evidence with non-fatal parser warnings |
QUARANTINED_INVALID_SIGNATURE |
cryptographic invalidity |
QUARANTINED_UNVERIFIABLE |
required proof cannot be completed |
PARSE_ERROR |
structural/technical parse failure |
Quarantine files remain visible/exportable but cannot create trusted person/vehicle links, contribute to combined C/M analysis or compliance snapshots.
8. C/M comparison¶
The selected archive remains the base. Opposite-source intervals match by normalised card number, card generation and UTC overlap. A sweep-line comparison cuts only on interval boundaries. Valid overlapping data is shown as C and M available; one-sided coverage remains C-only or M-only. C data has priority only in the complete person-history view, never by modifying raw source rows.
9. Reprocessing and idempotency¶
Archive hash prevents duplicate originals. Reprocessing writes new derived rows only after a successful parse/verification transaction. A failed reparse preserves the last valid details. Import, deletion, restore or reparse invalidates affected UI comparison caches.
10. Extending the parser¶
When adding a record type:
- document normative file/record identifiers and generation;
- validate lengths before reading;
- preserve source section/index and raw reference;
- keep UTC values unchanged;
- add fixture and malformed-length tests;
- add signature impact tests;
- update both language versions of this document and API schemas;
- never infer a business identity from an ambiguous value.
The older technical module and table names containing ddd or DLTNG remain compatibility identifiers.