Parallel Printer in 2.4.0

From: Allen Barnett (
Date: Wed Feb 14 2001 - 08:15:55 EST

This code worked OK in kernel 2.2 for talking to an HP printer connected
to a parallel port:
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#define UEL "\033%%-12345X"

int main ( int argc, char* argv[] )
  char buffer[33];
  int i, n;

  int fd = open( "/dev/lp0", O_RDWR | O_SYNC );

  write( fd, UEL, strlen(UEL) );
  write( fd, COMMAND1, strlen(COMMAND1) );
  write( fd, COMMAND2, strlen(COMMAND2) );
  write( fd, UEL, strlen(UEL) );

  usleep( 4000000 ); /* Wait for the printer to digest the command */

  /* Once for each command */
  for ( i=0; i<2; i++ ) {
    while ( n = read( fd, buffer, sizeof(buffer)-1 ) ) {
      buffer[n] = '\0';
      printf( "%s", buffer );

  close( fd );
The output from *each* PJL INFO command was treated by the kernel as one
string and read() returned 0 after all the bytes of one INFO command
were read (thus the for loop over 2).

Under 2.4.0, after the returned data from the first INFO command is
read, the second read() command hangs. The kernel produces syslog
messages like:

parport0: No more nibble data (15 bytes)
parport0: Nibble timeout at event 9 (0 bytes)

Is this a bug or is there a new (or better) procedure for reading data
through the lp device in 2.4?

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

This archive was generated by hypermail 2b29 : Thu Feb 15 2001 - 21:00:24 EST