Java on Mac / Can't connect to Phidgets

Supporting Java SE version 7 and up
mathieu

Java on Mac / Can't connect to Phidgets

Postby mathieu » Fri Mar 25, 2011 3:56 am

Hi,

I got a Phidget 8/8/8 and I'm trying to connect it to my mac.

I installed it with the DMG file and it works well, I can access it via System Settings / Phidgets and light an LED with the interface.

So I guess the connection between MacOS and the phidget is ok.

Then I start eclipse and try to control it with JAVA.

I started a new project, added the phidget21.jar to the environment and tried the following code :

Code: Select all

package com.bowe.ledlighter.core;

import com.phidgets.AnalogPhidget;
import com.phidgets.InterfaceKitPhidget;
import com.phidgets.PhidgetException;

public class Main {
   
   static InterfaceKitPhidget ik;

   public static void main(String[] args) throws PhidgetException, InterruptedException {
      
   
//      ik = new InterfaceKitPhidget();
//      ik.openAny();
//      ik.waitForAttachment();
      
      AnalogPhidget ap = new AnalogPhidget();
      ap.openAny();
      ap.waitForAttachment(5000);
      
      System.out.println("Voltage mini = "+ap.getVoltageMin(0));
      System.out.println("Voltage maxi = "+ap.getVoltageMax(0));
      
      ap.setVoltage(0, ap.getVoltageMax(0));
      
      // toto
      Thread.sleep(10000);
      
      ap.close();
   }
   
}


Unfortunately I get an exception :

Exception in thread "main" PhidgetException 13 (Given timeout has been exceeded.)
at com.phidgets.Phidget.waitForAttachment(Native Method)
at com.bowe.ledlighter.core.Main.main(Main.java:20)

I also checked the install and manually checked that the files are in the different folders (jnilib) and so on...

Can you help me on this topic ?

User avatar
Patrick
Lead Developer
Posts: 3100
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Java on Mac / Can't connect to Phidgets

Postby Patrick » Fri Mar 25, 2011 7:53 pm

Do you still have the example open? Only one program can have a Phidget open at a time.

-Patrick

mathieu

Re: Java on Mac / Can't connect to Phidgets

Postby mathieu » Mon May 09, 2011 10:42 am

Hi Patrick,

Thanks for help.
I wanted to use an AnalogPhidget Class with this Phidget that has no AnalogOutPut...

Now I use the DigitalOutput of my phidget interface kit 8/8/8 and it works perfectly.

I'm just a beginner ; )

I hope this can avoid this mistake to someone else.


Return to “Java”

Who is online

Users browsing this forum: No registered users and 2 guests