package serial import "time" // Allow several normal four-second sweeps to recover from a slow/noisy reply. // A CR timeout alone cannot establish physical cable disconnection. const CRResponseGracePeriod = 15 * time.Second func CRConnectionStatus(probe CRProbeState, now time.Time) string { if !probe.Enabled { return "unknown" } if probe.Up { return "up" } if probe.EverUp && probe.LastResponseAt != nil { age := now.Sub(*probe.LastResponseAt) if age >= 0 && age <= CRResponseGracePeriod { return "up" } } return "unknown" }