flipdot_testing/
lib.rs

1//! Tools for testing and debugging Luminator sign communications.
2//!
3//! For the basic task of sign communication, you likely want to use the high-level API
4//! in the [`flipdot`] crate instead.
5//!
6//! This crate isn't directly related to controlling a real sign, but provides some helpful diagnostic tools.
7//! [`VirtualSignBus`] is a general-purpose mock implementation of one or more signs attached to the bus,
8//! and [`Odk`] allows connecting a real ODK over serial to a [`SignBus`](flipdot_core::SignBus).
9//!
10//! Intended only for hobbyist and educational purposes. Not affiliated with Luminator in any way.
11//!
12//! # Examples
13//!
14//! ```no_run
15//! use flipdot_core::PageFlipStyle;
16//! use flipdot_serial::SerialSignBus;
17//! use flipdot_testing::{Address, Odk, VirtualSign, VirtualSignBus};
18//!
19//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
20//! #
21//! // Populate bus with signs from addresses 2 to 126
22//! // (which seems to be the possible range for actual signs).
23//! let signs = (2..127).map(Address).map(|addr| VirtualSign::new(addr, PageFlipStyle::Manual));
24//! let bus = VirtualSignBus::new(signs);
25//!
26//! // Hook up ODK to virtual bus.
27//! let port = serial::open("COM3")?;
28//! let mut odk = Odk::try_new(port, bus)?;
29//! loop {
30//!     // ODK communications are forwarded to/from the virtual bus.
31//!     odk.process_message()?;
32//! }
33//! #
34//! # Ok(()) }
35//! ```
36//!
37//! [`flipdot`]: https://docs.rs/flipdot
38#![doc(html_root_url = "https://docs.rs/flipdot-testing/0.8.0")]
39#![deny(
40    missing_copy_implementations,
41    missing_debug_implementations,
42    trivial_casts,
43    trivial_numeric_casts,
44    unsafe_code
45)]
46#![warn(
47    missing_docs,
48    unused_extern_crates,
49    unused_import_braces,
50    unused_qualifications,
51    unused_results
52)]
53
54mod odk;
55mod virtual_sign_bus;
56
57pub use self::odk::{Odk, OdkError};
58pub use self::virtual_sign_bus::{VirtualSign, VirtualSignBus};
59
60pub use flipdot_core::Address;