Search code examples
serial-portrxtx

Serial Port Comunication RXTX


I am working on a project for work that opens 4 serial ports and assigns each to a new (identical) object initially (tab). Each of these tabs can close their individual port and can open any free port by selection in a drop down box, setting the parameters using radio buttons, and open the selected free port. Once the port is open the user can click a selection of buttons and send a binary string down the port. This is not my issue. This I have working and have included only for context and framing of my question.

My question is in regards to the rxtxSerial.dll library. I have tried several versions of this file (2.1-7, 2.2-3, 2.2-4, etc) and the corresponding RXTXcomm.jar file and it runs on my test computer (which only has two serial ports available) but when I run it on the computer with four serial ports I get this error message:


Java(TM) Platform SE binary has stopped working

Problem signature:
Problem Event Name: BEX
Application Name: java.exe
Application Version: 7.0.510.13
Application Timestamp: 52b26621
Fault Module Name: rxtxSerial.dll
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 4c2d952a
Exception Offset: 00007ef2
Exception Code: c0000417
Exception Data: 00000000
OS Version: 6.1.7600.2.0.0.256.48
Locale ID: 1033
Additional Information 1: 5844
Additional Information 2: 584492d8ff48ad655801e1ea86dce8ff
Additional Information 3: c3f6
Additional Information 4: c3f694d7fdd57adf7aa97e597a203712


My question is: Has anyone had this error and found a way to fix it? I am using the 32-bit version of RXTXcomm, Java 1.7(x86), and Windows 7 OS. I have tried to put this in the running directory of the project, as well as the 'C:\Program Files (x86)\Java\jre7\bin'. Which if that was the problem I would be getting a linker error (which I have fixed in the past).

Update 1

I have found a way to make this work. What I did was use the rxtx version 2.1-7 for the jar and the .dll's. The way I fixed it was I added a Thread.sleep(3000) between where the input/output streams were closed and where the serial port itself was closed. The issue was that they were not fully closing before the serial port was being closed. Now the issue I have is that the rxtx function 'isCurrentlyOwned()' always returns false.

Update 2

I have found the answer I needed in a rxtx library that was fixed on github by Bart Prokop: https://github.com/bartprokop/rxtx. This library does everything I need it to. The way I used this was instead of using the rxtx 2.1-7 jar I downloaded this project and pasted the gnu folder in my main directory of my project and used it as a source rather than a jar file. Also, on a side note, when speaking with the user I was informed that he would be releasing a stable release in about three weeks.


Solution

  • I had the same problem and posted on the RxTx mailing list. It is a serious bug that has not been fixed. The libraries have not been updated in a while. Your best option is to switch to PJC. Many people have reported benefits to PJC. see https://github.com/nyholku/purejavacomm and http://www.sparetimelabs.com/purejavacomm/purejavacomm.php The creator is very responsive and helpful.