[Rxtx] Baud rate problem
Mike Markowski
mike.ab3ap at gmail.com
Sun Apr 29 09:25:42 MDT 2012
You're right, Andy, that it should have been 1 stop bit and has been
changed - 2 was left over from another device. But here is something
interesting that I missed last night (probably I compiled for 2.2-2 but
against 2.1.7 RXTXcomm.jar). When compiling and running for 2.1.7 all
is exactly the same as previously reported even after changing stop bits
to 1. But when compiling with 2.2-pre2 and running:
mm at ab3ap ~/baudTest $ javac -classpath "222/RXTXcomm.jar:." Baud.java
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
RXTX Warning: Removing stale lock file. /var/lock/LCK..ttyUSB0
Exception in thread "main" gnu.io.UnsupportedCommOperationException:
Invalid Parameter
at gnu.io.RXTXPort.setSerialPortParams(RXTXPort.java:211)
at Baud.main(Baud.java:13)
where line 13 is the setSerialPortParams() call. When I change the
baud rate to 9600 and compile/run:
mm at ab3ap ~/baudTest $ $ jac -classpath "222/RXTXcomm.jar:." Baud.java
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
RXTX Warning: Removing stale lock file. /var/lock/LCK..ttyUSB0
there is no 'Invalid parameter' error, though it can't communicate at
that baud rate. I wonder if the same errors can be reproduced by others
even with no device ready to communicate on the port.
My machine is:
mm at ab3ap ~ $ uname -a
Linux ab3ap 3.3.3-gentoo #1 SMP Tue Apr 24 17:14:12 EDT 2012 i686
Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz GenuineIntel GNU/Linux
Later today I'll download the source and start looking around. TIll now
I've been using the rxtx binaries.
Thanks,
Mike
On 04/29/2012 08:19 AM, Andy Eskelson wrote:
> Stopbits_2 is rather unusual might be worth checking.
>
>
> Andy
>
>
> On Sat, 28 Apr 2012 22:54:56 -0400
> Mike Markowski<mike.ab3ap at gmail.com> wrote:
>
>> 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();
>> }
>> }
More information about the Rxtx
mailing list