@@ -34,6 +34,7 @@ import (
34
34
"github.com/arduino/arduino-cli/commands"
35
35
"github.com/arduino/arduino-cli/internal/inventory"
36
36
rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
37
+ "github.com/arduino/go-properties-orderedmap"
37
38
"github.com/pkg/errors"
38
39
"github.com/sirupsen/logrus"
39
40
)
@@ -128,20 +129,22 @@ func apiByVidPid(vid, pid string) ([]*rpc.BoardListItem, error) {
128
129
}, nil
129
130
}
130
131
131
- func identifyViaCloudAPI (port * discovery. Port ) ([]* rpc.BoardListItem , error ) {
132
+ func identifyViaCloudAPI (props * properties. Map ) ([]* rpc.BoardListItem , error ) {
132
133
// If the port is not USB do not try identification via cloud
133
- id := port .Properties
134
- if ! id .ContainsKey ("vid" ) || ! id .ContainsKey ("pid" ) {
134
+ if ! props .ContainsKey ("vid" ) || ! props .ContainsKey ("pid" ) {
135
135
return nil , nil
136
136
}
137
137
138
138
logrus .Debug ("Querying builder API for board identification..." )
139
- return cachedAPIByVidPid (id .Get ("vid" ), id .Get ("pid" ))
139
+ return cachedAPIByVidPid (props .Get ("vid" ), props .Get ("pid" ))
140
140
}
141
141
142
142
// identify returns a list of boards checking first the installed platforms or the Cloud API
143
143
func identify (pme * packagemanager.Explorer , port * discovery.Port ) ([]* rpc.BoardListItem , error ) {
144
144
boards := []* rpc.BoardListItem {}
145
+ if port .Properties == nil {
146
+ return boards , nil
147
+ }
145
148
146
149
// first query installed cores through the Package Manager
147
150
logrus .Debug ("Querying installed cores for board identification..." )
@@ -167,7 +170,7 @@ func identify(pme *packagemanager.Explorer, port *discovery.Port) ([]*rpc.BoardL
167
170
// if installed cores didn't recognize the board, try querying
168
171
// the builder API if the board is a USB device port
169
172
if len (boards ) == 0 {
170
- items , err := identifyViaCloudAPI (port )
173
+ items , err := identifyViaCloudAPI (port . Properties )
171
174
if err != nil {
172
175
// this is bad, but keep going
173
176
logrus .WithError (err ).Debug ("Error querying builder API" )
0 commit comments