Modbus: add delay setting (#2228)
This commit is contained in:
parent
7c88e5099c
commit
d8a652ffe2
2 changed files with 12 additions and 0 deletions
|
|
@ -35,6 +35,7 @@ func NewModbusFromConfig(other map[string]interface{}) (api.Meter, error) {
|
|||
modbus.Settings `mapstructure:",squash"`
|
||||
Power, Energy, SoC string
|
||||
Currents []string
|
||||
Delay time.Duration
|
||||
Timeout time.Duration
|
||||
}{
|
||||
Power: "Power",
|
||||
|
|
@ -63,6 +64,11 @@ func NewModbusFromConfig(other map[string]interface{}) (api.Meter, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// set non-default delay
|
||||
if cc.Delay > 0 {
|
||||
conn.Delay(cc.Delay)
|
||||
}
|
||||
|
||||
// set non-default timeout
|
||||
if cc.Timeout > 0 {
|
||||
conn.Timeout(cc.Timeout)
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ func NewModbusFromConfig(other map[string]interface{}) (IntProvider, error) {
|
|||
Register modbus.Register
|
||||
Value string
|
||||
Scale float64
|
||||
Delay time.Duration
|
||||
Timeout time.Duration
|
||||
}{
|
||||
Scale: 1,
|
||||
|
|
@ -62,6 +63,11 @@ func NewModbusFromConfig(other map[string]interface{}) (IntProvider, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// set non-default delay
|
||||
if cc.Delay > 0 {
|
||||
conn.Delay(cc.Delay)
|
||||
}
|
||||
|
||||
// set non-default timeout
|
||||
if cc.Timeout > 0 {
|
||||
conn.Timeout(cc.Timeout)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue