Expand description
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, 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.
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)?;Re-exports§
pub use api::SerialManager;pub use error::Error;pub use events::EventSink;pub use events::PortListSink;
Modules§
- api
SerialManagerand the helpers it routes exchanges through.- at
- AT command parsing, session config, and high-level command orchestration.
- cmux
- GSM 07.10 CMUX (virtual serial channels over one physical port).
- error
- events
- Streaming event types, event sinks and watch / exchange options.
- exchange
- Low-level request/response exchange (physical port + CMUX), without Tauri.
- hub
- RX hub layer (shared state + poll loop on all platforms).
- logger
- Logging macros that respect the global log level (
state::set_log_level). Centralized logging module for the serial plugin - mock_
serial - Shared desktop serial port mock for unit tests (scripted RX, TX capture, error injection).
- port
- Port enumeration, monitoring, TX queue, and watch registry.
- state
- State types and enums for serial port configuration.
- sync_
util - Mutex helpers for background threads (recover from poison instead of panicking).