@@ -514,7 +514,8 @@ func runProgramAction(pme *packagemanager.Explorer,
514514
515515 updatedPort := updatedUploadPort .Await ()
516516 if updatedPort == nil {
517- return nil , nil
517+ // If the algorithms can not detect the new port, fallback to the user-provided port.
518+ return userPort , nil
518519 }
519520 return updatedPort .ToRPC (), nil
520521}
@@ -526,7 +527,7 @@ func detectUploadPort(
526527 result f.Future [* discovery.Port ],
527528) {
528529 log := logrus .WithField ("task" , "port_detection" )
529- log .Tracef ("Detecting new board port after upload" )
530+ log .Debugf ("Detecting new board port after upload" )
530531
531532 candidate := uploadPort .Clone ()
532533 defer func () {
@@ -542,11 +543,11 @@ func detectUploadPort(
542543 return
543544 }
544545 if candidate != nil && ev .Type == "remove" && ev .Port .Equals (candidate ) {
545- log .WithField ("event" , ev ).Trace ("User-specified port has been disconnected, forcing wait for upload port" )
546+ log .WithField ("event" , ev ).Debug ("User-specified port has been disconnected, forcing wait for upload port" )
546547 waitForUploadPort = true
547548 candidate = nil
548549 } else {
549- log .WithField ("event" , ev ).Trace ("Ignored watcher event before upload" )
550+ log .WithField ("event" , ev ).Debug ("Ignored watcher event before upload" )
550551 }
551552 continue
552553 case <- uploadCtx .Done ():
@@ -568,17 +569,17 @@ func detectUploadPort(
568569 return
569570 }
570571 if candidate != nil && ev .Type == "remove" && candidate .Equals (ev .Port ) {
571- log .WithField ("event" , ev ).Trace ("Candidate port is no longer available" )
572+ log .WithField ("event" , ev ).Debug ("Candidate port is no longer available" )
572573 candidate = nil
573574 if ! waitForUploadPort {
574575 waitForUploadPort = true
575576 timeout = time .After (5 * time .Second )
576- log .Trace ("User-specified port has been disconnected, now waiting for upload port, timeout extended by 5 seconds" )
577+ log .Debug ("User-specified port has been disconnected, now waiting for upload port, timeout extended by 5 seconds" )
577578 }
578579 continue
579580 }
580581 if ev .Type != "add" {
581- log .WithField ("event" , ev ).Trace ("Ignored non-add event" )
582+ log .WithField ("event" , ev ).Debug ("Ignored non-add event" )
582583 continue
583584 }
584585
@@ -601,21 +602,21 @@ func detectUploadPort(
601602 evPortPriority := portPriority (ev .Port )
602603 candidatePriority := portPriority (candidate )
603604 if evPortPriority <= candidatePriority {
604- log .WithField ("event" , ev ).Tracef ("New upload port candidate is worse than the current one (prio=%d)" , evPortPriority )
605+ log .WithField ("event" , ev ).Debugf ("New upload port candidate is worse than the current one (prio=%d)" , evPortPriority )
605606 continue
606607 }
607- log .WithField ("event" , ev ).Tracef ("Found new upload port candidate (prio=%d)" , evPortPriority )
608+ log .WithField ("event" , ev ).Debugf ("Found new upload port candidate (prio=%d)" , evPortPriority )
608609 candidate = ev .Port
609610
610611 // If the current candidate have the desired HW-ID return it quickly.
611612 if candidate .HardwareID == ev .Port .HardwareID {
612613 timeout = time .After (time .Second )
613- log .Trace ("New candidate port match the desired HW ID, timeout reduced to 1 second." )
614+ log .Debug ("New candidate port match the desired HW ID, timeout reduced to 1 second." )
614615 continue
615616 }
616617
617618 case <- timeout :
618- log .WithField ("selected_port" , candidate ).Trace ("Timeout waiting for candidate port" )
619+ log .WithField ("selected_port" , candidate ).Debug ("Timeout waiting for candidate port" )
619620 return
620621 }
621622 }
0 commit comments