Programming a "PARALLEL PORT" in C using "inb " and "outb()"

                           For programming a parallel port in C,the user program is supposed to get the permission for accesing  the I/O port using the call

iopl(permission value)

which changes the previlege of the calling process.
By default the user program has a permission value of 0.So for accessing the parallel port,the user program  is supposed to have a permission value of 3


  • outb()

For porting a value onto the parallel – port,the function outb() is used .


parallel port the out pins are from 2 to 9 pin.


will port a byte to the portaddr address.
the port address is to be selected as follows 

/dev/lp0     ——    0x378 
/dev/lp1     ——–   0x3bc

a simple program in C to port a value to the parallel port


parallel port register set

there are three main registers for a parallel port

  • status register
  • controll register
  • status  register

so these registers are used to read  the values of specific pins

the address of the status register
/dev/lp0 — >  0x378
/dev/lp1 — >  0x

  1. #1 by Rick on September 20, 2011 - 8:18 AM

    Hello, how can i read the value of pins so that if the value of a pin is “x” i’ll type another command..

    • #2 by nairrohit on November 17, 2011 - 6:17 AM

      @Rick : Try using ‘inb’ for reading the values from the pin.

  2. #3 by Emma on July 1, 2012 - 7:55 AM

    but the inb give segmentation fault

  3. #4 by iain m on November 19, 2012 - 8:13 PM

    I suggest the iopl(3) failed; print out the result of it?
    you need a zero for iopl to have been ok; if you dont get zero then something else has the parallel port; rmmod parport?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: