CÓDIGO EJEMPLO B-1
ald.alarm_state = ALARM_OFF;
lom_ioctl(LOMIOCALSTATE, (char *)&ald);
if ((ald.alarm_state != ALARM_OFF) &&
}
printf("ALARM.%s = %s\n", alarm, get_alarmval(ald.alarm_state));
}
static int
set_alarm(const char *alarm, const char *alarmstate)
{
ts_aldata_t
int alarmval = ALARM_OFF, altype = parse_alarm(alarm);
if (altype
}
if (strcmp(alarmstate, "on") == 0)
else
if (strcmp(alarmstate, "off") == 0)
else {
}
ald.alarm_no = altype;
ald.alarm_state = alarmval;
if (lom_ioctl(LOMIOCALCTL, (char *)&ald) != 0) {
} else {
alarmstate);
}
}
Apéndice B
Programa de ejemplo para efectuar get y set en el estado de las alarmas (continuación)
(ald.alarm_state != ALARM_ON)) {
printf("Invalid value returned: %d\n", ald.alarm_state);
exit(1);
ald;
== ALARM_INVALID) {
usage();
exit(1);
alarmval = ALARM_ON;
alarmval = ALARM_OFF;
usage();
exit(1);
printf("Setting ALARM.%s to %s failed\n", alarm, alarmstate);
return (1);
printf("Setting ALARM.%s successfully set to %s\n", alarm,
return (1);
Interfaz de programación de aplicaciones (API) de salida de relés de alarma
97