Skip to content

Commit 436277f

Browse files
authored
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

Diff for: cli/board/list.go

+2
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

Diff for: commands/board/list.go

+7
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
}

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)