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
67
68
69
70
71
72
73
74
//! 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 ([`SerialManager::watch_framed`]), 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`].
//!
//! New in 4.2 (core only, the 4.x API is unchanged): methods returning [`CoreError`]
//! with an [`ErrorKind`] (`open_core`, `write_core`, `exchange_core`, …), any number
//! of [`SerialManager::watch_core`] streams of [`CoreEvent`]s with bounded queues,
//! port-state subscriptions ([`SerialManager::subscribe_core`]) and
//! [`SerialManager::insert_port`] for your own `SerialPort` (a fake in tests).
//!
//! ```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`]).
/// The `log` crate, for the logging macros (feature `log`, and always on Android).
pub use log as __log;
/// The snippets of serialplugin-testing's README run here: one of them uses this crate.
;
pub use SerialManager;
pub use ;
pub use ;