Page 1 of 1

open() throws 'TimeOut' PhidgetException

Posted: Sun Oct 29, 2017 5:25 am
by Zebajin
Hi everybody.
I'm new to phidget programming and was just trying to write a little program that displays the voltage of a VoltageInput type sensor (slider) in Java.

I looked at the VoltageInput exemple and the online guide.

Whenever I execute the code, the open() method throws a timeout exception which I believe is due to no phidgets being attached during the duration of the open.

However I do have a slider plugged in my 8/8/8 1018 interface kit and it shows in the software control panel.

Here is my code:

Code: Select all

import com.phidget22.*;

public class LedSlider {
   private static VoltageInput sl;
   public static void main(String[] args) throws PhidgetException {

      sl = new VoltageInput();
      //Attach Listener
      sl.addAttachListener(new AttachListener() {
         public void onAttach(AttachEvent ae) {
            VoltageInput slider = (VoltageInput) ae.getSource();
            try {
               System.out.println("Channel" + slider.getChannel() + "on device" + slider.getDeviceSerialNumber() + "connected\n" + slider.getVoltage());
            }catch (PhidgetException ex){
               System.out.println("AL ex " + ex.getDescription());
      //Detach Listener
      sl.addDetachListener(new DetachListener() {
         public void onDetach(DetachEvent de) {
            VoltageInput slider = (VoltageInput) de.getSource();
            try {
               System.out.println("Channel " + slider.getChannel() + "on device " + slider.getDeviceSerialNumber() + "detached");
            }catch(PhidgetException ex) {
               System.out.println("DL ex " + ex.getDescription());
      //Upgrade Listener
      sl.addVoltageChangeListener(new VoltageInputVoltageChangeListener() {
         public void onVoltageChange(VoltageInputVoltageChangeEvent e) {
            System.out.printf("Voltage changed: %.2f\n", e.getVoltage());
      try {
         System.out.println("5000ms to attach device");;
         System.out.println("Channel closed");
      } catch (PhidgetException ex) {
      } catch (InterruptedException ex) {



Re: open() throws 'TimeOut' PhidgetException

Posted: Mon Oct 30, 2017 7:38 am
by mparadis
1. Use functions like setDeviceSerialNumber (to the serial number of the 1018) and setChannel (the number above the analog input on the 1018) on your object ("sl" in this case) before opening in order to narrow down which port it's looking for.

2. Ensure that the same channel is not open in the Control Panel while you run your program. A Phidget channel can only be opened by one program at a time, so having it open in the control panel blocks your Java program from finding it. The only way to have a Phidget channel open in two programs simultaneously is to open it remotely (using setIsRemote) in both programs.