Remove reboot from auto_serial
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

We have a whole state machine here. Might as well use it.
This commit is contained in:
Blizzard Finnegan 2023-06-26 11:29:47 -04:00
parent a59a3c590d
commit 1300e040d7
Signed by: blizzardfinnegan
GPG key ID: 61C1E13067E0018E

View file

@ -353,9 +353,23 @@ impl Device{
return true
}
pub fn auto_set_serial(&mut self) -> bool{
self.reboot();
loop {
match self.current_state {
State::LoginPrompt => {
self.usb_tty.write_to_device(Command::Login);
while self.usb_tty.read_from_device(None) != Response::ShellPrompt {}
while self.usb_tty.read_from_device(None) != Response::ShellPrompt {};
self.current_state = State::ShellPrompt;
},
State::Shutdown => {
while self.usb_tty.read_from_device(None) != Response::LoginPrompt{};
self.current_state = State::LoginPrompt;
},
State::DebugMenu | State::LifecycleMenu | State::BrightnessMenu => {
self.usb_tty.write_to_device(Command::Quit);
_ = self.usb_tty.read_from_device(None);
self.current_state = State::ShellPrompt;
},
State::ShellPrompt => {
self.usb_tty.write_to_device(Command::GetSerial);
loop{
let return_value = self.usb_tty.read_from_device(None);
@ -384,7 +398,11 @@ impl Device{
self.load_values();
self.save_values();
return true
},
}
}
}
pub fn manual_set_serial(&mut self, serial:&str) -> &mut Self{
self.serial = serial.to_string();
self.load_values();