pub struct Spy<T, F>{ /* private fields */ }
Expand description
embedded hal spy implemnets call backs for used traits
Intended use is chaining over an existing embedded_hal implementation sniffing all the data. Useful when preparing for a refacforing and want to collect actual data for unit test case.
Blocking SPI API hal::blocking::spi::Transfer will return DataWord::First at start of transfer, all data sent in DataWord::Byte(u8) DataWord::Response to indicate where transmit ends and response begins all recived bytes in DataWord::Byte(u8) ending with DataWord::Last
Usage:
extern crate embedded_hal_spy;
use embedded_hal_spy::DataWord;
let mut spix = embedded_hal_spy::new(spi,
|w|{
match w {
DataWord::First => {
print!("data = [");
},
DataWord::Last => {println!("],"); },
DataWord::Response => { print!("],\r\n ["); },
DataWord::Byte(num) => {
print!("{:x},",num);
},
_other => {},
}
}
);
Trait Implementations§
Source§impl<T, F> StatefulOutputPin for Spy<T, F>
impl<T, F> StatefulOutputPin for Spy<T, F>
Source§impl<T, F> ToggleableOutputPin for Spy<T, F>
impl<T, F> ToggleableOutputPin for Spy<T, F>
Source§impl<T, F> FullDuplex<u8> for Spy<T, F>
FullDuplex will return every data sent and read in DataWord::Byte(u8)
impl<T, F> FullDuplex<u8> for Spy<T, F>
FullDuplex will return every data sent and read in DataWord::Byte(u8)
Auto Trait Implementations§
impl<T, F> !Freeze for Spy<T, F>
impl<T, F> !RefUnwindSafe for Spy<T, F>
impl<T, F> Send for Spy<T, F>
impl<T, F> !Sync for Spy<T, F>
impl<T, F> Unpin for Spy<T, F>
impl<T, F> UnwindSafe for Spy<T, F>where
T: UnwindSafe,
F: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more