Hi everybody.
I'm trying to turn on (or off) some LEDs conected to the Parallel Port. The program opens the port correctly but for some reason, it only allows me to use the LPT.MODE.SPP, even though that according to my Device Manager, the LPT1 mode is ECP.
Besides that, the program works until the "getOutputStream().write(256);" , where it just stays there...no error, no returning to system, no nothing. I have to manually stop the building of the program. Another weird thing is that I've tried setting the OutputBufferSize to 256 but no matter what I do, it always stays at 1024.
What i'm supposed to do is turn on 8 LEDs connected to the port; but even that's strange: the LEDs ARE turned on. The second I plug the cable, the all get turned on...maybe I'm supposed to turn them off?
Here's the code:
import java.lang.*;
import java.io.*;
import javax.comm.*;
import java.util.*;
/**
*
* @author inzomniac
*/
public class ParallelPortTest
{
static Enumeration portList;
static CommPortIdentifier portId;
ParallelPort parallelPort;
/** Creates a new instance of ParallelPortTest */
public ParallelPortTest()
{
try
{
parallelPort = (ParallelPort) portId.open("Parallel", 2000);
try
{
parallelPort.setMode(ParallelPort.LPT_MODE_SPP);
parallelPort.getOutputStream().write(256);
System.out.println("Mode: " + parallelPort.getMode());
System.out.println(parallelPort.getOutputBufferSize());
}
catch (IOException ex)
{
ex.printStackTrace();
}
catch (UnsupportedCommOperationException ex)
{
ex.printStackTrace();
}
}
catch (PortInUseException e)
{
e.printStackTrace();
}
}
public static void main(String args[])
{
portList = CommPortIdentifier.getPortIdentifiers();
while (portList.hasMoreElements())
{
portId = (CommPortIdentifier) portList.nextElement();
System.out.println(portId.getName());
if (portId.getPortType() == CommPortIdentifier.PORT_PARALLEL)
{
if (portId.getName().equals("LPT1"))
{
ParallelPortTest ppt = new ParallelPortTest();
}
}
}
}
}
thanks in advance!