Serial communication with an Arduino Uno on Linux with Java

I have an Arduino Uno that I want to use to drive a LED banner sign which posts messages from IRC. Accessing the serial port from Java on a Dockstar with Debian proved to be somewhat of a challenge.

Normally, you would be able to access the device with RXTX using something like

Enumeration portEnum = CommPortIdentifier.getPortIdentifiers();

and then pick the right CommPortIdentifier. This works perfectly for an Arduino NG that is also connected to the Dockstar and turns up as /dev/ttyUSB0. However, the Uno connects as /dev/ttyACM0 and the aforementioned command does not return that comm port.

After lots of checking, reconnection, fretting, minicom, more fretting and googling the solution turned out to be ridiculously simple: just create a symlink to /dev/ttyACM0 using the /dev/ttyUSB* naming scheme:

ln -sf /dev/ttyACM0 /dev/ttyUSB1

And presto!, getPortIdentifiers() returns both /dev/ttyUSB0 and /dev/ttyUSB1, the latter representing the Uno, and the LED banner is up and running!

 

  • Facebook
  • LinkedIn

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>