From: Allen Barnett <barnett@localnet.com>
To: linux-kernel@vger.kernel.org
Subject: Parallel Printer in 2.4.0
Date: Wed, 14 Feb 2001 08:15:55 -0500 [thread overview]
Message-ID: <3A8A850B.29CDAC50@localnet.com> (raw)
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
next reply other threads:[~2001-02-14 13:13 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2001-02-14 13:15 Allen Barnett [this message]
2001-02-14 13:17 ` Parallel Printer in 2.4.0 Tim Waugh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3A8A850B.29CDAC50@localnet.com \
--to=barnett@localnet.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox