[][src]Crate dlt_parse

A zero allocation rust library for basic parsing & writing DLT (Diagnostic Log and Trace) packets. Currently only the parsing and writing of the header is supported (excluding the verbose packet definitions).


First, add the following to your Cargo.toml:

dlt_parse = "0.1.0"

Next, add this to your crate:

use dlt_parse;

What is dlt_parse?

dlt_parse is a library that aims to provide serialisation & deserialisation funtions for DLT (Diagnostic Log and Trace) packets. It should make it possible to anlyse recordings of DLT packets as fast as possible, as well as writing servers that send DLT packets to the network.

Some key points are:

  • It is completly written in Rust and thoroughly tested.
  • Special attention has been paid to not use allocations or syscalls.
  • The package is still in development and can & will still change.
  • Methods for parsing verbose DLT packets are still missing (but maybe implemented in future versions).

Example: Serializing & Slicing/Deserializing DLT Packets

In this example a non verbose DLT packet is serialized and deserialized again. Specificly the serialized packet is converted into a DltPacketSlice. This has the advantage, that not all fields have to be deserialied to access the payload or specific fields in the header. Note that it is also possible to completely deserialize DLT headers with the DltHeader::read function. This can make sense, if most fields of the header are used anyways.

use self::dlt_parse::{DltHeader, DltExtendedHeader, SliceIterator};

let header = {
    let mut header = DltHeader {
        is_big_endian: true, //payload & message id are encoded with big endian
        version: 0,
        message_counter: 0,
        length: 0,
        ecu_id: None,
        session_id: None,
        timestamp: None,
        extended_header: Some(DltExtendedHeader::new_non_verbose(
            123,//application id
            1,//context id
    header.length = header.header_len() + 4 + 4; //header + message id + payload


//buffer to store serialized header & payload
let mut buffer = Vec::<u8>::with_capacity(usize::from(header.length));
header.write(&mut buffer).unwrap();

//write payload (message id 1234 & non verbose payload)
    //for write_all
    use std::io::Write;
    //byteorder crate is used for writing the message id with  the correct endianess
    use byteorder::{BigEndian, WriteBytesExt};

    //write the message id & payload
    buffer.write_u32::<BigEndian>(1234).unwrap(); //message id
    buffer.write_all(&[1,2,3,4]); //payload

//packets can contain multiple dlt messages, iterate through them
for dlt_message in SliceIterator::new(&buffer) {
    match dlt_message {
        Ok(dlt_slice) => {
            //check if the message is verbose or non verbose (non verbose messages have message ids)
            if let Some(message_id) = dlt_slice.message_id() {
                println!("non verbose message {:x}", message_id);
                println!("  with payload {:?}", dlt_slice.non_verbose_payload());
            } else {
                println!("verbose message (parsing not yet supported)");
        Err(err) => {
            //error parsing the dlt packet
            println!("ERROR: {:?}", err);

An complete example which includes the parsing of the ethernet & udp headers can be found in examples/print_messages_ids.rs




Extended dlt header (optional header in the dlt header)


A dlt message header


A slice containing an dlt header & payload.


Allows iterating over the someip message in a udp or tcp payload.



Errors that can occure on reading a dlt header.


Errors that can occur when serializing a dlt header.