pub struct Assembler { /* private fields */ }Expand description
Assembles bytes from a UART into complete sentences.
Resynchronizing is the normal case, not the exceptional one: a
receiver powering up mid-sentence, a UART overrun, and a line longer
than MAX_SENTENCE all leave the assembler mid-line, and all of
them recover at the next $ without any caller involvement.
Implementations§
Source§impl Assembler
impl Assembler
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Discard any partial line. Call after powering the receiver, so bytes from before the power cycle cannot join a sentence from after it.
Sourcepub fn push(&mut self, byte: u8) -> Option<Sentence>
pub fn push(&mut self, byte: u8) -> Option<Sentence>
Feed one byte, yielding a parsed sentence when one completes.
Returns None for every byte that does not finish a valid
sentence — including ones that finish an invalid one, since a bad
checksum and an unrecognized sentence are both simply nothing to
report.