DHaylock / poll

Listen to GPIO devices

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NAME

poll ---- monitor special files, character devices and named pipes for changes.

SYNOPSIS

poll [ [OPTIONS] FILE ]...

DESCRIPTION

poll outputs a special file's contents, when it changes, one line at a time. It is intended for use with files such as GPIO inputs which appear in the /sys file system. It will also work with named pipes and character devices but not normal files. It is often of use with embedded Linux machines such as the Raspberry Pi.

poll, contrary to what its name suggests, sleeps between changes in files. It is based on the system library poll(2).

Examples:

poll --debounce 20 --unique "+gpio %l %t\n" /sys/class/gpio/gpio4/value --default --delimiter '\2\3\r\n' "+rfid %l\n" /dev/ttyAMA0

Monitor a switch conected to a GPIO pin and an RFID reader connected to a serial port. Output the switch value and a time (in nanoseconds) when it changes state ignoring any bouncing for 20ms after it is switched. Output the value read by the RFID reader, delimited by any of ctrl-B, ctrl-C, carriage return and newline.

OPTIONS

Options apply to all subsequent files until they are overridden.

+FORMAT

Controls output. Interpretted sequences are:

%l  Line from file
%p  Filename
%t  Time since Unix epoch in nanoseconds
%%  A single %

--debounce TIME

After a value change, wait this amount of time (in milliseconds) before reporting any further change. Useful with --unique as switch bouncing will be completely ignored.

--unique

Only report unique values. Useful with --debounce.

--duplicates

Allow all values to be output (opposite of --unique).

--delimiters STRING

Lines in the file are delimited by one of the characters in STRING.

--default

Set options back to default values.

CAVEATS

Hard coded to have a limit of 64 files and an input line length of 1024 characters. Won't list changes to a "normal" file - use tail -f instead.

AUTHOR

Written by Tarim. Errors to poll-cmd@mediaplaygrounds.co.uk.

SEE ALSO

poll(2), tail(1)

About

Listen to GPIO devices


Languages

Language:C++ 96.2%Language:Makefile 3.8%