diff --git a/yasnd.c b/yasnd.c index aa5b772..a0eeb7c 100644 --- a/yasnd.c +++ b/yasnd.c @@ -1,5 +1,6 @@ #include #include +#include #include #include #include @@ -130,6 +131,30 @@ void check_host(int num,host_decl* host) host->helper_pid=pid; } +/* + Function, that turn on only one LPT port pin, defined by it argument, wait a second, + and turn off all pins. That is enough to reset specified host. +*/ +void reset_pin(int pin_num) +{ + if (pin_num<1 || pin_num>8) + { + log_event("Error: incorrent LPT pin number"); + return; + } + #define LPTPORT 0x378 + int pins = 2<<(pin_num-1); + if (ioperm (LPTPORT, 3, 1)) + { + log_event("Error: LPT port access error"); + exit(EXIT_FAILURE); + } + // Reset host + outb (pins, LPTPORT); + sleep(1); + outb (0, LPTPORT); +} + void loop_function() { for (int i=0;i