29 #include <sys/types.h> 38 #include "rnr/rnrconfig.h" 74 "Block wait for GPIO value to change.",
77 "The %P command block waits for the value of the inoput GPIO associated with " 78 "the <gpio> exported number to change. " 79 "When the GPIO value changes or a timeout " 80 "occurs, the value of \"0\" or \"1\" is printed to stdout. On error, the " 81 "value \"-1\" is printed to stdout, and the program terminates.\n" 83 " The exported GPIO interface must be configured to trigger on an " 87 " gpionotify --timeout=1.5 --monitor 172" 110 "Keep listening for events. Default will terminate after one trigger." 124 "Set wait timeout in seconds. A value of 0.0 means no timeout." 135 fprintf(stderr,
"Try '%s --help' for more information.\n",
Argv0);
146 if( sscanf(str.c_str(),
"%lli", &val1) != 1 )
171 Argv0 = basename(argv[0]);
178 fprintf(stderr,
"%s: No GPIO pin number <gpio> specified.\n",
Argv0);
184 fprintf(stderr,
"%s: '%s': Bad GPIO number.\n",
Argv0, argv[0]);
188 for(
int i = 2; i<argc; ++i)
189 printf(
".%s.\n", argv[i]);
193 int main(
int argc,
char *argv[])
215 fprintf(stdout,
"%d\n", rc);
int main(int argc, char *argv[])
Main.
static void mainInit(int argc, char *argv[])
Main initialization.
int gpioOpen(int gpio)
Open GPIO pin.
GPIO interface declarations and defines.
static char * Argv0
the command
static int ArgsGpioNum
gpio number
int gpioNotify(int fd, double timeout)
Notify on GPIO input value change.
static int strToInt(const string &str, int &val)
Convert string to integer.
int gpioQuickRead(int fd)
Quick read GPIO pin's current value.
static double OptsTimeout
event timeout (none)
static OptsInfo_T OptsInfo[]
Command line options information.
static OptsPgmInfo_T PgmInfo
Program information.
static void badCmdExit()
Exit program on bad command-line values.
static const PkgInfo_T PkgInfo
#define APP_EC_EXEC
execution exit code
Package version information.
#define APP_EC_ARGS
command-line options/arguments error exit code
#define APP_EC_OK
success exit code
static bool_t OptsMonitor
do [not] keep listening for events