how to read data pins from parallel port ieee1284


I can send data to the printer no problem.
using the command to test if the printer receives data

cat file.txt > /dev/usbpar0

my problem is I don’t know how to read the values of the parallel port pins.
i wish to read the values to check for errors.
for example pin 12 or pin 32 for out of paper condition and if there is a fault.

using the code below i always get no matter what the condition 170 = 10101010
i would really appreciate it if somebody can point me the right direction.

#include <iostream>
#include <iomanip>

#include <fcntl.h>   /* File control definitions */
#include <errno.h>   /* Error number definitions */
#include <termios.h> /* POSIX terminal control definitions */

#include "stdio.h"
#include "stdlib.h"
#include "unistd.h"
#include "sys/io.h"

#include <hw/inout.h>
#include <stdint.h>
#include <sys/mman.h>

using namespace std;

int main(int argc, char **argv)
	int fd; /* File descriptor for the port */
	fd = open("/dev/usbpar0",O_RDONLY);

	uintptr_t   ioPtr = mmap_device_io (2, fd);    // for the factory supplied base address
	ThreadCtl(_NTO_TCTL_IO, 0);

	unsigned char dataReadFromPort = in8(ioPtr);

	cout << (int)dataReadFromPort << endl;

	return 0;


Many Thanks

First of all, you do mean IEEE1284, right?

A starting point might be, which processor are you using?

I took a look at the QNX 6 parallel port driver, and unfortunately it provides no IOCTL interface that would provide this information. That’s probably the best way to accomplish this, so you might consider talking with QNX about getting the source and upgrading it.

On the other hand, reading a parallel port status lines is pretty darn easy. Once you have the base port, you just read in base_port+1 if it’s a standard port. If not, you will have to look up where the status port is.

I looked at your code, and it seems quite confused. eg.

ioPtr = mmap_device_io (2, fd);

Why are you sending an fd to mmap_device_io(). If you look up the documentation, the 2nd parameter is a memory address.

If you are using x86, you do not need to use mmap_device_io() at all, just the ThreadCtl() call. Give in8() the port you want to read, eg.

int status = in8(0x379);

Thanks for your help. I finally managed to get information from the printer using the code below.


#include <devctl.h>
#include <sys/dcmd_chr.h>

#include <errno.h> /* Error number definitions /
#include <termios.h> /
POSIX terminal control definitions */

#include “stdlib.h”
#include “unistd.h”
#include “sys/io.h”

#include <hw/inout.h>
#include <stdint.h>
#include <sys/mman.h>

#include <stdio.h>
#include <fcntl.h> /* open() /
#include <sys/types.h> /
open() /
#include <sys/stat.h> /
open() */
#include <sys/ioctl.h>
#include “parport.h”
#include “ppdev.h”

#define DEVICE “/dev/usbpar0”

int status_pins(int fd);

using namespace std;

int main(int argc, char **argv)
int fd;

if((fd=open(DEVICE, O_RDWR)) < 0) {
    fprintf(stderr, "can not open %s\n", DEVICE);
    return 10;

int data = 0, error;

if (error = devctl (fd, DCMD_CHR_LINESTATUS, &data,
                      sizeof(data), NULL))
     fprintf(stderr, "Error setting RTS: %s\n",
         strerror ( error ));

	  printf("No Error Detected!\n");
	  printf("Error Detected\n");


return 0;