Go Down

Topic: Arduino 0017 breaks comm between Arduino/Java (Read 1 time) previous topic - next topic


Aug 26, 2009, 05:17 am Last Edit: Aug 26, 2009, 05:18 am by magitek Reason: 1
There's a few guides out there that describe how to interface the arduino with a PC and Java.


In both of their tutorials, they use Processing's app.Preferences to sniff the device that the PC sees the arduino as. Their code runs along the lines of:

Code: [Select]

CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(

This works fine and dandy up until 0017, which upgraded to Processing 1.0.3

Since the last time arduino updated its Processing library, the Preferences class has since changed init's method signature to:

Code: [Select]
static protected void init(String cmdlineargs)


And thus causing an interesting dilemma. The quick hack to get around this signature change would be to first make the class trying to implement this functionality to extend processing.app.Preferences, and to simply pass a String to init.

Unfortunately, this does not solve the problem as Preferences starts throwing more NullPointerExceptions, probably related to my subclassing of Preferences.

Has anyone successfully interfaced with Java with 0017?


Hi magitek,

I got it to work by continuing down the path you took.  I extended the Preferences class with a PrefsHack class that adds a public static init() method.  All it does is call Preferences.init with the String path to a preferences.txt file (I'm running on a Mac so yours may look different).

Code: [Select]

import processing.app.Preferences;

public class PrefsHack extends Preferences
     public static void init()

Then, I had to make sure that the lib/preferences.txt, hardware/boards.txt, hardware/programmers.txt, and the *.jnilib files were in the execution directory.

After that, test application worked fine.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131