Parrallel Port program triggers on Shutdown??

Discussion in 'Programming/Scripts' started by Tezux, Jul 14, 2009.

  1. Tezux

    Tezux New Member

    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:
     

Share This Page