Hi
I studied your code. It is better that you use
outportb(PORTADDRESS,databyte);
for example outportb(0x378,0x01);
Another mistake i found is sleep() is a function used to suspend the program execution by that much seconds you specify as the arguments.
You wrote sleep(2000); i.e. you are asking the program to hold for 2000 seconds. Instead you use
delay(milliseconds); to control the port.
All the best. If any queries regarding parallel port control in C. please be free to mail me to this ID : [email]muralikvn81@yahoo.com[/email]
I am having trouble when trying to send information through the PC parallel port. I am using the following code to try to send data:
#include #include #include
int main(void){ ioperm( 0x378, 1, 1 ); outb( 0x378, 0xAA ); sleep( 2000 ); outb( 0x378, 0x55 ); sleep( 2000 ); outb( 0x378, 0x00 ); return 0; }
Because it failed (for a reason that I am unaware of) I tried the following program which, I think, is equivalent to the previous one:
#include #include #include #include #include
int main(void){ const int PORT = 0x378; int fd = open("/dev/port", O_WRONLY, 0); unsigned char val;
if( fd < 0 ){ exit(1); } lseek(fd, PORT, SEEK_SET); val = 0x50; write(fd, &val, sizeof(val)); sleep(2000); val = 0xA0; write(fd, &val, sizeof(val)); sleep(2000); val = 0x00; write(fd, &val, sizeof(val)); close(fd); return 0; } I'm running the program as the root user, so I have all priveleges. I am verifying the output with a bunch of LEDs that are supposed to turn on when I send a 1. I've already tried a similar code in Windows and it works as expected. Help or suggestions are warmly welcome.