gpio  1.4.2
General Purpose I/O Package
gpionotify.cxx File Reference

Create GPIO exported interface. More...

#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <unistd.h>
#include <fcntl.h>
#include <string>
#include "rnr/rnrconfig.h"
#include "rnr/log.h"
#include "rnr/opts.h"
#include "rnr/pkg.h"
#include "rnr/gpio.h"
#include "version.h"

Go to the source code of this file.

Macros

#define APP_EC_OK   0
 success exit code
 
#define APP_EC_ARGS   2
 command-line options/arguments error exit code
 
#define APP_EC_EXEC   4
 execution exit code
 

Functions

static void badCmdExit ()
 Exit program on bad command-line values.
 
static int strToInt (const string &str, int &val)
 Convert string to integer.
 
static void mainInit (int argc, char *argv[])
 Main initialization. More...
 
int main (int argc, char *argv[])
 Main. More...
 

Variables

static char * Argv0
 the command
 
static bool_t OptsMonitor = false
 do [not] keep listening for events
 
static double OptsTimeout = 0.0
 event timeout (none)
 
static int ArgsGpioNum
 gpio number
 
static OptsPgmInfo_T PgmInfo
 Program information. More...
 
static OptsInfo_T OptsInfo []
 Command line options information.
 

Detailed Description

Create GPIO exported interface.

LastChangedDate
2015-04-08 17:22:10 -0600 (Wed, 08 Apr 2015)
Rev
3913
Author
Robin Knight (robin.nosp@m..kni.nosp@m.ght@r.nosp@m.oadn.nosp@m.arrow.nosp@m.s.co.nosp@m.m)

Definition in file gpionotify.cxx.

Function Documentation

static void mainInit ( int  argc,
char *  argv[] 
)
static

Main initialization.

Parameters
argcCommand-line argument count.
argvCommand-line argument list.
Exits:
Program terminates on conversion error.
Returns
Exit code.

Definition at line 168 of file gpionotify.cxx.

References APP_EC_EXEC, APP_EC_OK, ArgsGpioNum, Argv0, badCmdExit(), gpioNotify(), gpioOpen(), gpioQuickRead(), main(), OptsInfo, OptsMonitor, OptsTimeout, PgmInfo, PkgInfo, and strToInt().

169 {
170  // name of this process
171  Argv0 = basename(argv[0]);
172 
173  // parse input options
174  argv = OptsGet(Argv0, &PkgInfo, &PgmInfo, OptsInfo, true, &argc, argv);
175 
176  if( argc == 0 )
177  {
178  fprintf(stderr, "%s: No GPIO pin number <gpio> specified.\n", Argv0);
179  badCmdExit();
180  }
181 
182  else if( strToInt(argv[0], ArgsGpioNum) < 0 )
183  {
184  fprintf(stderr, "%s: '%s': Bad GPIO number.\n", Argv0, argv[0]);
185  badCmdExit();
186  }
187 
188  for(int i = 2; i<argc; ++i)
189  printf(".%s.\n", argv[i]);
190 
191 }
static char * Argv0
the command
Definition: gpionotify.cxx:59
static int ArgsGpioNum
gpio number
Definition: gpionotify.cxx:63
static int strToInt(const string &str, int &val)
Convert string to integer.
Definition: gpionotify.cxx:142
static OptsInfo_T OptsInfo[]
Command line options information.
Definition: gpionotify.cxx:97
static OptsPgmInfo_T PgmInfo
Program information.
Definition: gpionotify.cxx:68
static void badCmdExit()
Exit program on bad command-line values.
Definition: gpionotify.cxx:133
static const PkgInfo_T PkgInfo
Definition: version.h:45