pl2303relay

package module
v0.0.0-...-2584ef9 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: GPL-2.0 Imports: 4 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

PkgGoDev

pl2303relay

A Go driver for common USB-attached relay boards using the PL2303 USB to RS232 chip.

The package comes with a simple command-line tool to control relays. For example, to turn on both relays on a two relay board:

go run github.com/jamesfcarter/pl2303relay/cmd/relay /dev/ttyUSB0 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PL2303Relay

type PL2303Relay struct {

	// Value is the last value successfully written to the relays,
	// or nil if no value has yet been written.
	Value *byte
	// contains filtered or unexported fields
}

PL2303Relay represents a set of USB-connected relays.

func New

func New(device string) (*PL2303Relay, error)

New created a new PL2303Relay or returns an error if it is unable to open the device.

func (*PL2303Relay) Init

func (p *PL2303Relay) Init() (count int, err error)

Init initialises the relay board and returns the number of relays available. This call can only be made once after the board gets power. If a second call is made then 0 will be returned, and the relays will be in an undefined state.

func (*PL2303Relay) Update

func (p *PL2303Relay) Update(b byte) error

Update turns the relays on or off in a pattern described by b.

Directories

Path Synopsis
cmd
relay command

Jump to

Keyboard shortcuts

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