File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed
Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ use log::error;
2626use miette:: { IntoDiagnostic , Result } ;
2727#[ cfg( feature = "serialport" ) ]
2828use serialport:: SerialPort ;
29+ use std:: thread:: sleep;
2930use strum:: { Display , EnumIter , EnumString , VariantNames } ;
3031
3132use crate :: {
@@ -79,7 +80,20 @@ pub fn monitor(
7980 interactive_mode : bool ,
8081 processors : Option < String > ,
8182 elf_file : Option < PathBuf > ,
83+ wait_for_port : bool ,
8284) -> miette:: Result < ( ) > {
85+ if wait_for_port {
86+ println ! ( "Waiting for serial port to appear..." ) ;
87+ while !serialport:: available_ports ( )
88+ . unwrap ( )
89+ . iter ( )
90+ . any ( |p| p. port_name == serial. name ( ) . unwrap ( ) )
91+ {
92+ sleep ( Duration :: from_millis ( 100 ) ) ;
93+ }
94+ println ! ( "Serial port detected: {}" , serial. name( ) . unwrap( ) ) ;
95+ }
96+
8397 if interactive_mode {
8498 println ! ( "Commands:" ) ;
8599 println ! ( " CTRL+R Reset chip" ) ;
You can’t perform that action at this time.
0 commit comments