Skip to content

Commit 3ac0088

Browse files
committed
windows: Fix --console follow
Now you can get a live view of the EC console on Windows, too. Signed-off-by: Daniel Schaefer <[email protected]>
1 parent a62ad50 commit 3ac0088

File tree

1 file changed

+8
-8
lines changed
  • framework_lib/src/chromium_ec

1 file changed

+8
-8
lines changed

framework_lib/src/chromium_ec/mod.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1044,21 +1044,21 @@ impl CrosEc {
10441044
loop {
10451045
match cmd.send_command_vec(self) {
10461046
Ok(data) => {
1047-
// EC Buffer is empty. That means we've read everything from the snapshot
1048-
// The windows crosecbus driver returns all NULL instead of empty response
1049-
if data.is_empty() || data.iter().all(|x| *x == 0) {
1047+
// EC Buffer is empty. That means we've read everything from the snapshot.
1048+
// The windows crosecbus driver returns all NULL with a leading 0x01 instead of
1049+
// an empty response.
1050+
if data.is_empty() || data.iter().all(|x| *x == 0 || *x == 1) {
10501051
debug!("Empty EC response. Stopping console read");
1051-
// Don't read too fast, wait a second before reading more
1052-
os_specific::sleep(1_000_000);
1052+
// Don't read too fast, wait 100ms before reading more
1053+
os_specific::sleep(100_000);
10531054
EcRequestConsoleSnapshot {}.send_command(self)?;
10541055
cmd.subcmd = ConsoleReadSubCommand::ConsoleReadRecent as u8;
10551056
continue;
10561057
}
10571058

10581059
let utf8 = std::str::from_utf8(&data).unwrap();
1059-
let ascii = utf8
1060-
.replace(|c: char| !c.is_ascii(), "")
1061-
.replace(['\0'], "");
1060+
let full_ascii = utf8.replace(|c: char| !c.is_ascii(), "");
1061+
let ascii = full_ascii.replace(['\0'], "");
10621062

10631063
print!("{}", ascii);
10641064
}

0 commit comments

Comments
 (0)