File tree Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Expand file tree Collapse file tree 1 file changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -122,14 +122,28 @@ async function store(state, emitter) {
122122 state . isConnecting = true
123123 emitter . emit ( 'render' )
124124
125- let timeout_id = setTimeout ( ( ) => emitter . emit ( 'connection-timeout' ) , 5000 )
126- await serial . connect ( path )
127- clearTimeout ( timeout_id )
128-
125+ // The following Timeout operation will be cleared after a succesful getPrompt()
126+ // If a board has crashed and/or cannot return a REPL prompt, the connection will fail
127+ // and the user will be prompted to reset the device and try again.
128+ let timeout_id = setTimeout ( ( ) => {
129+ let response = win . openDialog ( {
130+ type : 'question' ,
131+ buttons : [ 'OK' ] ,
132+ cancelId : 0 ,
133+ message : "Could not connect to the board. Reset it and try again."
134+ } )
135+ console . log ( 'Reset request acknowledged' , response )
136+ emitter . emit ( 'connection-timeout' )
137+ } , 3500 )
138+ try {
139+ await serial . connect ( path )
140+ } catch ( e ) {
141+ console . error ( e )
142+ }
129143 // Stop whatever is going on
130144 // Recover from getting stuck in raw repl
131145 await serial . getPrompt ( )
132-
146+ clearTimeout ( timeout_id )
133147 // Connected and ready
134148 state . isConnecting = false
135149 state . isConnected = true
You can’t perform that action at this time.
0 commit comments