Hybrid View
-
28 May 2008 1:55 AM #1
Can Adobe AIR accessing serial port?
Can Adobe AIR accessing serial port?
I just have made use of Adobe AIR .I want to use printer with air . Do air have some poperties to accessing serial port or usb?
I look up that on the Adobe AIR documents.I only found 'Adobe
-
28 May 2008 8:09 AM #2
It does not support any kind of direct hardware access. I do not know if there are any plans for that in the future, but i doubt it. It may be possible to issue a print command to the internal webkit browser via javascript though.
-
12 Mar 2009 10:05 PM #3
It is possible...
It is possible...
This is possible with a binary socket and serial proxy.
Download this: http://download.berlios.de/arduino/s....bin.win32.zip
Next, update the config file with the specific comport settings... baudrate, etc...
Running this program will forward all serial port data to a specific tcp port, which you can then bind to within Air, using the air.Socket() object.
Once you are ready, launch the proxy, then launch your air app. This would be cooler, if adobe let you launch an external program from within air.
Here is a small example...
I am working on a pretty big Ext/Air app that interfaces with microcontrollers and sensors... let me know if you need anything else.Code:var serialPortApplication = function() { var socket; var onSocketData = function(event) { var data = socket.readUTFBytes(socket.bytesAvailable); air.trace(data); }; var createSocket = function() { socket = new air.Socket(); socket.addEventListener( air.ProgressEvent.SOCKET_DATA, onSocketData ); // this is the port specified in the serial proxy config file socket.connect( 'localhost', 5334 ); }; return { run : function() { createSocket(); } }; }(); // Then.... serialPortApplication.run();
-
23 Jun 2009 11:54 AM #4
-
13 Jan 2010 1:02 AM #5
-
4 Oct 2011 7:51 AM #6
Anyone done this in as3?
Anyone done this in as3?
Has anyone tried this in as3?
When i run serproxy I get a connection was made, but my listener for data ("data recieved") never fires there after. The serial device in question sends out a package each second so i should be picking up on somthing.
Any ideas?
My code looks like this....
Code:package com { import flash.display.Sprite; import flash.events.*; import flash.net.Socket; import flash.net.XMLSocket; public class XMLSocketSender extends Sprite { private var hostName:String = "localhost"; private var port:uint = 5332; public var socket:Socket; private var troot public function XMLSocketSender(_troot) { troot = _troot socket = new Socket(); configureListeners(socket); socket.connect(hostName, port); } public function send(data:Object):void { //socket.send(data); } private function configureListeners(dispatcher:IEventDispatcher):void { dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); dispatcher.addEventListener(ProgressEvent.PROGRESS, progressHandler); dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler); dispatcher.addEventListener(DataEvent.DATA, dataRecieved); dispatcher.addEventListener(Event.CONNECT, shakeHand); } public function dataRecieved(e:DataEvent) { trace("data recieved"); troot.debugger.text += "DATA RECIEVED"; } public function shakeHand(e:Event) { trace("connection made"); troot.debugger.text += "A CONNECTION WAS MADE"; } private function closeHandler(event:Event):void { trace("closeHandler: " + event); troot.debugger.text += "</br>"+ event } private function connectHandler(event:Event):void { trace("connectHandler: " + event); troot.debugger.text += "</br>connection made "+event //send("1"+sep+"V1.0"+end); } private function dataHandler(event:DataEvent):void { trace("dataHandler: " + event); troot.debugger.text += "</br>handling data "+event //send("3"); } private function ioErrorHandler(event:IOErrorEvent):void { trace("ioErrorHandler: " + event); troot.debugger.text += "</br> "+event } private function progressHandler(event:ProgressEvent):void { trace("progressHandler loaded:" + event.bytesLoaded + " total: " + event.bytesTotal); troot.debugger.text += event } private function securityErrorHandler(event:SecurityErrorEvent):void { trace("securityErrorHandler: " + event); troot.debugger.text += "</br>"+ event } } }
-
15 Jul 2009 7:37 AM #7
Hi to everybody and hi untunedman,
I've found your trick interesting, since I would like to implement a special controller for robotic servos, within a Flex application, in this case using AIR player.
I will need to send to COM some strings so I think that this way will be the right one.
I'm a little bit confused on how to send commands to the soket... Actually I program on FLASH but I'm new in AIR and FLEX.
Do you have some more example I can start from ? thank you very much!
-
20 Mar 2009 11:25 PM #8
I'm not too hot on this subject, but would it not be possible to use Binary Sockets to connect to another app on the machine that could connect to a serial port?


Reply With Quote
