Struct flipdot_testing::Odk [−][src]
Connects to a real ODK over the specified serial port and uses it to drive a SignBus
.
Typically this will be used to drive a VirtualSignBus
in order to study the bus traffic
or inspect the pages of pixel data sent by the ODK.
Examples
use flipdot_serial::SerialSignBus; use flipdot_testing::{Address, Odk, VirtualSign, VirtualSignBus}; // Populate bus with signs from addresses 2 to 126 // (which seems to be the possible range for actual signs). let signs = (2..127).map(Address).map(VirtualSign::new); let bus = VirtualSignBus::new(signs); // Hook up ODK to virtual bus. let port = serial::open("/dev/ttyUSB0")?; let mut odk = Odk::try_new(port, bus)?; loop { // ODK communications are forwarded to/from the virtual bus. odk.process_message()?; }
Implementations
impl<P: SerialPort, B: SignBus> Odk<P, B>
[src]
pub fn try_new(port: P, bus: B) -> Result<Self, Error>
[src]
Create a new Odk
that connects the specified serial port and bus.
Errors
Returns the underlying serial_core::Error
if the serial port cannot be configured.
Examples
let bus = VirtualSignBus::new(vec![VirtualSign::new(Address(3))]); let port = serial::open("COM3")?; let odk = Odk::try_new(port, bus)?;
Note: You would typically use the env_logger
crate and run with
RUST_LOG=debug
to watch the bus messages go by.
pub fn process_message(&mut self) -> Result<(), OdkError>
[src]
Reads the next frame from the ODK over the serial port, forwards it to the attached bus, and sends the response, if any, back to the ODK.
Errors
Returns:
OdkError::Communication
if there was an error reading or writing the data.OdkError::Bus
if the bus failed to process the message.
Examples
let bus = VirtualSignBus::new(vec![VirtualSign::new(Address(3))]); let port = serial::open("/dev/ttyUSB0")?; let mut odk = Odk::try_new(port, bus)?; loop { odk.process_message()?; }
Trait Implementations
impl<P: Debug + SerialPort, B: Debug + SignBus> Debug for Odk<P, B>
[src]
impl<P: Eq + SerialPort, B: Eq + SignBus> Eq for Odk<P, B>
[src]
impl<P: Hash + SerialPort, B: Hash + SignBus> Hash for Odk<P, B>
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
pub fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<P: PartialEq + SerialPort, B: PartialEq + SignBus> PartialEq<Odk<P, B>> for Odk<P, B>
[src]
impl<P: SerialPort, B: SignBus> StructuralEq for Odk<P, B>
[src]
impl<P: SerialPort, B: SignBus> StructuralPartialEq for Odk<P, B>
[src]
Auto Trait Implementations
impl<P, B> RefUnwindSafe for Odk<P, B> where
B: RefUnwindSafe,
P: RefUnwindSafe,
B: RefUnwindSafe,
P: RefUnwindSafe,
impl<P, B> Send for Odk<P, B> where
B: Send,
P: Send,
B: Send,
P: Send,
impl<P, B> Sync for Odk<P, B> where
B: Sync,
P: Sync,
B: Sync,
P: Sync,
impl<P, B> Unpin for Odk<P, B> where
B: Unpin,
P: Unpin,
B: Unpin,
P: Unpin,
impl<P, B> UnwindSafe for Odk<P, B> where
B: UnwindSafe,
P: UnwindSafe,
B: UnwindSafe,
P: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,