diff --git a/internal/cli/arguments/fqbn.go b/internal/cli/arguments/fqbn.go index b48ae8baf46..84c805c0088 100644 --- a/internal/cli/arguments/fqbn.go +++ b/internal/cli/arguments/fqbn.go @@ -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 } diff --git a/internal/cli/arguments/port.go b/internal/cli/arguments/port.go index d8b0617cb58..08192049c2c 100644 --- a/internal/cli/arguments/port.go +++ b/internal/cli/arguments/port.go @@ -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" @@ -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 @@ -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 } @@ -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 diff --git a/internal/cli/burnbootloader/burnbootloader.go b/internal/cli/burnbootloader/burnbootloader.go index 45f0374bd27..23cd9a5006e 100644 --- a/internal/cli/burnbootloader/burnbootloader.go +++ b/internal/cli/burnbootloader/burnbootloader.go @@ -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(), diff --git a/internal/cli/upload/upload.go b/internal/cli/upload/upload.go index 0f2a798d979..3c33f2675b0 100644 --- a/internal/cli/upload/upload.go +++ b/internal/cli/upload/upload.go @@ -24,8 +24,8 @@ import ( "github.com/arduino/arduino-cli/arduino" "github.com/arduino/arduino-cli/arduino/cores/packagemanager" - "github.com/arduino/arduino-cli/arduino/sketch" "github.com/arduino/arduino-cli/commands" + sk "github.com/arduino/arduino-cli/commands/sketch" "github.com/arduino/arduino-cli/commands/upload" "github.com/arduino/arduino-cli/i18n" "github.com/arduino/arduino-cli/internal/cli/arguments" @@ -90,7 +90,7 @@ func runUploadCommand(command *cobra.Command, args []string) { arguments.WarnDeprecatedFiles(sketchPath) } - sk, err := sketch.New(sketchPath) + sketch, err := sk.LoadSketch(context.Background(), &rpc.LoadSketchRequest{SketchPath: sketchPath.String()}) if err != nil && importDir == "" && importFile == "" { feedback.Fatal(tr("Error during Upload: %v", err), feedback.ErrGeneric) } @@ -99,7 +99,7 @@ func runUploadCommand(command *cobra.Command, args []string) { var profile *rpc.Profile if profileArg.Get() == "" { - inst, profile = instance.CreateAndInitWithProfile(sk.Project.DefaultProfile, sketchPath) + inst, profile = instance.CreateAndInitWithProfile(sketch.GetDefaultProfile().GetName(), sketchPath) } else { inst, profile = instance.CreateAndInitWithProfile(profileArg.Get(), sketchPath) } @@ -108,8 +108,9 @@ func runUploadCommand(command *cobra.Command, args []string) { fqbnArg.Set(profile.GetFqbn()) } - defaultFQBN := sk.GetDefaultFQBN() - defaultAddress, defaultProtocol := sk.GetDefaultPortAddressAndProtocol() + defaultFQBN := sketch.GetDefaultFqbn() + defaultAddress := sketch.GetDefaultPort() + defaultProtocol := sketch.GetDefaultProtocol() fqbn, port := arguments.CalculateFQBNAndPort(&portArgs, &fqbnArg, inst, defaultFQBN, defaultAddress, defaultProtocol) userFieldRes, err := upload.SupportedUserFields(context.Background(), &rpc.SupportedUserFieldsRequest{