participate


Java Desktop Applications - javax.comm v.3 IOException in Linux 2.6.12 [Locked]
This topic is locked
<<   Back to Forum  |   Give us Feedback Topics: « Previous | Next
This topic has 30 replies on 3 pages.    1 | 2 | 3 | Next »
MarceloFernandez
Posts:1
Registered: 10/17/05
javax.comm v.3 IOException in Linux 2.6.12   
Oct 17, 2005 4:10 PM

 
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.

Thanks!
Marcelo
 
andrejFurlan
Posts:1
Registered: 10/22/05
Re: javax.comm v.3 IOException in Linux 2.6.12   
Oct 22, 2005 6:07 AM (reply 1 of 30)  (In reply to original post )

 
I get the same (similar) error:

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");
}
 
i_hate_commapi
Posts:7
Registered: 9/17/05
Re: javax.comm v.3 IOException in Linux 2.6.12   
Oct 25, 2005 2:07 AM (reply 2 of 30)  (In reply to #1 )

 
sleep still does not help:

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_hate_commapi
Posts:7
Registered: 9/17/05
Re: javax.comm v.3 IOException in Linux 2.6.12   
Oct 25, 2005 1:46 PM (reply 3 of 30)  (In reply to #1 )

 
Hi! I got a different SOLUTION, but I can't explain it:
The code below works only with System.out.println() but not with Threed.sleep(10) ;(

/
Constructor declaration


@see
*/
public SimpleRead() {
try {
serialPort = (SerialPort) portId.open("SimpleRead", 2000);
} catch (PortInUseException e) {}

try {
inputStream = serialPort.getInputStream();
} catch (IOException e) {}

try {
serialPort.addEventListener(this);
} catch (TooManyListenersException e) {}

serialPort.notifyOnDataAvailable(true);

try {
System.out.println("setSerialPortParams()");
serialPort.setSerialPortParams(9600, SerialPort.DATABITS_8,
SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
System.out.println("ok");
} catch (UnsupportedCommOperationException e) {}

readThread = new Thread(this);

readThread.start();
}

Linux hp 2.6.9-1.667 #1 Tue Nov 2 14:41:25 EST 2004 i686 i686 i386 GNU/Linux
 
RickKnight
Posts:1
Registered: 10/28/05
Re: javax.comm v.3 IOException in Linux 2.6.12   
Oct 28, 2005 8:03 PM (reply 4 of 30)  (In reply to #3 )

 
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.

Maybe this will work for you.
RickKnight
 
mirceapop
Posts:9
Registered: 4/8/01
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

Does anyone know a workarround?

Thanks,
Mircea
 
Przemek_Krygier_KCE
Posts:1
Registered: 1/26/06
Re: javax.comm v.3 IOException in Linux 2.6.12   
Jan 26, 2006 1:00 AM (reply 6 of 30)  (In reply to original post )

 
My solution is quite simple, the code used in SerialDemo:

try {

sPort.setSerialPortParams(parameters.getBaudRate(),
parameters.getDatabits(),
parameters.getStopbits(),
parameters.getParity());
} catch (UnsupportedCommOperationException e) {
parameters.setBaudRate(oldBaudRate);
parameters.setDatabits(oldDatabits);
parameters.setStopbits(oldStopbits);
parameters.setParity(oldParity);

throw new SerialConnectionException("Unsupported parameter");
}

caused an Runtime IOException:
java.io.IOException: Not all params are supported by kernel

so we can just add another catch block:

catch (Exception e ) {
parameters.setBaudRate(oldBaudRate);
parameters.setDatabits(oldDatabits);
parameters.setStopbits(oldStopbits);
parameters.setParity(oldParity);
System.out.println( e );
}

it's a dirty Exception handling, but I only intend to show the solution ..
 
Trebiani
Posts:5
Registered: 4/26/05
Re: javax.comm v.3 IOException in Linux 2.6.12   
Feb 21, 2006 6:02 AM (reply 7 of 30)  (In reply to #3 )

 
hi!

i have to use the same workaround here:
a System.out.println(""); right befor calling the setSerialPortParams(...) method. this is very strange.

@sun.com: please help us with this strange problem!

some system informations:
java version "1.5.0_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode, sharing)
 
Ubuntu Linux: Linux herakles 2.6.12-10-386 #1 Mon Feb 13 12:13:15 UTC 2006 i686 GNU/Linux
 
fervic
Posts:2
Registered: 3/20/06
Re: javax.comm v.3 IOException in Linux 2.6.12   
Mar 20, 2006 8:21 AM (reply 8 of 30)  (In reply to #7 )

 
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.
 
maherhome
Posts:2
Registered: 4/28/06
Re: javax.comm v.3 IOException in Linux 2.6.12   
Apr 28, 2006 6:12 AM (reply 9 of 30)  (In reply to #8 )

 
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.

This is 1.5_06 on 2.4.27bigphysmem.

			try {
				fSerialPort.setSerialPortParams(fBaudRate, fDataBits,
						fStopBits, fParity);
			} catch (Exception e) {
				//  ignore					
			}
			
			fSerialPort.setSerialPortParams( 
					fBaudRate, fDataBits, fStopBits, fParity );	


Steve
 
jcrada@gmail.com
Posts:2
Registered: 7/11/06
Re: javax.comm v.3 IOException in Linux 2.6.12   
Jul 11, 2006 9:57 PM (reply 10 of 30)  (In reply to original post )

 
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...

Good luck!

Juan Rada
 
jcrada@gmail.com
Posts:2
Registered: 7/11/06
Re: javax.comm v.3 IOException in Linux 2.6.12   
Jul 11, 2006 10:13 PM (reply 11 of 30)  (In reply to original post )

 
Localized a weird solution...

Like I said before, go to the SerialConnection.java and comment the try-catch that calls setConnectionParameters()...

The weird thing is that it works only when I run the file SerialDemo.java. NOT when I Run the Main Project!!!

Still working on it....

Juan Rada.
 
Jose_Santa
Posts:1
Registered: 7/18/06
Re: javax.comm v.3 IOException in Linux 2.6.12   
Jul 18, 2006 7:25 AM (reply 12 of 30)  (In reply to #11 )

 
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.

OS: Linux Fedora Core 5
JDK 1.5.0_07
 
pkskar1
Posts:1
Registered: 8/5/06
Re: javax.comm v.3 IOException in Linux 2.6.12   
Aug 5, 2006 4:39 AM (reply 13 of 30)  (In reply to #12 )

 
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.
 
Cristinziani
Posts:10
Registered: 1/26/00
Re: javax.comm v.3 IOException in Linux 2.6.12   
Aug 5, 2006 12:44 PM (reply 14 of 30)  (In reply to #13 )

 
Hello,

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 »
Back to Forum
 
Read the Developer Forums Code of Conduct

Click to email this message Email this Topic

Edit this Topic
  
 
 
Forums Statistics
    Users Online : 58
  • Guests : 111

About Sun forums
  • Sun Forums is a large collection of user generated discussions. It is here to help you ask questions, find answers, and participate in discussions.

    Check out our guide on Getting started with Sun Forums for a full walkthrough of how to best leverage the benefits of this community.

Powered by Jive Forums