From e56864384c4f3a4819312a7db8b74dd7010fc84b Mon Sep 17 00:00:00 2001 From: Google Code Exporter Date: Sat, 21 Mar 2015 21:03:41 -0400 Subject: [PATCH] Migrating wiki contents from Google Code --- FAQ.md | 21 ++++++++++++++++++++ Introduction.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ ProjectHome.md | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 125 insertions(+) create mode 100644 FAQ.md create mode 100644 Introduction.md create mode 100644 ProjectHome.md diff --git a/FAQ.md b/FAQ.md new file mode 100644 index 0000000..2ddcd31 --- /dev/null +++ b/FAQ.md @@ -0,0 +1,21 @@ +## Common Errors ## +Below is a list of reported errors that have come up, and how to fix them. + +### The file pthreadGC2.dll is missing or not loaded ### +This ANE depends on the POSIX Threading Library provided by GCC. This file is extremely common, but may not be present on all copies of Windows. It is included in this ANE package, but may need to be installed separately. Either extract the .ANE file (it is located in the /META-INF/ane/Windows-x86 folder), or download a copy from the Downloads tab in the project. Copy it to the following locations : + + * Windows XP(32/64), Windows Vista(32), Windows 7(32) - C:\Windows\System32\ + * Windows Vista(64), Windows 7(64) - C:\Windows\SysWOW64\ + +### My AIR Application or ADL.EXE crashes when the app is closing ### +It is a requirement of the AIR Runtime that you call the `dispose()` function before the app ends in order to unload the ANE and all of its allocated resources. This is extra important with this ANE as it works with file handlers that the OS will need to free up for other applications. + +There are instances where the ADL will crash even though the dispose function is called. This is a known timing issue with AIR 3. + +### I get an error stating that the method `setupPort` was not found ### +There is a known issue with Flash Builder 4.6 and Flash Builder 4.7 on the Mac OSX platform. FB 4.x does not pass the proper command line parameters to ADL in order to include the ANE. + +You have three options to fix the issue : + * Execute your app using the Export Release Build. This will build the AIR app in a way that will run the project just fine. + * Run ADL from the command line. Extract the .ANE to a location you will be familar with, and execute the adl -profile extendedDesktop -extdir + * Create an ANT script to launch the debug version of your app. This is what I recommend, but it takes a bit of setup. \ No newline at end of file diff --git a/Introduction.md b/Introduction.md new file mode 100644 index 0000000..45ad541 --- /dev/null +++ b/Introduction.md @@ -0,0 +1,52 @@ +Connecting Arduino Prototyping board to Adobe AIR through an AIR Native Extension. Available for Windows and MacOSX. + +# AIR Native Extensions # +AIR Native Extensions, or ANEs are compiled code that includes both Native code (specific code for Windows, Mac, or one of the many mobile platforms) and ActionScript code that allows developers to extend the feature set that is available in AIR or the Flash Player. + +This ANE exposes the Serial port that is created by the Arduino Uno, Arduino LilyPad, Arduino Mega, Arduino Duemilanove and various other Arduino Compatibles. It can also be used with any device that communicates via a serial port (COM port). + +## Background ## +The ArduinoConnector mimics the _flash.net.Socket_ class that is internal to the Flex Framework. It was chosen to mimic this class because many of the more popular Arduino projects target the Socket class because they use serProxy to transport the data to the serial port. + +## Use ## +Instruct your IDE to include the ANE that you downloaded from the Downloads tab. In Flash Builder 4.6+, right click on your project, go to the Flash Builder Path properties, click on the Native Extensions tab, and add the ANE. + +Next, add a new ArduinoConnector instance. You will need to pass the COM port that the Arduino is connected to, along with the baud rate to the `connect()` function (as3Glue uses 57600, most Arduino samples use 9600). You can get a list of valid COM ports for your operating system by taking in the `getComPorts()` array. Also, add a function that will "dispose" or clean up the connection when you are finished (if you do not do this, the AIR runtime may crash when your app closes). +``` +public var arduino:ArduinoConnector; + +public function initApp():void +{ + arduino = new ArduinoConnector(); + arduino.connect("COM10",9600); +} + +protected function closeApp(event:Event):void +{ + arduino.dispose(); +} +``` + +### Reading Data ### +When ArduinoConnector gets data from the serial port, it will fire an event that has the "socketData" signature. When the event is fired, you can check the `bytesAvailable` variable to see how much data is in the buffer, and you can use one of the following functions to get data : + * public function readBytesAsArray():Array + * public function readBytesAsString():String + * public function readBytesAsByteArray():ByteArray + * public function readByte():uint +The buffer mirrors the UART, and holds at most 4046 bytes (4k) worth of data. All the above functions will clear the buffer, with the exception of readByte(), which will only return the top byte from the buffer (FIFO order). + +### Sending Data ### +Before sending data, make sure the port was successfully opened by checking the 'portOpen' variable. If the port is not open, the write functions will fail and return false. You can use the following functions to send data to the serial port : + * public function writeByte(byte:uint):Boolean + * public function writeString(stringToSend:String):Boolean + * public function writeBytes(bytesToSend:ByteArray):Boolean +The functions will return TRUE if the data was successfully sent, and FALSE if there was an error sending the data. The data is sent in another thread, but is virtually synchronous. There is no send buffer, so there is no need to 'flush' the data. + +## Using with as3Glue ## +as3Glue is the most popular library for people to deal with Arduinos. It allows the developer to load the Firmata code onto their Arduino and control all the pins using AS3 rather than the embedded C that the Arduino uses natively. + +Download either the SWC or Source Code from the Downloads section of this project for a patched version of as3Glue. This patched version has the exact same interfaces as v20, with a notable exception of the constructor. When you instantiate a new "Arduino" object, replace the IP address and port with the COM port and baud rate. For example : + +`public var myArduino:Arduino = new Arduino("COM10", 57600);` + +You can find out more about as3Glue at http://code.google.com/p/as3Glue \ No newline at end of file diff --git a/ProjectHome.md b/ProjectHome.md new file mode 100644 index 0000000..e7491aa --- /dev/null +++ b/ProjectHome.md @@ -0,0 +1,52 @@ +Connecting Arduino Prototyping board to Adobe AIR through an AIR Native Extension. Available for Windows and MacOSX. + +# AIR Native Extensions # +AIR Native Extensions, or ANEs are compiled code that includes both Native code (specific code for Windows, Mac, or one of the many mobile platforms) and ActionScript code that allows developers to extend the feature set that is available in AIR or the Flash Player. + +This ANE exposes the Serial port that is created by the Arduino Uno, Arduino LilyPad, Arduino Mega, Arduino Duemilanove and various other Arduino Compatibles. + +## Background ## +The ArduinoConnector mimics the _flash.net.Socket_ class that is internal to the Flex Framework. It was chosen to mimic this class because many of the more popular Arduino projects target the Socket class because they use serProxy to transport the data to the serial port. + +## Use ## +Instruct your IDE to include the ANE that you downloaded from the Downloads tab. In Flash Builder 4.6, right click on your project, go to the Flash Builder Path properties, click on the Native Extensions tab, and add the ANE. + +Next, add a new ArduinoConnector instance. You will need to pass the COM port that the Arduino is connected to, along with the baud rate to the `connect()` function (as3Glue uses 57600, most Arduino samples use 9600). You can get a list of valid COM ports for your operating system by taking in the `getComPorts()` array. Also, add a function that will "dispose" or clean up the connection when you are finished (if you do not do this, the AIR runtime may crash when your app closes). +``` +public var arduino:ArduinoConnector; + +public function initApp():void +{ + arduino = new ArduinoConnector(); + arduino.connect("COM10",9600); +} + +protected function closeApp(event:Event):void +{ + arduino.dispose(); +} +``` + +### Reading Data ### +When ArduinoConnector gets data from the serial port, it will fire an event that has the "socketData" signature. When the event is fired, you can check the `bytesAvailable` variable to see how much data is in the buffer, and you can use one of the following functions to get data : + * public function readBytesAsArray():Array + * public function readBytesAsString():String + * public function readBytesAsByteArray():ByteArray + * public function readByte():uint +The buffer mirrors the UART, and holds at most 4046 bytes (4k) worth of data. All the above functions will clear the buffer, with the exception of readByte(), which will only return the top byte from the buffer (FIFO order). + +### Sending Data ### +Before sending data, make sure the port was successfully opened by checking the 'portOpen' variable. If the port is not open, the write functions will fail and return false. You can use the following functions to send data to the serial port : + * public function writeByte(byte:uint):Boolean + * public function writeString(stringToSend:String):Boolean + * public function writeBytes(bytesToSend:ByteArray):Boolean +The functions will return TRUE if the data was successfully sent, and FALSE if there was an error sending the data. The data is sent in another thread, but is virtually synchronous. There is no send buffer, so there is no need to 'flush' the data. + +## Using with as3Glue ## +as3Glue is the most popular library for people to deal with Arduinos. It allows the developer to load the Firmata code onto their Arduino and control all the pins using AS3 rather than the embedded C that the Arduino uses natively. + +Download either the SWC or Source Code from the Downloads section of this project for a patched version of as3Glue. This patched version has the exact same interfaces as v20, with a notable exception of the constructor. When you instantiate a new "Arduino" object, replace the IP address and port with the COM port and baud rate. For example : + +`public var myArduino:Arduino = new Arduino("COM10", 57600);` + +You can find out more about as3Glue at http://code.google.com/p/as3Glue \ No newline at end of file