fdevents

package
v0.0.0-...-8327cd9 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package fdevents implements epoll_wait loop for GPIO events and exposes a channel interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event struct {
	RisingEdge bool      // Whether this event is triggered by a rising edge.
	Time       time.Time // The best estimate of time of event occurrence.
}

Event is a GPIO event.

type FdEvents

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

FdEvents converts epoll_wait loops to a chanel.

func New

func New(fd int, closeFdOnClose bool, fdEpollEvents uint32, readFd ReadFdFunc) (events *FdEvents, err error)

New creates a FdEvents and returns any error encountered. The returned FdEvents waits fd for fdEpollEvents in a epoll_wait loop. If epoll_wait returns successfully, readFd is called to generate a value, and that value is sent to the event channel returned by Events.

readFd should return the best estimate of time of event occurrence.

Package fdevents will not block sending to the channel: it only keeps the lastest value in the channel.

func (*FdEvents) Close

func (events *FdEvents) Close() (err error)

Close stops the epoll_wait loop, close the fd, and close the event channel.

func (*FdEvents) Events

func (events *FdEvents) Events() <-chan *Event

Events returns a channel from which the occurrence time of events can be read. The best estimate of time of event occurrence is sent to the returned channel, and the channel is closed when events is closed.

Package fdevents will not block sending to the channel: it only keeps the lastest value in the channel.

type ReadFdFunc

type ReadFdFunc func(fd int) *Event

Jump to

Keyboard shortcuts

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