use crate::Diagnostic;
use crate::Report;
use crate::report::{Finding, Location, Severity};
#[derive(Debug, Clone, Copy)]
pub struct SyncByteCheck;
impl Diagnostic for SyncByteCheck {
fn run(&self, ts: &[u8], report: &mut Report) {
const SYNC: u8 = 0x47;
const PACKET_SIZE: usize = 188;
let n_packets = ts.len() / PACKET_SIZE;
for i in 0..n_packets {
let offset = i * PACKET_SIZE;
if ts[offset] != SYNC {
report.push(Finding::new(
Severity::Error,
Location::new(
i,
u16::from_be_bytes([ts[offset + 1], ts[offset + 2]]) & 0x1FFF,
),
"sync-byte",
alloc::format!(
"Expected sync byte 0x47 at start of packet {}, found 0x{:02X}",
i,
ts[offset]
),
));
}
}
}
}