tlv493d: improved reset logging (#53)

pull/54/head
bezineb5 4 years ago committed by GitHub
parent 43cd79527c
commit f454513a2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -194,7 +194,7 @@ func New(i i2c.Bus, opts *Opts) (*Dev, error) {
// String implements conn.Resource.
func (d *Dev) String() string {
return "TLV493D"
return fmt.Sprintf("TLV493D{i2c:0x%x}", d.i2c.Addr)
}
// Halt implements conn.Resource.
@ -407,9 +407,9 @@ func (d *Dev) ReadContinuous(frequency physic.Frequency, precision Precision) (<
// Try resetting the sensor to recover from errors
if err := d.initialize(true); err == nil {
if err := d.SetMode(newMode); err != nil {
log.Println("Unable to reset TLV493D mode:", err)
log.Printf("%s: unable to reset tlv493d mode: %v", d, err)
} else {
log.Println("Sensor reset successfully")
log.Printf("%s: sensor reset successfully", d)
}
}
continue

@ -52,7 +52,7 @@ func TestDev_String(t *testing.T) {
if err != nil {
t.Fatal(err)
}
if s := d.String(); s != "TLV493D" {
if s := d.String(); s != "TLV493D{i2c:0x5e}" {
t.Fatal(s)
}
if err := d.Halt(); err != nil {

Loading…
Cancel
Save