Skip to content

Commit 6d7eec2

Browse files
committed
Removed unused ManufacutrerId and DeviceClass, renamed some fields
1 parent 87642c7 commit 6d7eec2

File tree

2 files changed

+12
-20
lines changed

2 files changed

+12
-20
lines changed

serial.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,15 +165,14 @@ func (sp *SerialPortList) Update() {
165165
for _, item := range ports {
166166
port := SpPortItem{
167167
Name: item.Name,
168-
SerialNumber: item.ISerial,
169-
DeviceClass: item.DeviceClass,
168+
SerialNumber: item.SerialNumber,
170169
IsOpen: false,
171170
IsPrimary: false,
172171
Baud: 0,
173172
BufferAlgorithm: "",
174173
Ver: version,
175-
VendorID: item.IDVendor,
176-
ProductID: item.IDProduct,
174+
VendorID: item.VID,
175+
ProductID: item.PID,
177176
}
178177

179178
// figure out if port is open

seriallist.go

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package main
1919

2020
import (
21-
"fmt"
2221
"slices"
2322

2423
log "github.com/sirupsen/logrus"
@@ -28,12 +27,9 @@ import (
2827
// OsSerialPort is the Os serial port
2928
type OsSerialPort struct {
3029
Name string
31-
DeviceClass string
32-
Manufacturer string
33-
Product string
34-
IDProduct string
35-
IDVendor string
36-
ISerial string
30+
PID string
31+
VID string
32+
SerialNumber string
3733
}
3834

3935
// enumerateSerialPorts will return the OS serial port
@@ -47,16 +43,13 @@ func enumerateSerialPorts() ([]*OsSerialPort, error) {
4743

4844
for _, element := range ports {
4945
if element.IsUSB {
50-
vid := element.VID
51-
pid := element.PID
52-
vidString := fmt.Sprintf("0x%s", vid)
53-
pidString := fmt.Sprintf("0x%s", pid)
54-
if vid != "0000" && pid != "0000" {
46+
vid, pid := "0x"+element.VID, "0x"+element.PID
47+
if vid != "0x0000" && pid != "0x0000" {
5548
arrPorts = append(arrPorts, &OsSerialPort{
56-
Name: element.Name,
57-
IDVendor: vidString,
58-
IDProduct: pidString,
59-
ISerial: element.SerialNumber,
49+
Name: element.Name,
50+
VID: vid,
51+
PID: pid,
52+
SerialNumber: element.SerialNumber,
6053
})
6154
}
6255
}

0 commit comments

Comments
 (0)