8000 feature: Detect board port change after upload by cmaglie · Pull Request #2253 · arduino/arduino-cli · GitHub
[go: up one dir, main page]

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
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
Always return an updatedUploadPort.
Arduino CLI should always return the port after an upload, even in the case
where no port change is expected. The consumer shouldn't be required to
implement "if not updated_upload_port, use original port" logic.

The whole point is that all the logic for determining which port should be
selected after an upload should be implemented in Arduino CLI. The consumer
should be able to simply select the port Arduino CLI tells it to select in
all cases.
  • Loading branch information
cmaglie committed Aug 9, 2023
commit 5896fba900db441a1a3a2a3af30536c0d8cb3425
8000
9 changes: 7 additions & 2 deletions commands/upload/upload.go
< 550B /tr>
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func UsingProgrammer(ctx context.Context, req *rpc.UploadUsingProgrammerRequest,
func runProgramAction(pme *packagemanager.Explorer,
sk *sketch.Sketch,
watch <-chan *rpc.BoardListWatchResponse,
importFile, importDir, fqbnIn string, port *rpc.Port,
importFile, importDir, fqbnIn string, userPort *rpc.Port,
programmerID string,
verbose, verify, burnBootloader bool,
outStream, errStream io.Writer,
Expand All @@ -212,6 +212,7 @@ func runProgramAction(pme *packagemanager.Explorer,
go f.DiscardCh(watch)
}()

port := userPort
if port == nil || (port.Address == "" && port.Protocol == "") {
// For no-port uploads use "default" protocol
port = &rpc.Port{Protocol: "default"}
Expand Down Expand Up @@ -519,7 +520,11 @@ func runProgramAction(pme *packagemanager.Explorer,
uploadCompleted()
logrus.Tracef("Upload successful")

return updatedUploadPort.Await(), nil
updatedPort := updatedUploadPort.Await()
if updatedPort == nil {
updatedPort = userPort
}
return userPort, nil
}

func detectUploadPort(uploadCtx context.Context, uploadPort *rpc.Port, watch <-chan *rpc.BoardListWatchResponse, result f.Future[*rpc.Port]) {
Expand Down
0