通信:RS232接口
命令語法
<前綴><地址><命令串><參數><終止符>
Field |
Description |
Prefix |
一個分號字符“;”(59),必須放在所有命令的前面,當設備接收到前綴符後會重置命令輸入緩存區。 |
Address |
兩個ASCII 字符,激光使用“LA” 作爲其地址 |
Command String |
Commands are specific to each device -- see the following sections for the commands that each device supports. |
Parameters |
Some commands may have parameters which immediately follow the command string. Multiple parameters are separated by commas(逗號). You must supply the correct number of characters for all parameters under all circumstances. For example, if a command expects a three-digit value, then the parameter must in the form “000”, “001”… “100” etc. |
Terminator |
ASCII 回車字符(13),接受設備在終端沒有收到終止符時不會處理任何命令。 |
- 能量 ;LAAT### 000-255
- 頻率 ;LARR### 000-255
- 激發模式 ;LAMO# 0連續 1單槍 2爆發
- 鐳射指示燈 亮度 ;LASP### 000-255 是否閃爍 ;LASB# 0不閃 1閃爍 閃頻 ;LABR### 000-255
- 波長選擇 IR高低 ;LAHS# 1 低 2高 Green高低 ;LAHS#
3 低 5高
- 爆發次數 ;LABU#### 0000-0050
- 形狀(SlitX、SlitY): ;LAXS### ;LAYS### 000-255
- 能量高 ;LAENH 能量低 ;LAENL
- 鐳射開槍 ;LAGO
- 停止開槍 ;LAST
- 開啓激光 ;LAON
- 關閉激光 ;LAOF
- 計數 ;LASC 統計激光到當前時間爲止一共激發了多少次
保持通訊打開串口
Send “;LASM1” 打開激光控制串口。激光會返回一個消息“ok”
Send “;LASS” 檢查聯動裝置和電機的安全狀態,在處理前應等待電機移動位被清零
若安全聯鎖裝置可靠, send “;LAON” 將激光置爲待機模式。
發射激光當激光被打開後(發送了“;LAON”命令)必須定時(至少兩秒一次)發送命令給激光,否則激光會自動關閉。 使用了“;LASS”來定時間檢查激光狀態。
程序實現設定激光的能量、頻率、激發模式、波長、光圈
Send “;LAGO” 發射激光
Send “;LAST” 停止 發射激光
Send “:LAOF”將激光置爲停止模式
void RS232_cputs(int comport_number, const char *text) /* sends a string to serial port */{while(*text != 0) RS232_SendByte(comport_number, *(text++));}
int res;交互界面
pthread_t a_thread,b_thread;
res = pthread_create(&a_thread, NULL,thread_function,NULL);
if (res!=0)
{
printf("Create pthread error!/n");
return 1;}
使用QT編寫gui界面