Interfacing multiple phidgets on Android/JAVA

Supporting 4.1 and up
pritesh
Fresh meat
Posts: 2
Joined: Thu Jul 12, 2012 4:50 pm
Contact:

Interfacing multiple phidgets on Android/JAVA

Postby pritesh » Thu Jul 12, 2012 5:05 pm

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

MarqTwine
Phidgetly
Posts: 17
Joined: Mon Dec 27, 2010 11:45 pm
Contact:

Re: Interfacing multiple phidgets on Android/JAVA

Postby MarqTwine » Tue Jul 17, 2012 1:41 pm

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.

pritesh
Fresh meat
Posts: 2
Joined: Thu Jul 12, 2012 4:50 pm
Contact:

Re: Interfacing multiple phidgets on Android/JAVA

Postby pritesh » Fri Jul 27, 2012 9:39 pm

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

MarqTwine
Phidgetly
Posts: 17
Joined: Mon Dec 27, 2010 11:45 pm
Contact:

Re: Interfacing multiple phidgets on Android/JAVA

Postby MarqTwine » Mon Jul 30, 2012 12:39 pm

Removed by user.
Last edited by MarqTwine on Sun Aug 05, 2012 5:38 pm, edited 1 time in total.

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

Re: Interfacing multiple phidgets on Android/JAVA

Postby Patrick » Tue Jul 31, 2012 8:25 am

You can use a [code][/code] block to display your Tabs properly.

-Patrick

MarqTwine
Phidgetly
Posts: 17
Joined: Mon Dec 27, 2010 11:45 pm
Contact:

Re: Interfacing multiple phidgets on Android/JAVA

Postby MarqTwine » Tue Jul 31, 2012 2:24 pm

Thank you. I shall try it next time.


Return to “Android”

Who is online

Users browsing this forum: No registered users and 1 guest