@@ -519,7 +519,8 @@ func runProgramAction(pme *packagemanager.Explorer,
519
519
520
520
updatedPort := updatedUploadPort .Await ()
521
521
if updatedPort == nil {
522
- return nil , nil
522
+ // If the algorithms can not detect the new port, fallback to the user-provided port.
523
+ return userPort , nil
523
524
}
524
525
return updatedPort .ToRPC (), nil
525
526
}
@@ -531,7 +532,7 @@ func detectUploadPort(
531
532
result f.Future [* discovery.Port ],
532
533
) {
533
534
log := logrus .WithField ("task" , "port_detection" )
534
- log .Tracef ("Detecting new board port after upload" )
535
+ log .Debugf ("Detecting new board port after upload" )
535
536
536
537
candidate := uploadPort .Clone ()
537
538
defer func () {
@@ -547,11 +548,11 @@ func detectUploadPort(
547
548
return
548
549
}
549
550
if candidate != nil && ev .Type == "remove" && ev .Port .Equals (candidate ) {
550
- log .WithField ("event" , ev ).Trace ("User-specified port has been disconnected, forcing wait for upload port" )
551
+ log .WithField ("event" , ev ).Debug ("User-specified port has been disconnected, forcing wait for upload port" )
551
552
waitForUploadPort = true
552
553
candidate = nil
553
554
} else {
554
- log .WithField ("event" , ev ).Trace ("Ignored watcher event before upload" )
555
+ log .WithField ("event" , ev ).Debug ("Ignored watcher event before upload" )
555
556
}
556
557
continue
557
558
case <- uploadCtx .Done ():
@@ -573,17 +574,17 @@ func detectUploadPort(
573
574
return
574
575
}
575
576
if candidate != nil && ev .Type == "remove" && candidate .Equals (ev .Port ) {
576
- log .WithField ("event" , ev ).Trace ("Candidate port is no longer available" )
577
+ log .WithField ("event" , ev ).Debug ("Candidate port is no longer available" )
577
578
candidate = nil
578
579
if ! waitForUploadPort {
579
580
waitForUploadPort = true
580
581
timeout = time .After (5 * time .Second )
581
- log .Trace ("User-specified port has been disconnected, now waiting for upload port, timeout extended by 5 seconds" )
582
+ log .Debug ("User-specified port has been disconnected, now waiting for upload port, timeout extended by 5 seconds" )
582
583
}
583
584
continue
584
585
}
585
586
if ev .Type != "add" {
586
- log .WithField ("event" , ev ).Trace ("Ignored non-add event" )
587
+ log .WithField ("event" , ev ).Debug ("Ignored non-add event" )
587
588
continue
588
589
}
589
590
@@ -606,21 +607,21 @@ func detectUploadPort(
606
607
evPortPriority := portPriority (ev .Port )
607
608
candidatePriority := portPriority (candidate )
608
609
if evPortPriority <= candidatePriority {
609
- log .WithField ("event" , ev ).Tracef ("New upload port candidate is worse than the current one (prio=%d)" , evPortPriority )
610
+ log .WithField ("event" , ev ).Debugf ("New upload port candidate is worse than the current one (prio=%d)" , evPortPriority )
610
611
continue
611
612
}
612
- log .WithField ("event" , ev ).Tracef ("Found new upload port candidate (prio=%d)" , evPortPriority )
613
+ log .WithField ("event" , ev ).Debugf ("Found new upload port candidate (prio=%d)" , evPortPriority )
613
614
candidate = ev .Port
614
615
615
616
// If the current candidate have the desired HW-ID return it quickly.
616
617
if candidate .HardwareID == ev .Port .HardwareID {
617
618
timeout = time .After (time .Second )
618
- log .Trace ("New candidate port match the desired HW ID, timeout reduced to 1 second." )
619
+ log .Debug ("New candidate port match the desired HW ID, timeout reduced to 1 second." )
619
620
continue
620
621
}
621
622
622
623
case <- timeout :
623
- log .WithField ("selected_port" , candidate ).Trace ("Timeout waiting for candidate port" )
624
+ log .WithField ("selected_port" , candidate ).Debug ("Timeout waiting for candidate port" )
624
625
return
625
626
}
626
627
}
0 commit comments