javaioparallel-port

How to switch data pins on/off on parallel port?


I want to simply switch certain data pins on and off, so that they can control a set of relays. I'm not asking about the hardware bit (should be easy), but I don't know where to begin writing the software. I don't want a high level library that can send bytes to a device - I literally want to switch on/off certain pins.

I'm running Linux and I want to do this in Java, so would I just need a library? It would be nice if the library has good documentation and is easy to use, but if not then a short example code will help me get started.


Solution

  • There's a pretty easy-to-use API called ParalelPort:

    http://www.oocities.com/Juanga69/parport/index.html?20112

    Its very easy, you could use "write(int oneByte)", where in the "oneByte" you send a 8 bit word, turning on and off the pins you want, according to this diagram:

         Bit | Pin # | Printer DATA
        -----+-------+--------------
          7  |   9   |   DATA 7
          6  |   8   |   DATA 6
          5  |   7   |   DATA 5
          4  |   6   |   DATA 4
          3  |   5   |   DATA 3
          2  |   4   |   DATA 2
          1  |   3   |   DATA 1
          0  |   2   |   DATA 0