Need to open a Parallel port...Help!

Dear all,

Currently, I need to write a program that will read data from a parallel port. The hardware that consists of a temperature sensor is connected to the parallel port. And I need to construct a program that will read data from the port.

So far, i've managed to identify the ports on my machine. The code for identifying the ports is:

/* Files: ReadPort.java */

import javax.comm.CommPortIdentifier;

import java.util.Enumeration;

import javax.comm.CommDriver.*;

public class ReadPort

{

/** Port Identifier. */

static CommPortIdentifier portId;

/** Container of the present ports. */

static Enumeration portList;

public static void main(String[] args)

{

String driverName = "com.sun.comm.Win32Driver";

try{

javax.comm.CommDriver commdriver = (javax.comm.CommDriver)Class.forName(driverName).newInstance();

commdriver.initialize();

}

catch (Exception e2)

{

e2.printStackTrace();

}

// demand present ports.

portList = CommPortIdentifier.getPortIdentifiers();

// this cycle allows to capture one to one the found ports.

while (portList.hasMoreElements())

{

// Port Identifier.

portId = (CommPortIdentifier) portList.nextElement();

// view the port.

System.out.println("Port --> " + portId.getName());

}

try

{

CommPortIdentifier.getPortIdentifier("COM2");

}

catch(Exception e)

{

System.out.println("ERROR " +e);

}

System.out.println("Done");

}

}

I know on my machine that i have a parallel port. Now i have to open the parallel port, and i'm having problems knowing how to. Can anyone help me construct a piece of code to open a parallel port using javax.comm? Even some code would be really helpful.

Regards,

Raheal

[1924 byte] By [Raheal_Maza] at [2007-11-26 20:08:38]
# 1
Annoyingly crossposted. http://forum.java.sun.com/thread.jspa?threadID=5142916
warnerjaa at 2007-7-9 23:11:25 > top of Java-index,Java Essentials,Java Programming...