MDF Library in ANSI C

Moving Forward

Vector MDF FormatA project closely related to the automotive industry had a display that communicated via J1939 and had a large storage capacity.  At the time, the display logged data, but only in an ascii csv format.  It was decided that the logging needed an overhaul to adhere to a more versatile logging standard, and the MDF (Measurement Data Format) developed in 1991 by the combined efforts of Vector and Robert Bosch GmbH was the choice.

I took this opportunity to write a library in ANSI C that implements the MDF format (see the entire MDF specification here). The library provided public functions to add new data definitions, write the header, and add data to an unsorted MDF file.  It also provisioned for space limitations on the storage device and unexpected power loss.

The code was written using structs and as much function and data hiding as ANSI C allows, so it was fairly object oriented.  It also allocated memory dynamically using malloc, calloc, and realloc, and while a memory leak was not a concern because the logger would only be shut down on total loss of power, care was still taken to free any dynamically allocated memory appropriately.

Moving Backward

csv File

Having completed the MDF library for the embedded linux display, it was necessary to be able to convert the MDF logs into the old ascii format to support legacy tools.  Within hours, I had created the first revision of a quick and easy converter program using Visual Basic 6 that would convert selected MDF files or all MDF files in a chosen directory to the old ascii csv format. Knowing that the csv files were used by legacy Excel tools, I took care to split MDF files into multiple csv files so as to not exceed the older Excel’s 65,535 row per worksheet limit.