Skip to content

feature: Detect board port change after upload #2253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Aug 18, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply suggestions from code review
Co-authored-by: per1234 <[email protected]>
  • Loading branch information
cmaglie and per1234 authored Aug 16, 2023
commit 69d9ae7e9d1285e596e814462b60e0bcbed344fe
2 changes: 1 addition & 1 deletion arduino/discovery/discovery.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type Port struct {

var tr = i18n.Tr

// Equals return true if the given port has the same address and protocol
// Equals returns true if the given port has the same address and protocol
// of the current port.
func (p *Port) Equals(o *Port) bool {
return p.Address == o.Address && p.Protocol == o.Protocol
Expand Down
6 changes: 3 additions & 3 deletions commands/upload/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -538,7 +538,7 @@ func detectUploadPort(
return
}
if candidate != nil && ev.Type == "remove" && ev.Port.Equals(candidate) {
log.WithField("event", ev).Trace("User-specified port has been disconnected, forcing waiting for upload port")
log.WithField("event", ev).Trace("User-specified port has been disconnected, forcing wait for upload port")
waitForUploadPort = true
candidate = nil
} else {
Expand All @@ -565,12 +565,12 @@ func detectUploadPort(
return
}
if candidate != nil && ev.Type == "remove" && candidate.Equals(ev.Port) {
log.WithField("event", ev).Trace("Candidate port is no more available")
log.WithField("event", ev).Trace("Candidate port is no longer available")
candidate = nil
if !waitForUploadPort {
waitForUploadPort = true
timeout = time.After(5 * time.Second)
log.Trace("User-specified port has been disconnected, now waiting for upload port, timeout exteneded by 5 seconds")
log.Trace("User-specified port has been disconnected, now waiting for upload port, timeout extended by 5 seconds")
}
continue
}
Expand Down
2 changes: 1 addition & 1 deletion internal/algorithms/channels.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ package f

import "sync"

// DiscardCh consume all incoming messages from the given channel until its closed.
// DiscardCh consumes all incoming messages from the given channel until it's closed.
func DiscardCh[T any](ch <-chan T) {
for range ch {
}
Expand Down