Go Down

Topic: as3glue and serproxy (Read 894 times) previous topic - next topic

Phildo

Hey, I have firmata, as3glue, and serproxy running with an arduino UNO. I'm pretty sure I've set them up correctly, because when I run the standalone monitor that comes with as3glue, it works (well... sorta). However, it only works after some teasing (close out of it, open it, wait 20 seconds, close out of it again, open it, etc... until I notice a signal from the analog input). But when it gets started, it works fine.

So I have 2 questions:
1. Does anyone have any idea how I can get the serial monitor, and thus the entire "UNO->firmata->serproxy->as3glue->serial monitor" chain to be more reliable?
2. I have some basic testing actionscript files using as3glue that work (occasionally) when they try to set output, and NEVER work when trying to retrieve input. What is the problem with not getting input, and once again, how can I get the whole thing consistent.

And once again, when I say consistent, I don't mean I try it, edit some code, and try it again. I will literally run the code, it won't work. Close it out and run it again without making any modifications, and it will.

How can I make sense of any of this?! Thanks!

PS- Heres my basic testing code that for some reason isn't working...



//Import the as3Glue stuff...
import net.eriksjodin.arduino.Arduino;
import net.eriksjodin.arduino.events.ArduinoEvent;

//The arduino object
var arduino:Arduino;

function setArdy(){
  arduino = new Arduino("127.0.0.1", 5331); //Sets up new arduino with localhost over port 5331
  arduino.addEventListener(Event.CONNECT, onSockCon); //Adds event that listens for connection to socket with serproxy
}

function onSockCon(e:Object):void {
  trace("Socket Connected");
  arduino.addEventListener(ArduinoEvent.FIRMWARE_VERSION, onReceiveFW); //Adds event that listens for firmware to be returned
  arduino.requestFirmwareVersion(); //Requests Firmware
}

function onReceiveFW(e:ArduinoEvent):void {
  trace("Firmware Received)";
  arduino.setPinMode(6, Arduino.INPUT); //Sets pin 6 to INPUT
  arduino.enableDigitalPinReporting(); //Knows to listen for digital input
  arduino.addEventListener(ArduinoEvent.DIGITAL_DATA, onReceiveD); //Adds event that listens for digital data to be returned
}

function onReceiveD(e:ArduinoEvent):void {
  trace("Data Received!");
}

setArdy();


Go Up