succd: add pirani failsafe

This commit is contained in:
Serge Bazanski 2024-09-27 02:24:19 +02:00
parent 6d97eb62a8
commit 34ab508b13

View file

@ -17,6 +17,8 @@ type daemon struct {
// Pirani gauge.
adcPirani adc
failsafe bool
gpioDiffusionPump gpio
gpioRoughingPump gpio
gpioBtnPumpDown gpio
@ -120,6 +122,24 @@ func (d *daemon) processOnce(_ context.Context) error {
d.aboveRough.process(float64(mbar))
d.aboveHigh.process(float64(mbar))
if mbar < 4e-6 {
// Unrealistic result, Pirani probe probably disconnected. Failsafe mode.
if !d.failsafe {
d.failsafe = true
klog.Errorf("Pirani probe seems disconnected; enabling failsafe mode")
}
} else {
if d.failsafe {
d.failsafe = false
klog.Infof("Pirani probe has been reconnected; quitting failsafe mode")
}
}
if d.failsafe {
d.aboveRough.output = true
d.aboveHigh.output = true
}
// Update relay outputs.
for _, rel := range []struct {
name string