You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
running version 606c02f and RTU 60 seconds sampling rate (modbus polls) == serialIdleTimeout, after changing hardware (to faster one) the following panic occured.
It appears closeIdle, from modbus/serial.go:90 runs in parallel with Send, from modbus/rtuclient.go:113. In some (unfrequent cases) mb.close(), modbus/serial.go:100, from previous Send, occurs in currentSend after 124 and before 137, resulting in panic on line 137.
113 func (mb *rtuSerialTransporter) Send(aduRequest []byte) (aduResponse []byte, err error) {
114 // Make sure port is connected
115 if err = mb.serialPort.connect(); err != nil {
116 return
117 }
118 // Start the timer to close when idle
119 mb.serialPort.lastActivity = time.Now()
120 mb.serialPort.startCloseTimer()
121
122 // Send the request
123 mb.serialPort.logf("modbus: sending % x\n", aduRequest)
124 if _, err = mb.port.Write(aduRequest); err != nil {
125 return
126 }
127 function := aduRequest[1]
128 functionFail := aduRequest[1] & 0x80
129 bytesToRead := calculateResponseLength(aduRequest)
130 time.Sleep(mb.calculateDelay(len(aduRequest) + bytesToRead))
131
132 var n int
133 var n1 int
134 var data [rtuMaxSize]byte
135 //We first read the minimum length and then read either the full package
136 //or the error package, depending on the error status (byte 2 of the response)
137 n, err = io.ReadAtLeast(mb.port, data[:], rtuMinSize)
138 if err != nil {
139 return
140 }
...
The text was updated successfully, but these errors were encountered:
Hi,
running version 606c02f and RTU 60 seconds sampling rate (modbus polls) == serialIdleTimeout, after changing hardware (to faster one) the following panic occured.
It appears
closeIdle
, frommodbus/serial.go:90
runs in parallel withSend
, frommodbus/rtuclient.go:113
. In some (unfrequent cases)mb.close()
,modbus/serial.go:100
, from previousSend
, occurs in currentSend
after124
and before137
, resulting in panic on line137
.The text was updated successfully, but these errors were encountered: