How to get the status of parallel port printer under Linux, such as paper missing, the device is not installed. Or How to get through the CUPS printer status etc.
Asked
Active
Viewed 397 times
1 Answers
0
int fd = open("/dev/lp0", O_RDWR);
if (fd < 0)
{
printf("can't open lp0\n");
}
else
{
int status = 0;
if (ioctl(fd, LPGETSTATUS, &status) == 0)
{
fprintf(stderr, "DEBUG: LPGETSTATUS returned a port status of %02X...\n", status);
if (status & LP_NOPA)
{
RET = T;
fputs("WARNING: Media tray empty!\n", stderr);
}
else if (status & LP_ERR)
{
RET = F;
fputs("WARNING: Printer fault!\n", stderr);
}
else if (status & LP_OFFL)
{
RET = F;
fputs("WARNING: Printer off-line.\n", stderr);
}
close(fd);
} }

MysticBoy
- 1
- 4