Reputation: 1199
I'm fairly new to C# by the way and need to convert .ddd
(digital tachograph output file extension) to .xml
.
As a first step I should read the file, so I'm looking at examples. Every source of information I find are using .txt
based examples on reading a file. The file type in my example, .ddd
, is nowhere near that.
I'm thinking about binary read but not sure about that either. What is the correct way for this?
Upvotes: 8
Views: 17658
Reputation: 31
There are also ready-made solutions, such as ReadESM (https://sourceforge.net/projects/readesm/files/) or DDD2XML (https://www.canlab.cz/en/DDD2XML). DDD2XML also supports the second generation of tachographs.
Upvotes: 3
Reputation: 749
Very late answer but this library is in C# and supports most parts of the digital tachograph spec.
https://github.com/jugglingcats/tachograph-reader
This library provides two classes that can read driver and vehicle card binary files and write to an XmlWriter. The XML is well structured and provides a clear representation of the content of the binary file for subsequent processing. Note that the code does not check the digital signatures in the file.
From the readme:
Usage is quite simple. There is a main class DataFileReader and two subclasses: VehicleUnitDataFile and DriverCardDataFile. You can create an instance of one of the sublasses using the following methods:
DataFile vudf=VehicleUnitDataFile.Create();
DataFile dcdf=DriverCardDataFile.Create();
Once you have a reader instance you can give it a binary file to read and an XML Writer:
vudf.Process("file.ddd", writer);
Most of the sections/features of both data file formats are catered for. It's possible to modify the data file formats using DriverCardData.config and VehicleUnitData.config. These are two XML files defining the structure of the data with features specific to the standard (such as cyclic buffer support).
Upvotes: 11
Reputation: 26446
To perform the conversion you need to know:
Reading binary data from a file is fairly simple - the BinaryReader
has all kinds of methods to access the data, especially if the data can be processed in a single forward pass (which seems to be the case). There are tons of BinaryReader
examples out there.
What's more important is knowledge of what the data means. A single byte, with the value 0x20
could mean:
32
UInt16
with an entirely different valueWithout information about what each byte at each position means, you won't get anywhere.
Then with that information, and having read the file into some fitting class(es), the conversion to Xml could be as simple as passing the class to an XmlSerializer
.
Upvotes: 3