@@ -92,9 +92,6 @@ func runProgramAction(pm *packagemanager.PackageManager,
9292 port = deviceURI .Host + deviceURI .Path
9393 }
9494 }
95- if port == "" {
96- return fmt .Errorf ("no upload port provided" )
97- }
9895 logrus .WithField ("port" , port ).Tracef ("Upload port" )
9996
10097 if fqbnIn == "" && sketch != nil && sketch .Metadata != nil {
@@ -266,6 +263,10 @@ func runProgramAction(pm *packagemanager.PackageManager,
266263 if programmer == nil && ! burnBootloader {
267264 // Perform reset via 1200bps touch if requested
268265 if uploadProperties .GetBoolean ("upload.use_1200bps_touch" ) {
266+ if port == "" {
267+ return fmt .Errorf ("no upload port provided" )
268+ }
269+
269270 ports , err := serial .GetPortsList ()
270271 if err != nil {
271272 return fmt .Errorf ("cannot get serial port list: %s" , err )
@@ -310,12 +311,14 @@ func runProgramAction(pm *packagemanager.PackageManager,
310311 }
311312 }
312313
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+ }
319322 }
320323
321324 // Build recipe for upload
@@ -348,6 +351,9 @@ func runTool(recipeID string, props *properties.Map, outStream, errStream io.Wri
348351 if strings .TrimSpace (recipe ) == "" {
349352 return nil // Nothing to run
350353 }
354+ if props .IsProertyMissingInExpandPropsInString ("serial.port" , recipe ) {
355+ return fmt .Errorf ("no upload port provided" )
356+ }
351357 cmdLine := props .ExpandPropsInString (recipe )
352358 cmdArgs , err := properties .SplitQuotedString (cmdLine , `"'` , false )
353359 if err != nil {
0 commit comments