Nanou said:
Hello
It's a machine made by an enterprise and this machine is connected to a
serial port of a PC.
The protocol is specified to this machine.
Under windows no problem to use the machine
My code is :
RXTXCommDriver driver = new RXTXCommDriver();
driver.initialize();
SerialPort port = driver.getCommPort("/dev/ttyS0", 1);
port.setInputBufferSize(32);
port.setOutputBufferSize(32);
port.setRTS(false);
port.enableReceiveTimeOut(1000);
InputStream is = port.getInputStream();
OutputStream os = port.getOutputStream();
ReadableByteChannel in = Channels.newChannel(is);
WritableByteChannel out = Channels.newChannel(os);
ByteBuffer buffer = ....
out.write(buffer);
ByteBuffer response = ByteBuffer.allocate(32);
in.read(response);
I would suggest testing it without the channels and see if you can see
the data just using the input and output streams. I'd bet your problem
has to do with the use of channels.
I'm a little confused as well because your error message below seems to
indicate that you are using JDK1.2.0_01, but channels were not
introduced until JDK1.4.
Also, i tried to use javax.comm for linux and i have the following
error:
Error loadingSolarisSerial: java.lang.unsatisfiedLinkError:
/usr/local/jdk1.2.0_01/jre/lib/i386/libSolarisSerialParallel.so:
libc.so.1 cannot open shared object file: no such file or directory
On my pc i have libc.so.6 and i can't use it.
Where can i found it ??
Looks like you didn't follow the directions for installing the JCL with
RXTX. It looks like you installed all of the Solaris implementation of
JavaComm. According to the directions for JCL the only part of the
Solaris JavaComm is the Jar file. You don't need the .so file which is
part of your error message. You also don't want the
javax.comm.properties file that came with the Solaris JavaComm. It needs
to be replaced with one that points to the RXTXCommDriver. It's all
spelled out in the install instructions here:
http://www.geeksville.com/~kevinh/linuxcomm.html
However, I recommend against using the JavaComm API at all. Sun wanted
to make it some kind of standard, but they implemented it in a very
stupid way (which makes it difficult to use it with WebStart apps), left
bugs in it, did not create a Linux version, and they have refused to
touch the thing since JDK 1.1 days. I say everyone should forget Sun's
API and we should standardize on the gnu.io.rxtx API.