Search code examples
javamacosarduinoportrxtx

Could not find COM port and port list is empty


Hey i would like to connect my eclipse programs written in Java with an Arduino. Previously i used Processing but now i am working on something more difficult: I will connect a Leap to an Arduino, but i get the following message when i try to connect to my port.

I am using a Mac and the port i used in processing was tty.usbserial-AM01VBFC

However this does not work with the given example from: http://playground.arduino.cc/interfacing/java

I changed this to match my port:

private static final String PORT_NAMES[] = { 
        "/dev/tty.usbserial-AM01VBFC", // Mac OS X
                    "/dev/ttyACM0", // Raspberry Pi
        "/dev/ttyUSB0", // Linux
        "COM3", // Windows
};

and the result is:

Stable Library
=========================================
Native lib Version = RXTX-2.1-7
Java lib Version   = RXTX-2.1-7
Could not find COM port.
Started

The port list is empty in my opinion because:

portEnum.hasMoreElements()

is false.

The full code can be found in the link above the only thing i changed is the port name for Mac OS X.

I have found only one guy with the same problem and he found a solution for ubuntu i do not understand: http://forum.arduino.cc/index.php?topic=73350.0;wap2

Hoping for some help, Georgi


Solution

  • I found a solution for the problem:

    System.setProperty("gnu.io.rxtx.SerialPorts", "/dev/tty.usbArduino");
    

    the line above has to be commented out and you have to delete your lock files for a "fresh" USB connection!

    Thanks to all the answers that lead me to the right way!

    edit: it was "/dev/tty.usbArduino" because i made a symlink of my ports! I deleted the symlink afterwards