Add debug menu init and blank newline handling
All checks were successful
Basic Cargo Checks / docker-check (push) Successful in 2m2s
Basic Cargo Checks / docker-build (push) Successful in 2m16s

This commit is contained in:
Blizzard Finnegan 2023-06-19 10:05:03 -04:00
parent 3b352472dc
commit 35d9c7b6fb
Signed by: blizzardfinnegan
GPG key ID: 61C1E13067E0018E
2 changed files with 12 additions and 2 deletions

View file

@ -106,7 +106,7 @@ impl Device{
initial_state = State::LoginPrompt; initial_state = State::LoginPrompt;
}, },
//Response::Empty parsing here is potentially in bad faith //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 => Response::LoginPrompt | Response::ShuttingDown | Response::Rebooting | Response::PreShellPrompt =>
initial_state = State::LoginPrompt, initial_state = State::LoginPrompt,
Response::BPOn | Response::BPOff | Response::TempCount(_) | 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 None => initial_state = State::LoginPrompt

View file

@ -42,6 +42,8 @@ pub enum Response{
ShuttingDown, ShuttingDown,
FailedDebugMenu, FailedDebugMenu,
PreShellPrompt, PreShellPrompt,
EmptyNewline,
DebugInit,
} }
@ -62,7 +64,7 @@ const COMMAND_MAP:Lazy<HashMap<Command,&str>> = Lazy::new(||HashMap::from([
(Command::Shutdown,"shutdown -r now\n"), (Command::Shutdown,"shutdown -r now\n"),
])); ]));
const RESPONSES:[(&str,Response);11] = [ const RESPONSES:[(&str,Response);12] = [
("Last login:",Response::PreShellPrompt), ("Last login:",Response::PreShellPrompt),
("reboot: Restarting",Response::Rebooting), ("reboot: Restarting",Response::Rebooting),
("command not found",Response::FailedDebugMenu), ("command not found",Response::FailedDebugMenu),
@ -74,6 +76,7 @@ const RESPONSES:[(&str,Response);11] = [
("Check NIBP In Progress: False",Response::BPOff), ("Check NIBP In Progress: False",Response::BPOff),
("SureTemp Probe Pulls:",Response::TempCount(0)), ("SureTemp Probe Pulls:",Response::TempCount(0)),
(">",Response::DebugMenu), (">",Response::DebugMenu),
("Loading App-Framework",Response::DebugInit)
]; ];
pub struct TTY{ pub struct TTY{
@ -128,6 +131,9 @@ impl TTY{
_ = reader.read_to_end(&mut read_buffer); _ = reader.read_to_end(&mut read_buffer);
if read_buffer.len() > 0 { if read_buffer.len() > 0 {
let read_line:String = String::from_utf8_lossy(read_buffer.as_slice()).to_string(); 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{ for (string,enum_value) in RESPONSES{
if read_line.contains(string){ if read_line.contains(string){
if(enum_value == Response::BPOn) || (enum_value == Response::BPOff) { if(enum_value == Response::BPOn) || (enum_value == Response::BPOff) {