make LPT port configurable

This commit is contained in:
Sergey Popov 2011-12-19 09:56:50 +04:00
parent 7ecbe35d83
commit 4c1fb5fa9d

11
yasnd.c
View File

@ -20,6 +20,8 @@ char* phone_device=NULL; // phone device for gammu, for example: "/dev/ttyACM0"
char* phone_model=NULL; // gammu phone model, for example: "at"
char* phone_connection=NULL; // gammu phone connection type, for example: "at"
char* recipient_number=NULL; // recipient of sms alerts
bool lpt_enable=false; // control usage of LPT port to reset target devices
int lpt_port=0x378; // LPT port in hex(0x378 is usually LPT1)
bool loop_locked=false ; // flag for locking main loop while config re-reading
int failures_first=3 ; // count of failures while hosts checking, that triggers first SMS sending
pid_t mainloop_clone_pid; // pid of clone process, that containt main loop
@ -52,6 +54,8 @@ void init()
cfg_opt_t opts[] = {
CFG_STR_LIST("hosts", "{}", CFGF_NONE),
CFG_SIMPLE_INT("debug", &debug_flag),
CFG_SIMPLE_BOOL("lpt_enable", &lpt_enable),
CFG_SIMPLE_INT("lpt_port", &lpt_port),
CFG_SIMPLE_BOOL("sms_send_enable", &sms_send_enable),
CFG_SIMPLE_STR("phone_device", &phone_device),
CFG_SIMPLE_STR("phone_model", &phone_connection),
@ -146,17 +150,16 @@ void reset_pin(int pin_num)
log_event("Error: incorrent LPT pin number");
return;
}
#define LPTPORT 0x378
int pins = 2<<(pin_num-1);
if (ioperm (LPTPORT, 3, 1))
if (ioperm (lpt_port, 3, 1))
{
log_event("Error: LPT port access error");
exit(EXIT_FAILURE);
}
// Reset host
outb (pins, LPTPORT);
outb (pins, lpt_port);
sleep(1);
outb (0, LPTPORT);
outb (0, lpt_port);
}
int loop_function()