Pages: [1]   Go Down
Author Topic: Arduino 0017 breaks comm between Arduino/Java  (Read 990 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 2
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There's a few guides out there that describe how to interface the arduino with a PC and Java.

http://www.arduino.cc/playground/Interfacing/Java
http://silveiraneto.net/2009/03/01/arduino-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:
Preferences.init();
CommPortIdentifier portId = CommPortIdentifier.getPortIdentifier(
                Preferences.get("serial.port"));

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:
static protected void init(String cmdlineargs)

http://dev.processing.org/source/index.cgi/tags/processing-1.0.3/app/src/processing/app/Preferences.java?rev=5503&view=log

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?
« Last Edit: August 25, 2009, 10:18:21 pm by magitek » Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
import processing.app.Preferences;

public class PrefsHack extends Preferences
{
      public static void init()
      {
            Preferences.init("/Users/Me/Library/Arduino/preferences.txt");
      }
}

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.
Logged

Pages: [1]   Go Up
Jump to: