diff --git a/src/device.rs b/src/device.rs index 857535b..21c06f1 100755 --- a/src/device.rs +++ b/src/device.rs @@ -106,7 +106,7 @@ impl Device{ initial_state = State::LoginPrompt; }, //Response::Empty parsing here is potentially in bad faith - Response::Other | Response::Empty | Response::ShellPrompt | Response::FailedDebugMenu | + Response::Other | Response::Empty | Response::ShellPrompt | Response::FailedDebugMenu | Response::DebugInit | Response::LoginPrompt | Response::ShuttingDown | Response::Rebooting | Response::PreShellPrompt => initial_state = State::LoginPrompt, Response::BPOn | Response::BPOff | Response::TempCount(_) | @@ -130,6 +130,10 @@ impl Device{ } }; }, + Response::EmptyNewline => { + log::error!("Unknown state for TTY {:?}!!! Consult logs immediately.",usb_port); + return Err("Failed TTY init. Unknown state, cannot trust.".to_string()); + }, }; }, None => initial_state = State::LoginPrompt diff --git a/src/tty.rs b/src/tty.rs index 8fcf571..d62f54d 100755 --- a/src/tty.rs +++ b/src/tty.rs @@ -42,6 +42,8 @@ pub enum Response{ ShuttingDown, FailedDebugMenu, PreShellPrompt, + EmptyNewline, + DebugInit, } @@ -62,7 +64,7 @@ const COMMAND_MAP:Lazy> = Lazy::new(||HashMap::from([ (Command::Shutdown,"shutdown -r now\n"), ])); -const RESPONSES:[(&str,Response);11] = [ +const RESPONSES:[(&str,Response);12] = [ ("Last login:",Response::PreShellPrompt), ("reboot: Restarting",Response::Rebooting), ("command not found",Response::FailedDebugMenu), @@ -74,6 +76,7 @@ const RESPONSES:[(&str,Response);11] = [ ("Check NIBP In Progress: False",Response::BPOff), ("SureTemp Probe Pulls:",Response::TempCount(0)), (">",Response::DebugMenu), + ("Loading App-Framework",Response::DebugInit) ]; pub struct TTY{ @@ -128,6 +131,9 @@ impl TTY{ _ = reader.read_to_end(&mut read_buffer); if read_buffer.len() > 0 { let read_line:String = String::from_utf8_lossy(read_buffer.as_slice()).to_string(); + if read_line.eq("\r\n") { + return Response::EmptyNewline; + } for (string,enum_value) in RESPONSES{ if read_line.contains(string){ if(enum_value == Response::BPOn) || (enum_value == Response::BPOff) {