[prev in list] [next in list] [prev in thread] [next in thread] 

List:       rxtx
Subject:    Re: [RxTx] Reading parallel port data
From:       Trent Jarvi <taj () linuxgrrls ! org>
Date:       2003-09-16 11:03:33
[Download RAW message or body]


On Mon, 15 Sep 2003, David Morris wrote:

> Hello
>   I have a motor system running under Java that positions a multi axis 
> stage in a beam of protons (someone has to do it!)
> 
>   The user needs a way to watch the position of the stage and push 
> buttons to move an axis back and forth until it is aligned. (This would 
> be when the protons are not bouncing around the room)  I have a pendant 
> with a selection of buttons which select the axis, speed and direction. 
> I want to connect this to the parallel port so that I don't need some 
> complicated I/O card. Eight bits gives 3 bits for motor selection, 3 
> bits for speed, and 2 bits for direction. I had previously done this 
> under Win98 using direct port access, but want to use RxTx because I am 
> also using it for serial communication with the motor controller. (Less 
> clutter in the make file).
> 
>   I have explored RxTx, fiddled with ParallelImp.c,and confirmed the 
> file handle to lp0 is opened. I always get a "Input/output error" when I 
> try to read the port.
> 
>   The one thing I realize is that the control of the parallel port must 
> be such that the output mode of the port is disabled, so you can read 
> the state of the switches with a read. Perhaps I am missing something, 
> but I haven't seen this sort of manipulation in the ParallelImp.c file. 
> Would it be done by the device driver based on the port configuration 
> (EPP, ECP, PS/2?) Of course I can't remember what mode it is in right 
> now, and that would require a re-boot.
> 
>   Does this method of access require the use of /dev/parport instead of 
> /dev/lp?
> 


Hi David

When I put the Parallel port code in, the linux kernel drivers appeared to 
be in flux.  linux 2.0 had lp[0-3] bound to ioaddresses.  I've not looked 
at the parallel port much since then so take this with a grain of salt.

The parport/lp devices should be mapping to the same thing.  In rxtx you 
can edit RXTXCommDriver and add parport to the list of ports supported.

                                {
                                        String[] temp={
						"parport",
                                                "lp"    // linux printer port
                                        };
                                        CandidatePortPrefixes=temp;
                                }

That will try to enumerata parport[0-255].  That would be the easy thing 
to try.

In the linux kernel source tree the code for handling the ports would be
linux-version/drivers/char/lp.c.  This should get you to where you can 
look for the code you used on w32.

from linux-version/Documentation/devices.txt:

  6 char        Parallel printer devices
                  0 = /dev/lp0          Parallel printer on parport0
                  1 = /dev/lp1          Parallel printer on parport1
                    ...


                Current Linux kernels no longer have a fixed mapping
                between parallel ports and I/O addresses.  Instead,
                they are redirected through the parport multiplex layer.

 99 char        Raw parallel ports
                  0 = /dev/parport0     First parallel port
                  1 = /dev/parport1     Second parallel port
                    ...

you will want to read linux-version/Documentation/parport.txt and perhaps
linux-version/Documentation/parport-lowlevel.txt

I've not tried reading from the parport.  All changes posted here have 
been put into the rxtx-2.1 cvs.  (the .c files can drop into 2.0 after a 
couple search and replaces to move gnu.io to javax.comm).

Thats not much help but should point you to the info.  There is also the 
possibility of modifying the RawImp.c files to do the io to addresses as 
you did in w32.  These are also in rxtx 2.1 as they are not part of 
CommAPI.  These filesmore or less outline of how it can be done 
and not fully implemented solutions. 

This question shows up every few months with people doing odd things (I 
guess you fit that group :)  If you do find more could you post a quick 
note about what you found to the list and I'll put in the RXTX 
documentation?
_______________________________________________
Rxtx mailing list
Rxtx@linuxgrrls.org
http://hex.linuxgrrls.org/mailman/listinfo/rxtx
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic