Skip to content

Commit

Permalink
Add example for testing open baud rate takes effect
Browse files Browse the repository at this point in the history
  • Loading branch information
sirhcel committed Apr 10, 2024
1 parent 7c069ae commit 81df81b
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions examples/pr133_baud_rate_not_changed.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
use clap::Parser;
use std::io::Write;

#[derive(Debug, Parser)]
struct Config {
device: String,
baud: u32,
}

fn main() {
let config = Config::parse();
let mut port = serialport::new(config.device, config.baud)
.open()
.unwrap();
port.set_baud_rate(config.baud).unwrap();

let data = b"Hello world!\r\n";

port.write_all(data).unwrap();
port.flush().unwrap();
}

0 comments on commit 81df81b

Please sign in to comment.