Function resol_vbus::utils::calc_and_set_checksum_v0
source · pub fn calc_and_set_checksum_v0(buf: &mut [u8])
Expand description
Calc and set 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.
Examples
use resol_vbus::utils::calc_and_set_checksum_v0;
let mut buf = [ 0x10, 0x00, 0x11, 0x7E, 0x10, 0x00, 0x01, 0x1B, 0x00 ];
calc_and_set_checksum_v0(&mut buf [..]);
assert_eq!(0x34, buf [8]);