From 4c1fb5fa9d71a8ca04ef380fe5f9e2c91d481450 Mon Sep 17 00:00:00 2001 From: Sergey Popov Date: Mon, 19 Dec 2011 09:56:50 +0400 Subject: [PATCH] make LPT port configurable --- yasnd.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/yasnd.c b/yasnd.c index 8e7ac0e..5324706 100644 --- a/yasnd.c +++ b/yasnd.c @@ -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()