Quoting Nate Jenkins (nate@uniwest.com):
> To use a LapLink cable, you must have "parport", "parport_pc" and "ppdev"
> already compiled into the kernel or insert via 'insmod' into the kernel.
I must be really mis-understand :-)
What I'm trying to do is use the parallel port as generic digital I/O interface.
My first swing at it is very basic.
I just want to send the letter 'a' from PC1 with a parallel port in EPP-1.9
mode to PC2 with a parallel port in EPP-1.9 mode.
I've tried both a straight-through and laplink cable between PC1 and PC2. No
success at all.
I've template my code based on what I found here:
http://people.redhat.com/twaugh/parport/
Read the above url, I think that if you have to parallel ports in EPP mode the
kernel and parallel port will take care of the IEEE1284 protocol and you can
just use read(2) and write(2) to communicate with the parallel port.
Am I way off here?
I was first looking at parapin
<http://www.circlemud.org/~jelson/software/parapin/> but thought parport looked
easier to use.
Any suggestions?
Here is the write code (include and error checking removed):
============================================================
fd = open ("/dev/parport0", O_RDWR|O_NOCTTY);
ioctl (fd, PPCLAIM);
int mode = IEEE1284_MODE_EPP;
ioctl(fd, PPSETMODE, &mode);
for (;;) {
char buffer[1000];
char *ptr = buffer;
ssize_t got;
got = read(0, buffer, 1000);
if (got < 0) {
perror("read");
close(fd);
return 1;
}
if (got == 0) {
break;
}
while (got > 0 ) {
ssize_t written = write_printer(fd, ptr, got);
if (written < 0) {
perror("write");
close(fd);
return 1;
}
ptr += written;
got -= written;
}
}
Here is the read code (include and error checking removed):
============================================================
fd = open ("/dev/parport0", O_RDWR|O_NOCTTY);
ioctl(fd, PPCLAIM)
int mode = IEEE1284_MODE_EPP;
ioctl(fd, PPSETMODE, &mode);
/* Now do whatever we want with fd */
close (0);
dup2 (fd, 0);
if (!fork()) {
/* child */
printf("child\n");
execlp ("cat", "cat", NULL);
printf("child\n");
exit (1);
} else {
/* parent */
wait (NULL);
}
/* Okay, finished */
ioctl (fd, PPRELEASE);
close (fd);
-- Bob Tanner <tanner@real-time.com> | Phone : (952)943-8700 http://www.mn-linux.org, Minnesota, Linux | Fax : (952)943-8500 Key fingerprint = AB15 0BDF BCDE 4369 5B42 1973 7CF1 A709 2CC1 B288-- To unsubscribe, send mail to: linux-parport-request@torque.net -- -- with the single word "unsubscribe" in the body of the message. --
This archive was generated by hypermail 2b29 : Wed Feb 12 2003 - 00:11:19 EST