@@ -34,6 +34,7 @@ import (
3434 "github.com/arduino/arduino-cli/commands"
3535 "github.com/arduino/arduino-cli/internal/inventory"
3636 rpc "github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
37+ "github.com/arduino/go-properties-orderedmap"
3738 "github.com/pkg/errors"
3839 "github.com/sirupsen/logrus"
3940)
@@ -128,20 +129,22 @@ func apiByVidPid(vid, pid string) ([]*rpc.BoardListItem, error) {
128129 }, nil
129130}
130131
131- func identifyViaCloudAPI (port * discovery. Port ) ([]* rpc.BoardListItem , error ) {
132+ func identifyViaCloudAPI (props * properties. Map ) ([]* rpc.BoardListItem , error ) {
132133 // 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" ) {
135135 return nil , nil
136136 }
137137
138138 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" ))
140140}
141141
142142// identify returns a list of boards checking first the installed platforms or the Cloud API
143143func identify (pme * packagemanager.Explorer , port * discovery.Port ) ([]* rpc.BoardListItem , error ) {
144144 boards := []* rpc.BoardListItem {}
145+ if port .Properties == nil {
146+ return boards , nil
147+ }
145148
146149 // first query installed cores through the Package Manager
147150 logrus .Debug ("Querying installed cores for board identification..." )
@@ -167,7 +170,7 @@ func identify(pme *packagemanager.Explorer, port *discovery.Port) ([]*rpc.BoardL
167170 // if installed cores didn't recognize the board, try querying
168171 // the builder API if the board is a USB device port
169172 if len (boards ) == 0 {
170- items , err := identifyViaCloudAPI (port )
173+ items , err := identifyViaCloudAPI (port . Properties )
171174 if err != nil {
172175 // this is bad, but keep going
173176 logrus .WithError (err ).Debug ("Error querying builder API" )
0 commit comments