The monitor now correctly outputs stuff to the screen
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
use std::io::Error;
|
use std::io::{Error, ErrorKind, Write};
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use serial2::SerialPort;
|
use serial2::SerialPort;
|
||||||
@@ -46,13 +46,31 @@ impl Monitor {
|
|||||||
|
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
let mut _stdout = std::io::stdout().into_raw_mode().unwrap();
|
let mut stdout = std::io::stdout().into_raw_mode().unwrap();
|
||||||
|
|
||||||
let mut stdin = termion::async_stdin().keys();
|
let mut stdin = termion::async_stdin().keys();
|
||||||
|
|
||||||
'main: loop {
|
'main: loop {
|
||||||
|
let mut buf = [0u8; 1];
|
||||||
|
|
||||||
|
let res = port.read_exact(&mut buf);
|
||||||
|
|
||||||
|
if res.is_ok() {
|
||||||
|
if buf[0] == b'\n' {
|
||||||
|
stdout.write_all(b"\r")?;
|
||||||
|
}
|
||||||
|
|
||||||
|
stdout.write_all(&buf)?;
|
||||||
|
stdout.flush()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Err(err) = res && err.kind() != ErrorKind::TimedOut {
|
||||||
|
Err(err)?
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(Ok(key)) = stdin.next() {
|
if let Some(Ok(key)) = stdin.next() {
|
||||||
if let Key::Ctrl('r') = key {
|
if let Key::Ctrl('r') = key {
|
||||||
|
stdout.write_all(b"\r\n*** Reboot ***\r\n")?;
|
||||||
port.set_dtr(true)?;
|
port.set_dtr(true)?;
|
||||||
port.set_rts(true)?;
|
port.set_rts(true)?;
|
||||||
std::thread::sleep(Duration::from_millis(10));
|
std::thread::sleep(Duration::from_millis(10));
|
||||||
|
Reference in New Issue
Block a user