lkml.org 
[lkml]   [2001]   [Feb]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectParallel Printer in 2.4.0
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"
#define COMMAND1 "@PJL INFO CONFIG\r\n"
#define COMMAND2 "@PJL INFO VARIABLES\r\n"

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?

Thanks,
Allen
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:14    [W:0.027 / U:6.860 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site