Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Added BoardIdentify gRPC call. #2794

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 9 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Board identification function do not require a full Port but just the…
… properties
  • Loading branch information
cmaglie committed Jan 7, 2025
commit 433102210fd3649c3dd7c1ebd08e0c2fe6a1e735
19 changes: 9 additions & 10 deletions 19 commands/service_board_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import (
"github.com/arduino/arduino-cli/pkg/fqbn"
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/go-properties-orderedmap"
discovery "github.com/arduino/pluggable-discovery-protocol-handler/v2"
"github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -139,20 +138,20 @@ func identifyViaCloudAPI(props *properties.Map, settings *configuration.Settings
}

// identify returns a list of boards checking first the installed platforms or the Cloud API
func identify(pme *packagemanager.Explorer, port *discovery.Port, settings *configuration.Settings, skipCloudAPI bool) ([]*rpc.BoardListItem, error) {
boards := []*rpc.BoardListItem{}
if port.Properties == nil {
return boards, nil
func identify(pme *packagemanager.Explorer, properties *properties.Map, settings *configuration.Settings, skipCloudAPI bool) ([]*rpc.BoardListItem, error) {
if properties == nil {
return nil, nil
}

// first query installed cores through the Package Manager
boards := []*rpc.BoardListItem{}
logrus.Debug("Querying installed cores for board identification...")
for _, board := range pme.IdentifyBoard(port.Properties) {
for _, board := range pme.IdentifyBoard(properties) {
fqbn, err := fqbn.Parse(board.FQBN())
if err != nil {
return nil, &cmderrors.InvalidFQBNError{Cause: err}
}
fqbn.Configs = board.IdentifyBoardConfiguration(port.Properties)
fqbn.Configs = board.IdentifyBoardConfiguration(properties)

// We need the Platform maintaner for sorting so we set it here
platform := &rpc.Platform{
Expand All @@ -171,7 +170,7 @@ func identify(pme *packagemanager.Explorer, port *discovery.Port, settings *conf
// if installed cores didn't recognize the board, try querying
// the builder API if the board is a USB device port
if len(boards) == 0 && !skipCloudAPI && !settings.SkipCloudApiForBoardDetection() {
items, err := identifyViaCloudAPI(port.Properties, settings)
items, err := identifyViaCloudAPI(properties, settings)
if err != nil {
// this is bad, but keep going
logrus.WithError(err).Debug("Error querying builder API")
Expand Down Expand Up @@ -225,7 +224,7 @@ func (s *arduinoCoreServerImpl) BoardList(ctx context.Context, req *rpc.BoardLis

ports := []*rpc.DetectedPort{}
for _, port := range dm.List() {
boards, err := identify(pme, port, s.settings, req.GetSkipCloudApiForBoardDetection())
boards, err := identify(pme, port.Properties, s.settings, req.GetSkipCloudApiForBoardDetection())
if err != nil {
warnings = append(warnings, err.Error())
}
Expand Down Expand Up @@ -298,7 +297,7 @@ func (s *arduinoCoreServerImpl) BoardListWatch(req *rpc.BoardListWatchRequest, s

boardsError := ""
if event.Type == "add" {
boards, err := identify(pme, event.Port, s.settings, req.GetSkipCloudApiForBoardDetection())
boards, err := identify(pme, event.Port.Properties, s.settings, req.GetSkipCloudApiForBoardDetection())
if err != nil {
boardsError = err.Error()
}
Expand Down
3 changes: 1 addition & 2 deletions 3 commands/service_board_list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/arduino/arduino-cli/internal/cli/configuration"
"github.com/arduino/go-paths-helper"
"github.com/arduino/go-properties-orderedmap"
discovery "github.com/arduino/pluggable-discovery-protocol-handler/v2"
"github.com/stretchr/testify/require"
"go.bug.st/downloader/v2"
semver "go.bug.st/relaxed-semver"
Expand Down Expand Up @@ -157,7 +156,7 @@ func TestBoardIdentifySorting(t *testing.T) {
defer release()

settings := configuration.NewSettings()
res, err := identify(pme, &discovery.Port{Properties: idPrefs}, settings, true)
res, err := identify(pme, idPrefs, settings, true)
require.NoError(t, err)
require.NotNil(t, res)
require.Len(t, res, 4)
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.