Hello, I was trying the latest version of javax.comm in Linux (this is the first release for this OS). But I get this IOException when I open /dev/ttyS0 in SerialDemo (as root):
kronos:/home/marcelo/src/commapi/examples/SerialDemo# java SerialDemo
Exception in thread "AWT-EventQueue-0" java.io.IOException: Not all params are supported by kernel
at com.sun.comm.LinuxSerial.nativeSetSerialPortParams(Native Method)
at com.sun.comm.LinuxSerial.setSerialPortParams(LinuxSerial.java:346)
at SerialConnection.setConnectionParameters(Unknown Source)
at SerialConnection.openConnection(Unknown Source)
at SerialDemo.actionPerformed(Unknown Source)
at java.awt.Button.processActionEvent(Button.java:388)
at java.awt.Button.processEvent(Button.java:356)
at java.awt.Component.dispatchEventImpl(Component.java:3955)
at java.awt.Component.dispatchEvent(Component.java:3803)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
I'm running Debian Testing, linux kernel version 2.6.12-1-686, JDK 1.5.0_04 and running 1.4.2_07 I also get this error.
Maybe I should post this as a bug, but I wanted some feedback from you first.
java.io.IOException: Not all params are supported by kernel
at com.sun.comm.LinuxSerial.nativeSetSerialPortParams(Native Method)
at com.sun.comm.LinuxSerial.setFlowControlMode(LinuxSerial.java:374)
at ............................................
System: CentOS 4.2 Linux
kernel: 2.6.9-22.EL
JRE: 1.4.2_09-b05
CommAPI: 3.0_u1 Linux
SOLUTION: Sleeping for a while between a call to setSerialPortParams() and setFlowControlMode()! After some experimenting I found out that sleeping for 1ns (yes, nanosecond!) is enough to eliminate the error. Very, very strange...
The code:
try {
sPort.setSerialPortParams(baudRate, dataBits, stopBits, parity);
}
catch (UnsupportedCommOperationException e) {
LOG.error("setConnectionParameters()", e);
throw new SerialConnectionException("Unsupported connection parameters!");
}
// Set flow control:
try {
// If we do not delay for a while,
// there are great chances for errors like: "Parameters not supported by kernel"!!!:
try {
Thread.sleep(10);
}
catch (InterruptedException e) {
e.printStackTrace();
}
sPort.setFlowControlMode(flowControl);
}
catch (UnsupportedCommOperationException e) {
System.out.println("Unsupported flow control = "+flowControl);
LOG.error("setConnectionParameters()", e);
throw new SerialConnectionException("Unsupported flow control");
}
Simple]$ java -Djava.library.path=/usr/lib -cp .:/opt/commapi/jar/comm.jar SimpleRead /dev/ttyS0
Found port: /dev/ttyS0
Exception in thread "main" java.io.IOException: Not all params are supported by kernel
at com.sun.comm.LinuxSerial.nativeSetSerialPortParams(Native Method)
at com.sun.comm.LinuxSerial.setSerialPortParams(LinuxSerial.java:346)
at SimpleRead.<init>(SimpleRead.java:107)
at SimpleRead.main(SimpleRead.java:75)
Simple]$ uname -a
Linux xpc 2.6.10-1.770_FC2smp #1 SMP Sat Feb 26 21:54:45 EST 2005 i686 i686 i386 GNU/Linux
I was getting the same error on just one of two nearly identical systems. One of the few differences between the two machines was the java version. The working machine has j2sdk1.4.2_09. The non-working machine had j2sdk1.5. I removed the 1.5 and replaced it with 1.4.2_09 and now my app works.
Re: javax.comm v.3 IOException in Linux 2.6.12
Nov 3, 2005 3:48 AM
(reply 5
of 30) (In reply to
#4 )
Hi,
I have the same problem with jre 1.5.0. I have switched on jre 1.4.2_09 but now a get another error:
java.lang.RuntimeException:
Error opening "/dev/ttyS0"
tcgetattr(): Input/output error
at com.sun.comm.LinuxDriver.getCommPort(LinuxDriver.java:66)
at javax.comm.CommPortIdentifier.open(CommPortIdentifier.java:369)
at
I have the exact same problem, tried the workarounds you mentioned but with no success.
What I'm trying to do is connect my PC to my phone over Bluetooth. The phone is on virtual serial port /dev/rfcomm0
I used: rfcomm bind 0 XX:XX:XX:XX 3 ... (where XX..:...XX is the phone address).
I first had some trouble making the API find this port. But after editing the javax.comm.properties file so that this /dev/rfcomm0 appears second in the serial ports list, it finally finds it.
Now that everything seems to be ok I tried to run that SerialDemo.java and it establishes the connection with the phone, but then it throws the exception.
The same happens when I try to run another sample I got from the jsmsengine api (www.jsmsengine.org).
PD. When I use minicom, I can communicate with the cell-phone flawlessly. So it must be something wrong with the javax.comm API.
If I call the setSerialPortParams twice, the first time catching and ignoring exception, it works for me. (The second call works successfully)
The idea came when running the BlackBox demo. The first time you set the parity you get the "not all params are supported by kernel" exception. After that, it works fine.
FOUND A SOLUTION!!!!
Hi, I found a solution under Linux...
In the SerialDemo, go to the openConnection() method and comment the whole try-catch that calls setConnectionParameters()... After you've done this it will work without a problem!...
I just found it... now I'm going to analyze why...
I have the same problem and I cannot solve it using the solutions exposed. There is something true in the error because the communication with my device does not work porperly if I ignore the exception and request a new configuration in the try-catch block.
I also tried in the Fedora Core 4 using the latest javax.comm (commapi-3.0.1) to read a data from the port. I had connected an RS 232 modem to receive message. I was able to connect to the port but unable to read the inbox of the sim kept in that modem. Please can any one help me in getting a solution for reading the message from the inbox of the messages either from Nokia 6610 mobile or Modem with RS 232 connector using Java Programming.
I had similar problems to the one discribed (Exception: some parameters not supported by the kernel), and one of the proposed solutions, the one with the System.out.println( something ) works.
BUT: I still experience some problems with the serial port (/dev/ttySx) and checked this on two different PCs.
I'm trying to interconnnect my old Apple][ via the serial port to the PC. so they can communicate byte per byte.
I have got an older C program which is supposed to do exactly the same as my Java program I'm working on. Now this is funny: If I start the C program first, stop it, kill it and then start the java program, then the java program works fine. But, if I do NOT start the C program first but the java program directly, then my java program does its job for a short while, and then some bytes to the serial port I don't know where these are coming from ???!!!!
Very strange thing.
Anyone experienced similar strange problems ?
This topic has
30
replies
on
3
pages.
1
|
2
|
3
|
Next »