Continue tweaking reboot algorithm
All checks were successful
Basic Cargo Checks / docker-check (push) Successful in 47s
Basic Cargo Checks / docker-build (push) Successful in 4m54s

This commit is contained in:
Blizzard Finnegan 2023-06-14 13:31:39 -04:00
parent 714c198f54
commit 4bc8383016
Signed by: blizzardfinnegan
GPG key ID: 61C1E13067E0018E
2 changed files with 21 additions and 7 deletions

View file

@ -107,8 +107,8 @@ impl Device{
_ = usb_port.read_from_device(None); _ = usb_port.read_from_device(None);
initial_state = State::LoginPrompt; initial_state = State::LoginPrompt;
}, },
Response::Other | Response::Empty | Response::ShellPrompt Response::Other | Response::Empty | Response::ShellPrompt |
| Response::LoginPrompt | Response::Rebooting => Response::LoginPrompt | Response::ShuttingDown | Response::Rebooting =>
initial_state = State::LoginPrompt, initial_state = State::LoginPrompt,
Response::BPOn | Response::BPOff | Response::TempCount(_) => Response::BPOn | Response::BPOff | Response::TempCount(_) =>
initial_state = State::LifecycleMenu, initial_state = State::LifecycleMenu,
@ -417,9 +417,22 @@ impl Device{
} }
pub fn reboot(&mut self) -> () { pub fn reboot(&mut self) -> () {
self.usb_tty.write_to_device(Command::Quit); self.usb_tty.write_to_device(Command::Quit);
while self.usb_tty.read_from_device(None) != Response::Rebooting {} let mut successful_reboot:bool = false;
self.current_state = State::Shutdown; loop{
while self.usb_tty.read_from_device(None) != Response::LoginPrompt {} match self.usb_tty.read_from_device(None){
Response::LoginPrompt => break,
Response::Rebooting => {
log::trace!("Successful reboot detected for device {}.",self.serial);
successful_reboot = true;
},
Response::ShuttingDown => {
log::warn!("Failed reboot on device {}!",self.serial);
successful_reboot = false;
},
_ => {}
}
};
if successful_reboot { self.reboots += 1; }
self.current_state = State::LoginPrompt; self.current_state = State::LoginPrompt;
} }
pub fn is_rebooted(&mut self) -> bool { pub fn is_rebooted(&mut self) -> bool {
@ -463,7 +476,6 @@ impl Device{
} }
log::info!("Rebooting {} for the {}th time",self.serial, self.reboots); log::info!("Rebooting {} for the {}th time",self.serial, self.reboots);
self.reboot(); self.reboot();
self.reboots += 1;
self.save_values(); self.save_values();
} }
} }

View file

@ -39,6 +39,7 @@ pub enum Response{
Rebooting, Rebooting,
Other, Other,
Empty, Empty,
ShuttingDown
} }
@ -58,10 +59,11 @@ const COMMAND_MAP:Lazy<HashMap<Command,&str>> = Lazy::new(||HashMap::from([
(Command::Newline,"\n"), (Command::Newline,"\n"),
])); ]));
const RESPONSES:[(&str,Response);9] = [ const RESPONSES:[(&str,Response);10] = [
("reboot: Restarting",Response::Rebooting), ("reboot: Restarting",Response::Rebooting),
("login:",Response::LoginPrompt), ("login:",Response::LoginPrompt),
("Password:",Response::PasswordPrompt), ("Password:",Response::PasswordPrompt),
("EXIT Debug menu",Response::ShuttingDown),
("root@",Response::ShellPrompt), ("root@",Response::ShellPrompt),
("Check NIBP In Progress: True",Response::BPOn), ("Check NIBP In Progress: True",Response::BPOn),
("Check NIBP In Progress: False",Response::BPOff), ("Check NIBP In Progress: False",Response::BPOff),