HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Programming/Scripts (http://www.howtoforge.com/forums/forumdisplay.php?f=7)
-   -   Parrallel Port program triggers on Shutdown?? (http://www.howtoforge.com/forums/showthread.php?t=37425)

Tezux 14th July 2009 10:01

Parrallel Port program triggers on Shutdown??
 
Hi Guys, I have copied this little C Program from the net and I am using to turn a relay on and off which triggers a solenoid to open my cash register. This works great but the problem im having is that when I shutdown the PC for some reason the parrallel port triggers the relay and my cash draw opens by itself. Im am a terrible programmer in C and just dont understand the language very well at all and was wondering if someone could tell me how to fix this problem with this program so the cash register wont open by itself when the PC is shutdown everynight, this also causes a security issue like this as if the power goes off the cash register will probably open and the money could be stolen. Heres the c program

#include <stdio.h>
#include <stdlib.h>
#include <sys/io.h>

#define base 0x0378 /* printer port base address */

main(int argc, char **argv)
{

int value;

if (argc!=2)
fprintf(stderr, "Error: Wrong number of arguments. This program needs one argument which is number between 0 and 255.\n"), exit(1);
if (sscanf(argv[1],"%i",&value)!=1)

fprintf(stderr, "Error: Parameter is not a number.\n"), exit(1);
if ((value<0) || (value>255))
fprintf(stderr, "Error: Invalid numeric value. The parameter number must be between 0 and 255\n"), exit(1);

if (ioperm(base,1,1))
fprintf(stderr, "Error: Couldn't get the port at %x\n", base), exit(1);

outb((unsigned char)value, base);
}

Anyone know how to fix the problem?:confused:


All times are GMT +2. The time now is 01:03.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.