* Parallel Printer in 2.4.0
@ 2001-02-14 13:15 Allen Barnett
2001-02-14 13:17 ` Tim Waugh
0 siblings, 1 reply; 2+ messages in thread
From: Allen Barnett @ 2001-02-14 13:15 UTC (permalink / raw)
To: linux-kernel
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Parallel Printer in 2.4.0
2001-02-14 13:15 Parallel Printer in 2.4.0 Allen Barnett
@ 2001-02-14 13:17 ` Tim Waugh
0 siblings, 0 replies; 2+ messages in thread
From: Tim Waugh @ 2001-02-14 13:17 UTC (permalink / raw)
To: Allen Barnett; +Cc: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 193 bytes --]
On Wed, Feb 14, 2001 at 08:15:55AM -0500, Allen Barnett wrote:
> Is this a bug or is there a new (or better) procedure for reading data
> through the lp device in 2.4?
Bug, I think.
Tim.
*/
[-- Attachment #2: Type: application/pgp-signature, Size: 232 bytes --]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-02-14 13:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-02-14 13:15 Parallel Printer in 2.4.0 Allen Barnett
2001-02-14 13:17 ` Tim Waugh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox