[Linux-parport] Re: Please help with ppdev parallel signals

Robert Heller heller at deepsoft.com
Tue Sep 14 18:32:39 EDT 2004


  "Alvarado Rodriguez, Melvin J" <melvin.j.alvarado.rodriguez at intel.com>,
  In a message on Tue, 14 Sep 2004 09:06:03 -0600, wrote :

"RMJ> Hi Robert,
"RMJ> 
"RMJ> I used the examples on the document "The Linux 2.4 Parport Subsystem",
"RMJ> and no errors were found when I compiled or executed it, but when I
"RMJ> verified the parallel signals with a Logic Analizer, no one changed. 
"RMJ> I don't know what happened, could you please help me?

I know *very little* about the The Linux 2.4 Parport Subsystem. You
really should post a message to the linux-parport at lists.infradead.org
mailing list.

"RMJ> 
"RMJ> I am using Debian with kernel 2.6.0, and the code:

Well, for starters I would guess that documentation for a 2.4 kernel
subsystem might not be totally useful with a 2.6 kernel, but I don't
really know that much about parallel port programming.

"RMJ> 
"RMJ> ------------------------------------------------------------------------
"RMJ> ---
"RMJ> #include <sys/ioctl.h>
"RMJ> #include <sys/types.h>
"RMJ> #include <sys/ioctl.h>
"RMJ> #include <stdio.h>    
"RMJ> #include <unistd.h>
"RMJ> #include <fcntl.h> 
"RMJ> #include <errno.h> 
"RMJ> #include <getopt.h>
"RMJ> 
"RMJ> #include "/usr/include/linux/ppdev.h"
"RMJ> #include "/usr/include/linux/parport.h"
"RMJ> 
"RMJ> #include "driver.h"
"RMJ> 
"RMJ> 
"RMJ> ssize_t write_printer (int fd, const void *ptr, size_t count) {
"RMJ>   return write (fd, ptr, count);
"RMJ> }
"RMJ>   
"RMJ> 
"RMJ> int drive_printer (const char *name) {
"RMJ>   int fd;
"RMJ>   int mode;
"RMJ>   
"RMJ> 
"RMJ>   fd = open (name, O_RDWR);
"RMJ>   if (fd == -1) {
"RMJ>     perror ("open");
"RMJ>     printf("Error: Can not open %s\n",name);
"RMJ>     return 1;
"RMJ>   }
"RMJ> 
"RMJ>  if (ioctl (fd, PPCLAIM)) {
"RMJ>     perror ("PPCLAIM");
"RMJ>     close (fd);
"RMJ>     return 1;
"RMJ>   }
"RMJ>   
"RMJ>   for (;;) {
"RMJ>     char buffer[1000];
"RMJ>     char *ptr = buffer;
"RMJ>     size_t got;
"RMJ>     got = read (0 /* stdin */, buffer, 1000);
"RMJ>     
"RMJ>     if (got < 0) {
"RMJ>       perror ("read");
"RMJ>       close (fd);
"RMJ>       return 1;
"RMJ>     }
"RMJ>     
"RMJ>     if (got == 0)
"RMJ>       /* End of input */
"RMJ>       break;
"RMJ>     while (got > 0) {
"RMJ>       int written = write_printer (fd, ptr, got);
"RMJ>       if (written < 0) {
"RMJ>         perror ("write");
"RMJ>         close (fd);
"RMJ>         return 1;
"RMJ>       }
"RMJ>     
"RMJ>     ptr += written;
"RMJ>     got -= written;
"RMJ>     }
"RMJ>   
"RMJ>   }   
"RMJ> 
"RMJ> }
"RMJ> 
"RMJ> 
"RMJ> ______________________
"RMJ> 
"RMJ> Melvin J. Alvarado R.
"RMJ> 
"RMJ> Intel Costa Rica - FA
"RMJ> ext 67288
"RMJ> Office: 298-7288
"RMJ> 
"RMJ>                                                     

                                     \/
Robert Heller                        ||InterNet:   heller at cs.umass.edu
http://vis-www.cs.umass.edu/~heller  ||            heller at deepsoft.com
http://www.deepsoft.com              /\FidoNet:    1:321/153






                                                                                                                



More information about the Linux-parport mailing list