Skip to content

data format

Lukas Sigrist edited this page Dec 23, 2016 · 96 revisions

RocketLogger Data (RLD) Format Specification

The sampled data can be stored either in CSV or in binary RLD format, which is explained below.

Overview

A RLD file consists of a file header and a data structure. The header contains a constant size lead-in, a comment and a list of channel structs, describing all sampled channels. The data part contains a list of data blocks. All blocks are aligned to 32-bit and the data ist saved in Little-Endian.

The following picture shows an overview of the file structure. Red blocks define data, whereras all other colors are only used to show the logic structure.

Data Format

File Header

Lead-In

The file header lead in contains general measurement information and has a fixed size.

Offset Size (byte) Field Content
0x00 4 Magic Number %RLD ( = 0x444C5225) magic number (unsigned integer)
0x04 2 File Version Current file version number (unsigned integer)
0x06 2 Header Length Total header length in bytes (unsigned integer)
0x08 4 Data Block Size Data block size in samples (unsigned integer)
0x0C 4 Data Block Count Number of data blocks (unsigned integer), last block may not be full
0x10 8 Sample Count Total number of samples taken (unsigned integer)
0x18 2 Sampling Rate Sampling rate in SPS (unsigned integer)
0x1A 6 x 1 MAC Address MAC address as device identifier, stored in Big-Endian (unsigned integer)
0x20 8 Start Time Seconds Start time seconds in UNIX UTC time (integer)
0x28 8 Start Time Nanoseconds Start time nanoseconds (integer)
0x30 4 Comment Length Length of header comment in bytes (unsigned integer), needs to be a multiple of 4 for alignment purposes
0x34 2 Binary Channel Count Number of binary channels (unsigned integer), nb
0x36 2 Analog Channel Count Number of analog channels (unsigned integer), na

Total size: 56 bytes

Comment

An additional comment can be put here in ASCII format. Its size is defined in the header lead-in and it is aligned to 32-bit using bit stuffing.

Channels

This part contains detailed information about all sampled channels. There can be an custom number of channels (defined in lead-in field "Binary Channel Count" and "Analog Channel Count"). The channel order determines the channel position in the data block. Each channel can have a different sample size ("Data Size" field), however it is recommended to have equal sizes for improved import into processing tools (e.g. Matlab).

Offset Size (byte) Field Content
0x00 4 Channel Unit Encoded channel unit 1 (integer)
0x04 4 Channel Scale Channel scaling in power of tens, ignored for binary channels (integer)
0x08 2 Data Size Channel sample size in bytes, ignored for binary channels (unsigned integer)
0x0A 2 Valid Data Link Link to additional range valid binary channel (unsigned integer)
0x0C 16 x 1 Channel Name Name of channel (char array)

Total size per channel: 28 bytes

1 Channel unit codings:
Code Unit
0 Undefined
1 Voltage
2 Current
3 Binary
4 Range Valid (binary)

Channel Data

The channel data is stored in a list of blocks. The number of blocks is defined in lead-in field "Data Block Count". Every data block starts with two different timestamps, which both specify the time at which the first samples of each block was read. The first timestamp is stored in UNIX format (UTC) and is read from the Linux OS real-time clock. This timestamp is adjusted by the operating system when time updates are received from the network via a time synchronization protocol. The second timestamp is read from the Linux OS monotonic timer and unaffected by these measurements and alywas refers to the (drifting) clock of the hardware. It is also stored in UNIX format and has a fixed, but unspecified time reference in the past. More details about the differences of these timers can be found in the Linux manpage of clock_gettime. This clock is not being adjusted by any time synchronization and uses a fixed but not necessarily specific time. These two timestamps are followed by a specific number of samples (defined in lead-in field "Data Block Size"). The last block may not be full. The binary channels are merged into bit-stuffed 32-bit values, right aligned with the first channel at LSB. The number of binary values nbv is equal to nbv = ceil(nb/32), where nb is lead-in field "Binary Channel Count". nbv may be zero.

An overview over a data block can be seen in the following figure.

Data Block

Data Block Offsets
Offset Size (byte) Field Content
0x00 8 Seconds Timestamp of first sample in UNIX UTC seconds (integer)
0x08 8 Nanoseconds Nanoseconds timestamp of first sample (integer)
0x10 8 Seconds Timestamp of first sample in UNIX UTC seconds (integer)
0x18 8 Nanoseconds Nanoseconds timestamp of first sample (integer)
0x20 nbv x 4 (nbv = ceil(nb/32)) Binary Values Merged binary channels, right aligned, stuffed to 32-bit
0x#0 CH1 size (defined in channel field "Data Size") Analog Channel 1 First sample of analog channel one (integer)
...
Clone this wiki locally