Getting my serial port to communicate with my Adobe Air app

I ran into this problem when I needed simple medical equipment to output a string of comma-separated numbers into my Adobe Air application. I'm just thrilled to talk with something other than a web service!

So, I got a USB to serial adapter, connected to a computer, and used the Cornflake program to read this from the machine:

0,1,71,0,234,2,453,31.1,72.8,161.4,118.2,30,32.7,9336

Success! Thus, I do some search queries, and it seems that serproxy is a convenient tool that Arduino buffs use to do exactly what I need: serial run. So I download, install and configure like this:

newlines_to_nils=false

serial_device1=/dev/cu.usbserial


comm_ports=1,2,3,4

comm_baud=2400
comm_databits=7
comm_stopbits=1
comm_parity=even

timeout=300

net_port1=5331 
...

, Cornflake. , , :

private function onSocketData(event:Event):void {
  var data:String = socket.readUTFBytes(socket.bytesAvailable);
  trace(data);
}

:

¬ ± ¬ ± ±.0¬²3'.0¬'53¬3 ±. ± ¬ · ².¸¬ ± 6 ±.²¬ ± a ¸.0¬3 0¬3².6¬93 3 ±

, . , ascii, :

var data:String = socket.readMultiByte(bytes.bytesAvailable, "us-ascii");

. . tty.usbserial, , . , , , , serproxy:

trace(socket.readByte().toString());

, :

48 -84 -79 -84 -73 -79 46 48 -84 -78 51 -76 46 -78 -84 -76 53 48 -84 51 48 46 57 -84 -73 -78 46 -76 -84 - 79 54 -79 46 -72 -84 -79 -79 -72 46 -76 -84 51 48 -84 51 -78 46 -73 -84 57 51 51 54 -115 10

, , stackoverflow , - , serialports101.

data

[]

, , , ActionScript . , 10101100 (44 ), -84. , , .

, , , , 1, . , ActionScript .

var text:String = "";
var tmp:int = socket.readByte();
var charCode:int code;
if(tmp < 0)  //check to see if the parity bit was flipped to 1
{
     code=tmp & 0x7F;  //reset the parity bit to 0
}
else
{
     code=tmp;  //nothing to do if parity bit is 0
}
text+=String.fromCharCode(code);

, .

[/]

+5
1

48 decimal = 0 ()

, ; ( )

[]
, 46 =. ()
54 = 6 ()
51 = 3 ()

, , 0,1,71,0,234,2,453,31,1,72,8,161,4,118,2,30,32,7,9336 ± 0,2 ²² ² 6¬933..

, . [/]

+3

All Articles