Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > Linux Forums > Programming/Scripts

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 14th July 2009, 11:01
Tezux Tezux is offline
Member
 
Join Date: Jun 2009
Posts: 38
Thanks: 0
Thanked 2 Times in 2 Posts
 
Default 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?
Reply With Quote
Sponsored Links
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Monit & Munin SamTzu HOWTO-Related Questions 2 23rd September 2014 23:20
Monit on Debian Hans Tips/Tricks/Mods 2 6th October 2008 14:53
Mail Question: installed smf forum on centos perfect server setup with ispconfig happz Installation/Configuration 7 22nd August 2008 14:15
Getting e-mail working hansoffate Installation/Configuration 29 13th August 2008 17:33
How to install BFD (Brute Force Detection) domino Tips/Tricks/Mods 9 31st March 2006 23:40


All times are GMT +2. The time now is 23:53.


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