CANSU
Posts: 1
Nickname: cansu
Registered: Jan, 2003
|
|
parallelport
|
Posted: Jan 22, 2003 4:11 PM
|
|
hi! I ve a very big problem ..i want to control a steppermotor with java.but firstly i have to succeed in sending some data to parallel port with below codes . this program is compiled and when i run it, doesn t give any error.but i m sure that there is some problem in that line --> DOSone.write(5);
I tested with assembly.and i saw that this codes have mistake.because no data were sent to parallel port ,after program run(actually, 5 must be sent).But as i sad, there is no error while compiling or running.if you look and find where the mistake is,i ll be so happy..bacause this is my term project.. thanks a lot..
import java.io.*; import java.util.*; import javax.comm.*; import java.lang.*;
class ParallelWrite { static Enumeration portListesi; static CommPortIdentifier portId; static ParallelPort parPort; static OutputStream outputstream; static OutputStreamWriter DOSone;
public static void main (String arg[]) { portListesi = CommPortIdentifier.getPortIdentifiers(); while (portListesi.hasMoreElements()) { portId = (CommPortIdentifier) portListesi.nextElement(); if((portId.getPortType()==CommPortIdentifier.PORT_PA RALLEL)&&((portId.getName()).compareTo("LPT1")==0)) { try { parPort = (ParallelPort) portId.open("Parallel Test", 3000);
try { DOSone = new OutputStreamWriter(parPort.getOutputStream()); }catch(IOException e){} try { DOSone.write(5); DOSone.close(); parPort.close(); }catch(IOException e){}
} catch (PortInUseException e) { System.err.println(e.toString()); System.exit(1); } } } } }
|
|