File tree 1 file changed +7
-6
lines changed
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ type serialhub struct {
49
49
// SerialPortList is the serial port list
50
50
type SerialPortList struct {
51
51
Ports []SpPortItem
52
- Mu sync.Mutex `json:"-"`
52
+ portsLock sync.Mutex
53
53
enumerationLock sync.Mutex
54
54
}
55
55
@@ -120,9 +120,9 @@ func write(wr writeRequest) {
120
120
121
121
// List broadcasts a Json representation of the ports found
122
122
func (sp * SerialPortList ) List () {
123
- sp .Mu .Lock ()
124
- ls , err := json .MarshalIndent (& serialPorts , "" , "\t " )
125
- sp .Mu .Unlock ()
123
+ sp .portsLock .Lock ()
124
+ ls , err := json .MarshalIndent (sp , "" , "\t " )
125
+ sp .portsLock .Unlock ()
126
126
127
127
if err != nil {
128
128
//log.Println(err)
@@ -148,9 +148,10 @@ func (sp *SerialPortList) Update() {
148
148
ports = []* OsSerialPort {}
149
149
}
150
150
list := spListDual (ports )
151
- serialPorts .Mu .Lock ()
151
+
152
+ serialPorts .portsLock .Lock ()
152
153
serialPorts .Ports = list
153
- serialPorts .Mu .Unlock ()
154
+ serialPorts .portsLock .Unlock ()
154
155
}
155
156
156
157
func spListDual (list []* OsSerialPort ) []SpPortItem {
You can’t perform that action at this time.
0 commit comments