95
APPENDIX
B
Alarm Relay Output Application
Programming Interface
This appendix provides an example program that illustrates how to get or set the
status of the alarms. The application can use the LOMIOCALSTATE ioctl function
to obtain the status of each alarm and the LOMIOCALCTL ioctl function to set the
alarms individually. For more details on the alarm indicators, see “Alarm Status
Indicators” on page 41.
CODE EXAMPLE B-1 Example Program to get and set Status of the Alarms
#include <sys/types.h>
#include <string.h>
#include <stdlib.h>
#include <sys/unistd.h>
#include <fcntl.h>
#include "lom_io.h"
#define ALARM_INVALID -1
#define LOM_DEVICE "/dev/lom"
static void usage();
static void get_alarm(const char *alarm);
static int set_alarm(const char *alarm, const char *alarmval);
static int parse_alarm(const char *alarm);
static int lom_ioctl(int ioc, char *buf);
static char *get_alarmval(int state);
static void get_alarmvals();
main(int argc, char *argv[])
{
if (argc < 3) {
usage();
if (argc == 1)