Closed GoogleCodeExporter closed 9 years ago
m_PortIdentifyer.open("Modbus Serial Master", 30000) crashes JVM if serial
device file doesn't exist. Probably some defect in serial library...
I prepared small workaround for this issue.
Before calling m_PortIdentifyer.open("Modbus Serial Master", 30000) we need to
check that device file exists in file system. One more important thing is that
we need to check wherever it is Linux. Not sure about Windows - I don't have it.
It's pretty ugly (I added comment about it) but I don't see another way how to
handle it...
So code (SerialConnectiom.java):
public void open() throws Exception {
+ // If this is Linux then first of all we need to check that
+ // device file exists. Otherwise call to m_PortIdentifyer.open()
+ // method will crash JVM.
+ // It is ugly patch but it is too late...
+ if (SystemUtils.IS_OS_LINUX) {
+ File portDevFile = new File(m_Parameters.getPortName());
+
+ if (!portDevFile.exists()) {
+ throw new Exception("Modbus serial device " +
+ m_Parameters.getPortName() + " doesn't exist!");
+ }
+ }
I tested it trying to plug/unplug USB modbus master. Device unplugging doesn't
crash Openhub. After plugging USB master - Openhub restores connection to it.
So it works pretty well.
I cannot create my own server side clone of openhab
(https://groups.google.com/forum/#!topic/openhab/fi6Y_O-2rok) so added patch
file instead (see attachments).
How and to whom can I show it?
P.S.
I'm not Java programmer - C++.
Original comment by igor.zel...@gmail.com
on 2 Sep 2013 at 7:07
Attachments:
Proposed patch is for Linux only.
If somebody uses modbus binding and USB rs485 (modbus) master under mac
os/windows: check it please there as well.
For future:
If problem will occur under Mac OS then line: if (SystemUtils.IS_OS_LINUX) {
Should be replaced with: if (SystemUtils.IS_OS_UNIX) {
SystemUtils.IS_OS_UNIX covers both of Linux and Mac OS. Of course it will
require testing. That is why I restricted it to Linux only.
If problem will occur under Windows then it will require separate workaround
(check if USB device exist at the moment).
Original comment by igor.zel...@gmail.com
on 2 Sep 2013 at 9:53
This has been fixed with 1.3.0 with changeset
https://code.google.com/p/openhab/source/detail?r=d5852603d140cba796afff1c6eac58
423ccdae3a
Original comment by kai.openhab
on 14 Sep 2013 at 9:03
Original issue reported on code.google.com by
igor.zel...@gmail.com
on 1 Sep 2013 at 6:10