[−][src]Function sensirion_hdlc::decode
pub fn decode(
input: &[u8],
s_chars: SpecialChars
) -> Result<ArrayVec<[u8; 1024]>, HDLCError>
Produces unescaped (decoded) message without FEND
characters.
Inputs
- Vec
: A vector of the bytes you want to decode - SpecialChars: The special characters you want to swap
Output
- Result<ArrayVec<u8;1024>>: Decoded output message
Error
- HDLCError::TooMuchDecodedData: More than expected 260 bytes of decoded data
- HDLCError::FendCharInData: Checks to make sure the full decoded message is the full
length. Found the
SpecialChars::fend
inside the message. - HDLCError::MissingTradeChar: Checks to make sure every frame escape character
fesc
is followed by either atfend
or atfesc
. - HDLCError::MissingFirstFend: Input vector is missing a first
SpecialChars::fend
- HDLCError::MissingFinalFend: Input vector is missing a final
SpecialChars::fend
- HDLCError::TooFewData: Data to decode is fewer than 4 bytes`
- HDLCError::TooMuchData: Data to decode is larger than 1000 bytes`
Example
extern crate sensirion_hdlc; let chars = sensirion_hdlc::SpecialChars::default(); let input =[ 0x7E, 0x01, 0x50, 0x00, 0x00, 0x00, 0x05, 0x80, 0x09, 0x7E]; let op_vec = sensirion_hdlc::decode(&input.to_vec(), chars);