Skip to content

Commit

Permalink
Change GetPort's returned type to rpc.Port
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoPologruto committed Sep 6, 2023
1 parent 9dede8a commit 6f508c2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion internal/cli/arguments/fqbn.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,5 @@ func CalculateFQBNAndPort(portArgs *Port, fqbnArg *Fqbn, instance *rpc.Instance,
if err != nil {
feedback.Fatal(tr("Error getting port metadata: %v", err), feedback.ErrGeneric)
}
return fqbn, port.ToRPC()
return fqbn, port
}
10 changes: 4 additions & 6 deletions internal/cli/arguments/port.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"time"

"github.com/arduino/arduino-cli/arduino"
"github.com/arduino/arduino-cli/arduino/discovery"
"github.com/arduino/arduino-cli/commands"
"github.com/arduino/arduino-cli/commands/board"
"github.com/arduino/arduino-cli/internal/cli/feedback"
Expand Down Expand Up @@ -70,8 +69,7 @@ func (p *Port) GetPortAddressAndProtocol(instance *rpc.Instance, defaultAddress,

// GetPort returns the Port obtained by parsing command line arguments.
// The extra metadata for the ports is obtained using the pluggable discoveries.
func (p *Port) GetPort(instance *rpc.Instance, defaultAddress, defaultProtocol string) (*discovery.Port, error) {
// TODO: REMOVE discovery from here (use board.List instead)
func (p *Port) GetPort(instance *rpc.Instance, defaultAddress, defaultProtocol string) (*rpc.Port, error) {

address := p.address
protocol := p.protocol
Expand All @@ -84,7 +82,7 @@ func (p *Port) GetPort(instance *rpc.Instance, defaultAddress, defaultProtocol s
// the attached board without specifying explictly a port.
// Tools that work this way must be specified using the property
// "BOARD_ID.upload.tool.default" in the platform's boards.txt.
return &discovery.Port{
return &rpc.Port{
Protocol: "default",
}, nil
}
Expand Down Expand Up @@ -113,13 +111,13 @@ func (p *Port) GetPort(instance *rpc.Instance, defaultAddress, defaultProtocol s
}
port := portEvent.Port
if (protocol == "" || protocol == port.Protocol) && address == port.Address {
return port, nil
return port.ToRPC(), nil
}

case <-deadline:
// No matching port found
if protocol == "" {
return &discovery.Port{
return &rpc.Port{
Address: address,
Protocol: "serial",
}, nil
Expand Down
2 changes: 1 addition & 1 deletion internal/cli/burnbootloader/burnbootloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func runBootloaderCommand(command *cobra.Command, args []string) {
if _, err := upload.BurnBootloader(context.Background(), &rpc.BurnBootloaderRequest{
Instance: instance,
Fqbn: fqbn.String(),
Port: discoveryPort.ToRPC(),
Port: discoveryPort,
Verbose: verbose,
Verify: verify,
Programmer: programmer.String(),
Expand Down

0 comments on commit 6f508c2

Please sign in to comment.