Skip to content

Commit

Permalink
fix(modbus): set idle timeout in client creation
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelpeterswa committed Jul 16, 2024
1 parent 4fd81f2 commit d62380e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion renogymodbus.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ type ModbusClient struct {
Client modbus.Client
}

func NewModbusClient(logger *log.Logger, address string) (*ModbusClient, error) {
func NewModbusClient(logger *log.Logger, address string, idleTimeout time.Duration) (*ModbusClient, error) {
// Modbus RTU/ASCII
handler := modbus.NewRTUClientHandler(address)
handler.BaudRate = 9600
handler.SlaveId = 1
handler.Timeout = 1 * time.Second
handler.IdleTimeout = idleTimeout
handler.StopBits = 1
handler.DataBits = 8
handler.Parity = "N"
Expand Down

0 comments on commit d62380e

Please sign in to comment.