8
8
//! - `portio` - It uses raw port I/O. This works on UEFI and on Linux if the system isn't in lockdown mode (SecureBoot disabled).
9
9
//! - `windows` - It uses [DHowett's Windows driver](https://github.com/DHowett/FrameworkWindowsUtils)
10
10
11
+ use crate :: os_specific;
11
12
use crate :: smbios;
12
13
#[ cfg( feature = "uefi" ) ]
13
14
use crate :: uefi:: shell_get_execution_break_flag;
@@ -287,14 +288,21 @@ impl CrosEc {
287
288
loop {
288
289
match cmd. send_command_vec ( self ) {
289
290
Ok ( data) => {
290
- // I think that means the buffer is empty
291
+ // EC Buffer is empty. We can wait a bit and see if there's more
292
+ // Can't run it too quickly, otherwise the commands might fail
291
293
if data. is_empty ( ) {
292
- return Ok ( console) ;
294
+ trace ! ( "Empty EC response" ) ;
295
+ println ! ( "---" ) ;
296
+ os_specific:: sleep ( 1_000_000 ) ; // 1s
293
297
}
294
298
295
- let string = std:: str:: from_utf8 ( & data) . unwrap ( ) ;
296
- print ! ( "{}" , string) ;
297
- console. push_str ( string) ;
299
+ let utf8 = std:: str:: from_utf8 ( & data) . unwrap ( ) ;
300
+ let ascii = utf8
301
+ . replace ( |c : char | !c. is_ascii ( ) , "" )
302
+ . replace ( |c : char | c == '\0' , "" ) ;
303
+
304
+ print ! ( "{}" , ascii) ;
305
+ console. push_str ( ascii. as_str ( ) ) ;
298
306
}
299
307
Err ( err) => {
300
308
println ! ( "Err: {:?}" , err) ;
@@ -318,7 +326,11 @@ impl CrosEc {
318
326
subcmd : ConsoleReadSubCommand :: ConsoleReadRecent as u8 ,
319
327
}
320
328
. send_command_vec ( self ) ?;
321
- Ok ( std:: str:: from_utf8 ( & data) . unwrap ( ) . to_string ( ) )
329
+ let utf8 = std:: str:: from_utf8 ( & data) . unwrap ( ) ;
330
+ let ascii = utf8
331
+ . replace ( |c : char | !c. is_ascii ( ) , "" )
332
+ . replace ( |c : char | c == '\0' , "" ) ;
333
+ Ok ( ascii)
322
334
}
323
335
}
324
336
0 commit comments