serialport-stream-rs
A runtime-agnostic async stream wrapper for serialport-rs that implements futures::Stream using platform-specific I/O mechanisms.
Installation
Add this to your Cargo.toml:
[]
= "0.1"
= "2.0"
Usage
Basic Streaming
use ;
use stream;
Advanced Configuration
use new;
use ;
use Duration;
let stream = new
.data_bits
.flow_control
.parity
.stop_bits
.timeout
.dtr_on_open
.open?;
Synchronous Read/Write
use ;
let mut stream = new.open?;
// Write data synchronously
stream.write_all?;
stream.flush?;
// Read data synchronously
let mut buffer = ;
let n = stream.read?;
println!;
API Overview
Builder Functions
new(path, baud_rate)- Create a new builder.data_bits(DataBits)- Set data bits (5, 6, 7, 8).flow_control(FlowControl)- Set flow control (None, Software, Hardware).parity(Parity)- Set parity (None, Odd, Even).stop_bits(StopBits)- Set stop bits (One, Two).timeout(Duration)- Set read/write timeout.dtr_on_open(bool)- Control DTR signal on open.open()- Open the port and create the stream
SerialPortStream Methods
- Implements
std::io::Read- Synchronous reading - Implements
std::io::Write- Synchronous writing - Implements
futures::Stream- Asynchronous streaming - Item type:
Result<Vec<u8>, std::io::Error>
License
This project is licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Acknowledgments
This crate builds upon serialport-rs for cross-platform serial port access.