mirror of
https://codeberg.org/icewind/hlk_ld6002.git
synced 2026-06-03 08:34:17 +02:00
docs, clippy
This commit is contained in:
parent
9c6b900707
commit
e55e68920c
3 changed files with 50 additions and 13 deletions
|
|
@ -6,13 +6,13 @@ use std::time::{Duration, Instant};
|
|||
|
||||
fn main() {
|
||||
let port = args().nth(1).expect("no port provided");
|
||||
let port = serialport::new(&port, 1_382_400)
|
||||
let port = serialport::new(port, 1_382_400)
|
||||
.timeout(Duration::from_millis(50))
|
||||
.open()
|
||||
.expect("Failed to open port");
|
||||
port.clear(ClearBuffer::All).expect("clear");
|
||||
|
||||
let mut messages = MessageStream::new(FromStd::new(port));
|
||||
let messages = MessageStream::new(FromStd::new(port));
|
||||
|
||||
let mut data = Data::default();
|
||||
|
||||
|
|
@ -20,15 +20,11 @@ fn main() {
|
|||
|
||||
print!("{}", termion::cursor::Save);
|
||||
|
||||
loop {
|
||||
if let Some(message) = messages.next() {
|
||||
if let Ok(message) = message {
|
||||
data.update(message);
|
||||
if last.elapsed() > Duration::from_millis(100) {
|
||||
last = Instant::now();
|
||||
print!("{:?}{}", data, termion::cursor::Restore);
|
||||
}
|
||||
}
|
||||
for message in messages.flatten() {
|
||||
data.update(message);
|
||||
if last.elapsed() > Duration::from_millis(100) {
|
||||
last = Instant::now();
|
||||
print!("{:?}{}", data, termion::cursor::Restore);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue