Skip to main content

disagrees

Function disagrees 

Source
pub const fn disagrees(first: &[u8; 8], second: &[u8; 8]) -> bool
Expand description

Whether a second reading of the counters disagrees with the first.

A read of eight bytes can catch the counter mid-step, so the reference reads them twice and takes a third reading when either high byte has moved. It is a different guard from the one on the receive byte count, where the larger of two readings is kept instead.

§Arguments

  • first - the first reading.
  • second - the second.

§Returns

Whether either counter stepped over a high byte between them.

§Examples

use pamoja_radios::sx1302::timestamp::disagrees;

// The low bytes moving is ordinary; the counter is running.
assert!(!disagrees(&[1, 0, 0, 0, 2, 0, 0, 0], &[1, 0, 0, 9, 2, 0, 0, 9]));

// A high byte moving means the reading straddles a step.
assert!(disagrees(&[1, 0, 0, 0, 2, 0, 0, 0], &[1, 0, 0, 0, 3, 0, 0, 0]));