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

Commit 7946379

Browse filesBrowse files
author
Luca Bianconi
committed
feat: filter boards by fqbn in connected list
1 parent a63aff4 commit 7946379
Copy full SHA for 7946379

File tree

Expand file treeCollapse file tree

17 files changed

+134
-96
lines changed
Filter options
Expand file treeCollapse file tree

17 files changed

+134
-96
lines changed

‎commands/board/list.go

Copy file name to clipboardExpand all lines: commands/board/list.go
+22-1Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,15 @@ func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, discoveryStartError
205205
}
206206
defer release()
207207

208+
var requestedFqbn *cores.FQBN
209+
if f := req.GetFqbn(); f != "" {
210+
var err error
211+
requestedFqbn, err = cores.ParseFQBN(f)
212+
if err != nil {
213+
return nil, nil, &arduino.InvalidFQBNError{Cause: err}
214+
}
215+
}
216+
208217
dm := pme.DiscoveryManager()
209218
discoveryStartErrors = dm.Start()
210219
time.Sleep(time.Duration(req.GetTimeout()) * time.Millisecond)
@@ -222,11 +231,23 @@ func List(req *rpc.BoardListRequest) (r []*rpc.DetectedPort, discoveryStartError
222231
Port: port.ToRPC(),
223232
MatchingBoards: boards,
224233
}
225-
retVal = append(retVal, b)
234+
235+
if requestedFqbn == nil || hasMatchingBoard(b, requestedFqbn) {
236+
retVal = append(retVal, b)
237+
}
226238
}
227239
return retVal, discoveryStartErrors, nil
228240
}
229241

242+
func hasMatchingBoard(b *rpc.DetectedPort, requestedFqbn *cores.FQBN) bool {
243+
for _, detectedBoard := range b.MatchingBoards {
244+
if detectedBoard.Fqbn == requestedFqbn.String() {
245+
return true
246+
}
247+
}
248+
return false
249+
}
250+
230251
// Watch returns a channel that receives boards connection and disconnection events.
231252
// It also returns a callback function that must be used to stop and dispose the watch.
232253
func Watch(req *rpc.BoardListWatchRequest) (<-chan *rpc.BoardListWatchResponse, func(), error) {

‎internal/cli/board/list.go

Copy file name to clipboardExpand all lines: internal/cli/board/list.go
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ func initListCommand() *cobra.Command {
4747
}
4848

4949
timeoutArg.AddToCommand(listCommand)
50+
fqbn.AddToCommand(listCommand)
5051
listCommand.Flags().BoolVarP(&watch, "watch", "w", false, tr("Command keeps running and prints list of connected boards whenever there is a change."))
5152

5253
return listCommand
@@ -66,6 +67,7 @@ func runListCommand(cmd *cobra.Command, args []string) {
6667
ports, discvoeryErrors, err := board.List(&rpc.BoardListRequest{
6768
Instance: inst,
6869
Timeout: timeoutArg.Get().Milliseconds(),
70+
Fqbn: fqbn.String(),
6971
})
7072
if err != nil {
7173
feedback.Warning(tr("Error detecting boards: %v", err))

‎rpc/cc/arduino/cli/commands/v1/board.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/board.pb.go
+94-82Lines changed: 94 additions & 82 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/commands/v1/board.proto

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/board.proto
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,9 @@ message BoardListRequest {
152152
Instance instance = 1;
153153
// Search for boards for the given time (in milliseconds)
154154
int64 timeout = 2;
155+
// The fully qualified board name of the board you want information about
156+
// (e.g., `arduino:avr:uno`).
157+
string fqbn = 3;
155158
}
156159

157160
message BoardListResponse {

‎rpc/cc/arduino/cli/commands/v1/commands.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/commands.pb.go
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/commands/v1/commands_grpc.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/commands_grpc.pb.go
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/commands/v1/common.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/common.pb.go
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/commands/v1/compile.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/compile.pb.go
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/commands/v1/core.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/core.pb.go
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/commands/v1/lib.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/lib.pb.go
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/commands/v1/monitor.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/monitor.pb.go
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/commands/v1/port.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/port.pb.go
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/commands/v1/upload.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/commands/v1/upload.pb.go
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/debug/v1/debug.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/debug/v1/debug.pb.go
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/debug/v1/debug_grpc.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/debug/v1/debug_grpc.pb.go
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/settings/v1/settings.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/settings/v1/settings.pb.go
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/cc/arduino/cli/settings/v1/settings_grpc.pb.go

Copy file name to clipboardExpand all lines: rpc/cc/arduino/cli/settings/v1/settings_grpc.pb.go
+1-1Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.