Freedom The Open Source Way Contribute Articles or News to OSForgeOSForge HomeLogout from Forums
Contacting OSForgeOSForge HomeAbout OSForge
  
Forum Main Page User Control Panel Register to be a member - It's Free Search for Posts Event Calendar Members Lists Help on Using This Forum
OSForge Forums ? Hardware & Drivers ? Parallel port access trouble ? Hello Guest [login|register]
Last Post | First unread Post Print Page | Recommend to Friend | Add Thread to Favorites

Post New Thread Post Reply

Parallel port access trouble


Author
Post ? Previous Thread | Next Thread ?

mfierro
Fresh Tux
Posts : 2
Joined : 03-18-2003
Status: Offline



Quote | Edit | Report | IP | Up


Attention Parallel port access trouble

I haven't been able to send information through the PC parallel port. I am using the following code to try to send data:

#include <stdio.h>
#include <asm/io.h>
#include <unistd.h>

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 <asm/io.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>

int main(void){
const int PORT = 0x378;
int fd = open("/dev/port", O_WRONLY, 0);
unsigned char val;

if( fd < 0 ){
printf("Error");
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.

__________________
History is the memory of humanity.

03-18-2003 13:19 Search for Posts by mfierro Add mfierro to your Buddy List

ewdi ewdi is a Male
Veteran Tux
Posts : 121
Joined : 01-12-2003
Status: Offline
Location: Texas



Quote | Edit | Report | IP | Up


can you post the error of the output message?

03-18-2003 21:25 Homepage of ewdi Search for Posts by ewdi Add ewdi to your Buddy List

Tree Structure | Board Structure

Rate Parallel port access trouble

 

Poor very bad 

1

2

3

4

5
 very good Excellent
Post New Thread Post Reply
Go to:

Scroll Up

   About OSForge | Term of Use | Privacy | Contact us | Tell a Friend | Advertise

Powered by Burning Board, ? 2002WoltLab GbR