From a4edfd6d72ca03f21eb24ddc3c640cb3a4dc8f7c Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Wed, 25 Jan 2023 14:42:58 +0100 Subject: [PATCH 1/6] feat: filter boards by fqbn in connected list --- commands/board/list.go | 23 ++- internal/cli/arguments/fqbn.go | 19 +- internal/cli/board/list.go | 6 + internal/integrationtest/board/board_test.go | 33 ++++ rpc/cc/arduino/cli/commands/v1/board.pb.go | 176 ++++++++++-------- rpc/cc/arduino/cli/commands/v1/board.proto | 3 + rpc/cc/arduino/cli/commands/v1/commands.pb.go | 2 +- .../cli/commands/v1/commands_grpc.pb.go | 2 +- rpc/cc/arduino/cli/commands/v1/common.pb.go | 2 +- rpc/cc/arduino/cli/commands/v1/compile.pb.go | 2 +- rpc/cc/arduino/cli/commands/v1/core.pb.go | 2 +- rpc/cc/arduino/cli/commands/v1/lib.pb.go | 2 +- rpc/cc/arduino/cli/commands/v1/monitor.pb.go | 2 +- rpc/cc/arduino/cli/commands/v1/port.pb.go | 2 +- rpc/cc/arduino/cli/commands/v1/upload.pb.go | 2 +- rpc/cc/arduino/cli/debug/v1/debug.pb.go | 2 +- rpc/cc/arduino/cli/debug/v1/debug_grpc.pb.go | 2 +- rpc/cc/arduino/cli/settings/v1/settings.pb.go | 2 +- .../cli/settings/v1/settings_grpc.pb.go | 2 +- 19 files changed, 187 insertions(+), 99 deletions(-) diff --git a/commands/board/list.go b/commands/board/list.go index 6335fa69cb3..ae71bdc14ea 100644 --- a/commands/board/list.go +++ b/commands/board/list.go @@ -205,6 +205,15 @@ func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, discoveryStartError } defer release() + var fqbnFilter *cores.FQBN + if f := req.GetFqbn(); f != "" { + var err error + fqbnFilter, err = cores.ParseFQBN(f) + if err != nil { + return nil, nil, &arduino.InvalidFQBNError{Cause: err} + } + } + dm := pme.DiscoveryManager() discoveryStartErrors = dm.Start() time.Sleep(time.Duration(req.GetTimeout()) * time.Millisecond) @@ -222,11 +231,23 @@ func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, discoveryStartError Port: port.ToRPC(), MatchingBoards: boards, } - retVal = append(retVal, b) + + if fqbnFilter == nil || hasMatchingBoard(b, fqbnFilter) { + retVal = append(retVal, b) + } } return retVal, discoveryStartErrors, nil } +func hasMatchingBoard(b *rpc.DetectedPort, requestedFqbn *cores.FQBN) bool { + for _, detectedBoard := range b.MatchingBoards { + if detectedBoard.Fqbn == requestedFqbn.String() { + return true + } + } + return false +} + // Watch returns a channel that receives boards connection and disconnection events. // It also returns a callback function that must be used to stop and dispose the watch. func Watch(req *rpc.BoardListWatchRequest) (<-chan *rpc.BoardListWatchResponse, func(), error) { diff --git a/internal/cli/arguments/fqbn.go b/internal/cli/arguments/fqbn.go index 4d81a3c86b8..9e5eb417e6c 100644 --- a/internal/cli/arguments/fqbn.go +++ b/internal/cli/arguments/fqbn.go @@ -33,14 +33,27 @@ type Fqbn struct { boardOptions []string // List of boards specific options separated by commas. Or can be used multiple times for multiple options. } -// AddToCommand adds the flags used to set fqbn to the specified Command +// AddToCommand adds the flags used to set fqbn and the board options to the specified Command func (f *Fqbn) AddToCommand(cmd *cobra.Command) { + f.addToCommand(cmd, true) +} + +// AddToCommand adds the flags used to set fqbn to the specified Command, board options flag is not provided +func (f *Fqbn) AddToCommandWithoutBoardOptions(cmd *cobra.Command) { + f.addToCommand(cmd, false) +} + +func (f *Fqbn) addToCommand(cmd *cobra.Command, enableBoardOptions bool) bool { cmd.Flags().StringVarP(&f.fqbn, "fqbn", "b", "", tr("Fully Qualified Board Name, e.g.: arduino:avr:uno")) cmd.RegisterFlagCompletionFunc("fqbn", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return GetInstalledBoards(), cobra.ShellCompDirectiveDefault }) - cmd.Flags().StringSliceVar(&f.boardOptions, "board-options", []string{}, - tr("List of board options separated by commas. Or can be used multiple times for multiple options.")) + + if enableBoardOptions { + cmd.Flags().StringSliceVar(&f.boardOptions, "board-options", []string{}, + tr("List of board options separated by commas. Or can be used multiple times for multiple options.")) + } + return false } // String returns the fqbn with the board options if there are any diff --git a/internal/cli/board/list.go b/internal/cli/board/list.go index 4bf73b11fc4..93833c592ca 100644 --- a/internal/cli/board/list.go +++ b/internal/cli/board/list.go @@ -20,6 +20,7 @@ import ( "os" "sort" + "github.com/arduino/arduino-cli/arduino" "github.com/arduino/arduino-cli/arduino/cores" "github.com/arduino/arduino-cli/commands/board" "github.com/arduino/arduino-cli/internal/cli/arguments" @@ -47,6 +48,7 @@ func initListCommand() *cobra.Command { } timeoutArg.AddToCommand(listCommand) + fqbn.AddToCommandWithoutBoardOptions(listCommand) listCommand.Flags().BoolVarP(&watch, "watch", "w", false, tr("Command keeps running and prints list of connected boards whenever there is a change.")) return listCommand @@ -66,8 +68,12 @@ func runListCommand(cmd *cobra.Command, args []string) { ports, discvoeryErrors, err := board.List(&rpc.BoardListRequest{ Instance: inst, Timeout: timeoutArg.Get().Milliseconds(), + Fqbn: fqbn.String(), }) if err != nil { + if _, isFqbnError := err.(*arduino.InvalidFQBNError); isFqbnError { + feedback.Fatal(tr(err.Error()), feedback.ErrBadArgument) + } feedback.Warning(tr("Error detecting boards: %v", err)) } for _, err := range discvoeryErrors { diff --git a/internal/integrationtest/board/board_test.go b/internal/integrationtest/board/board_test.go index 14fbf9ebfd0..af4f2ffa921 100644 --- a/internal/integrationtest/board/board_test.go +++ b/internal/integrationtest/board/board_test.go @@ -91,6 +91,39 @@ func TestBoardList(t *testing.T) { MustBeEmpty() } +func TestBoardListWithFqbnFilter(t *testing.T) { + if os.Getenv("CI") != "" { + t.Skip("VMs have no serial ports") + } + + env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) + defer env.CleanUp() + + _, _, err := cli.Run("core", "update-index") + require.NoError(t, err) + stdout, _, err := cli.Run("board", "list", "-b", "arduino:avr:uno", "--format", "json") + require.NoError(t, err) + // this is a bit of a passpartout test, it actually filters the "bluetooth boards" locally + // but it would succeed even if the filtering wasn't working properly + // TODO: find a way to simulate connected boards or create a unit test which + // mocks or initializes multiple components + requirejson.Parse(t, stdout). + MustBeEmpty() +} + +func TestBoardListWithFqbnFilterInvalid(t *testing.T) { + if os.Getenv("CI") != "" { + t.Skip("VMs have no serial ports") + } + + env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) + defer env.CleanUp() + + _, stderr, err := cli.Run("board", "list", "-b", "yadayada", "--format", "json") + require.Error(t, err) + requirejson.Query(t, stderr, ".error", `"Invalid FQBN: not an FQBN: yadayada"`) +} + func TestBoardListWithInvalidDiscovery(t *testing.T) { env, cli := integrationtest.CreateArduinoCLIWithEnvironment(t) defer env.CleanUp() diff --git a/rpc/cc/arduino/cli/commands/v1/board.pb.go b/rpc/cc/arduino/cli/commands/v1/board.pb.go index cc131f0740e..0acad885e22 100644 --- a/rpc/cc/arduino/cli/commands/v1/board.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/board.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.17.3 +// protoc v3.21.12 // source: cc/arduino/cli/commands/v1/board.proto package commands @@ -851,6 +851,9 @@ type BoardListRequest struct { Instance *Instance `protobuf:"bytes,1,opt,name=instance,proto3" json:"instance,omitempty"` // Search for boards for the given time (in milliseconds) Timeout int64 `protobuf:"varint,2,opt,name=timeout,proto3" json:"timeout,omitempty"` + // The fully qualified board name of the board you want information about + // (e.g., `arduino:avr:uno`). + Fqbn string `protobuf:"bytes,3,opt,name=fqbn,proto3" json:"fqbn,omitempty"` } func (x *BoardListRequest) Reset() { @@ -899,6 +902,13 @@ func (x *BoardListRequest) GetTimeout() int64 { return 0 } +func (x *BoardListRequest) GetFqbn() string { + if x != nil { + return x.Fqbn + } + return "" +} + type BoardListResponse struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -1570,93 +1580,95 @@ var file_cc_arduino_cli_commands_v1_board_proto_rawDesc = []byte{ 0x1f, 0x0a, 0x0b, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x4c, 0x61, 0x62, 0x65, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x08, 0x52, 0x08, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x22, 0x6e, 0x0a, 0x10, - 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, - 0x12, 0x40, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, - 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, - 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, - 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, - 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x22, 0x53, 0x0a, 0x11, - 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, - 0x65, 0x12, 0x3e, 0x0a, 0x05, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x28, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, - 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, - 0x74, 0x65, 0x63, 0x74, 0x65, 0x64, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x05, 0x70, 0x6f, 0x72, 0x74, - 0x73, 0x22, 0x98, 0x01, 0x0a, 0x0c, 0x44, 0x65, 0x74, 0x65, 0x63, 0x74, 0x65, 0x64, 0x50, 0x6f, - 0x72, 0x74, 0x12, 0x52, 0x0a, 0x0f, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, 0x5f, 0x62, - 0x6f, 0x61, 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x63, + 0x28, 0x08, 0x52, 0x08, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x22, 0x82, 0x01, 0x0a, + 0x10, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x40, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, + 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, + 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, + 0x6e, 0x63, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69, 0x6d, 0x65, 0x6f, 0x75, 0x74, 0x12, 0x12, 0x0a, + 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, + 0x6e, 0x22, 0x53, 0x0a, 0x11, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3e, 0x0a, 0x05, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, + 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, + 0x76, 0x31, 0x2e, 0x44, 0x65, 0x74, 0x65, 0x63, 0x74, 0x65, 0x64, 0x50, 0x6f, 0x72, 0x74, 0x52, + 0x05, 0x70, 0x6f, 0x72, 0x74, 0x73, 0x22, 0x98, 0x01, 0x0a, 0x0c, 0x44, 0x65, 0x74, 0x65, 0x63, + 0x74, 0x65, 0x64, 0x50, 0x6f, 0x72, 0x74, 0x12, 0x52, 0x0a, 0x0f, 0x6d, 0x61, 0x74, 0x63, 0x68, + 0x69, 0x6e, 0x67, 0x5f, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x29, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, + 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, + 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x0e, 0x6d, 0x61, 0x74, + 0x63, 0x68, 0x69, 0x6e, 0x67, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x12, 0x34, 0x0a, 0x04, 0x70, + 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x63, 0x2e, 0x61, + 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, + 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x04, 0x70, 0x6f, 0x72, + 0x74, 0x22, 0xac, 0x01, 0x0a, 0x13, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x41, + 0x6c, 0x6c, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x08, 0x69, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, - 0x73, 0x74, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x0e, 0x6d, 0x61, 0x74, 0x63, 0x68, 0x69, 0x6e, 0x67, - 0x42, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x12, 0x34, 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x20, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, - 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, - 0x31, 0x2e, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x22, 0xac, 0x01, 0x0a, - 0x13, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x71, + 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, + 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, + 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f, 0x61, 0x72, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, + 0x52, 0x0a, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x41, 0x72, 0x67, 0x73, 0x12, 0x32, 0x0a, 0x15, + 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x5f, 0x62, + 0x6f, 0x61, 0x72, 0x64, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x69, 0x6e, 0x63, + 0x6c, 0x75, 0x64, 0x65, 0x48, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x73, + 0x22, 0x59, 0x0a, 0x14, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x06, 0x62, 0x6f, 0x61, 0x72, + 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, + 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, + 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x49, + 0x74, 0x65, 0x6d, 0x52, 0x06, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x22, 0x77, 0x0a, 0x15, 0x42, + 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, - 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, - 0x5f, 0x61, 0x72, 0x67, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x61, - 0x72, 0x63, 0x68, 0x41, 0x72, 0x67, 0x73, 0x12, 0x32, 0x0a, 0x15, 0x69, 0x6e, 0x63, 0x6c, 0x75, - 0x64, 0x65, 0x5f, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x5f, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x48, - 0x69, 0x64, 0x64, 0x65, 0x6e, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x22, 0x59, 0x0a, 0x14, 0x42, - 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x41, 0x6c, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x6f, - 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x06, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, - 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, - 0x2e, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, - 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x22, 0x77, 0x0a, 0x15, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, - 0x69, 0x73, 0x74, 0x57, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, - 0x40, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, - 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, - 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, - 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x72, 0x75, 0x70, 0x74, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x72, 0x75, 0x70, 0x74, 0x22, - 0x8b, 0x01, 0x0a, 0x16, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x57, 0x61, 0x74, - 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x65, 0x76, - 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, - 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x3c, 0x0a, 0x04, 0x70, 0x6f, 0x72, - 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, - 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, - 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x74, 0x65, 0x63, 0x74, 0x65, 0x64, 0x50, 0x6f, 0x72, - 0x74, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x22, 0x96, 0x01, - 0x0a, 0x0d, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x74, 0x65, 0x6d, 0x12, - 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, - 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x73, 0x5f, 0x68, 0x69, - 0x64, 0x64, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73, 0x48, 0x69, - 0x64, 0x64, 0x65, 0x6e, 0x12, 0x40, 0x0a, 0x08, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, - 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, - 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, - 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x52, 0x08, 0x70, 0x6c, - 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x22, 0xab, 0x01, 0x0a, 0x12, 0x42, 0x6f, 0x61, 0x72, 0x64, - 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x40, 0x0a, - 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, - 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, - 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x49, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, - 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f, 0x61, 0x72, 0x67, 0x73, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x41, 0x72, 0x67, 0x73, - 0x12, 0x32, 0x0a, 0x15, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x68, 0x69, 0x64, 0x64, - 0x65, 0x6e, 0x5f, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, - 0x13, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x48, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x42, 0x6f, - 0x61, 0x72, 0x64, 0x73, 0x22, 0x58, 0x0a, 0x13, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x53, 0x65, 0x61, - 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x41, 0x0a, 0x06, 0x62, - 0x6f, 0x61, 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x29, 0x2e, 0x63, 0x63, + 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x72, + 0x75, 0x70, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x72, 0x75, 0x70, 0x74, 0x22, 0x8b, 0x01, 0x0a, 0x16, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, + 0x73, 0x74, 0x57, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x1d, 0x0a, 0x0a, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x74, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x09, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x54, 0x79, 0x70, 0x65, 0x12, 0x3c, + 0x0a, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x28, 0x2e, 0x63, + 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, + 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x44, 0x65, 0x74, 0x65, 0x63, 0x74, + 0x65, 0x64, 0x50, 0x6f, 0x72, 0x74, 0x52, 0x04, 0x70, 0x6f, 0x72, 0x74, 0x12, 0x14, 0x0a, 0x05, + 0x65, 0x72, 0x72, 0x6f, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x65, 0x72, 0x72, + 0x6f, 0x72, 0x22, 0x96, 0x01, 0x0a, 0x0d, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, + 0x49, 0x74, 0x65, 0x6d, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66, 0x71, 0x62, 0x6e, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x66, 0x71, 0x62, 0x6e, 0x12, 0x1b, 0x0a, 0x09, + 0x69, 0x73, 0x5f, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x08, 0x69, 0x73, 0x48, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x12, 0x40, 0x0a, 0x08, 0x70, 0x6c, 0x61, + 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x18, 0x06, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, - 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, - 0x73, 0x74, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x42, 0x48, - 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x61, 0x72, 0x64, - 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2d, 0x63, 0x6c, 0x69, - 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, - 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2f, 0x76, 0x31, 0x3b, - 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x50, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, + 0x6d, 0x52, 0x08, 0x70, 0x6c, 0x61, 0x74, 0x66, 0x6f, 0x72, 0x6d, 0x22, 0xab, 0x01, 0x0a, 0x12, + 0x42, 0x6f, 0x61, 0x72, 0x64, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, + 0x73, 0x74, 0x12, 0x40, 0x0a, 0x08, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, + 0x6f, 0x2e, 0x63, 0x6c, 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, + 0x31, 0x2e, 0x49, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x52, 0x08, 0x69, 0x6e, 0x73, 0x74, + 0x61, 0x6e, 0x63, 0x65, 0x12, 0x1f, 0x0a, 0x0b, 0x73, 0x65, 0x61, 0x72, 0x63, 0x68, 0x5f, 0x61, + 0x72, 0x67, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x61, 0x72, 0x63, + 0x68, 0x41, 0x72, 0x67, 0x73, 0x12, 0x32, 0x0a, 0x15, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, + 0x5f, 0x68, 0x69, 0x64, 0x64, 0x65, 0x6e, 0x5f, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x08, 0x52, 0x13, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x48, 0x69, 0x64, + 0x64, 0x65, 0x6e, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x22, 0x58, 0x0a, 0x13, 0x42, 0x6f, 0x61, + 0x72, 0x64, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x41, 0x0a, 0x06, 0x62, 0x6f, 0x61, 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x29, 0x2e, 0x63, 0x63, 0x2e, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2e, 0x63, 0x6c, + 0x69, 0x2e, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x2e, 0x76, 0x31, 0x2e, 0x42, 0x6f, + 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x06, 0x62, 0x6f, 0x61, + 0x72, 0x64, 0x73, 0x42, 0x48, 0x5a, 0x46, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, + 0x6d, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x61, 0x72, 0x64, 0x75, 0x69, 0x6e, + 0x6f, 0x2d, 0x63, 0x6c, 0x69, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x63, 0x63, 0x2f, 0x61, 0x72, 0x64, + 0x75, 0x69, 0x6e, 0x6f, 0x2f, 0x63, 0x6c, 0x69, 0x2f, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, + 0x73, 0x2f, 0x76, 0x31, 0x3b, 0x63, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/rpc/cc/arduino/cli/commands/v1/board.proto b/rpc/cc/arduino/cli/commands/v1/board.proto index 5fdcb885333..53f9d571334 100644 --- a/rpc/cc/arduino/cli/commands/v1/board.proto +++ b/rpc/cc/arduino/cli/commands/v1/board.proto @@ -152,6 +152,9 @@ message BoardListRequest { Instance instance = 1; // Search for boards for the given time (in milliseconds) int64 timeout = 2; + // The fully qualified board name of the board you want information about + // (e.g., `arduino:avr:uno`). + string fqbn = 3; } message BoardListResponse { diff --git a/rpc/cc/arduino/cli/commands/v1/commands.pb.go b/rpc/cc/arduino/cli/commands/v1/commands.pb.go index 91729aeaa13..390a4f951a8 100644 --- a/rpc/cc/arduino/cli/commands/v1/commands.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/commands.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.17.3 +// protoc v3.21.12 // source: cc/arduino/cli/commands/v1/commands.proto package commands diff --git a/rpc/cc/arduino/cli/commands/v1/commands_grpc.pb.go b/rpc/cc/arduino/cli/commands/v1/commands_grpc.pb.go index b092524084e..82d583822f6 100644 --- a/rpc/cc/arduino/cli/commands/v1/commands_grpc.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/commands_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.2.0 -// - protoc v3.17.3 +// - protoc v3.21.12 // source: cc/arduino/cli/commands/v1/commands.proto package commands diff --git a/rpc/cc/arduino/cli/commands/v1/common.pb.go b/rpc/cc/arduino/cli/commands/v1/common.pb.go index 12b37d90347..a7027614534 100644 --- a/rpc/cc/arduino/cli/commands/v1/common.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/common.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.17.3 +// protoc v3.21.12 // source: cc/arduino/cli/commands/v1/common.proto package commands diff --git a/rpc/cc/arduino/cli/commands/v1/compile.pb.go b/rpc/cc/arduino/cli/commands/v1/compile.pb.go index 83455c64ecb..35de0ac1d3f 100644 --- a/rpc/cc/arduino/cli/commands/v1/compile.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/compile.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.17.3 +// protoc v3.21.12 // source: cc/arduino/cli/commands/v1/compile.proto package commands diff --git a/rpc/cc/arduino/cli/commands/v1/core.pb.go b/rpc/cc/arduino/cli/commands/v1/core.pb.go index fc5844fef4f..203111dba3c 100644 --- a/rpc/cc/arduino/cli/commands/v1/core.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/core.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.17.3 +// protoc v3.21.12 // source: cc/arduino/cli/commands/v1/core.proto package commands diff --git a/rpc/cc/arduino/cli/commands/v1/lib.pb.go b/rpc/cc/arduino/cli/commands/v1/lib.pb.go index bd315dc76bc..ff81767c199 100644 --- a/rpc/cc/arduino/cli/commands/v1/lib.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/lib.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.17.3 +// protoc v3.21.12 // source: cc/arduino/cli/commands/v1/lib.proto package commands diff --git a/rpc/cc/arduino/cli/commands/v1/monitor.pb.go b/rpc/cc/arduino/cli/commands/v1/monitor.pb.go index a64fedccdb3..2d366f8be67 100644 --- a/rpc/cc/arduino/cli/commands/v1/monitor.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/monitor.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.17.3 +// protoc v3.21.12 // source: cc/arduino/cli/commands/v1/monitor.proto package commands diff --git a/rpc/cc/arduino/cli/commands/v1/port.pb.go b/rpc/cc/arduino/cli/commands/v1/port.pb.go index ee185906d70..baedafdb82e 100644 --- a/rpc/cc/arduino/cli/commands/v1/port.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/port.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.17.3 +// protoc v3.21.12 // source: cc/arduino/cli/commands/v1/port.proto package commands diff --git a/rpc/cc/arduino/cli/commands/v1/upload.pb.go b/rpc/cc/arduino/cli/commands/v1/upload.pb.go index f151a4288ea..0e524dca392 100644 --- a/rpc/cc/arduino/cli/commands/v1/upload.pb.go +++ b/rpc/cc/arduino/cli/commands/v1/upload.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.17.3 +// protoc v3.21.12 // source: cc/arduino/cli/commands/v1/upload.proto package commands diff --git a/rpc/cc/arduino/cli/debug/v1/debug.pb.go b/rpc/cc/arduino/cli/debug/v1/debug.pb.go index 11989af3fa8..464bdb0e902 100644 --- a/rpc/cc/arduino/cli/debug/v1/debug.pb.go +++ b/rpc/cc/arduino/cli/debug/v1/debug.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.17.3 +// protoc v3.21.12 // source: cc/arduino/cli/debug/v1/debug.proto package debug diff --git a/rpc/cc/arduino/cli/debug/v1/debug_grpc.pb.go b/rpc/cc/arduino/cli/debug/v1/debug_grpc.pb.go index 31a3c8d680f..c15bf5c0b8a 100644 --- a/rpc/cc/arduino/cli/debug/v1/debug_grpc.pb.go +++ b/rpc/cc/arduino/cli/debug/v1/debug_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.2.0 -// - protoc v3.17.3 +// - protoc v3.21.12 // source: cc/arduino/cli/debug/v1/debug.proto package debug diff --git a/rpc/cc/arduino/cli/settings/v1/settings.pb.go b/rpc/cc/arduino/cli/settings/v1/settings.pb.go index 7fff84832e9..4e1c13611b4 100644 --- a/rpc/cc/arduino/cli/settings/v1/settings.pb.go +++ b/rpc/cc/arduino/cli/settings/v1/settings.pb.go @@ -16,7 +16,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.26.0 -// protoc v3.17.3 +// protoc v3.21.12 // source: cc/arduino/cli/settings/v1/settings.proto package settings diff --git a/rpc/cc/arduino/cli/settings/v1/settings_grpc.pb.go b/rpc/cc/arduino/cli/settings/v1/settings_grpc.pb.go index 305d1f96cea..746eb2df020 100644 --- a/rpc/cc/arduino/cli/settings/v1/settings_grpc.pb.go +++ b/rpc/cc/arduino/cli/settings/v1/settings_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.2.0 -// - protoc v3.17.3 +// - protoc v3.21.12 // source: cc/arduino/cli/settings/v1/settings.proto package settings From a4265f1f0dd964c208f9dff02d062045561a0f3a Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Thu, 26 Jan 2023 14:39:44 +0100 Subject: [PATCH 2/6] chore: doc comment --- internal/cli/arguments/fqbn.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/cli/arguments/fqbn.go b/internal/cli/arguments/fqbn.go index 9e5eb417e6c..ec8dd4f54b2 100644 --- a/internal/cli/arguments/fqbn.go +++ b/internal/cli/arguments/fqbn.go @@ -38,7 +38,7 @@ func (f *Fqbn) AddToCommand(cmd *cobra.Command) { f.addToCommand(cmd, true) } -// AddToCommand adds the flags used to set fqbn to the specified Command, board options flag is not provided +// AddToCommandWithoutBoardOptions adds the flags used to set fqbn to the specified Command, board options flag is not provided func (f *Fqbn) AddToCommandWithoutBoardOptions(cmd *cobra.Command) { f.addToCommand(cmd, false) } From 29a96664f323d02adf1db11a819ada15dcc227a2 Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Fri, 27 Jan 2023 09:19:33 +0100 Subject: [PATCH 3/6] refactor: style --- internal/cli/arguments/fqbn.go | 6 +++--- internal/cli/board/list.go | 12 +++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/internal/cli/arguments/fqbn.go b/internal/cli/arguments/fqbn.go index ec8dd4f54b2..d518b0c470d 100644 --- a/internal/cli/arguments/fqbn.go +++ b/internal/cli/arguments/fqbn.go @@ -35,15 +35,15 @@ type Fqbn struct { // AddToCommand adds the flags used to set fqbn and the board options to the specified Command func (f *Fqbn) AddToCommand(cmd *cobra.Command) { - f.addToCommand(cmd, true) + f.configureForCommand(cmd, true) } // AddToCommandWithoutBoardOptions adds the flags used to set fqbn to the specified Command, board options flag is not provided func (f *Fqbn) AddToCommandWithoutBoardOptions(cmd *cobra.Command) { - f.addToCommand(cmd, false) + f.configureForCommand(cmd, false) } -func (f *Fqbn) addToCommand(cmd *cobra.Command, enableBoardOptions bool) bool { +func (f *Fqbn) configureForCommand(cmd *cobra.Command, enableBoardOptions bool) bool { cmd.Flags().StringVarP(&f.fqbn, "fqbn", "b", "", tr("Fully Qualified Board Name, e.g.: arduino:avr:uno")) cmd.RegisterFlagCompletionFunc("fqbn", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return GetInstalledBoards(), cobra.ShellCompDirectiveDefault diff --git a/internal/cli/board/list.go b/internal/cli/board/list.go index 93833c592ca..84ea6647bd1 100644 --- a/internal/cli/board/list.go +++ b/internal/cli/board/list.go @@ -16,6 +16,7 @@ package board import ( + "errors" "fmt" "os" "sort" @@ -65,18 +66,19 @@ func runListCommand(cmd *cobra.Command, args []string) { return } - ports, discvoeryErrors, err := board.List(&rpc.BoardListRequest{ + ports, discoveryErrors, err := board.List(&rpc.BoardListRequest{ Instance: inst, Timeout: timeoutArg.Get().Milliseconds(), Fqbn: fqbn.String(), }) + var invalidFQBNErr *arduino.InvalidFQBNError + if errors.As(err, &invalidFQBNErr) { + feedback.Fatal(tr(err.Error()), feedback.ErrBadArgument) + } if err != nil { - if _, isFqbnError := err.(*arduino.InvalidFQBNError); isFqbnError { - feedback.Fatal(tr(err.Error()), feedback.ErrBadArgument) - } feedback.Warning(tr("Error detecting boards: %v", err)) } - for _, err := range discvoeryErrors { + for _, err := range discoveryErrors { feedback.Warning(tr("Error starting discovery: %v", err)) } feedback.PrintResult(result{ports}) From d274e24368b6a6bef05c0c1a35c1074b2cd4acb1 Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Fri, 27 Jan 2023 16:39:36 +0100 Subject: [PATCH 4/6] fix: add board options to fqbn filter --- arduino/cores/fqbn.go | 23 +++++++++++++++++++++++ arduino/cores/fqbn_test.go | 34 ++++++++++++++++++++++++++++++++++ commands/board/list.go | 8 ++++++-- internal/cli/arguments/fqbn.go | 19 +++---------------- internal/cli/board/list.go | 2 +- 5 files changed, 67 insertions(+), 19 deletions(-) diff --git a/arduino/cores/fqbn.go b/arduino/cores/fqbn.go index f85d9af476c..a5ff60dc014 100644 --- a/arduino/cores/fqbn.go +++ b/arduino/cores/fqbn.go @@ -76,6 +76,29 @@ func (fqbn *FQBN) String() string { return res } +// Match check if the target FQBN corresponds to the receiver one. +// The core parts are checked for exact equality while board options are loosely +// matched: the set of boards options of the target must be fully contained within +// the one of the receiver and their values must be equal. +func (fqbn *FQBN) Match(target *FQBN) bool { + if fqbn.StringWithoutConfig() != target.StringWithoutConfig() { + return false + } + searchedProperties := target.Configs.Clone() + actualConfigs := fqbn.Configs.AsMap() + for neededKey, neededValue := range searchedProperties.AsMap() { + targetValue, hasKey := actualConfigs[neededKey] + if !hasKey { + return false + } + if targetValue != neededValue { + return false + } + } + + return true +} + // StringWithoutConfig returns the FQBN without the Config part func (fqbn *FQBN) StringWithoutConfig() string { return fqbn.Package + ":" + fqbn.PlatformArch + ":" + fqbn.BoardID diff --git a/arduino/cores/fqbn_test.go b/arduino/cores/fqbn_test.go index ab0fdd6253a..5c4cd9836f8 100644 --- a/arduino/cores/fqbn_test.go +++ b/arduino/cores/fqbn_test.go @@ -121,3 +121,37 @@ func TestFQBN(t *testing.T) { "properties.Map{\n \"cpu\": \"atmega\",\n \"speed\": \"1000\",\n \"extra\": \"core=arduino\",\n}", f.Configs.Dump()) } + +func TestMatch(t *testing.T) { + expectedMatches := [][]string{ + {"arduino:avr:uno", "arduino:avr:uno"}, + {"arduino:avr:uno", "arduino:avr:uno:opt1=1,opt2=2"}, + {"arduino:avr:uno:opt1=1", "arduino:avr:uno:opt1=1,opt2=2"}, + {"arduino:avr:uno:opt1=1,opt2=2", "arduino:avr:uno:opt1=1,opt2=2"}, + {"arduino:avr:uno:opt3=3,opt1=1,opt2=2", "arduino:avr:uno:opt2=2,opt3=3,opt1=1,opt4=4"}, + } + + for _, pair := range expectedMatches { + a, err := ParseFQBN(pair[0]) + require.NoError(t, err) + b, err := ParseFQBN(pair[1]) + require.NoError(t, err) + require.True(t, b.Match(a)) + } + + expectedMismatches := [][]string{ + {"arduino:avr:uno", "arduino:avr:due"}, + {"arduino:avr:uno", "arduino:avr:due:opt1=1,opt2=2"}, + {"arduino:avr:uno:opt1=1", "arduino:avr:uno"}, + {"arduino:avr:uno:opt1=1,opt2=", "arduino:avr:uno:opt1=1,opt2=3"}, + {"arduino:avr:uno:opt1=1,opt2=2", "arduino:avr:uno:opt2=2"}, + } + + for _, pair := range expectedMismatches { + a, err := ParseFQBN(pair[0]) + require.NoError(t, err) + b, err := ParseFQBN(pair[1]) + require.NoError(t, err) + require.False(t, b.Match(a)) + } +} diff --git a/commands/board/list.go b/commands/board/list.go index ae71bdc14ea..7d2c11f0fb2 100644 --- a/commands/board/list.go +++ b/commands/board/list.go @@ -239,9 +239,13 @@ func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, discoveryStartError return retVal, discoveryStartErrors, nil } -func hasMatchingBoard(b *rpc.DetectedPort, requestedFqbn *cores.FQBN) bool { +func hasMatchingBoard(b *rpc.DetectedPort, fqbnFilter *cores.FQBN) bool { for _, detectedBoard := range b.MatchingBoards { - if detectedBoard.Fqbn == requestedFqbn.String() { + detectedFqbn, err := cores.ParseFQBN(detectedBoard.Fqbn) + if err != nil { + continue + } + if detectedFqbn.Match(fqbnFilter) { return true } } diff --git a/internal/cli/arguments/fqbn.go b/internal/cli/arguments/fqbn.go index d518b0c470d..4d81a3c86b8 100644 --- a/internal/cli/arguments/fqbn.go +++ b/internal/cli/arguments/fqbn.go @@ -33,27 +33,14 @@ type Fqbn struct { boardOptions []string // List of boards specific options separated by commas. Or can be used multiple times for multiple options. } -// AddToCommand adds the flags used to set fqbn and the board options to the specified Command +// AddToCommand adds the flags used to set fqbn to the specified Command func (f *Fqbn) AddToCommand(cmd *cobra.Command) { - f.configureForCommand(cmd, true) -} - -// AddToCommandWithoutBoardOptions adds the flags used to set fqbn to the specified Command, board options flag is not provided -func (f *Fqbn) AddToCommandWithoutBoardOptions(cmd *cobra.Command) { - f.configureForCommand(cmd, false) -} - -func (f *Fqbn) configureForCommand(cmd *cobra.Command, enableBoardOptions bool) bool { cmd.Flags().StringVarP(&f.fqbn, "fqbn", "b", "", tr("Fully Qualified Board Name, e.g.: arduino:avr:uno")) cmd.RegisterFlagCompletionFunc("fqbn", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return GetInstalledBoards(), cobra.ShellCompDirectiveDefault }) - - if enableBoardOptions { - cmd.Flags().StringSliceVar(&f.boardOptions, "board-options", []string{}, - tr("List of board options separated by commas. Or can be used multiple times for multiple options.")) - } - return false + cmd.Flags().StringSliceVar(&f.boardOptions, "board-options", []string{}, + tr("List of board options separated by commas. Or can be used multiple times for multiple options.")) } // String returns the fqbn with the board options if there are any diff --git a/internal/cli/board/list.go b/internal/cli/board/list.go index 84ea6647bd1..0b033524221 100644 --- a/internal/cli/board/list.go +++ b/internal/cli/board/list.go @@ -49,7 +49,7 @@ func initListCommand() *cobra.Command { } timeoutArg.AddToCommand(listCommand) - fqbn.AddToCommandWithoutBoardOptions(listCommand) + fqbn.AddToCommand(listCommand) listCommand.Flags().BoolVarP(&watch, "watch", "w", false, tr("Command keeps running and prints list of connected boards whenever there is a change.")) return listCommand From e73a04d28d35637395b50dbd4fc09a08124df123 Mon Sep 17 00:00:00 2001 From: Luca Bianconi <71259950+Bikappa@users.noreply.github.com> Date: Fri, 27 Jan 2023 13:58:49 +0100 Subject: [PATCH 5/6] Update internal/integrationtest/board/board_test.go Co-authored-by: per1234 --- internal/integrationtest/board/board_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/integrationtest/board/board_test.go b/internal/integrationtest/board/board_test.go index af4f2ffa921..4a714277e8a 100644 --- a/internal/integrationtest/board/board_test.go +++ b/internal/integrationtest/board/board_test.go @@ -101,7 +101,7 @@ func TestBoardListWithFqbnFilter(t *testing.T) { _, _, err := cli.Run("core", "update-index") require.NoError(t, err) - stdout, _, err := cli.Run("board", "list", "-b", "arduino:avr:uno", "--format", "json") + stdout, _, err := cli.Run("board", "list", "-b", "foo:bar:baz", "--format", "json") require.NoError(t, err) // this is a bit of a passpartout test, it actually filters the "bluetooth boards" locally // but it would succeed even if the filtering wasn't working properly From e07272f04d324e1759a6997207fc43396a56767e Mon Sep 17 00:00:00 2001 From: Luca Bianconi Date: Mon, 30 Jan 2023 09:05:35 +0100 Subject: [PATCH 6/6] style: less ifs --- arduino/cores/fqbn.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/arduino/cores/fqbn.go b/arduino/cores/fqbn.go index a5ff60dc014..6df5598682a 100644 --- a/arduino/cores/fqbn.go +++ b/arduino/cores/fqbn.go @@ -84,18 +84,15 @@ func (fqbn *FQBN) Match(target *FQBN) bool { if fqbn.StringWithoutConfig() != target.StringWithoutConfig() { return false } + searchedProperties := target.Configs.Clone() actualConfigs := fqbn.Configs.AsMap() for neededKey, neededValue := range searchedProperties.AsMap() { targetValue, hasKey := actualConfigs[neededKey] - if !hasKey { - return false - } - if targetValue != neededValue { + if !hasKey || targetValue != neededValue { return false } } - return true }