RXTX Disconnecting/Intermittent Communication

Real quick post:

So I am working with RXTX (Windows 7, 64-bit), and just wanted to quickly point out a few things. I am working with the JY-MCU serial bluetooth module, and was experiencing a lot of difficulty connecting to it via RXTX. Well, turns out the solution was pretty simple, and connecting is much better now. The key was this line:

commPort.enableReceiveTimeout(500);

Place that line right after

CommPort commPort = portIdentifier.open(this.getClass().getName(),2000);

And everything should work great (did for me, anyway). I found this solution in an e-mail thread found here.

On a related note, if anyone is having difficulty compiling and running RXTX in a system similar to mine (I really should be using a Linux distro for this, but oh well), here’s what I did:

1. Go to http://www.cloudhopper.com/opensource/rxtx/ and download the necessary files (choose x64 if you are on 64-bit like me)
2. Navigate to your JRE directory (i.e. for me it is … C:Program FilesJavajdk1.6.0_21jre)
3. Place rxtxSerial.dll in bin
4. Place RXTXcomm in libext

Compile your code as you normally would (i.e. javac SerialIO.java), and hopefully everything should work just right!

Good luck!

Edit: Here is the complete code (99% based on example) in case you need it:

Posted in Mini Tuts

Leave a Reply

Your email address will not be published. Required fields are marked *