Function calc_and_compare_checksum_v0

Source
pub fn calc_and_compare_checksum_v0(buf: &[u8]) -> bool
Expand description

Calc and compare checksum according to VBus protocol version x.0.

This function calculates the checksum over all but the last bytes in the provided slice and compares the calculated checksum with the last byte in the slice, returning the result of the comparison.

ยงExamples

use resol_vbus::utils::calc_and_compare_checksum_v0;

assert_eq!(true, calc_and_compare_checksum_v0(&[ 0x10, 0x00, 0x11, 0x7E, 0x10, 0x00, 0x01, 0x1B, 0x34 ]));
assert_eq!(false, calc_and_compare_checksum_v0(&[ 0x10, 0x00, 0x11, 0x7E, 0x10, 0x00, 0x01, 0x1B, 0x00 ]));