Documentation ¶
Overview ¶
Package onewirereg defines a registry for onewire buses present on the host.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Open ¶
Open opens an 1-wire bus by its name, an alias or its number and returns an handle to it.
Specify the empty string "" to get the first available bus. This is the recommended default value unless an application knows the exact bus to use.
Each bus can register multiple aliases, each leading to the same bus handle.
"Bus number" is a generic concept that is highly dependent on the platform and OS. On some platform, the first bus may have the number 0, 1 or higher. Bus numbers are not necessarily continuous and may not start at 0. It was observed that the bus number as reported by the OS may change across OS revisions.
When the 1-wire bus is provided by an off board plug and play bus like USB via a FT232H USB device, there can be no associated number.
func Register ¶
Register registers an 1-wire bus.
Registering the same bus name twice is an error, e.g. o.Name(). o.Number() can be -1 to signify that the bus doesn't have an inherent "bus number". A good example is a bus provided over a FT232H device connected on an USB bus. In this case, the bus name should be created from the serial number of the device for unique identification.
func Unregister ¶
Unregister removes a previously registered 1-wire bus.
This can happen when an 1-wire bus is exposed via an USB device and the device is unplugged.
Types ¶
type Ref ¶
type Ref struct { // Name of the bus. // // It must not be a sole number. It must be unique across the host. Name string // Aliases are the alternative names that can be used to reference this bus. Aliases []string // Number of the bus or -1 if the bus doesn't have any "native" number. // // Buses provided by the CPU normally have a 0 based number. Buses provided // via an addon (like over USB) generally are not numbered. Number int // Open is the factory to open an handle to this 1-wire bus. Open Opener }
Ref references an 1-wire bus.
It is returned by All() to enumerate all registered buses.