Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 436277f

Browse files
authoredMar 10, 2021
Add serial number of connected board to board list command (#1216)
* Add serial number of connected board to board details command * Moved serial number from board details to board list
1 parent 13c6edf commit 436277f

File tree

5 files changed

+202
-165
lines changed

5 files changed

+202
-165
lines changed
 

‎cli/board/list.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ func watchList(cmd *cobra.Command, inst *rpc.Instance) {
109109
Protocol: event.Port.Protocol,
110110
ProtocolLabel: event.Port.ProtocolLabel,
111111
Boards: event.Port.Boards,
112+
SerialNumber: event.Port.SerialNumber,
112113
Error: event.Error,
113114
})
114115
}
@@ -181,6 +182,7 @@ type watchEvent struct {
181182
Protocol string `json:"protocol,omitempty"`
182183
ProtocolLabel string `json:"protocol_label,omitempty"`
183184
Boards []*rpc.BoardListItem `json:"boards,omitempty"`
185+
SerialNumber string `json:"serial_number,omitempty"`
184186
Error string `json:"error,omitempty"`
185187
}
186188

‎commands/board/list.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ func List(instanceID int32) (r []*rpc.DetectedPort, e error) {
185185
Protocol: port.Protocol,
186186
ProtocolLabel: port.ProtocolLabel,
187187
Boards: boards,
188+
SerialNumber: port.Prefs.Get("serialNumber"),
188189
}
189190
retVal = append(retVal, p)
190191
}
@@ -222,13 +223,19 @@ func Watch(instanceID int32, interrupt <-chan bool) (<-chan *rpc.BoardListWatchR
222223
}
223224
}
224225

226+
serialNumber := ""
227+
if props := event.Port.Properties; props != nil {
228+
serialNumber = props.Get("serialNumber")
229+
}
230+
225231
outChan <- &rpc.BoardListWatchResp{
226232
EventType: event.Type,
227233
Port: &rpc.DetectedPort{
228234
Address: event.Port.Address,
229235
Protocol: event.Port.Protocol,
230236
ProtocolLabel: event.Port.ProtocolLabel,
231237
Boards: boards,
238+
SerialNumber: serialNumber,
232239
},
233240
Error: boardsError,
234241
}

‎go.sum

Lines changed: 1 addition & 0 deletions
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=

‎rpc/commands/board.pb.go

Lines changed: 188 additions & 165 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rpc/commands/board.proto

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ message BoardDetailsResp {
5959
repeated Programmer programmers = 13;
6060
// Set to true if the board supports debugging
6161
bool debugging_supported = 14;
62+
// If a board with the specified FQBN is connected returns its serial number too
63+
string serialNumber = 15;
6264
}
6365

6466
message IdentificationPref {
@@ -192,6 +194,8 @@ message DetectedPort {
192194
string protocol_label = 3;
193195
// The boards attached to the port.
194196
repeated BoardListItem boards = 4;
197+
// Serial number of connected board
198+
string serial_number = 5;
195199
}
196200

197201
message BoardListAllReq {

0 commit comments

Comments
 (0)
Please sign in to comment.