Page 1 of 1

HelloWorld not working

Posted: Mon Jul 31, 2017 1:30 pm
by bmoon
I'm on a mac. The native os/x app show's my devices. I've used phidgets21 in the past. Trying phidgets22 now. The basic HelloWorld never detects devices!!! I tried adding a debug line as follows:

Code: Select all

/*

Phidgets HelloWorld example for all devices

*/

import com.phidget22.*;

public class HelloWorldExample {

    public static void main(String[] args) throws Exception {

        com.phidget22.Log.enable(LogLevel.DEBUG, null);
        Manager phidman = new Manager();
        
        phidman.addAttachListener((ManagerAttachEvent ev)->{
            Phidget phid = ev.getChannel();
            try{
            System.out.println("Hello device: " + phid.getDeviceName() + ", Serial Number: " + phid.getDeviceSerialNumber());
            }catch(PhidgetException ex){
                System.out.println(ex.getDescription());
            }
        });
       
        phidman.addDetachListener((ManagerDetachEvent ev) -> {
            Phidget phid = ev.getChannel();
            try{
            System.out.println("Goodbye device: " + phid.getDeviceName() + ", Serial Number: " + phid.getDeviceSerialNumber());
            }catch(PhidgetException ex){
                System.out.println(ex.getDescription());
            }
        });
		
        try {
            System.out.println("Opening...");
            phidman.open();
            System.out.println("Phidget simple playground (plug and unplug devices)");
            System.out.println("Press enter to end anytime");
            System.in.read();
            
            System.out.println("Closing...");
            phidman.close();
            
        } catch (PhidgetException ex) {
            System.out.println(ex.getDescription());
        }
    }
}
Here's the output from that run:

java -cp .:phidget22.jar HelloWorldExample
Opening...
DEBUG [phidget22][2017-07-31T15:30:13 dispatch.c+161 entryDispatched()]: creating dispatcher
DEBUG [phidget22][2017-07-31T15:30:13 dispatch.c+163 entryDispatched()]: created dispatcher
INFO [phidget22][2017-07-31T15:30:13 macusb.c+416 RawDeviceAdded()]: Attach: 0x00007603
DEBUG [phidget22][2017-07-31T15:30:13 phidget.c+1463 _addDevice()]: PhidgetInterfaceKit 8/8/8(1010/1018/1019) (433248)
DEBUG [phidget22][2017-07-31T15:30:13 dispatch.c+161 entryDispatched()]: creating dispatcher
DEBUG [phidget22][2017-07-31T15:30:13 dispatch.c+163 entryDispatched()]: created dispatcher
DEBUG [phidget22][2017-07-31T15:30:13 dispatch.c+161 entryDispatched()]: creating dispatcher
DEBUG [phidget22][2017-07-31T15:30:13 dispatch.c+163 entryDispatched()]: created dispatcher
INFO [phidget22][2017-07-31T15:30:13 macusb.c+416 RawDeviceAdded()]: Attach: 0x00009003
DEBUG [phidget22][2017-07-31T15:30:13 phidget.c+1463 _addDevice()]: PhidgetLED-64 Advanced(1032) (436843)
Phidget simple playground (plug and unplug devices)
Press enter to end anytime


NOTICE that we never get the "Hello Device" with serial number printed out.

I can hard code the address shown in the debug output (436843) as the device address of one of my objects and that will work, but why is discovery not working?