Skip to content

Commit d1cd49f

Browse files
committed
Made portsLock (ex Mu) field private
1 parent b74c406 commit d1cd49f

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

serial.go

+7-6
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type serialhub struct {
4949
// SerialPortList is the serial port list
5050
type SerialPortList struct {
5151
Ports []SpPortItem
52-
Mu sync.Mutex `json:"-"`
52+
portsLock sync.Mutex
5353
enumerationLock sync.Mutex
5454
}
5555

@@ -120,9 +120,9 @@ func write(wr writeRequest) {
120120

121121
// List broadcasts a Json representation of the ports found
122122
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()
126126

127127
if err != nil {
128128
//log.Println(err)
@@ -148,9 +148,10 @@ func (sp *SerialPortList) Update() {
148148
ports = []*OsSerialPort{}
149149
}
150150
list := spListDual(ports)
151-
serialPorts.Mu.Lock()
151+
152+
serialPorts.portsLock.Lock()
152153
serialPorts.Ports = list
153-
serialPorts.Mu.Unlock()
154+
serialPorts.portsLock.Unlock()
154155
}
155156

156157
func spListDual(list []*OsSerialPort) []SpPortItem {

0 commit comments

Comments
 (0)