Struct tmc2209::Reader [−][src]
pub struct Reader { /* fields omitted */ }
Expand description
A serial reader, for reading responses via the TMC2209’s UART interface.
The Reader
is stateful and stores its progress between calls to read
.
Implementations
Read a ReadResponse from the given slice of bytes.
The Reader will preserve its state between calls to read
.
This method is particularly useful when reading from a UART receiver in a non-blocking
manner. For example, if the UART receiver does not have the full response buffered (perhaps
within a UART interrupt), the Reader
retains its progress and allows for other work to be
performed before attempting to read the remainder of the message.
Returns the number of bytes read and the ReadResponse if one could be read.
This method works by reading through the bytes for a SYNC_AND_RESERVED
byte. Once found,
the next byte must be a MASTER_ADDR
byte. If found, the rest of the data is read directly
into the remainder of the byte slice. Otherwise, the state is rest and the reader goes back
to searching for a SYNC_AND_RESERVED
byte.
This function does not check the validity of the CRC, the slave address or the register address.
Which byte the reader is currently awaiting.
This method is purely to assist with debugging UART communication issues.