File tree 2 files changed +12
-20
lines changed
2 files changed +12
-20
lines changed Original file line number Diff line number Diff line change @@ -165,15 +165,14 @@ func (sp *SerialPortList) Update() {
165
165
for _ , item := range ports {
166
166
port := SpPortItem {
167
167
Name : item .Name ,
168
- SerialNumber : item .ISerial ,
169
- DeviceClass : item .DeviceClass ,
168
+ SerialNumber : item .SerialNumber ,
170
169
IsOpen : false ,
171
170
IsPrimary : false ,
172
171
Baud : 0 ,
173
172
BufferAlgorithm : "" ,
174
173
Ver : version ,
175
- VendorID : item .IDVendor ,
176
- ProductID : item .IDProduct ,
174
+ VendorID : item .VID ,
175
+ ProductID : item .PID ,
177
176
}
178
177
179
178
// figure out if port is open
Original file line number Diff line number Diff line change 18
18
package main
19
19
20
20
import (
21
- "fmt"
22
21
"slices"
23
22
24
23
log "github.com/sirupsen/logrus"
@@ -28,12 +27,9 @@ import (
28
27
// OsSerialPort is the Os serial port
29
28
type OsSerialPort struct {
30
29
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
37
33
}
38
34
39
35
// enumerateSerialPorts will return the OS serial port
@@ -47,16 +43,13 @@ func enumerateSerialPorts() ([]*OsSerialPort, error) {
47
43
48
44
for _ , element := range ports {
49
45
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" {
55
48
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 ,
60
53
})
61
54
}
62
55
}
You can’t perform that action at this time.
0 commit comments