Documentation
¶
Index ¶
- Variables
- type Temper
- func (t *Temper) Close() error
- func (t *Temper) Descriptor() string
- func (t *Temper) ReadC() (float32, error)
- func (t *Temper) ReadCWithContext(ctx context.Context) (float32, error)
- func (t *Temper) ReadF() (float32, error)
- func (t *Temper) ReadFWithContext(ctx context.Context) (float32, error)
- func (t *Temper) String() string
Constants ¶
This section is empty.
Variables ¶
var ErrUninitializedTemper = errors.New("temper device is uninitialized")
ErrUninitializedTemper is returned when reading from a nil, zero-value, partially initialized, or closed Temper device.
Functions ¶
This section is empty.
Types ¶
type Temper ¶
type Temper struct {
// contains filtered or unexported fields
}
Temper represents a connection to a TEMPer USB thermometer device. It holds file descriptors for reading and writing to the HID device. Close must be called when the device is no longer needed to prevent file descriptor leaks.
func FindTempers ¶ added in v1.1.0
FindTempers returns a list of temper devices available in /dev.
Uses the recommended default timeout of 250ms. See FindTempersWithTimeout and FindTempersWithContext for more control.
func FindTempersWithContext ¶ added in v1.4.0
FindTempersWithContext scans /dev for temperXX devices (configured by udev), respecting the provided context for cancellation. Each candidate device is probed with a temperature read; if the read fails or the context is cancelled, the device is skipped and its file descriptors are closed.
func FindTempersWithTimeout ¶ added in v1.1.0
FindTempersWithTimeout scans /dev for temperXX devices (configured by udev).
A timeout of 250ms is recommended but as YMMV, this function allows for an arbitrary timeout. Each candidate device is probed with a temperature read; devices that fail or time out are skipped.
func New ¶
New opens a new Temper device at the given descriptor path. It is the caller's responsibility to call Close() to prevent a file descriptor leak.
func (*Temper) Close ¶
Close releases the file descriptors for the Temper device.
It is safe to call on a nil or partially initialized Temper.
func (*Temper) Descriptor ¶ added in v1.1.0
func (*Temper) ReadC ¶
ReadC reads the internal sensor temperature in Celsius.
This is a convenience wrapper around ReadCWithContext using a background context. For cancellation or timeout support, use ReadCWithContext directly.
func (*Temper) ReadCWithContext ¶ added in v1.1.0
ReadCWithContext reads the internal sensor temperature in Celsius, respecting the provided context for cancellation/timeout.
The device I/O is genuine blocking I/O on a hidraw node; cancellation is implemented by driving the underlying file's read/write deadlines from the context, so an in-flight, unresponsive read is actually unblocked rather than abandoned. The device lock is held for the whole transaction, so reads are serialized and the descriptors are never touched concurrently.
func (*Temper) ReadF ¶
ReadF reads the internal sensor temperature in Fahrenheit.
This is a convenience wrapper around ReadFWithContext using a background context. For cancellation or timeout support, use ReadFWithContext directly.
func (*Temper) ReadFWithContext ¶ added in v1.1.0
ReadFWithContext reads the internal sensor temperature in Fahrenheit, respecting the provided context for cancellation/timeout.