[Linux-parport] user-land program for transferring data

Vinay Binny c_attitude at yahoo.com
Wed Sep 15 10:21:26 EDT 2004


I am trying to write a small user land program for
transfer of data b/w 2 computers via parallel port. I
am using the Linux 2.4 parport system. 

While receiving data, I get the same character
repeated multiple time, if I send 'good' I receive
'gggoooooddd' at the other end. I tried using
select(fd +1, &rfds, NULL, NULL, NULL); along with
PPWCTLOIRQ and PPWCONTROL, but I was not able to catch
any interrupt. I do not know what I am doing wrong.
Pls help....

#define nAck 0x40
#define Busy 0x80
#define nFault 0x08
struct timeval tv;*/

/*receiving program*/

int main(void){
	int fd, x, retval;
	char buf;
	int dir = 1, count;
	int mode = IEEE1284_MODE_ECP;
	fd = open("/dev/parport0" , O_RDONLY );

	x =	ioctl(fd , PPCLAIM);
	x = ioctl(fd, PPSETMODE, &mode);
	x =	ioctl(fd, PPDATADIR, &dir);
		x = ioctl(fd, PPRDATA, &buf);
		printf("%c", buf);
	ioctl(fd, PPRELEASE);
	return 0;

/*Transmitting program */

int mode = IEEE1284_MODE_ECP;
fd = open("/dev/parport0",O_WRONLY | O_NONBLOCK);
fd1 = open("data",O_RDONLY);
x = ioctl(fd, PPCLAIM);
x = ioctl(fd, PPSETMODE , &mode);
	x = read ( fd1, &buf, 1 );  	
	y = ioctl(fd, PPWDATA, &buf);
	printf ("%c\n" , buf );
}while(x ==1);

ioctl(fd, PPRELEASE);


Do you Yahoo!?
Read only the mail you want - Yahoo! Mail SpamGuard.

More information about the Linux-parport mailing list