Skip to content

Commit d70b1fb

Browse files
committed
Port does not have identification properties anymore
1 parent 51184d9 commit d70b1fb

File tree

1 file changed

+13
-18
lines changed

1 file changed

+13
-18
lines changed

main.go

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,11 @@ func main() {
134134
}
135135

136136
type boardPortJSON struct {
137-
Address string `json:"address"`
138-
Label string `json:"label,omitempty"`
139-
Prefs *properties.Map `json:"prefs,omitempty"`
140-
IdentificationPrefs *properties.Map `json:"identificationPrefs,omitempty"`
141-
Protocol string `json:"protocol,omitempty"`
142-
ProtocolLabel string `json:"protocolLabel,omitempty"`
137+
Address string `json:"address"`
138+
Label string `json:"label,omitempty"`
139+
Protocol string `json:"protocol,omitempty"`
140+
ProtocolLabel string `json:"protocolLabel,omitempty"`
141+
Properties *properties.Map `json:"properties,omitempty"`
143142
}
144143

145144
type listOutputJSON struct {
@@ -170,22 +169,18 @@ func outputList() {
170169

171170
func newBoardPortJSON(port *enumerator.PortDetails) *boardPortJSON {
172171
prefs := properties.NewMap()
173-
identificationPrefs := properties.NewMap()
174172
portJSON := &boardPortJSON{
175-
Address: port.Name,
176-
Label: port.Name,
177-
Protocol: "serial",
178-
ProtocolLabel: "Serial Port",
179-
Prefs: prefs,
180-
IdentificationPrefs: identificationPrefs,
173+
Address: port.Name,
174+
Label: port.Name,
175+
Protocol: "serial",
176+
ProtocolLabel: "Serial Port",
177+
Properties: prefs,
181178
}
182179
if port.IsUSB {
183180
portJSON.ProtocolLabel = "Serial Port (USB)"
184-
portJSON.Prefs.Set("vendorId", "0x"+port.VID)
185-
portJSON.Prefs.Set("productId", "0x"+port.PID)
186-
portJSON.Prefs.Set("serialNumber", port.SerialNumber)
187-
portJSON.IdentificationPrefs.Set("pid", "0x"+port.PID)
188-
portJSON.IdentificationPrefs.Set("vid", "0x"+port.VID)
181+
portJSON.Properties.Set("vid", "0x"+port.VID)
182+
portJSON.Properties.Set("pid", "0x"+port.PID)
183+
portJSON.Properties.Set("serialNumber", port.SerialNumber)
189184
}
190185
return portJSON
191186
}

0 commit comments

Comments
 (0)