@@ -136,6 +136,11 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
136
136
// it happened within 250 ms. So we wait until the reset should
137
137
// have already occured before we start scanning.
138
138
actualUploadPort = waitForUploadPort (userSelectedUploadPort , before );
139
+
140
+ // on OS X, if the port is opened too quickly after it is detected,
141
+ // a "Resource busy" error occurs, add a delay to workaround this,
142
+ // apply to other platforms as well.
143
+ Thread .sleep (250 );
139
144
}
140
145
} catch (SerialException e ) {
141
146
throw new RunnerException (e );
@@ -247,11 +252,10 @@ private String waitForUploadPort(String uploadPort, List<String> before) throws
247
252
Thread .sleep (250 );
248
253
elapsed += 250 ;
249
254
250
- // On Windows, it can take a long time for the port to disappear and
251
- // come back, so use a longer time out before assuming that the
252
- // selected
253
- // port is the bootloader (not the sketch).
254
- if (((!OSUtils .isWindows () && elapsed >= 500 ) || elapsed >= 5000 ) && now .contains (uploadPort )) {
255
+ // On Windows and OS X, it can take a few seconds for the port to disappear and
256
+ // come back, so use a time out before assuming that the selected port is the
257
+ // bootloader (not the sketch).
258
+ if (elapsed >= 5000 && now .contains (uploadPort )) {
255
259
if (verbose )
256
260
System .out .println ("Uploading using selected port: " + uploadPort );
257
261
return uploadPort ;
0 commit comments