Open deepakahuja opened 9 years ago
Please turn on the logging to see the actual reason why the port is closed.
See here:
https://github.com/nyholku/purejavacomm/wiki/Trouble-shooting
Hi,
First of all thanks for the prompt reply.
I turned on the logging but the sender & receiver threads stopped immediately with following exception. But this exception was with log level 3 or 4 or 5 or 6 or 7. With log level 1 or 2 we got the same result that is also mentioned below:
With log level 3 or 4 or 5 or 6 or 7 :
2015-09-30 17:56:52,523 INFO [com.csc.opuslab.is.drivers.instrumentdrivers.Test.Test.jt workReceiver.InstrumentAdaptor] Driver start
2015-09-30 17:56:52,523 FATAL [com.csc.opuslab.is.drivers.instrumentdrivers.Test.Test.jt workReceiver] Driver version string: com.csc.opuslab.is.drivers.instrumentdrivers.Test.Test: 1.1(4)-1.1(1)
2015-09-30 17:56:53,101 FATAL [com.csc.opuslab.is.drivers.instrumentdrivers.Test.Test.jt workReceiver.InstrumentAdaptor] Error initializing SerielPortCommunicationDevice. Port: COM11
java.util.IllegalFormatConversionException: x != java.lang.String
at java.util.Formatter$FormatSpecifier.failConversion(Formatter.java:4045)
at java.util.Formatter$FormatSpecifier.printInteger(Formatter.java:2748)
at java.util.Formatter$FormatSpecifier.print(Formatter.java:2702)
at java.util.Formatter.format(Formatter.java:2488)
at java.util.Formatter.format(Formatter.java:2423)
at java.lang.String.format(String.java:2797)
at jtermios.JTermios$JTermiosLogging.log(JTermios.java:633)
at jtermios.JTermios.ioctl(JTermios.java:446)
at purejavacomm.PureJavaSerialPort.
And with log level 1 or 2, we got failed with same exception as mentioned in my first comment but a little logging was there on weblogic console as mentioned below:
<30-09-2015 18:05:55 CEST>
jtermios.windows.JTermiosImpl$Fail at jtermios.windows.JTermiosImpl$Port.fail(JTermiosImpl.java:100) at jtermios.windows.JTermiosImpl.select(JTermiosImpl.java:863) at jtermios.JTermios.select(JTermios.java:467) at purejavacomm.PureJavaSerialPort$3.run(PureJavaSerialPort.java:1222) at java.lang.Thread.run(Thread.java:744) log: select() or poll() returned -1, errno 24 Exception in thread "Thread-26" purejavacomm.PureJavaIllegalStateException: File descriptor is -1 < 0, maybe closed by previous error condition at purejavacomm.PureJavaSerialPort.failWithIllegalStateException(PureJavaSerialPort.java:1285) at purejavacomm.PureJavaSerialPort.checkState(PureJavaSerialPort.java:1290) at purejavacomm.PureJavaSerialPort.access$0(PureJavaSerialPort.java:1288) at purejavacomm.PureJavaSerialPort$1.write(PureJavaSerialPort.java:627) at purejavacomm.PureJavaSerialPort$1.write(PureJavaSerialPort.java:653) at com.csc.opuslab.is.drivers.communication.devices.SerialPortCommunicationDevice.send(SerialPortCommunicationDevice.java:391) at com.csc.opuslab.is.drivers.instrumentdrivers.Test.Test.run(Test.java:74) at java.lang.Thread.run(Thread.java:744)
Hi, Is there any update on the issue reported? Regards Deepak
Hi,
I've not had time to look at this and it will be some time before I do. Have you tried an earlier version like 0.0.22 after which a lot changes were made, Would be interesting to know if those changes are causing the problem.'
Actually, something just caught my eye in the log you provided.
It appear that in JTermios.java line 446 there is a problem that only appears when logging is turned on and which renders the logging useless:
It now reads:
log = log && log(5, "> ioctl(%d,%d,[%08X])\n", fd, cmd, Arrays.toString(data));
int ret = m_Termios.ioctl(fd, cmd, data);
log = log && log(3, "< ioctl(%d,%d,[%08X]) => %d\n", fd, cmd, Arrays.toString(data), ret);
it should be
log = log && log(5, "> ioctl(%d,%d,[%s])\n", fd, cmd, Arrays.toString(data));
int ret = m_Termios.ioctl(fd, cmd, data);
log = log && log(3, "< ioctl(%d,%d,[%s]) => %d\n", fd, cmd, Arrays.toString(data), ret);
Note the %08X should be %s. Please do that change in the code and rerun with the log enabled. The log you provided is wrong/bad because of that bug.
br Kusti
Hi,
is there any update on this issue? Since we are using this library in our development tool, it would be nice to know when we can expect an update, if ever ;)
We are facing the same problems on windows 10. There seem to be an exception from jtermios.windows.JTermiosImpl$Fail thrown when removing a device from the USB port.
It works for windows 7 for us.
Best regards, Thomas
it'd be useful for us also to fix this issue. is there any progress? thanks
I really don't have much time to work on this right now.
I would have appreciated it if 'deepakahuja ' had reported back with the log fix in place, now the log is useless.
Also it appears 'tkutz' has different problem because he/she has this problem when unpluggin a device.
Since I do NOT experience this problems (and I've got no Windows 10) it is hard for me to debug this.
Contributions in the form of debugging would be more than welcome, after all this is open source and Java so easy to debug, this is really the point of this library ... while I'm happy to work on this when I have the time, if I had problems with this and this was not my project I would just dig in deep to find the problem and not expect the author to do my work for me....
Hi Guys,
Sorry! We put this ticket on hold for some priority work. So, do not have updated logs. But I will be back with logs as soon as we start working on this again.
Closing this as there is nothing to do ATM. Please feel free to open anytime.
I am having the same issue - please reopen this issue for discussion.
Please provide more details.
The exception is misleading and you might want to change it's wording. In my case it happened simply because there was no connection. I was using an USB to serial converter an the USB cable was not plugged in. I'll try to setup the circumstances again to see if things are reproducible. For the time being my workaround will be to display a different message to my users.
How do you mean it is misleading, can you suggest a better wording?
IMHO it's better to do it like logging frameworks do it. In the sourc code checkstate() is called at different points e.g. https://github.com/nyholku/purejavacomm/blob/master/src/purejavacomm/PureJavaSerialPort.java#L127
so the call is from addEventListener .. if you change the function to checkState(msg) and call it with checkState("addEventListener") you can now create a message like: IllegalStateException: can't addEventListener while closed (maybe by previous error condition)
So instead of giving the internals about the encoding of the error flag I'd give more information on the context. E.g. "can't write while closed ..."
Is there some logging framework that can trace when a close is forced by an error condition?
Now I understand your suggestion. But the same information is available from the stacktrace of isn't it?
Loggin can be enabled like this:
https://github.com/nyholku/purejavacomm/wiki/Trouble-shooting
Did I miss something, the latest code doesnt seem to have this fix? or is the a new branch some place? The master branch doesnt seem to be setup for 1.0.2 even though maven has it listed.
Fix for what, a lot things were discussed in this thread?
The fix to change the error thrown to an IOException. Also the code files dont seem to reflect the change to 1.0.2 as the version, and the releases tab does not show that release. The pom.xml still reports 1.0.1 thus I was asking if the code moved to some other repo to got closed sourced for that version?
Hi,
I am getting following exception while using purejavacomm API for serial port communication. I have a Test class which receive & also send some data over serial port. I have used a MOXA device to send data from one serial port & receive data on another serial port. At both the ends i.e. sender & receiver the same Test class is used. It does not fail in first attempt but after sending & receiving some data may be after 10/15 minutes. Until 10/15 minutes, both sender & receiver communicate with each other using same method but after that receiver usually stops & we can see following exception. The version that we are using of purejavacomm is 28 & JNA is 4.0. Please help.
purejavacomm.PureJavaIllegalStateException: File descriptor is -1 < 0, maybe closed by previous error condition at purejavacomm.PureJavaSerialPort.failWithIllegalStateException(PureJavaSerialPort.java:1289) at purejavacomm.PureJavaSerialPort.checkState(PureJavaSerialPort.java:1294) at purejavacomm.PureJavaSerialPort.access$0(PureJavaSerialPort.java:1292) at purejavacomm.PureJavaSerialPort$1.write(PureJavaSerialPort.java:631) at purejavacomm.PureJavaSerialPort$1.write(PureJavaSerialPort.java:657)
Regards Deepak