Monitor GPIO for the SHUTDOWN signal.
More...
#include <errno.h>
#include <fcntl.h>
#include <getopt.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <time.h>
#include <unistd.h>
#include <linux/gpio.h>
|
|
void | init_config () |
| | Initialize global configuration with default values.
|
| |
|
void | usage (FILE *out) |
| | Display a usage message.
|
| |
| void | monitor_shutdown_pin () |
| | Loop until we detect a shutdown request. More...
|
| |
|
void | parse_args (int argc, char *argv[]) |
| | Handle command line options.
|
| |
|
int | main (int argc, char *argv[]) |
| |
Monitor GPIO for the SHUTDOWN signal.
| void monitor_shutdown_pin |
( |
| ) |
|
Loop until we detect a shutdown request.
First check the initial state of the shutdown pin. If a shutdown request has been asserted, exit immediately unless --ignore-initial-state was provided. If there is no active shutdown request, monitor the pin for rising edge events and exit when one is received.
| const struct option longopts[] |
Initial value:= {
{
"gpio-pin", required_argument, 0,
OPT_PIN},
}
#define OPT_PIN
--pin|-p <pin>
Definition: pipowerd.c:39
#define OPT_IGNORE_INITIAL_STATE
--ignore-initial-state|-i
Definition: pipowerd.c:42
#define OPT_SHUTDOWN_COMMAND
--shutdown-command|-c <command>
Definition: pipowerd.c:40
#define OPT_VERBOSE
--verbose|-v (may be specified multiple times)
Definition: pipowerd.c:41
#define OPT_HELP
--help|-h
Definition: pipowerd.c:43
#define OPT_GPIO_DEV
--device|-d <device>
Definition: pipowerd.c:38
Configure options handling.