Sbc2 1072 & Advanced servo : getPosition help.

Legacy support with Phidget21
CharlyKhul
Phidgetsian
Posts: 5
Joined: Fri Jul 29, 2011 7:24 pm
Contact:

Sbc2 1072 & Advanced servo : getPosition help.

Postby CharlyKhul » Mon Oct 22, 2012 3:56 pm

Hi everybody,

I'm trying to use the advancedservo connected to the Sbc2 1072, but i got some error.
I can setPosition an setEngaged but nothing more.
Here is my as3 code :

import com.phidgets.*;
import com.phidgets.events.*;

var phid:com.phidgets.PhidgetInterfaceKit;
phid = new PhidgetInterfaceKit();
phid.open("localhost", 5001);

var phidservo:PhidgetAdvancedServo;
phidservo = new PhidgetAdvancedServo();
phidservo.open("phidgetsbc.local", 5001,"", 169304);

stage.addEventListener(KeyboardEvent.KEY_UP,clavieru);
function clavieru(evt:KeyboardEvent){
phidservo.setEngaged( 0,false); //////OK
phidservo.setEngaged( 1,false);
}

stage.addEventListener(KeyboardEvent.KEY_DOWN,clavierd);
function clavierd(evt:KeyboardEvent):void {
if (evt.keyCode == 37){
var temp =phidservo.getPosition(0);/////Not OK
trace(temp);
phidservo.setVelocity(0,80);
}
}

I got this error :

1061: Appel à la méthode setVelocity peut-être non définie, via la référence de type static com.phidgets:PhidgetAdvancedServo.

or :

Error: Value is Unknown (State not yet received from device).
at com.phidgets::PhidgetAdvancedServo/getPosition()[C:\Users\CK\Desktop\TestFlash\New folder\com\phidgets\PhidgetAdvancedServo.as:383]
at Sansnom_fla::MainTimeline/clavierd()[Sansnom_fla.MainTimeline::frame1:21]


If somebody can do something for me?
Thanks.
:D

CharlyKhul
Phidgetsian
Posts: 5
Joined: Fri Jul 29, 2011 7:24 pm
Contact:

Re: Sbc2 1072 & Advanced servo : getPosition help.

Postby CharlyKhul » Wed Oct 31, 2012 10:59 am

Please, Need Help :(

erik
King of the Lab
Posts: 476
Joined: Fri Mar 06, 2009 12:42 pm
Location: Calgary, Canada
Contact:

Re: Sbc2 1072 & Advanced servo : getPosition help.

Postby erik » Thu Nov 01, 2012 11:54 am

After you call open, you need to call waitForAttachment. This will block your program until the devices can be initialized and set-up properly. You can also set a timeout time in milliseconds that your program will wait for the attach. Since the program does not have enough time to initialize the devices after the open method, you get "Value is Unknown" when trying to getPosition.


Return to “ActionScript 3.0 - Flash CS3 / Flex / AIR”

Who is online

Users browsing this forum: No registered users and 1 guest