Skip to main content

Module slip

Module slip 

Source
Expand description

SLIP framing (RFC 1055).

Each frame ends with C0; inside a frame C0 is sent as DB DC and DB as DB DD. Senders send no leading C0.

use divecomputer_core::slip::{SlipDecoder, encode};

let mut frame = Vec::new();
encode(&[0x01, 0xC0, 0xDB], &mut frame);
assert_eq!(frame, [0x01, 0xDB, 0xDC, 0xDB, 0xDD, 0xC0]);

let mut decoder = SlipDecoder::new(16);
let decoded: Vec<_> = frame.iter().filter_map(|&b| decoder.push(b).transpose()).collect();
assert_eq!(decoded, [Ok(vec![0x01, 0xC0, 0xDB])]);

Structs§

SlipDecoder
Incremental SLIP decoder: feed it received bytes one at a time.

Functions§

encode
Appends the SLIP encoding of data, including the terminating C0, to out.