@@ -514,7 +514,8 @@ func runProgramAction(pme *packagemanager.Explorer,
514
514
515
515
updatedPort := updatedUploadPort .Await ()
516
516
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
518
519
}
519
520
return updatedPort .ToRPC (), nil
520
521
}
@@ -526,7 +527,7 @@ func detectUploadPort(
526
527
result f.Future [* discovery.Port ],
527
528
) {
528
529
log := logrus .WithField ("task" , "port_detection" )
529
- log .Tracef ("Detecting new board port after upload" )
530
+ log .Debugf ("Detecting new board port after upload" )
530
531
531
532
candidate := uploadPort .Clone ()
532
533
defer func () {
@@ -542,11 +543,11 @@ func detectUploadPort(
542
543
return
543
544
}
544
545
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" )
546
547
waitForUploadPort = true
547
548
candidate = nil
548
549
} else {
549
- log .WithField ("event" , ev ).Trace ("Ignored watcher event before upload" )
550
+ log .WithField ("event" , ev ).Debug ("Ignored watcher event before upload" )
550
551
}
551
552
continue
552
553
case <- uploadCtx .Done ():
@@ -568,17 +569,17 @@ func detectUploadPort(
568
569
return
569
570
}
570
571
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" )
572
573
candidate = nil
573
574
if ! waitForUploadPort {
574
575
waitForUploadPort = true
575
576
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" )
577
578
}
578
579
continue
579
580
}
580
581
if ev .Type != "add" {
581
- log .WithField ("event" , ev ).Trace ("Ignored non-add event" )
582
+ log .WithField ("event" , ev ).Debug ("Ignored non-add event" )
582
583
continue
583
584
}
584
585
@@ -601,21 +602,21 @@ func detectUploadPort(
601
602
evPortPriority := portPriority (ev .Port )
602
603
candidatePriority := portPriority (candidate )
603
604
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 )
605
606
continue
606
607
}
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 )
608
609
candidate = ev .Port
609
610
610
611
// If the current candidate have the desired HW-ID return it quickly.
611
612
if candidate .HardwareID == ev .Port .HardwareID {
612
613
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." )
614
615
continue
615
616
}
616
617
617
618
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" )
619
620
return
620
621
}
621
622
}
0 commit comments