@@ -147,16 +147,19 @@ function loadPropeller(sock, portPath, action, payload, debug) {
147
147
listen ( port , false ) ; //Disable listener
148
148
port . mode = ( debug !== "none" ) ? "debug" : "programming" ;
149
149
log ( notice ( nsDownloadSuccessful ) , mAll , sock ) ;
150
- if ( sock && debug !== "none" ) {
150
+ if ( sock && debug !== "none" ) { //If debug needed, open terminal/graph
151
151
sock . send ( JSON . stringify ( { type :"ui-command" , action :( debug === "term" ) ? "open-terminal" : "open-graph" } ) ) ;
152
152
sock . send ( JSON . stringify ( { type :"ui-command" , action :"close-compile" } ) ) ;
153
+ } else { //Else
154
+ if ( port . isWireless ) closePort ( port , false ) . catch ( function ( e ) { log ( e . message , mAll , sock ) ; } ) // Close Telnet port (if wireless)
153
155
}
154
156
} ) //Error? Disable listener and display error
155
157
. catch ( function ( e ) {
156
158
listen ( port , false ) ;
157
159
log ( e . message , mAll , sock ) ;
158
160
log ( notice ( neDownloadFailed ) , mAll , sock ) ;
159
- if ( port . connId ) { changeBaudrate ( port , originalBaudrate ) }
161
+ if ( ( port . isWired && port . connId ) || port . isWireless ) { changeBaudrate ( port , originalBaudrate ) }
162
+ if ( port . isWireless ) { closePort ( port , false ) }
160
163
} ) ;
161
164
} else {
162
165
// Port not found
@@ -215,8 +218,10 @@ function setPropCommTimer(timeout, timeoutError, command) {
215
218
log ( "Timed out in " + timeout + " ms" , mDbug ) ;
216
219
clearPropCommTimer ( ) ; // Clear timer
217
220
propComm . stage = sgIdle ; // Reset propComm stage to Idle (ignore incoming data)
218
- if ( propComm . port . isWireless ) { closePort ( propComm . port , command ) } // Close and/or forget HTTP or Telnet service socket
219
- propComm . response . reject ( Error ( propComm . timeoutError ) ) ; // And reject with error
221
+ Promise . resolve ( )
222
+ . then ( function ( ) { if ( propComm . port . isWireless ) { return closePort ( propComm . port , command ) } } ) // Close and/or forget HTTP or Telnet service socket
223
+ . then ( function ( ) { propComm . response . reject ( Error ( propComm . timeoutError ) ) } ) // And reject with error
224
+ . catch ( function ( e ) { propComm . response . reject ( Error ( propComm . timeoutError ) ) } )
220
225
} , timeout ) ;
221
226
}
222
227
0 commit comments