tweak error messages

This commit is contained in:
Josh Deprez 2023-01-21 17:08:11 +11:00
parent 00b58cbdb9
commit fa7b18bc2d
Signed by: josh
SSH key fingerprint: SHA256:zZji7w1Ilh2RuUpbQcqkLPrqmRwpiCSycbF2EfKm6Kw

View file

@ -134,7 +134,7 @@ func readRegs(client modbus.Client, start, qty uint16) error {
return fmt.Errorf("read input registers %d-%d: %v", start+1, start+qty, err) return fmt.Errorf("read input registers %d-%d: %v", start+1, start+qty, err)
} }
if len(data) != int(2*qty) { if len(data) != int(2*qty) {
return fmt.Errorf("reading input registers %d-%d: len(data) = %d != %d = 2*qty", start+1, start+qty, len(data), 2*qty) return fmt.Errorf("read input registers %d-%d: len(data) = %d != %d = 2*qty", start+1, start+qty, len(data), 2*qty)
} }
for addr, reg := range sungrowInputRegs { for addr, reg := range sungrowInputRegs {
if addr <= start || addr > start+qty { if addr <= start || addr > start+qty {
@ -146,7 +146,7 @@ func readRegs(client modbus.Client, start, qty uint16) error {
log.Printf("Couldn't parse input register data at %d, skipping: %v", addr, err) log.Printf("Couldn't parse input register data at %d, skipping: %v", addr, err)
continue continue
} }
return fmt.Errorf("parsing input register data at %d: %v", addr, err) return fmt.Errorf("parse input register data at %d: %v", addr, err)
} }
//fmt.Printf("%s: %v %s\n", reg.name, val, reg.unit) //fmt.Printf("%s: %v %s\n", reg.name, val, reg.unit)
lastValues[addr] = val lastValues[addr] = val