#frame #parser #parse #format #hdlc #hdlc-frame #hdlc-address

no-std hdlcparse

A no_std library for parsing HDLC frames

2 stable releases

2.0.0 Sep 17, 2022
1.0.0 Jul 4, 2022

#2026 in Parser implementations

21 downloads per month

MPL-2.0 license

16KB
301 lines

A HDLC parsing library

Currently only frame format type 3 is supported. This is the format used in DLMS.

Documentation

The documentation of the latest version can be found here


lib.rs:

This module can be used to parse HDLC frames.

Example

use hdlcparse::type3::{HdlcAddress, HdlcFrame};

let frame: [u8; 33] = [
   0x7E, 0xA0, 0x20, 0x76, 0x54, 0xAE, 0x1B, 0x46, 0xA9, 0x13, 0x2F, 0x2F, /*HCS*/
   0xE6, 0xE6, 0x00, 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA,
   0xBB, 0xCC, 0xDD, 0xEE, 0xFF, 0x4E, 0x66, /*FCS*/
];
// parse the frame
let hdlc_frame = HdlcFrame::parse(&frame).unwrap();
// check the destination address
assert_eq!(
    hdlc_frame.1.dest_addr,
    HdlcAddress {
        upper: 0x1DAA,
        lower: Some(0x2B8D),
    }
);

Dependencies

~1MB
~17K SLoC