Pages: [1]   Go Down
Author Topic: Linux + Processing + Arduino Uno: Serial Issues and a Solution  (Read 1367 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

This is my first post and I felt compelled to put this up because of the amount of problems I've noticed that some folks have had making their Arduino Uno work over USB in linux.  I'm pretty sure its a bug in Processing 1.2.1 because the Arduino IDE 0022 works OK given all the same circumstances.  I'm giving a bit of background on my setup and solution process here, but if you want the short story jump to the summary below the dashed line smiley

I started with a stock install of Ubuntu 10.10 Maverick Meerkat Desktop Edition (with updates downloaded during the install process), Processing 1.2.1, Arduino IDE 0022, running on at Intel-based Dell Vostro1400 laptop.  This laptop dual-boots into WinXP and I have Processing 1.2.1 and Arduino IDE 0022 running perfectly fine in Windows.

Under Windows I wrote a short Processing sketch using the Arduino for Processing libraries (0017).  My Uno has been flashed wth Standard Firmata and was using the original ATMega82 firmware.  Basically, the sketch controls the Uno via USB and makes it flash some colored LEDs.  Nothing fancy and it works just fine on Windows. 

My problems started when I tied to run the same sketch in Ubuntu.  Processing doesn't find /dev/ttyACM0, hence cannot enumerate a serial device and any subsequent attempt access serial functions will bomb.  Do note that while I discovered this problem while attempting to use the Arduino for Processing library, the built-in serial library distributed with Processing 1.2.1 also died in my setup.  Even the example SimpleSerialRead sketch provided fails to run.

I checked around and found that others had similar general problems with the Uno and Arduino IDE under linux too.  So, I tried using Arduino IDE 0022 on my setup and confirmed having the same problems.  The usual solutions on the forums were to re-flash the Uno with the updated ATMega82 firmware (which I did) and to copy over the RXTX files from earlier versions of the IDE.  Well, after the firmware reflash, the 0022 IDE worked great and I assumed that Processing would be OK too.  Wrong.  Under Processing, /dev/ttyACM0 was still not being picked up, even while I was happily able to upload Arduino sketches over the exact same setup.

After looking around some more, some people reported success in getting serial working by copying files (librxtxSerial.so and RXTXcomms.jar) from the Arduino IDE over into their Processing library ie. the files from Arduino *replace* the files of the same name in the Processing library directory.  OK, I tried this and it sort of worked.... partially.  Processing now sees /dev/ttyACM0, but everything promptly goes haywire once the serial port is initialized.  Gnome becomes garbled and unusable visually, but runs fine underneath.  To recover from this, I hit escape to stop the sketch running, then Ctrl-Alt-F2 to get into a console logon prompt (just to get into an all-text environment), finally Ctrl-Alt-F7 to get back into X, where my Gnome session is restored to normal, with everything the way it was before I ran the sketch.

Seeing how X/Gnome was messed up when running with the serial library, I figured it might be my display drivers.  I was right!  After the stock installation of Ubuntu, Maverick invited me to install the extra proprietary non-opensource Nvidia drivers so that I could enjoy 3D acceleration that wasn't offered in the standard open source drivers.  But its these Nvidia drivers that were the problem.  As soon as I removed them using the Ubuntu-provided Additional Drivers tool (System->Administration->Additional Drivers from the Ubuntu Gnome desktop), my Processing sketch worked as it should have... serial and arduino-for-processing 0017 libraries all playing nicely under linux at last! smiley-grin  Bummer that I can't have all the eye-candy on my desktop UI, but making Processing work with the Uno (and serial, in general) was the top priority, and that was a happy success.

----------------------- SUMMARY ----------------------

So, in short, this is what I did to get Processing 1.2.1 to talk to my Uno under Ubuntu Maverick on USB:

- flashed the ATMega82 on my Uno to the newest firmware (AFAIK, this is probably optional if you're not using the Arduino IDE)
- overwrite the Processing RXTX library files using the ones from the Arduino IDE (librxtxSerial.so and RXTXcomms.jar)
- removed additional display drivers (in my case it was Nvidia) that are not the standard drivers shipped with Ubuntu. 

Hope this helps! smiley
Logged

Pages: [1]   Go Up
Jump to: