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
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
accErrTrigger = 0
|
|
||||||
|
|
||||||
// Ensure that we wait for sensors to convert data.
|
// Ensure that we wait for sensors to convert data.
|
||||||
deltaSleep := sensorConversionTime - time.Since(start)
|
deltaSleep := sensorConversionTime - time.Since(start)
|
||||||
if deltaSleep > 0 {
|
if deltaSleep > 0 {
|
||||||
|
@ -116,19 +114,10 @@ func PollSensors(ctx context.Context, wg *sync.WaitGroup, readingInterval time.D
|
||||||
goto poll_bus
|
goto poll_bus
|
||||||
|
|
||||||
case BulkReadReady:
|
case BulkReadReady:
|
||||||
readSensors(hub)
|
if !readSensors(hub) {
|
||||||
}
|
accErrTrigger++
|
||||||
|
} else {
|
||||||
if accErrTrigger > 60 {
|
|
||||||
select {
|
|
||||||
case RequestReset <- true:
|
|
||||||
log.Print("Thermal bulk read failed 60 times in a row -- bus reset")
|
|
||||||
|
|
||||||
// Reset counter to allow 60 more reads
|
|
||||||
accErrTrigger = 0
|
accErrTrigger = 0
|
||||||
|
|
||||||
default:
|
|
||||||
log.Fatal("Thermal bulk read failed 60 times in a row -- terminating")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -138,10 +127,23 @@ func PollSensors(ctx context.Context, wg *sync.WaitGroup, readingInterval time.D
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if accErrTrigger > 60 {
|
||||||
|
select {
|
||||||
|
case RequestReset <- true:
|
||||||
|
log.Print("Thermal bulk read failed 60 times in a row -- bus reset")
|
||||||
|
|
||||||
|
// Reset counter to allow 60 more reads
|
||||||
|
accErrTrigger = 0
|
||||||
|
|
||||||
|
default:
|
||||||
|
log.Fatal("Thermal bulk read failed 60 times in a row -- terminating")
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func readSensors(hub *sentry.Hub) {
|
func readSensors(hub *sentry.Hub) bool {
|
||||||
r := TemperatureReading{
|
r := TemperatureReading{
|
||||||
Time: time.Now(),
|
Time: time.Now(),
|
||||||
Ambient: NaN,
|
Ambient: NaN,
|
||||||
|
@ -187,7 +189,7 @@ func readSensors(hub *sentry.Hub) {
|
||||||
|
|
||||||
// Throw away reading if any sensor failed
|
// Throw away reading if any sensor failed
|
||||||
if hasReadFailure {
|
if hasReadFailure {
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
|
@ -199,6 +201,8 @@ func readSensors(hub *sentry.Hub) {
|
||||||
hub.CaptureException(err)
|
hub.CaptureException(err)
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
func triggerBulkRead() error {
|
func triggerBulkRead() error {
|
||||||
|
|
Loading…
Reference in a new issue