@@ -92,9 +92,6 @@ func runProgramAction(pm *packagemanager.PackageManager,
92
92
port = deviceURI .Host + deviceURI .Path
93
93
}
94
94
}
95
- if port == "" {
96
- return fmt .Errorf ("no upload port provided" )
97
- }
98
95
logrus .WithField ("port" , port ).Tracef ("Upload port" )
99
96
100
97
if fqbnIn == "" && sketch != nil && sketch .Metadata != nil {
@@ -266,6 +263,10 @@ func runProgramAction(pm *packagemanager.PackageManager,
266
263
if programmer == nil && ! burnBootloader {
267
264
// Perform reset via 1200bps touch if requested
268
265
if uploadProperties .GetBoolean ("upload.use_1200bps_touch" ) {
266
+ if port == "" {
267
+ return fmt .Errorf ("no upload port provided" )
268
+ }
269
+
269
270
ports , err := serial .GetPortsList ()
270
271
if err != nil {
271
272
return fmt .Errorf ("cannot get serial port list: %s" , err )
@@ -310,12 +311,14 @@ func runProgramAction(pm *packagemanager.PackageManager,
310
311
}
311
312
}
312
313
313
- // Set serial port property
314
- uploadProperties .Set ("serial.port" , actualPort )
315
- if strings .HasPrefix (actualPort , "/dev/" ) {
316
- uploadProperties .Set ("serial.port.file" , actualPort [5 :])
317
- } else {
318
- uploadProperties .Set ("serial.port.file" , actualPort )
314
+ if port != "" {
315
+ // Set serial port property
316
+ uploadProperties .Set ("serial.port" , actualPort )
317
+ if strings .HasPrefix (actualPort , "/dev/" ) {
318
+ uploadProperties .Set ("serial.port.file" , actualPort [5 :])
319
+ } else {
320
+ uploadProperties .Set ("serial.port.file" , actualPort )
321
+ }
319
322
}
320
323
321
324
// Build recipe for upload
@@ -348,6 +351,9 @@ func runTool(recipeID string, props *properties.Map, outStream, errStream io.Wri
348
351
if strings .TrimSpace (recipe ) == "" {
349
352
return nil // Nothing to run
350
353
}
354
+ if props .IsProertyMissingInExpandPropsInString ("serial.port" , recipe ) {
355
+ return fmt .Errorf ("no upload port provided" )
356
+ }
351
357
cmdLine := props .ExpandPropsInString (recipe )
352
358
cmdArgs , err := properties .SplitQuotedString (cmdLine , `"'` , false )
353
359
if err != nil {
0 commit comments