Modbus: unify delay and timeout settings (BC) (#31996)

This commit is contained in:
andig 2026-07-23 17:03:28 +02:00 • committed by GitHub
parent ff2905a366
commit 02a66252ca
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
82 changed files with 410 additions and 369 deletions

View file

@ -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)