Skip to content

Commit

Permalink
Fix output from example receive_data
Browse files Browse the repository at this point in the history
There was no visible output without explicitly flushing stdout on on
macOS.
  • Loading branch information
sirhcel authored and eldruin committed May 24, 2024
1 parent d5c2605 commit 0a75184
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/receive_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ fn main() {
println!("Receiving data on {} at {} baud:", &port_name, &baud_rate);
loop {
match port.read(serial_buf.as_mut_slice()) {
Ok(t) => io::stdout().write_all(&serial_buf[..t]).unwrap(),
Ok(t) => {
io::stdout().write_all(&serial_buf[..t]).unwrap();
io::stdout().flush().unwrap();
}
Err(ref e) if e.kind() == io::ErrorKind::TimedOut => (),
Err(e) => eprintln!("{:?}", e),
}
Expand Down

0 comments on commit 0a75184

Please sign in to comment.