temper

package module
v1.2.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 13, 2023 License: 0BSD Imports: 8 Imported by: 1

README

temper

Latest Release Software License Go ReportCard Go Doc

A zero-dependency library to read USB TEMPer thermometers on Linux.

Configuration

On Linux you need to set up some udev rules to be able to access the device as a non-root/regular user. Edit /etc/udev/rules.d/99-temper.rules and add these lines:

SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="e025", GROUP="plugdev", SYMLINK+="temper%n"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7401", GROUP="plugdev", SYMLINK+="temper%n"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="0c45", ATTRS{idProduct}=="7402", GROUP="plugdev", SYMLINK+="temper%n"
SUBSYSTEM=="hidraw", ATTRS{idVendor}=="1130", ATTRS{idProduct}=="660c", GROUP="plugdev", SYMLINK+="temper%n"

Note that there are many versions of the TEMPer USB and your idVendor and idProduct ATTRs may differ.

Make sure your user is part of the plugdev group and reload the rules with sudo udevadm control --reload-rules. Unplug and replug the device.

Example Code

There are examples on how to use this repo in examples/main.go

Additionally, there is a cli-tool available at temper-cli

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Temper

type Temper struct {
	// contains filtered or unexported fields
}

func FindTempers added in v1.1.0

func FindTempers() ([]*Temper, error)

Helper function to return list of temper devices available in /dev

Uses the recommended default timeout of 250ms. See FindTempersWithTimeout for more details

func FindTempersWithTimeout added in v1.1.0

func FindTempersWithTimeout(timeout time.Duration) ([]*Temper, error)

Function which scans /dev for temperXX devices (configured by udev)

A timeout of 250ms is recommended but as YMMV, this function allows for an arbitrary timeout.

func New

func New(descriptor string) (*Temper, error)

Open a new Temper Device

It is the caller's responsibility to call Close() to prevent a file descriptor leak

func (*Temper) Close

func (t *Temper) Close() error

Close the file descriptors for the Temper Device

func (*Temper) Descriptor added in v1.1.0

func (t *Temper) Descriptor() string

func (*Temper) ReadC

func (t *Temper) ReadC() (float32, error)

Read the internal sensor temperature in Celcius

func (*Temper) ReadCWithContext added in v1.1.0

func (t *Temper) ReadCWithContext(ctx context.Context) (float32, error)

func (*Temper) ReadF

func (t *Temper) ReadF() (float32, error)

Read the internal sensor temperature in Fahrenheit

func (*Temper) ReadFWithContext added in v1.1.0

func (t *Temper) ReadFWithContext(ctx context.Context) (float32, error)

Read the internal sensor temperature in Fahrenheit

func (*Temper) String added in v1.1.0

func (t *Temper) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL