use meterbus_wired_datalink::{
CommunicationType, Frame, LongFrame,
decoder::exact::{DecodeError, decode},
};
fn main() -> Result<(), DecodeError> {
let frame = decode(&[0x10, 0x5b, 0x01, 0x5c, 0x16])?;
if let Frame::Short(short) = &frame {
assert_eq!(
short.control().communication_type(),
CommunicationType::ReqUd2
);
assert_eq!(short.address().value(), 1);
}
let mut output = [0_u8; LongFrame::MAX_LEN];
assert_eq!(
frame
.encode_into(&mut output)
.expect("maximum frame buffer is large enough"),
[0x10, 0x5b, 0x01, 0x5c, 0x16]
);
Ok(())
}