From 3ac0088fa8fa39c6e0f1274df2b7c41aed893d2e Mon Sep 17 00:00:00 2001 From: Daniel Schaefer Date: Wed, 7 May 2025 17:05:07 +0800 Subject: [PATCH] windows: Fix --console follow Now you can get a live view of the EC console on Windows, too. Signed-off-by: Daniel Schaefer --- framework_lib/src/chromium_ec/mod.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/framework_lib/src/chromium_ec/mod.rs b/framework_lib/src/chromium_ec/mod.rs index 4c99bcc9..afdaef0c 100644 --- a/framework_lib/src/chromium_ec/mod.rs +++ b/framework_lib/src/chromium_ec/mod.rs @@ -1044,21 +1044,21 @@ impl CrosEc { loop { match cmd.send_command_vec(self) { Ok(data) => { - // EC Buffer is empty. That means we've read everything from the snapshot - // The windows crosecbus driver returns all NULL instead of empty response - if data.is_empty() || data.iter().all(|x| *x == 0) { + // EC Buffer is empty. That means we've read everything from the snapshot. + // The windows crosecbus driver returns all NULL with a leading 0x01 instead of + // an empty response. + if data.is_empty() || data.iter().all(|x| *x == 0 || *x == 1) { debug!("Empty EC response. Stopping console read"); - // Don't read too fast, wait a second before reading more - os_specific::sleep(1_000_000); + // Don't read too fast, wait 100ms before reading more + os_specific::sleep(100_000); EcRequestConsoleSnapshot {}.send_command(self)?; cmd.subcmd = ConsoleReadSubCommand::ConsoleReadRecent as u8; continue; } let utf8 = std::str::from_utf8(&data).unwrap(); - let ascii = utf8 - .replace(|c: char| !c.is_ascii(), "") - .replace(['\0'], ""); + let full_ascii = utf8.replace(|c: char| !c.is_ascii(), ""); + let ascii = full_ascii.replace(['\0'], ""); print!("{}", ascii); }