Espigah / as3-arduino-connector

Automatically exported from code.google.com/p/as3-arduino-connector
0 stars 0 forks source link

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

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 bergmann...@gmail.com on 31 Jan 2013 at 3:44

GoogleCodeExporter commented 9 years ago
Will add this support in 2.0

Original comment by Nicholas...@gmail.com on 23 Apr 2013 at 3:29

GoogleCodeExporter commented 9 years ago
Hi Nicholas,

THANK YOU! This will be a real fine thing...not to hassle with Native 
Applications and serproxy.

Thanks for this great project!

Original comment by bergmann...@gmail.com on 23 Apr 2013 at 7:08

GoogleCodeExporter commented 9 years ago
Hi Nicholas,

Is it possible to establish two independent connections (on two COM ports) as 
above now in latest update? Thanks!

Andre

Original comment by andrexz...@gmail.com on 29 Jun 2013 at 12:32

GoogleCodeExporter commented 9 years ago
Really nice extension, it saved me so much time. I'm also wondering if you can 
use multiple Arduino boards with this.

Original comment by WaveLogi...@gmail.com on 21 Nov 2013 at 4:49

GoogleCodeExporter commented 9 years ago
Hello Nicholas, first of thank you for this great ANE, its a much better 
solution than having to deal with serproxy, zinc and a bunch of others. Just 
wanted to check if there are any updates about the multi comport support.

regards
Daniel

Original comment by alendiz...@gmail.com on 14 Aug 2014 at 8:18

GoogleCodeExporter commented 9 years ago
You have to use the "FREContext ctx" in C native app for working with multiple 
instances.

Original comment by Glo...@gmail.com on 21 Aug 2014 at 3:47