[Rxtx] getPortIdentifiers(); returning null enumertion

Trent Jarvi tjarvi at qbang.org
Mon Aug 14 18:06:29 MDT 2006


On Mon, 14 Aug 2006, Ed wrote:

> When I try to get the mode with int mode = pPort.getMode(); it returns 0
> which isn't any of the valid modes. I tried setting it explicitely with
> pPort.setMode(ParallelPort.LPT_MODE_XXX );and all failed with
>
> gnu.io.UnsupportedCommOperationException: setLPRMode was unable to proced
> the requested                   mode in nativeSetSerialPortParams
>       at gnu.io.LPRPort.setLPRMode(Native Method)
>       at gnu.io.LPRPort.setMode(LPRPort.java:87)
>
> Except for LPT_MODE_ANY, but the getMode call still failed out with an
> invalid state.

This is because rxtx only supports the basics.

JNIEXPORT jboolean JNICALL LPRPort(setLPRMode)(JNIEnv *env,
         jclass jclazz, jint mode)
{
         switch(mode)
         {
                 case LPT_MODE_ANY:
                         break;
                 case LPT_MODE_SPP:
                 case LPT_MODE_PS2:
                 case LPT_MODE_EPP:
                 case LPT_MODE_ECP:
                 case LPT_MODE_NIBBLE:
                 default:
                         throw_java_exception( env, UNSUPPORTED_COMM_OPERATION,
                                 "nativeSetSerialPortParams",
                                 "setLPRMode was unable to proced the requested \
                                 mode"
                         );
         }
         return(JNI_TRUE);
}

One could program in more support.  When I did that I just had a daisy 
wheel printer to test with and doing any more would have been blind.

So that behavior is expected.  I'll look to see if the Parallel Complete 
book mentions which pins you need to raise.  If you look in the source 
code [ParallelImp.c] you can see this code isn't well tested.  It has 
worked for hobby use in the past as I'd guess you are trying to do.  But 
my experience with the code is as is mentioned in the top of the source:

/*
    fear he who enter here.  It appears that things have changed.  An attempt
    has been made to put things the way the should be.

         It compiles and ParallelBlackBox runs.  No further guarantees.

         Well... One.. it will print "Hello World!" on an epson DX 10 printer.
         you know.. the 10 character per second daisy wheel printer ;)

         - Trent Jarvi
*/

That comment is from 1997 or so.

Since then some windows support was contributed but it is still very green 
code.  We get about four requests for parallel support a year so its just 
not a well traveled area.

It would be nice to have some documentation for the people trying to hook 
parallel ports to electronic projects.  That appears to be the exclusive 
use of the Parallel support.  The wiki pages are intended to let people 
share information like this to help each other in their projects as they 
figure out the details.

--
Trent Jarvi
tjarvi at qbang.org



More information about the Rxtx mailing list