From 34ab508b13724b8239680c96ec7e86eca9fcad56 Mon Sep 17 00:00:00 2001 From: Serge Bazanski Date: Fri, 27 Sep 2024 02:24:19 +0200 Subject: [PATCH] succd: add pirani failsafe --- succbone/succd/process.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/succbone/succd/process.go b/succbone/succd/process.go index b38cf25..a25aa26 100644 --- a/succbone/succd/process.go +++ b/succbone/succd/process.go @@ -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