简易报警系统与日志记录技术解析
1. 简易报警系统 ladd 实现
1.1 系统初始化
在实现简易报警系统 ladd 时,首先要对系统进行初始化操作。以下是相关代码:
if (ioperm(PORT,3,1)) {
fprintf(stderr, "Cannot open parallel port at %x\n", PORT);
exit(1);
}
outb((unsigned char)0x00FF, PORT);
/* Now read the input pins to get initial states */
value = inb(PORT+1);
for (i = 0; i < NUM_INPUTS; i++) {
Zone[i].input = (value & (8<<i)) ? 1 : 0;
}
/* Set the output pins on the control port low since we start
* in a "no-alarm" state. Set global alarm to match. */
outb((unsigned char)0x0000, PORT+2);
GlobalAlarm = 0;
/* Setup poll timer */
if (!add_timer(ED_PERIODIC, 100, poll_timeout, (void *)__LINE__)) {
fprintf(stderr, "Can not set up periodic timer. Exiting ....\n");
超级会员免费看
订阅专栏 解锁全文
45

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



