pub fn len_to_dlc(len: usize) -> u8Expand description
Maps a data length to the data-length code that represents it.
Classic CAN and the first nine CAN-FD codes are the length itself, 0 through 8. Above that CAN-FD jumps in steps, so a length between two steps rounds up to the next code.
§Arguments
len- the data length in bytes.
§Returns
The 4-bit data-length code.
§Examples
use pamoja_can::len_to_dlc;
assert_eq!(len_to_dlc(8), 8);
assert_eq!(len_to_dlc(12), 9);
assert_eq!(len_to_dlc(64), 15);