Add debug menu init and blank newline handling
This commit is contained in:
parent
3b352472dc
commit
35d9c7b6fb
2 changed files with 12 additions and 2 deletions
|
@ -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
|
||||
|
|
|
@ -42,6 +42,8 @@ pub enum Response{
|
|||
ShuttingDown,
|
||||
FailedDebugMenu,
|
||||
PreShellPrompt,
|
||||
EmptyNewline,
|
||||
DebugInit,
|
||||
}
|
||||
|
||||
|
||||
|
@ -62,7 +64,7 @@ const COMMAND_MAP:Lazy<HashMap<Command,&str>> = 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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue