From c6c34462bbf549810c97d6694f92f0f809daa37e Mon Sep 17 00:00:00 2001 From: Blizzard Finnegan Date: Mon, 26 Jun 2023 13:00:16 -0400 Subject: [PATCH] Attempt to resolve #10 --- src/tty.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/tty.rs b/src/tty.rs index a4297b6..87076d5 100755 --- a/src/tty.rs +++ b/src/tty.rs @@ -71,6 +71,12 @@ const COMMAND_MAP:Lazy> = Lazy::new(||HashMap::from([ (Command::GetSerial,"echo 'y1q' | python3 -m debugmenu\n"), ])); +const COMMAND_RESPONSES: [&str;3] = [ + "python3 -m debugmenu", + "q", + "root", +]; + const RESPONSES:[(&str,Response);14] = [ ("uboot=>",Response::UBoot), ("Last login:",Response::PreShellPrompt), @@ -143,7 +149,12 @@ impl TTY{ let read_line:String = String::from_utf8_lossy(read_buffer.as_slice()).to_string(); if read_line.eq("\r\n") { return Response::EmptyNewline; - } + } + for command in COMMAND_RESPONSES{ + if read_line.trim().eq(command.trim()){ + return self.read_from_device(None); + } + }; for (string,enum_value) in RESPONSES{ if read_line.contains(string){ if(enum_value == Response::BPOn) || (enum_value == Response::BPOff) {