Forum: JRuby How to access serial port - Linux, JRuby 1.7.2, Java 1.8?

Posted by Craig Anderson (cootcraig)
on 2013-01-11 17:52
(Received via mailing list)
<html><body><span style="font-family:Verdana; color:#000000; 
font-size:10pt;"><div><br></div><div>What are my options for using a 
serial port on this setup?<br></div><div><br></div><div>$ jruby 
-v<br>jruby 1.7.2 (1.9.3p327) 2013-01-04 302c706 on Java HotSpot(TM) 
64-Bit Server VM 1.8.0-ea-b71 +indy [linux-amd64]<br><br 
mce_bogus="1"></div></span></body></html>
Posted by Keith B. (keith_b)
on 2013-01-11 19:40
(Received via mailing list)
Craig -

JRuby accesses system resources through the Java Virtual Machine, so the 
question becomes 'how do I access the serial port in Java?'.  I googled 
"java access serial port".  There were several solutions; this one was 
at the top of the list:

http://pharos.ece.utexas.edu/wiki/index.php/How_to...

It discusses using rxtx (http://rxtx.qbang.org/wiki/index.php/Download) 
as a library providing/simplifying access to the serial port.  You 
download the tar ball, install the .so files, and use the .jar file 
included in it.

You can ignore all the instructions relating to Eclipse in any way, 
everything you need to do should be doable on the command line without 
Eclipse.

For a third party jar file, you can just put it somewhere accessible, 
and add its filespec to $CLASSPATH at runtime.  I have an example of 
doing that with an Oracle JDBC jar file in an article at 
http://www.bbs-software.com/blog/2013/01/09/using-....

Then you'll need to call the Java library from your JRuby code.

- Keith

---
Keith R. Bennett
http://about.me/keithrbennett
Posted by Keith B. (keith_b)
on 2013-01-11 19:41
(Received via mailing list)
On further examination, I recommend reading 
http://www.rfc1149.net/blog/2011/12/01/accessing-s.... 
He says that PureJavaComm is better than rxtx, and shows a way to access 
the serial port without any special code at all using sockets and the 
socat utility.

- Keith
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.