From b3c3440f51b2ee7541f118cbb382f2a5eb4ec91e Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Mon, 16 Nov 2020 15:34:44 +0100 Subject: [PATCH] Add board vid and pid in board list json output --- commands/board/list.go | 4 ++++ commands/board/list_test.go | 2 ++ rpc/commands/board.pb.go | 30 +++++++++++++++++++++++++----- rpc/commands/board.proto | 4 ++++ 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/commands/board/list.go b/commands/board/list.go index bae50fd9e53..d3ba92d556a 100644 --- a/commands/board/list.go +++ b/commands/board/list.go @@ -89,6 +89,8 @@ func apiByVidPid(vid, pid string) ([]*rpc.BoardListItem, error) { retVal = append(retVal, &rpc.BoardListItem{ Name: name, FQBN: fqbn, + VID: vid, + PID: pid, }) } else { return nil, errors.Wrap(err, "error querying Arduino Cloud Api") @@ -118,6 +120,8 @@ func identify(pm *packagemanager.PackageManager, port *commands.BoardPort) ([]*r boards = append(boards, &rpc.BoardListItem{ Name: board.Name(), FQBN: board.FQBN(), + VID: port.IdentificationPrefs.Get("vid"), + PID: port.IdentificationPrefs.Get("pid"), }) } diff --git a/commands/board/list_test.go b/commands/board/list_test.go index 94384419ffa..efa706d32d0 100644 --- a/commands/board/list_test.go +++ b/commands/board/list_test.go @@ -53,6 +53,8 @@ func TestGetByVidPid(t *testing.T) { require.Len(t, res, 1) require.Equal(t, "Arduino/Genuino MKR1000", res[0].Name) require.Equal(t, "arduino:samd:mkr1000", res[0].FQBN) + require.Equal(t, "0xf420", res[0].VID) + require.Equal(t, "0XF069", res[0].PID) // wrong vid (too long), wrong pid (not an hex value) res, err = apiByVidPid("0xfffff", "0xDEFG") diff --git a/rpc/commands/board.pb.go b/rpc/commands/board.pb.go index 73641e4c640..6e297db8645 100644 --- a/rpc/commands/board.pb.go +++ b/rpc/commands/board.pb.go @@ -1448,6 +1448,10 @@ type BoardListItem struct { FQBN string `protobuf:"bytes,2,opt,name=FQBN,proto3" json:"FQBN,omitempty"` // If the board is marked as "hidden" in the platform IsHidden bool `protobuf:"varint,3,opt,name=is_hidden,json=isHidden,proto3" json:"is_hidden,omitempty"` + // Vendor ID + VID string `protobuf:"bytes,4,opt,name=VID,proto3" json:"VID,omitempty"` + // Product ID + PID string `protobuf:"bytes,5,opt,name=PID,proto3" json:"PID,omitempty"` } func (x *BoardListItem) Reset() { @@ -1503,6 +1507,20 @@ func (x *BoardListItem) GetIsHidden() bool { return false } +func (x *BoardListItem) GetVID() string { + if x != nil { + return x.VID + } + return "" +} + +func (x *BoardListItem) GetPID() string { + if x != nil { + return x.PID + } + return "" +} + var File_commands_board_proto protoreflect.FileDescriptor var file_commands_board_proto_rawDesc = []byte{ @@ -1698,15 +1716,17 @@ var file_commands_board_proto_rawDesc = []byte{ 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 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, - 0x54, 0x0a, 0x0d, 0x42, 0x6f, 0x61, 0x72, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x49, 0x74, 0x65, 0x6d, + 0x78, 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, 0x46, 0x51, 0x42, 0x4e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x46, 0x51, 0x42, 0x4e, 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, 0x42, 0x2d, 0x5a, 0x2b, 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, 0x6f, 0x6d, 0x6d, - 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x69, 0x64, 0x64, 0x65, 0x6e, 0x12, 0x10, 0x0a, 0x03, 0x56, 0x49, 0x44, 0x18, 0x04, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x03, 0x56, 0x49, 0x44, 0x12, 0x10, 0x0a, 0x03, 0x50, 0x49, 0x44, 0x18, 0x05, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x50, 0x49, 0x44, 0x42, 0x2d, 0x5a, 0x2b, 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, 0x6f, 0x6d, 0x6d, 0x61, 0x6e, 0x64, 0x73, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/rpc/commands/board.proto b/rpc/commands/board.proto index e8a9c671d65..6b45b25d34e 100644 --- a/rpc/commands/board.proto +++ b/rpc/commands/board.proto @@ -231,4 +231,8 @@ message BoardListItem { string FQBN = 2; // If the board is marked as "hidden" in the platform bool is_hidden = 3; + // Vendor ID + string VID = 4; + // Product ID + string PID = 5; }