Air 與 rs232 串列埠通訊

2021-06-16 11:04:59 字數 1245 閱讀 5890

街機專案 用到了這個,總結一下:

1,用的air+ ane 本地擴充套件   

a,ane 版本:as3-arduinoconnector-1-0-0.zip  

b,新增 動態鏈結庫 pthreadgc2.dll 到window/system32中 (也許是window)- -!

注意: 這裡版本用1.0.0 可以,用最新的反而不行

pthreadgc2.dll 動態鏈結庫  ane的執行的基礎

2,銷毀  arduino.dispose();

usage:參考9ria的帖子

ane位址 

//-------------

首先把ane新增到專案中:專案--屬性--本機擴充套件--新增ane

這樣我們就可以使用了,ane中就2個類,arduinoconnector和arduinoconnectorevent。

我們只需要用arduinoconnector就可以了,使用也比較簡單

//建立arduino物件

var arduino:arduinoconnector=new arduinoconnector();

//監聽socketdata事件,當有資料傳入時呼叫。

//當有時我們只需要寫資料,而不需要讀資料時,可以無視

arduino.addeventlistener("socketdata",socketdata);

//與串列埠建立連線 "com1":也可以說是串列埠標識,如果只與乙個串列埠進行通訊的話,一般都是com1

//也可以 開啟裝置管理器,找到埠項,檢視你的埠標識

arduino.connect("com1",9600);

//傳送資料

//commanddata 就是你傳送的資料,傳送什麼樣的資料就是需要根據你的串列埠通訊

規範來定了

var strdata:string="commanddata";

arduino.writestring(strdata);

//不要忘記flush()

arduino.flush();

當然除了可以傳送字串型別外,還可以用如下方式

arduino.writebyte(byte:uint); 

arduino.writebytes(bytestosend:bytearray);

具體使用哪種就根據自己的需求來定了。

還有一點需要注意的就是當使用完成後,記得銷毀

arduino.dispose();

如果不銷毀的話會有問題。

RS232串列埠通訊詳解

rs232串列埠通訊詳解 引腳定義,電氣特性,傳輸格式,接收過程,微控制器晶振,rs485,rs422 轉 2010 03 13 15 47 串列埠是計算機上一種非常通用的裝置通訊協議。串列埠的引腳定義 9芯訊號方向來自 縮寫描述 1數據機 cd載波檢測 2數據機 rxd接收資料3pc txd傳送資...

RS232串列埠通訊模組

應為工作需要自己編寫的rs232通訊模組,該模組已經編寫了蠻久,在實際使用中可能有沒有考慮和不完善的地方。如果使用該模組請保留該注釋,如果被修改或編輯請將修改後的 傳送乙份給我 編寫 戴琪英 e mail qiyingdai 163.com 2000 09 01 unit r232comm inte...

RS232串列埠通訊詳解

rs232串列埠通訊詳解 串列埠是計算機上一種非常通用的裝置通訊協議。串列埠的引腳定義 9芯 訊號方向來自 縮寫 描述 1 數據機 cd 載波檢測 2 數據機 rxd 接收資料 3 pc txd 傳送資料 4 pc dtr 資料終端準備好 5 gnd 訊號地 6 數據機 dsr 通訊裝置準備好 7 ...