Modbus: unify delay and timeout settings (BC) (#31996)
This commit is contained in:
parent
ff2905a366
commit
02a66252ca
82 changed files with 410 additions and 369 deletions
|
|
@ -42,9 +42,7 @@ func NewModbusFromConfig(ctx context.Context, other map[string]any) (Plugin, err
|
|||
Register modbus.Register
|
||||
Block modbus.Block
|
||||
Scale float64
|
||||
Delay time.Duration
|
||||
ConnectDelay time.Duration
|
||||
Timeout time.Duration
|
||||
}{
|
||||
Scale: 1,
|
||||
}
|
||||
|
|
@ -56,17 +54,11 @@ func NewModbusFromConfig(ctx context.Context, other map[string]any) (Plugin, err
|
|||
modbus.Lock()
|
||||
defer modbus.Unlock()
|
||||
|
||||
conn, err := modbus.NewConnection(ctx, cc.URI, cc.Device, cc.Comset, cc.Baudrate, cc.Settings.Protocol(), cc.ID)
|
||||
conn, err := cc.Settings.Connection(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// set non-default timeout
|
||||
conn.Timeout(cc.Timeout)
|
||||
|
||||
// set non-default delay
|
||||
conn.Delay(cc.Delay)
|
||||
|
||||
// set non-default connect delay
|
||||
conn.ConnectDelay(cc.ConnectDelay)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue