Skip to content

Commit 92367f3

Browse files
committed
Add serial number of connected board to board details command
1 parent d35a3c9 commit 92367f3

File tree

4 files changed

+182
-147
lines changed

4 files changed

+182
-147
lines changed

Diff for: commands/board/details.go

+20
Original file line numberDiff line numberDiff line change
@@ -146,5 +146,25 @@ func Details(ctx context.Context, req *rpc.BoardDetailsReq) (*rpc.BoardDetailsRe
146146
})
147147
}
148148

149+
// Get connected boards
150+
ports, err := commands.ListBoards(pm)
151+
if err != nil {
152+
return nil, err
153+
}
154+
for _, port := range ports {
155+
// Skip the port if serial number is not found
156+
if !port.Prefs.ContainsKey("serialNumber") {
157+
continue
158+
}
159+
160+
// Search for a board with the same FQBN set in request
161+
for _, board := range pm.IdentifyBoard(port.IdentificationPrefs) {
162+
if board.FQBN() == req.Fqbn {
163+
details.SerialNumber = port.Prefs.Get("serialNumber")
164+
break
165+
}
166+
}
167+
}
168+
149169
return details, nil
150170
}

Diff for: go.sum

+1
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ golang.org/x/crypto v0.0.0-20200406173513-056763e48d71/go.mod h1:LzIPMQfyMNhhGPh
285285
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
286286
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
287287
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
288+
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3 h1:XQyxROzUlZH+WIQwySDgnISgOivlhjIEwaQaJEJrrN0=
288289
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
289290
golang.org/x/net v0.0.0-20180406214816-61147c48b25b/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
290291
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=

0 commit comments

Comments
 (0)