88//! - `portio` - It uses raw port I/O. This works on UEFI and on Linux if the system isn't in lockdown mode (SecureBoot disabled).
99//! - `windows` - It uses [DHowett's Windows driver](https://github.com/DHowett/FrameworkWindowsUtils)
1010
11+ use crate :: os_specific;
1112use crate :: smbios;
1213#[ cfg( feature = "uefi" ) ]
1314use crate :: uefi:: shell_get_execution_break_flag;
@@ -287,14 +288,21 @@ impl CrosEc {
287288 loop {
288289 match cmd. send_command_vec ( self ) {
289290 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
291293 if data. is_empty ( ) {
292- return Ok ( console) ;
294+ trace ! ( "Empty EC response" ) ;
295+ println ! ( "---" ) ;
296+ os_specific:: sleep ( 1_000_000 ) ; // 1s
293297 }
294298
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 ( ) ) ;
298306 }
299307 Err ( err) => {
300308 println ! ( "Err: {:?}" , err) ;
@@ -318,7 +326,11 @@ impl CrosEc {
318326 subcmd : ConsoleReadSubCommand :: ConsoleReadRecent as u8 ,
319327 }
320328 . 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)
322334 }
323335}
324336
0 commit comments