MacroBoard-rs/src/service.rs

26 lines
555 B
Rust
Raw Normal View History

2019-11-23 22:31:21 +00:00
mod port;
2019-11-22 10:24:12 +00:00
use utilities::prelude::*;
use port::*;
2019-11-22 10:24:12 +00:00
fn main() -> VerboseResult<()> {
let settings = SerialPortSettings {
baud_rate: 9600,
data_bits: DataBits::Eight,
parity: Parity::None,
stop_bits: StopBits::One,
flow_control: FlowControl::None,
timeout: Duration::from_millis(2500),
2019-11-23 22:31:21 +00:00
};
let port = Port::open(settings)?;
2019-11-23 22:31:21 +00:00
loop {
2019-11-24 11:41:15 +00:00
match port.read()? {
SerialReadResult::Message(msg) => println!("{}", msg),
SerialReadResult::Timeout => (),
2019-11-23 22:31:21 +00:00
}
}
2019-11-22 10:24:12 +00:00
}