This commit is contained in:
parent
e25905c20f
commit
2c8db8ff0b
1 changed files with 20 additions and 16 deletions
|
@ -104,8 +104,6 @@ func PollSensors(ctx context.Context, wg *sync.WaitGroup, readingInterval time.D
|
|||
break
|
||||
}
|
||||
|
||||
accErrTrigger = 0
|
||||
|
||||
// Ensure that we wait for sensors to convert data.
|
||||
deltaSleep := sensorConversionTime - time.Since(start)
|
||||
if deltaSleep > 0 {
|
||||
|
@ -116,7 +114,18 @@ func PollSensors(ctx context.Context, wg *sync.WaitGroup, readingInterval time.D
|
|||
goto poll_bus
|
||||
|
||||
case BulkReadReady:
|
||||
readSensors(hub)
|
||||
if !readSensors(hub) {
|
||||
accErrTrigger++
|
||||
} else {
|
||||
accErrTrigger = 0
|
||||
}
|
||||
}
|
||||
|
||||
case c := <-ConfigUpdate:
|
||||
configure(c)
|
||||
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
|
||||
if accErrTrigger > 60 {
|
||||
|
@ -131,17 +140,10 @@ func PollSensors(ctx context.Context, wg *sync.WaitGroup, readingInterval time.D
|
|||
log.Fatal("Thermal bulk read failed 60 times in a row -- terminating")
|
||||
}
|
||||
}
|
||||
|
||||
case c := <-ConfigUpdate:
|
||||
configure(c)
|
||||
|
||||
case <-ctx.Done():
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func readSensors(hub *sentry.Hub) {
|
||||
func readSensors(hub *sentry.Hub) bool {
|
||||
r := TemperatureReading{
|
||||
Time: time.Now(),
|
||||
Ambient: NaN,
|
||||
|
@ -187,7 +189,7 @@ func readSensors(hub *sentry.Hub) {
|
|||
|
||||
// Throw away reading if any sensor failed
|
||||
if hasReadFailure {
|
||||
return
|
||||
return false
|
||||
}
|
||||
|
||||
select {
|
||||
|
@ -199,6 +201,8 @@ func readSensors(hub *sentry.Hub) {
|
|||
hub.CaptureException(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func triggerBulkRead() error {
|
||||
|
|
Loading…
Reference in a new issue