Saturday, February 04, 2012

Linux, Arduino 1.0 and /dev/ttyACM0

I decided to start working with the Arduino under Linux. I'm writing code to make an Arduino work as an HCS II Comm-Link (part of my gHCS project). I need to add a RS485 chip and some circuitry but I can test the code with RS232.

I grabbed and load the Arduino IDE but quickly found that the Arduino Linux package doesn't have the avr-gcc & avr-g++ compiler environment. Those I needed to add separately. I'm using Debian, so I used aptitude and installed the avr compiler environment. The Arduino IDE is a usable IDE but it's not Emacs (oh no! Emacs! ;-) ). The good news is that the Arduino folks allow you to use an external editor. So I start up Emacs, load Arduino-mode and edit the ino file (I'm running Arduino 1.0). To compile, I save my changes in Emacs then switch over to the Arduino IDE and verfiy. One problem I have run into is that the Arduino IDE doesn't like to be put into the background (it will hang). I'm not sure why this is. Also the Emacs Arduino-mode has a problem with quotes (^G will get it unstuck). I'll work on that later. Uploading the code to the Arduino had me stuck for a while. When I plugged in the Uno R3 the USB device installed as /dev/ttyACM0 but the rxtx Java library, that the Arduino IDE uses, didn't recognize /dev/ttyACM0. So I added the following 2 lines:

 # Sample gnu.io.rxtx.properties
gnu.io.rxtx.SerialPorts=/dev/ttyS0:/dev/ttyS1:/dev/ttyACM0

to the gnu.io.rxtx.properties file (${JAVA_HOME}/jre/lib/ext/gnu.io.rxtx.properties). Now I can code, verify and upload all day long. I hope this helps others who may have gotten stuck or suffered TMI when searching with "fill in your favorite search engine here".

0 Comments:

Post a Comment

<< Home