| Crates.io | serial-arbiter |
| lib.rs | serial-arbiter |
| version | 0.2.1 |
| created_at | 2025-03-20 15:28:12.510527+00 |
| updated_at | 2025-04-26 00:04:21.739746+00 |
| description | Serial Port Arbiter - Manages serial port access and ensures it recovers from failures |
| homepage | |
| repository | https://github.com/drzymalanet/serial-arbiter |
| max_upload_size | |
| id | 1599384 |
| size | 59,479 |
This is a Linux-only serial port library that offers the following benefits
over directly using /dev/tty:
/dev/tty file with flags for non-blocking access.termios flags to use the TTY in raw mode.io::Read and io::Write.This is an "async-less" library, and it is intended to remain that way. If you need asynchronous behavior, you can easily make it async-compatible in your own code.
use std::{
io,
time::{Duration, Instant},
};
use serial_arbiter::*;
fn main() -> io::Result<()> {
let deadline = Instant::now() + Duration::from_secs(3);
// Connect
let port = Arbiter::new();
port.open("/dev/ttyACM0")?;
// Transmit request
port.transmit_str("Hello world\n", deadline)?;
println!("Request sent. Waiting for response...");
// Receive response
let response = port.receive_string(None, Some(deadline))?;
println!("Got response: {response:?}");
Ok(())
}
Go to the examples directory to see how automatic reconnection is working or how to use jsonrpc.