Skip to content

Commit aac8b3d

Browse files
committed
feat: 修改 SerialTerm 运行逻辑以处理键盘事件,并在退出时记录信息
feat: 注释掉 UbootShell 中的 flush 调用,简化命令发送逻辑
1 parent 33696cb commit aac8b3d

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

ostool/src/sterm/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,8 @@ impl SerialTerm {
9494

9595
while handle.is_running() {
9696
// 非阻塞读取键盘事件
97-
if event::poll(Duration::from_millis(10))?
98-
&& let Event::Key(key) = event::read()?
97+
if event::poll(Duration::from_millis(10)).is_ok()
98+
&& let Ok(Event::Key(key)) = event::read()
9999
&& key.kind == KeyEventKind::Press
100100
{
101101
// 检测 Ctrl+A+x 退出序列
@@ -134,7 +134,7 @@ impl SerialTerm {
134134

135135
// 等待接收线程结束
136136
let _ = rx_handle.join();
137-
137+
info!("Serial terminal exited");
138138
Ok(())
139139
}
140140

uboot-shell/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,14 @@ impl UbootShell {
170170
pub fn cmd_without_reply(&mut self, cmd: &str) -> Result<()> {
171171
self.tx().write_all(cmd.as_bytes())?;
172172
self.tx().write_all("\n".as_bytes())?;
173-
self.tx().flush()?;
173+
// self.tx().flush()?;
174174
// self.wait_for_reply(cmd)?;
175175
// debug!("cmd ok");
176176
Ok(())
177177
}
178178

179179
fn _cmd(&mut self, cmd: &str) -> Result<String> {
180+
let _ = self.read_to_end(&mut vec![]);
180181
let ok_str = "cmd-ok";
181182
let cmd_with_id = format!("{cmd}&& echo {ok_str}");
182183
self.cmd_without_reply(&cmd_with_id)?;

0 commit comments

Comments
 (0)