@@ -126,24 +126,28 @@ public boolean uploadUsingPreferences(String buildPath, String className,
126
126
throw new RunnerException (e );
127
127
}
128
128
129
- // For Leonardo wait until the bootloader serial port disconnects and the
130
- // sketch serial port reconnects (or timeout after a few seconds if the
131
- // sketch port never comes back). Doing this saves users from accidentally
132
- // opening Serial Monitor on the soon-to-be-orphaned bootloader port.
129
+ // Remove the magic baud rate (1200bps) to avoid
130
+ // future unwanted board resets
133
131
try {
134
- if (uploadResult && waitForUploadPort ) {
135
- Thread .sleep (500 );
136
- long timeout = System .currentTimeMillis () + 2000 ;
137
- while (timeout > System .currentTimeMillis ()) {
138
- List <String > portList = Serial .list ();
139
- String uploadPort = Preferences .get ("serial.port" );
140
- if (portList .contains (Preferences .get ("serial.port" ))) {
141
- // Remove the magic baud rate (1200bps) to avoid
142
- // future unwanted board resets
143
- Serial .touchPort (uploadPort , 9600 );
144
- break ;
132
+ if (uploadResult && doTouch ) {
133
+ String uploadPort = Preferences .get ("serial.port" );
134
+ if (waitForUploadPort ) {
135
+ // For Due/Leonardo wait until the bootloader serial port disconnects and the
136
+ // sketch serial port reconnects (or timeout after a few seconds if the
137
+ // sketch port never comes back). Doing this saves users from accidentally
138
+ // opening Serial Monitor on the soon-to-be-orphaned bootloader port.
139
+ Thread .sleep (500 );
140
+ long timeout = System .currentTimeMillis () + 2000 ;
141
+ while (timeout > System .currentTimeMillis ()) {
142
+ List <String > portList = Serial .list ();
143
+ if (portList .contains (uploadPort )) {
144
+ Serial .touchPort (uploadPort , 9600 );
145
+ break ;
146
+ }
147
+ Thread .sleep (100 );
145
148
}
146
- Thread .sleep (100 );
149
+ } else {
150
+ Serial .touchPort (uploadPort , 9600 );
147
151
}
148
152
}
149
153
} catch (InterruptedException ex ) {
0 commit comments