Page 1 of 1

Interfacing multiple phidgets on Android/JAVA

Posted: Thu Jul 12, 2012 5:05 pm
by pritesh
Hello,

I was able to interface one Spatialphidget with an Android tablet successfully. Now, I am trying to interface multiple (2 to begin with) Spatial Phidgets to the tablet through a hub and fetch the acceleration values from both of them at the same time. I would like to know how should I go about. I have tried the following ways but they don't seem to work.
1. I am using the Phidget Manager to get the list of the Phidgets attached and using a vector to store the serial numbers of each of the phidget.
I have created multiple Spatial Phidget objects, each having a separate data listeners. Then in the manager's attach listener I use the open(int serial number) method to open the phidget with the serial numbers which are stored in the vector.

This implementation gives only the acceleration readings of the recent phidget attached and doesn't consider the earlier phidget attached.

2.Secondly, I tried to call two separate threads in the manager attach listener and try to open them individually in their individual threads. Unfortunately, it gives the same result as above.

What is the ideal way to implement this functionality. Is there any sample/resources showing this implementation.

Thanks,
Pritesh

Re: Interfacing multiple phidgets on Android/JAVA

Posted: Tue Jul 17, 2012 1:41 pm
by MarqTwine
I am working with two IFkits and an Android tablet. I don't have things running smoothly yet, but I find that if I start my program through Eclipse about four times, it picks up both kits.

I also found that I have to supply 5V to the hub I use otherwise things don't work right.

How did you get the serial numbers? I haven't figured that bit out yet. I have to hard code the serial numbers before I can open the IFkits.

Thanks.

Re: Interfacing multiple phidgets on Android/JAVA

Posted: Fri Jul 27, 2012 9:39 pm
by pritesh
I am using the Manager class.
In the addAttachListener of the manager object, use the getSource() method of the AttachEvent class which returns a Phidget object.
Then use this phidget object and use the getSerialNumber() to get the serial number of the phidgets getting attached and add this to a list.

The code looks like this :

private Manager man;
private Vector<Integer> phidgetList;

man.addAttachListener(new AttachListener() {

@Override
public void attached(AttachEvent ae) {
// TODO Auto-generated method stub
p = ae.getSource();
Log.d(TAG, phidgetList + "");
try {
phidgetList.add(p.getSerialNumber());
//anything extra implementation code
}
catch (PhidgetException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}

Do you have a working framework for multiple phidgets running on the Android tablet?

Thanks,
Pritesh

Re: Interfacing multiple phidgets on Android/JAVA

Posted: Mon Jul 30, 2012 12:39 pm
by MarqTwine
Removed by user.

Re: Interfacing multiple phidgets on Android/JAVA

Posted: Tue Jul 31, 2012 8:25 am
by Patrick
You can use a [code][/code] block to display your Tabs properly.

-Patrick

Re: Interfacing multiple phidgets on Android/JAVA

Posted: Tue Jul 31, 2012 2:24 pm
by MarqTwine
Thank you. I shall try it next time.