Compare commits

..

2 commits

Author SHA1 Message Date
Rahix 152290f5a3 succd: Fix -KEC1 relay board updates
All checks were successful
/ test (push) Successful in 10s
/ test (pull_request) Successful in 10s
The accesses to -KEC1 always time out on the attempt to update the
output values.  We noticed that this is related to the timing between
the reading of the inputs and the following write to the outputs.

Fix -KEC1 accesses by waiting before sending the next request to the
board after receiving the reply for the previous one.
2024-11-10 06:36:43 +01:00
hmelder 6f93b96c39 succd: do not early return on error in modbusUpdate
When one device fails, this should not influence updates of the other
devices.  Thus, early return was the wrong strategy here.

Instead, when communication with a device fails, skip the process data
update and continue with the next device.
2024-11-10 06:35:50 +01:00

View file

@ -101,6 +101,11 @@ func (d *daemon) modbusUpdate() {
// TODO: Input mapping goes here
}
// We must wait between reading and writing to the -KEC1 relay board
// because otherwise it chokes and times out the write registers
// command.
time.Sleep(time.Millisecond * 10)
// KFA1-KFA8
var relayState [8]bool
d.mu.Lock()
@ -135,7 +140,7 @@ func (d *daemon) modbusUpdate() {
err = d.modbusClient.WriteRegisters(0x01, registerValuesKEC1[:])
if err != nil {
klog.Warningf("error while writing updated relay values to KEC1 %v", err)
klog.Warningf("error while updating registers %v", err)
}
}