《Laddie报警系统与日志记录详解》
1. Laddie报警系统
Laddie报警系统是一个简单的报警守护进程示例,下面将详细介绍其实现和测试方法。
1.1 报警检测代码
以下是一段用于检测报警状态的代码:
for (i = 0; i < NUM_INPUTS; i++) {
if (Zone[i].alarm == 1) {
if (GlobalAlarm == 0) {
/* A new alarm. Log it and set control bits (low three) high. */
syslog(LOG_ALERT, "Alarm system status: alarm");
outb((unsigned char)0x0007, PORT+2);
GlobalAlarm = 1;
}
return; // in alarm, no need to check the other zones
}
}
/* If we get here, there are no alarms */
if (GlobalAlarm == 1) {
/* Clear alarm. Log it and set control bits (low three) low. */
syslog(LOG_ALERT, "Alarm system status: safe");
outb((unsigned char)0x
超级会员免费看
订阅专栏 解锁全文
44

被折叠的 条评论
为什么被折叠?



