MDF4 File Format

Overview

Measurement Data Format version 4 (MDF 4) is a standard file format used by the automotive industry for storing measurement data in binary file format.Following blocks are supported.

  • ID block

  • Header block

  • Meta data block

  • File History block

  • Channel block

  • Channel group block

  • Data group block

  • DT block

Block Sections

Each block has three sections.

  • Header section

  • Link section

  • data section

Block Types

ID Block (ID)

Identification block is used to identify the file as an mdf4 file.It has MDF version and program Identification. This is the only block that has no general block header.IDblock are the only block types which occur only once and which have a fixed position in the MDF file.

Header Block (HD)

Header block defines the general description of measurement of a file. Header block is used to set the offset of following data group offset,channel group offset, and header text comment and set the start time in nano seconds.HD block are the only block types which occur only once and which have a fixed position in the MDF file.

Meta Data Block (MD)

Meta data block is a block which has a container for an XML string of variable length.

File history block (FH)

This block contains file time in nanoseconds and has file history text comment.

Channel Block (CN)

It contains channels that describes data structure and signals, i.e information about the measured signals and hwo the signal values are stored.

Channel Group Block (CG)

Describes the layout of records,i.e channels which are always measured jointly.

Data Group block (DG)

Contains description of the data block that may refer to one or more channel groups,measurement data including data blocks and channnel groups

Data Block (DT)

It contains data records with signal values (e.g CAN frames)

Refer to the MDF Demo page for an example about how the RAPIDSEA uses the mdf file format.

Documentation from the relevant header as follows:

MDF Specific APIs.

Defines macros and functions specific to Rapidsea MDF functionality

Author

Embien RAPIDSEA Team

Copyright

Embien Technologies India Pvt. Ltd.

Defines

RS_MD4_VERSION_4_0
RS_MD4_VERSION_4_1
RS_MAX_FILE_NAME_SIZE
RS_MAX_FILE_PATH_SIZE

Typedefs

typedef struct tag_rs_mdf_config rs_mdf_config_t

Contains information about mdf configuration.

Functions

rs_ret_val_t rs_mdf4_init(rs_mdf_config_t *ptr_config, uint8_t *ptr_buff, uint16_t u16_version, uint32_t u32_buff_size, uint32_t u32_max_file_size, uint32_t u32_max_blk_size)

This function init the mdf4 task.

This function initialize the mdf4 task

Parameters:
  • rs_mdf_config_t[in] *ptr_config - Configuration of mdf4

  • uint8_t[in] *ptr_buff - Buffer of the mdf4

  • uint32_t[in] u16_version - Version of the mdf4

  • uint32_t[in] u32_buff_size - Max buff size of mdf4 in bytes

  • uint32_t[in] u32_max_file_size - Max file size of mdf4 in bytes

  • uint32_t[in] u32_max_blk_size - Max block size of mdf4 in bytes

Returns:

return 0 for success

rs_ret_val_t rs_mdf4_set_file_info(rs_mdf_config_t *ptr_config, uint8_t *ptr_file_path, uint8_t *ptr_file_name)

This function sets the file name of the mdf4 file.

This function sets the file path and file name of the mdf4 file

Parameters:
  • rs_mdf_config_t[in] *ptr_config - Configuration of mdf4

  • uint8_t[in] *ptr_file_path - file path of the mdf4 file

  • uint8_t[in] *ptr_file_name - file name of the mdf4 file

Returns:

return 0 for success

rs_ret_val_t rs_mdf4_set_compression(rs_mdf_config_t *ptr_config, uint8_t u8_value)

This function sets type of the mdf4 file.

This function sets the compression mode of the mdf4 file given by the user

Parameters:
  • rs_mdf_config_t[in] *ptr_config - Configuration of mdf4

  • uint8_t[in] u8_value - compression mode

Returns:

return 0 for success

rs_ret_val_t rs_mdf4_set_prog_identity(rs_mdf_config_t *ptr_config, int8_t *ptr_identity)

This function sets identity of the mdf4 file.

This function sets the program identification of the mdf4 file given by the user

Parameters:
  • rs_mdf_config_t[in] *ptr_config - Configuration of mdf4

  • int8_t[in] *ptr_identity - identity of the mdf4 file

Returns:

return 0 for success

rs_ret_val_t rcb_can_data_get_first_frame(uint8_t *ptr_can_buff)

This function reads buffer of can data.

This function reads the first frame of can data

Parameters:

uint8_t[in] *ptr_can_buff - can data buffer

Returns:

return 0 for success

rs_ret_val_t rcb_can_data_get_second_frame(uint8_t *ptr_can_buff)

This function reads buffer of can data.

This function reads the second frame of can data

Parameters:

uint8_t[in] *ptr_can_buff - can data buffer

Returns:

return 0 for success

rs_ret_val_t rs_mdf4_data_log(rs_mdf_config_t *ptr_config, uint8_t *ptr_can_buff, uint32_t u32_data_size)

This function write the can data into the file.

This function writes the can data into mdf4 file based on the num_bytes.

Parameters:
  • rs_mdf_config_t[in] *ptr_config - Configuration of the mdf4 file

  • uint8_t[in] *ptr_can_buff - can data buffer

  • uint32_t[in] u32_data_size - can data size in bytes

Returns:

return 0 for success

struct tag_rs_mdf_config
#include <rs_mdf.h>

Contains information about mdf configuration.

Public Members

rs_fatfs_t file
int8_t *ptr_identity

Pointer to the identity of the mdf

uint8_t file_name[RS_MAX_FILE_NAME_SIZE]

File name of the mdf

uint8_t file_path[RS_MAX_FILE_PATH_SIZE]

File path of the mdf

uint8_t *ptr_log_buffer

Pointer to the log buffer of the mdf

uint8_t blk_index

Blk_index of the mdf

uint16_t version

Version of the mdf

uint32_t file_size

File size of the mdf

uint32_t blk_size

Block size of the mdf

uint32_t buff_size

Buffer of the mdf

uint32_t write_index

Write index of the input array