Skip to content

Possible to work with more than one ArduinoConnector / Arduinos in one application #19

Open
@GoogleCodeExporter

Description

@GoogleCodeExporter
What steps will reproduce the problem?
1. Create two ArduinoConnector instances in one AIR application
2. Connect to both devices on different COM Ports
3. Get Data just from one

What is the expected output? What do you see instead?
Expected output would be serial data from both input devices, instead I just 
get data from one inside my Air application.

What version of the product are you using? On what operating system?
Arduino Connector 1.2.0 with Flash Professional CS6 on Win 7 64bit

Please provide any additional information below.

I made a short code sample what I'd like to achieve, is this possible with 
ArduinoConnector? And if so, what should I change to get it working?

//

package  {

    import flash.display.MovieClip;

    import com.quetwo.Arduino.ArduinoConnector;
    import com.quetwo.Arduino.ArduinoConnectorEvent;    

    public class Main extends MovieClip {

        public var scannerConnector: ArduinoConnector = new ArduinoConnector();
        public var arduinoConnector: ArduinoConnector = new ArduinoConnector();

        public function Main() {
            fnc_setupScannerConnector();
        }

        // function to setup the scannerConnector
        public function fnc_setupScannerConnector(): void{
            trace("Hi from setupScannerConnector");
            scannerConnector.connect("COM13", 57600);
            scannerConnector.addEventListener("socketData", fnc_recievingData);
            arduinoConnector.connect("COM10", 57600);
            arduinoConnector.addEventListener("socketData", fnc_dataArduino)
        }

        private function fnc_dataArduino(aEvt: ArduinoConnectorEvent): void{
            trace("From Arduino: " + arduinoConnector.readBytesAsString());
        }
        // function that gets called after data has been sent over the socketStream
        private function fnc_recievingData(aEvt: ArduinoConnectorEvent): void{
            // read out the data and put it into a temporary String
            var tempArray: Array = scannerConnector.readBytesAsArray();

            // extract the URL values from inside the bytesArray
            var i: int;
            for(i = 0; i < tempArray.length; i++){
                // look for starting character
                if(tempArray[i] == "#"){
                    var urlString: String;
                    // write the array entries into a string
                    for(i = i+1; i < tempArray.length; i++){
                        urlString = urlString + tempArray[i];
                    }
                    // remove the null character
                    urlString = urlString.slice(4, urlString.length);
                    trace("Extracted URL: " + urlString);
                    break;
                }
            }
        }
    }
}


// Thanks for your time and this awesome ANE

Original issue reported on code.google.com by [email protected] on 31 Jan 2013 at 3:44

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions