B
Brzezi
Hi.
I am trying make paraller port to work under linux using rxtx library for
java, but i have problems:
port is recognized and opened correctly, but i cant read from it :/
It is my simple code:
#v+
<code>
import gnu.io.*;
[...]
CommPortIdentifier portId = null;
try{
portId = CommPortIdentifier.getPortIdentifier("/dev/lp0");
}
catch(NoSuchPortException e){
System.out.println(e);
}
CommPort port = null;
try{
port = portId.open("Tester", 1000);
}
catch(PortInUseException e){
System.out.println(e);
}
InputStream in = null;
try{
in = port.getInputStream();
}
catch(IOException e){
System.out.println(e);
}
try{
System.out.println("Wczytano: " + in.read()); // here is
// thrown exception
}catch(IOException e){
System.out.println(e.getMessage());
}
port.close();
}
</code>
#v-
When I run this code, I get Exception: "Input/output error in readByte"
this exception is thrown in line which I marked...
What is the problem? do you have any solution? or mayby there is any other
library for paraller/serial port?
PS. serial port works fine, when I change "/dev/lp0" to "/dev/ttyS0"
program waits for data to read, doesent throw any exception
Pozdrawiam
Brzezi
I am trying make paraller port to work under linux using rxtx library for
java, but i have problems:
port is recognized and opened correctly, but i cant read from it :/
It is my simple code:
#v+
<code>
import gnu.io.*;
[...]
CommPortIdentifier portId = null;
try{
portId = CommPortIdentifier.getPortIdentifier("/dev/lp0");
}
catch(NoSuchPortException e){
System.out.println(e);
}
CommPort port = null;
try{
port = portId.open("Tester", 1000);
}
catch(PortInUseException e){
System.out.println(e);
}
InputStream in = null;
try{
in = port.getInputStream();
}
catch(IOException e){
System.out.println(e);
}
try{
System.out.println("Wczytano: " + in.read()); // here is
// thrown exception
}catch(IOException e){
System.out.println(e.getMessage());
}
port.close();
}
</code>
#v-
When I run this code, I get Exception: "Input/output error in readByte"
this exception is thrown in line which I marked...
What is the problem? do you have any solution? or mayby there is any other
library for paraller/serial port?
PS. serial port works fine, when I change "/dev/lp0" to "/dev/ttyS0"
program waits for data to read, doesent throw any exception
Pozdrawiam
Brzezi