From a76f663ae2d93da45f509e1cc5f5eb4a0196415d Mon Sep 17 00:00:00 2001 From: Thorsten von Eicken Date: Wed, 14 Dec 2016 19:19:09 -0800 Subject: [PATCH] Add onewire smoke test (#104) * set SPI speed and mode in spi smoketest * add one-wire smoke test --- experimental/devices/ds248x/dev.go | 7 +++++++ experimental/devices/ds248x/ds248x.go | 6 +++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/experimental/devices/ds248x/dev.go b/experimental/devices/ds248x/dev.go index fa44ef5..e48cf77 100644 --- a/experimental/devices/ds248x/dev.go +++ b/experimental/devices/ds248x/dev.go @@ -37,6 +37,13 @@ func (d *Dev) String() string { return fmt.Sprintf("ds248x") } +// Close drops the I²C bus handle and sets a persistent error. +func (d *Dev) Close() error { + d.i2c = nil + d.err = fmt.Errorf("ds248x: invalid operation on closed bus") + return nil +} + // Tx performs a bus transaction, sending and receiving bytes, and // ending by pulling the bus high either weakly or strongly depending // on the value of power. diff --git a/experimental/devices/ds248x/ds248x.go b/experimental/devices/ds248x/ds248x.go index b072edc..0b71f4b 100644 --- a/experimental/devices/ds248x/ds248x.go +++ b/experimental/devices/ds248x/ds248x.go @@ -42,7 +42,11 @@ type Opts struct { PullupRes PupOhm // passive pull-up resistance, true: 500Ω, false: 1kΩ } -// New returns an device object that communicates over I²C to the DS2482/DS2483 controller. +// New returns a device object that communicates over I²C to the DS2482/DS2483 +// controller. +// +// This device object implements onewire.Bus and can be used to +// access devices on the bus. func New(i i2c.Bus, opts *Opts) (*Dev, error) { addr := uint16(0x18) if opts != nil {