Handle empty file on temperature reading
This commit is contained in:
parent
15f6d277a9
commit
c38b8e1ae6
1 changed files with 4 additions and 0 deletions
|
@ -248,6 +248,10 @@ func read(sensor string) (int64, error) {
|
||||||
|
|
||||||
raw := string(data)
|
raw := string(data)
|
||||||
|
|
||||||
|
if raw == "" {
|
||||||
|
return NaN, fmt.Errorf("%v: %w: empty file", sensor, ErrReadSensor)
|
||||||
|
}
|
||||||
|
|
||||||
if !strings.Contains(raw, " YES") {
|
if !strings.Contains(raw, " YES") {
|
||||||
return NaN, fmt.Errorf("%v: %w: checksum failed [%v]", sensor, ErrReadSensor, raw)
|
return NaN, fmt.Errorf("%v: %w: checksum failed [%v]", sensor, ErrReadSensor, raw)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue