Skip to content

Add board vid and pid in board list json output #1076

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 1 commit into from
Nov 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions commands/board/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why just VID & PID, and not the whole identificationPrefs?
In this case we have only vid/pid but the pluggable discovery can provide much more information.

})
}

Expand Down
2 changes: 2 additions & 0 deletions commands/board/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
30 changes: 25 additions & 5 deletions rpc/commands/board.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions rpc/commands/board.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}