@@ -136,6 +136,11 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
136136 // it happened within 250 ms. So we wait until the reset should
137137 // have already occured before we start scanning.
138138 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 );
139144 }
140145 } catch (SerialException e ) {
141146 throw new RunnerException (e );
@@ -247,11 +252,10 @@ private String waitForUploadPort(String uploadPort, List<String> before) throws
247252 Thread .sleep (250 );
248253 elapsed += 250 ;
249254
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 )) {
255259 if (verbose )
256260 System .out .println ("Uploading using selected port: " + uploadPort );
257261 return uploadPort ;
0 commit comments