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
//! Serial port core of `tauri-plugin-serialplugin`, usable from plain Rust (no Tauri).
//!
//! [`SerialManager`] owns every open port: one RX hub thread per port, watch streams
//! with native framing ([`events::WatchOptions::parser`]), request/response
//! [`exchange`](SerialManager::exchange), queued AT commands, GSM 07.10 CMUX virtual
//! channels, `tcp://host:port` bridges and (feature `ble`) Bluetooth LE serial.
//! Events are delivered to an [`EventSink`] closure you pass to
//! [`SerialManager::watch`].
//!
//! ```no_run
//! use serialplugin_core::{events::{SerialEvent, WatchOptions}, EventSink, SerialManager};
//! use std::sync::Arc;
//!
//! let serial = SerialManager::new();
//! let path = serial.open("/dev/ttyUSB0".into(), 115_200, None, None, None, None, None)?;
//! let sink: EventSink = Arc::new(|event| {
//! if let SerialEvent::Data { data, .. } = event {
//! println!("{}", String::from_utf8_lossy(&data));
//! }
//! true // keep the subscription
//! });
//! let watch_id = serial.watch(path.clone(), WatchOptions::default(), sink)?;
//! let reply = serial.at(path.clone(), "AT+CSQ".into(), None)?;
//! println!("{:?}", reply.status);
//! serial.unwatch(watch_id)?;
//! serial.close(path)?;
//! # Ok::<(), serialplugin_core::error::Error>(())
//! ```
/// Logging macros that respect the global log level ([`state::set_log_level`]).
pub use SerialManager;
pub use Error;
pub use ;