Reading / parsing .ddd (digital tachograph) file to XML in C #

I am new to C # and I need to convert .ddd

( tachograph digital file extension to .xml

,

As a first step, I have to read the file, so I am looking at examples. Every source of information I find uses examples based on .txt

when reading a file. The file type in my example .ddd

,, is nowhere close.

I am thinking about binary reading but not sure about it. What is the correct way to do this?

+3


source to share


2 answers


To perform the conversion, you need to know:

  • how to read binary data from a file
  • what the file can contain (every single byte)
  • desired output in Xml

Reading binary data from a file is pretty straightforward - BinaryReader

has all sorts of data access methods, especially if the data can be processed in a single forward hop (which seems to be the case). There are some examples there BinaryReader

.

More importantly, knowing what the data means. One byte with a value 0x20

can mean:



  • Symbol SPACE
  • Value 32

  • A byte can be the first byte UInt16

    with a completely different value
  • "The next block of data is 32 bytes long"
  • "The first block of data can be found at offset 32"
  • "The next block of data is metadata" (this byte indicates some type of block)
  • 32 bottles of beer on the wall

Without knowing what each byte in each position means, you're not going anywhere.

Then, with that information, and by reading the file into some suitable class (s), converting to Xml can be as simple as passing the class to XmlSerializer

.

+3


source


Very late answer, but this library is in C # and supports most parts of the digital tachograph specification.

https://github.com/jugglingcats/tachograph-reader

This library provides two classes that can read driver and transport card binaries and write them to the XmlWriter. XML is well structured and provides a clear representation of the contents of a binary file for later processing. Note that the code does not validate digital signatures in the file.

From the readme file:

The usage is pretty simple. There is a main DataFileReader class and two subclasses: VehicleUnitDataFile and DriverCardDataFile. You can instantiate one of the footers using the following methods:



DataFile vudf=VehicleUnitDataFile.Create();
DataFile dcdf=DriverCardDataFile.Create();

      

Once you have a reader instance, you can give it a binary to read and an XML writer:

vudf.Process("file.ddd", writer);

      

Most sections / functions of both data file formats are satisfied. It is possible to change the data file formats using DriverCardData.config and VehicleUnitData.config. These are two XML files that define a data structure with features specific to the standard (for example, circular buffer support).

+2


source







All Articles