Ignore temperature magic value -128
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
aaf865a72a
commit
8766932739
1 changed files with 7 additions and 2 deletions
|
@ -223,12 +223,12 @@ func read(sensor string) (int64, error) {
|
|||
raw := string(data)
|
||||
|
||||
if !strings.Contains(raw, " YES") {
|
||||
return 0.0, fmt.Errorf("%w: checksum failed [%v]", ErrReadSensor, raw)
|
||||
return 0.0, fmt.Errorf("%v: %w: checksum failed [%v]", sensor, ErrReadSensor, raw)
|
||||
}
|
||||
|
||||
i := strings.LastIndex(raw, "t=")
|
||||
if i == -1 {
|
||||
return 0.0, fmt.Errorf("%w: t= not found in [%v]", ErrReadSensor, raw)
|
||||
return 0.0, fmt.Errorf("%v: %w: t= not found in [%v]", sensor, ErrReadSensor, raw)
|
||||
}
|
||||
|
||||
c, err := strconv.ParseInt(raw[i+2:len(raw)-1], 10, 64)
|
||||
|
@ -236,5 +236,10 @@ func read(sensor string) (int64, error) {
|
|||
return 0.0, err
|
||||
}
|
||||
|
||||
// Ignore magic value -128
|
||||
if c == -128000 {
|
||||
return 0.0, fmt.Errorf("%v: magic value -128 detected", sensor)
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue