1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
//! # cashcode
//!
//! A Rust driver for CashCode bill validators using the **CCNET** serial
//! protocol (RS-232, 9600 baud, 8N1).
//!
//! ## Quick start
//!
//! ```no_run
//! use cashcode::{CashcodeDevice, DeviceState};
//! use std::time::Duration;
//!
//! fn main() -> cashcode::Result<()> {
//! let mut dev = CashcodeDevice::open("/dev/ttyUSB0", None, None)?;
//!
//! dev.initialize()?;
//!
//! loop {
//! match dev.poll()? {
//! DeviceState::EscrowPosition { bill_type } => {
//! let table = dev.bill_table()?;
//!
//! if let Some(entry) = table.get(bill_type) {
//! println!("Accepted: {entry}");
//! }
//!
//! dev.stack()?;
//! }
//! DeviceState::BillStacked { .. } => println!("Bill stacked."),
//! _ => {}
//! }
//!
//! std::thread::sleep(Duration::from_millis(200));
//! }
//! }
//! ```
//!
//! ## Protocol overview
//!
//! Every message uses the frame layout:
//!
//! ```text
//! ┌──────┬─────┬─────┬────────────┬───────┬───────┐
//! │ SYNC │ ADR │ LNG │ DATA ... │ CRC_L │ CRC_H │
//! │ 0x02 │ 1 B │ 1 B │ 0–250 B │ 1 B │ 1 B │
//! └──────┴─────┴─────┴────────────┴───────┴───────┘
//! ```
//!
//! - **LNG** is the total frame length (all 6+ bytes included).
//! - **CRC** is CRC-KERMIT (reflected poly `0x8408`, init `0x0000`),
//! transmitted LSB-first, covering every byte from `SYNC` through the last
//! `DATA` byte.
// Flatten the most-used types to the crate root for ergonomic imports.
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;