• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

RS232 and Java

 
Cory Hartford
Ranch Hand
Posts: 85
Eclipse IDE Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just wanted to share my experience with the ranchers in case someone may have deal with this. It is not readily apparent when googling what someone has to do in order to connect to and communicate with serial ports. Javax.com, from what I understand is deprecated, although people seem to use it with varying degrees of success. The other option that I found was RXTX. I am using Ubuntu 32bit and Eclipse; my need was to use RS232. To use the API, download the Linux/x86 archive from the Downloads page and point your build path to the jar file which resides in the extracted folder. In addition, you have to associate a native .so file with the rxtx.jar file in order for the code to access the OS devices. For whatever reason, the only packed .so files were for 64 bit OS'. Upon running the file I got an ELF (EFL?) error which apparently means I was using a 64bit .so file on a 32 bit machine. I poked around their "toybox" directory and found a Linux 386 .so file that you can find here. Point to that .so file in the rxtx.jar file in hte native code path (In eclipse, Project Build Path). After that, I used this example to help me test and learn the API.

In most cases, I would recommend getting a Rs232 to Ethernet Server, assign it an IP and go to town using socket connections. It's a far more flexible solution imo.

In this case, I had a device that had an embedded USB to serial drive so it was connected to a USB port, yet the OS recognized it as a COM port; specifically /dev/ttyUSB0. The rxrtx api helped me access and communicate with the device.


Hope this helps folks!
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15441
41
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for sharing your knowledge.

ELF (Executable and Linkable Format) is a common file format for executable programs and libraries that's used on several Unix-like operating systems, including Linux.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic