chore: log modbus timeouts
This commit is contained in:
parent
3d401bd18f
commit
baf15a62e8
1 changed files with 5 additions and 1 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package modbus
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/volkszaehler/mbmd/meters"
|
||||
|
|
@ -40,11 +41,14 @@ func (c *Connection) Timeout(timeout time.Duration) {
|
|||
}
|
||||
|
||||
func (c *Connection) exec(fun func() ([]byte, error)) ([]byte, error) {
|
||||
time.Sleep(c.delay)
|
||||
return c.WithLogger(c.logical, func() ([]byte, error) {
|
||||
time.Sleep(c.delay)
|
||||
start := time.Now()
|
||||
|
||||
b, err := fun()
|
||||
if err != nil {
|
||||
c.Connection.Close()
|
||||
fmt.Println("!!", time.Since(start), err)
|
||||
}
|
||||
return b, err
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue