Skip to main content

scan

Function scan 

Source
pub fn scan(buf: &[u8]) -> Scan<'_>
Expand description

Find the first valid frame in a receive buffer that may begin with noise, an echo or the tail of a broken frame (what a level converter delivers on a real bus).

Every byte that cannot start a valid frame is skipped. The first start byte whose frame is still incomplete wins: the rest may be arriving, and its data can contain bytes that look like a frame of their own (an E5, a 10 … 16). A stray start byte in front of a reply is resolved as soon as enough bytes arrive to show its frame is invalid (wrong length bytes, checksum or stop byte). Checksums are verified for every frame.