implement proper LPT control circuit init on daemon start
This commit is contained in:
parent
e7d900d9b7
commit
bb6b2328aa
55
yasnd.c
55
yasnd.c
@ -45,6 +45,42 @@ void* allocate_memory(int bytes)
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
Function, that turn off all LPT port pins.
|
||||
This is needed to unlock LPT control circuit, when
|
||||
management computer is just booted
|
||||
*/
|
||||
void lpt_init()
|
||||
{
|
||||
if (ioperm (lpt_port, 3, 1))
|
||||
{
|
||||
log_event("Error: Unlocking the circuit fails due to LPT port access error");
|
||||
// disable LPT port usage
|
||||
lpt_enable=false;
|
||||
return;
|
||||
}
|
||||
// Unlock circuit
|
||||
outb (0, lpt_port);
|
||||
}
|
||||
|
||||
/*
|
||||
Function, that turn on first LPT port pin and turn off others.
|
||||
This is needed to lock LPT control circuit, when
|
||||
management computer is rebooted
|
||||
*/
|
||||
void lpt_lock()
|
||||
{
|
||||
if (ioperm (lpt_port, 3, 1))
|
||||
{
|
||||
log_event("Error: Locking the circuit fails due to LPT port access error");
|
||||
// disable LPT port usage
|
||||
lpt_enable=false;
|
||||
return;
|
||||
}
|
||||
// Lock circuit
|
||||
outb (1, lpt_port);
|
||||
}
|
||||
|
||||
void init()
|
||||
{
|
||||
// Initialize config parsing library
|
||||
@ -110,6 +146,9 @@ void init()
|
||||
// initialize gammu structures
|
||||
if (sms_send_enable)
|
||||
gammu_init();
|
||||
// initialize LPT control circuit
|
||||
if (lpt_enable)
|
||||
lpt_init();
|
||||
}
|
||||
|
||||
void check_host(int num,host_decl* host)
|
||||
@ -136,22 +175,6 @@ void check_host(int num,host_decl* host)
|
||||
host->helper_pid=pid;
|
||||
}
|
||||
|
||||
/*
|
||||
Function, that turn on first LPT port pin and turn off others.
|
||||
This is needed to lock LPT control circuit, when
|
||||
management computer is rebooted
|
||||
*/
|
||||
void lpt_lock()
|
||||
{
|
||||
if (ioperm (lpt_port, 3, 1))
|
||||
{
|
||||
log_event("Error: LPT port access error");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
// Lock circuit
|
||||
outb (1, lpt_port);
|
||||
}
|
||||
|
||||
/*
|
||||
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.
|
||||
|
Loading…
Reference in New Issue
Block a user