Struct flipdot_testing::Odk[][src]

pub struct Odk<P: SerialPort, B: SignBus> { /* fields omitted */ }

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:

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]

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

impl<P, B> Send for Odk<P, B> where
    B: Send,
    P: Send

impl<P, B> Sync for Odk<P, B> where
    B: Sync,
    P: Sync

impl<P, B> Unpin for Odk<P, B> where
    B: Unpin,
    P: Unpin

impl<P, B> UnwindSafe for Odk<P, B> where
    B: UnwindSafe,
    P: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.