[Rxtx] Baud rate problem
Mike Markowski
mike.ab3ap at gmail.com
Sat Apr 28 20:54:56 MDT 2012
Andy and all,
It works fine with minicom as well as my own C code and Java using rxtx
2.1.7. I tried to make a minimal example which is tacked on below.
Here is output running the same program but first using 2.1.7r2 and then
2.2-2:
mm at ab3ap ~/baudTest $ java -classpath "217/RXTXcomm.jar:."
-Djava.library.path=217 Baud
Experimental: JNI_OnLoad called.
Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version = RXTX-2.1-7
RXTX Warning: Removing stale lock file. /var/lock/LCK..ttyUSB0
RVM04.39;
mm at ab3ap ~/baudTest $ java -classpath "222/RXTXcomm.jar:."
-Djava.library.path=222 Baud
WARNING: RXTX Version mismatch
Jar version = RXTX-2.2pre1
native lib Version = RXTX-2.2pre2
Unsupported comm op.
[Never returns here till I hit a ctrl-C]
And the code is below. (The RVM command returns firmware version.)
Many thanks for your ideas.
Mike
import gnu.io.*;
import java.io.*;
public class Baud {
public static void main(String args[]) throws Exception {
CommPortIdentifier portId
= CommPortIdentifier.getPortIdentifier("/dev/ttyUSB0");
SerialPort sport
= (SerialPort) portId.open("Baud rate test", 2000);
sport.setSerialPortParams(38400, SerialPort.DATABITS_8,
SerialPort.STOPBITS_2, SerialPort.PARITY_NONE);
sport.setFlowControlMode(SerialPort.FLOWCONTROL_NONE);
sport.setRTS(false);
sport.setDTR(false);
InputStream is = sport.getInputStream();
OutputStream os = sport.getOutputStream();
os.write("RVM;".getBytes());
Thread.sleep(100);
byte[] response = new byte[16];
is.read(response);
System.out.println(new String(response, 0, 9));
sport.close();
}
}
On 04/28/2012 09:15 PM, Andy Eskelson wrote:
> It is highly unlikely that 38400 would not be supported, it's a standard
> bitrate.
>
> If in doubt, this can be tested via minicom which is a perfectly good
> terminal program. very basic, very like the old DOS procom terminal.
>
> If you have never run this before, run as root, that makes things
> easier. ctl-A Z O will get to the setup screen. then you can select
> device, and bitrates.
>
>
> If you want to run as a normal user, then if I remember correctly you
> need to run as root first, then save the config file in the users
> home directory. After that i6t will run as a nor5mal users (providing the
> user is a member of the correct groups. uucp, and dialout (depends on
> distro)
>
>
> Andy
More information about the Rxtx
mailing list