@@ -125,8 +125,6 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
125125 throw new RunnerException (e );
126126 }
127127
128- // Remove the magic baud rate (1200bps) to avoid
129- // future unwanted board resets
130128 try {
131129 if (uploadResult && doTouch ) {
132130 String uploadPort = Preferences .get ("serial.port" );
@@ -136,25 +134,13 @@ public boolean uploadUsingPreferences(File sourcePath, String buildPath, String
136134 // sketch port never comes back). Doing this saves users from accidentally
137135 // opening Serial Monitor on the soon-to-be-orphaned bootloader port.
138136 Thread .sleep (1000 );
139- long timeout = System .currentTimeMillis () + 2000 ;
140- while (timeout > System .currentTimeMillis ()) {
137+ long started = System .currentTimeMillis ();
138+ while (System .currentTimeMillis () - started < 2000 ) {
141139 List <String > portList = Serial .list ();
142- if (portList .contains (uploadPort )) {
143- try {
144- Serial .touchPort (uploadPort , 9600 );
145- break ;
146- } catch (SerialException e ) {
147- // Port already in use
148- }
149- }
140+ if (portList .contains (uploadPort ))
141+ break ;
150142 Thread .sleep (250 );
151143 }
152- } else {
153- try {
154- Serial .touchPort (uploadPort , 9600 );
155- } catch (SerialException e ) {
156- throw new RunnerException (e );
157- }
158144 }
159145 }
160146 } catch (InterruptedException ex ) {
0 commit comments