張青 任宏
摘 要: 針對(duì)當(dāng)前智能人機(jī)交互通信系統(tǒng)存在的通信穩(wěn)定性和安全性差、延遲大的問題,提出并設(shè)計(jì)基于RS 232的智能人機(jī)交互通信系統(tǒng)。該系統(tǒng)主要由登錄與退出單元、通信數(shù)據(jù)傳輸單元和通信數(shù)據(jù)信息加密單元等模塊組成,系統(tǒng)運(yùn)行時(shí)下位機(jī)向上位機(jī)傳輸通信指令,下位機(jī)向上位機(jī)發(fā)送實(shí)時(shí)數(shù)據(jù)信息。上位機(jī)利用接收線程完成數(shù)據(jù)信息的處理,系統(tǒng)上位機(jī)向下位機(jī)傳輸反饋控制,同時(shí)請(qǐng)求下位機(jī)對(duì)人機(jī)交互設(shè)備進(jìn)行調(diào)整。在登錄與退出單元中,當(dāng)客戶端啟動(dòng)系統(tǒng),出現(xiàn)登錄界面后,立即輸入用戶名稱及密碼完成登錄,并隨即進(jìn)入通信程序。在通信數(shù)據(jù)傳輸單元中,依據(jù)發(fā)送端的地址找到與之相應(yīng)的對(duì)話框,在對(duì)話框中顯示出對(duì)應(yīng)消息,同時(shí)在顯示消息中設(shè)定接收選擇。在通信數(shù)據(jù)加密單元中,利用DES_ncbc_encryp加密和解密函數(shù)完成通信數(shù)據(jù)加密。實(shí)驗(yàn)表明,該系統(tǒng)運(yùn)行穩(wěn)定性和安全性均優(yōu)于當(dāng)前系統(tǒng),并具有延遲低的優(yōu)點(diǎn),可行性高,實(shí)用性和適用性均較強(qiáng)。
關(guān)鍵詞: 人機(jī)交互; 通信指令; 系統(tǒng)設(shè)計(jì); 加密; 數(shù)據(jù)傳輸; RS 232
中圖分類號(hào): TN915.5?34; TP827 文獻(xiàn)標(biāo)識(shí)碼: A 文章編號(hào): 1004?373X(2018)20?0175?04
Abstract: As the current intelligent human?computer interaction communication system has the problems of poor stability, security and large delays in communication, an intelligent human?machine interactive communication system based on RS 232 is proposed and designed. The system is mainly composed of the login and logout unit, communication data transmission unit, and communication data information encryption unit. During the system operation, the lower computer sends communication instructions to the upper computer, and the lower computer sends real?time data information to the upper computer. The upper computer uses the receiving thread to complete the processing of data information. The system upper computer transmits the feedback control to the lower computer and simultaneously requests the lower computer to adjust the human?computer interaction device. In the login and logout unit, when the system is started on the client and the login interface appears, the user name and password should be immediately entered to complete the login and enter the communication program immediately. In the communication data transmission unit, the corresponding dialog box is found according to the address of the transmitting terminal, the corresponding messages are displayed in the dialog box, and the receiving selection of displayed messages is set. In the communication data encryption unit, the communication data encryption is accomplished by using the DES_ncbc_encryp encryption and decryption function. The experimental results show that the system is superior to the current system in operation stability and security, and has the advantages of low delay, high feasibility, strong practicality and applicability.
Keywords: human?computer interaction; communication instruction; system design; encryption; data transmission; RS 232
智能人機(jī)交互即時(shí)通信是互聯(lián)網(wǎng)應(yīng)用的重要研究方向,針對(duì)它的研究已經(jīng)受到了業(yè)界的高度重視[1?3]。人機(jī)交互即時(shí)通信系統(tǒng)組建了一個(gè)能夠在線進(jìn)行實(shí)時(shí)溝通的平臺(tái),得到了廣大用戶的廣泛使用。左韜等人提出并設(shè)計(jì)基于以太網(wǎng)EtherCAT的人機(jī)交互通信系統(tǒng)[4]。對(duì)以太網(wǎng)通信總線網(wǎng)絡(luò)延時(shí)進(jìn)行分析,通過最小二乘法與支持向量機(jī)的有效結(jié)合,實(shí)現(xiàn)網(wǎng)絡(luò)延遲的在線測(cè)試。并以此為依據(jù),通過可變延遲校正PID控制器,對(duì)控制對(duì)象的參數(shù)進(jìn)行識(shí)別,完成控制對(duì)象模型變化的自適應(yīng)調(diào)解。實(shí)驗(yàn)結(jié)果表明,該系統(tǒng)可將通信延遲控制在合理范圍內(nèi),但存在通信信道較為擁擠,通信信號(hào)幅值波動(dòng)較大,即通信不穩(wěn)定的情況。李沫等人提出并設(shè)計(jì)基于星型網(wǎng)的通信系統(tǒng)[5]。該系統(tǒng)中將星型網(wǎng)絡(luò)組建為5個(gè)節(jié)點(diǎn)的無線網(wǎng)絡(luò)定位以及通信系統(tǒng),并將系統(tǒng)節(jié)點(diǎn)的硬件組成實(shí)現(xiàn)、定位,以及通信軟件設(shè)計(jì)當(dāng)作研究重點(diǎn)。實(shí)驗(yàn)結(jié)果表明,系統(tǒng)穩(wěn)定性較為可靠,但無法將通信延遲控制在相對(duì)合理的范圍內(nèi)。郭麗萍等人提出并設(shè)計(jì)基于Microchip MCP2515 CAN的通信系統(tǒng)[6]。以CAN協(xié)議原理和應(yīng)用技術(shù)為理論依據(jù),通過外掛Microchip MCP2515 CAN設(shè)計(jì)思想,實(shí)現(xiàn)基于AVR的CAN通信系統(tǒng)設(shè)計(jì),同時(shí)滿足電源控制體系方案需要。系統(tǒng)設(shè)計(jì)中分別設(shè)計(jì)了CAN總線整體結(jié)構(gòu)、控制器以及收發(fā)器等部分硬件和軟件,并對(duì)該系統(tǒng)的網(wǎng)絡(luò)負(fù)載情況進(jìn)行分析。實(shí)驗(yàn)結(jié)果表明,該系統(tǒng)網(wǎng)絡(luò)負(fù)載情況較為樂觀,但存在通信安全性差的問題。智能人機(jī)交互是當(dāng)前社會(huì)不可缺少的技術(shù)之一,智能人機(jī)交互的通信系統(tǒng)設(shè)計(jì)與實(shí)現(xiàn),更是該領(lǐng)域發(fā)展的重要途徑。
1.1 登錄與退出單元
在該單元中,當(dāng)客戶端啟動(dòng)系統(tǒng),出現(xiàn)登錄界面后,立即輸入用戶名稱及密碼完成登錄。過程中客戶端向服務(wù)器傳輸用戶登錄信息,服務(wù)器再對(duì)用戶登錄信息進(jìn)行解析,獲取用戶名與密碼,然后搜索數(shù)據(jù)庫相應(yīng)數(shù)據(jù),以完成數(shù)據(jù)驗(yàn)證。假設(shè)用戶不存在或是密碼不一致,那么服務(wù)器將驗(yàn)證失敗結(jié)果返送至客戶端;假設(shè)驗(yàn)證結(jié)果為通過,那么服務(wù)器將數(shù)據(jù)庫中用戶的狀態(tài)轉(zhuǎn)換為在線??蛻舳耸盏匠晒π畔⒅螅鶕?jù)系統(tǒng)提示實(shí)現(xiàn)即時(shí)通信。
客戶端在進(jìn)行登錄時(shí),會(huì)向服務(wù)器傳輸消息,服務(wù)器接收到信息后,得到客戶端IP和通信端口號(hào)??蛻舳送顺鱿到y(tǒng)時(shí),會(huì)向服務(wù)器傳輸用戶已下線的消息,此時(shí),服務(wù)器會(huì)將客戶端狀態(tài)改為離線狀態(tài)。系統(tǒng)登錄和退出流程如圖1所示。
1.2 通信數(shù)據(jù)傳輸單元
通信數(shù)據(jù)信息在傳輸過程中,共分為屬性消息傳輸與消息內(nèi)容傳輸兩種形式[7?8]。消息屬性中包含:消息名稱、擴(kuò)展名、全名。通信消息傳輸需要將消息并行傳輸,要利用多線程傳輸技術(shù)完成人機(jī)交互通信,進(jìn)而疏散通信流量,防治出現(xiàn)通信通道擁擠的狀況,增強(qiáng)通信系統(tǒng)的穩(wěn)定性。
通信數(shù)據(jù)信息傳輸具體流程如圖2所示。
圖2中,在智能人機(jī)交互通信數(shù)據(jù)信息傳輸?shù)倪^程中,傳送端和接收端有三種交互狀況:傳送端先傳送通信數(shù)據(jù)屬性到接收方,并由接收方?jīng)Q定接收信息與否;在通信數(shù)據(jù)傳輸時(shí),傳送方取消信息發(fā)送;在通信數(shù)據(jù)傳送時(shí),接收方取消信息的接收。
1.3 通信數(shù)據(jù)信息加密單元
智能人機(jī)交互通信自身存在的安全問題會(huì)嚴(yán)重阻礙其推廣利用,解決該問題成為了通信軟件設(shè)計(jì)中的關(guān)鍵之一[9?11]。在基于RS 232的智能人機(jī)交互通信系統(tǒng)中,使用DES加密法在通信數(shù)據(jù)信息傳送之前進(jìn)行加密,并在接收之后進(jìn)行解密。該系統(tǒng)使用OpenSSL開源軟件中DES加密函數(shù)完成智能人機(jī)交互通信數(shù)據(jù)信息加密以及解密。僅需在通信數(shù)據(jù)文件中代入“#include
1.4 智能人機(jī)交互通信系統(tǒng)實(shí)現(xiàn)
登錄智能人機(jī)交互通信系統(tǒng)之后,進(jìn)入人機(jī)通信模式。使用者上線以后,服務(wù)器向用戶傳送智能機(jī)器的相關(guān)信息。隨后進(jìn)入文本通信與文件傳輸界面,實(shí)現(xiàn)人機(jī)交互通信。詳細(xì)實(shí)現(xiàn)步驟如圖3所示。
為驗(yàn)證基于RS 232的智能人機(jī)交互通信系統(tǒng)具有高效性與否,進(jìn)行一次實(shí)驗(yàn)。在Matlab上運(yùn)行上述系統(tǒng),并分別在通信穩(wěn)定系數(shù)、通信延遲和通信安全性三方面對(duì)所提系統(tǒng)進(jìn)行驗(yàn)證。實(shí)驗(yàn)結(jié)果如圖4所示。
圖4中,基于以太網(wǎng)EtherCAT的人機(jī)交互通信系統(tǒng)運(yùn)行初期,穩(wěn)定性系數(shù)呈上升趨勢(shì),但隨著系統(tǒng)運(yùn)行時(shí)間的延長(zhǎng),該系統(tǒng)出現(xiàn)了穩(wěn)定性較差的情況?;赗S 232的智能人機(jī)交互通信系統(tǒng)運(yùn)行前期,穩(wěn)定性系數(shù)存在波動(dòng),但波動(dòng)較小,后期較為穩(wěn)定。經(jīng)驗(yàn)證,基于RS 232的智能人機(jī)交互通信系統(tǒng)穩(wěn)定性更加可靠。
綜合目前智能人機(jī)交互通信系統(tǒng)存在的通信穩(wěn)定行差、通信延遲高和通信安全性不理想的問題,提出并設(shè)計(jì)基于RS 232的智能人機(jī)交互通信系統(tǒng)。利用客戶端程序啟動(dòng)時(shí),通信數(shù)據(jù)信息接收線程也隨之啟動(dòng),同時(shí)創(chuàng)建監(jiān)聽線程,來降低通信延遲。通過多線程傳輸技術(shù)完成人機(jī)交互通信,提高通信穩(wěn)定性。依據(jù)通信數(shù)據(jù)信息加密單元的設(shè)置,提高通信系統(tǒng)安全性。實(shí)驗(yàn)表明,該系統(tǒng)可利用價(jià)值較高。
參考文獻(xiàn)
[1] 張艷.移動(dòng)自組織網(wǎng)絡(luò)通信模塊的設(shè)計(jì)與實(shí)現(xiàn)[J].現(xiàn)代電子技術(shù),2017,40(10):54?57.
ZHANG Yan. Design and implementation of mobile self?organizing network communication module [J]. Modern electronics technique, 2017, 40(10): 54?57.
[2] 張皓孫.大型城市污水輸送SCADA系統(tǒng)通信網(wǎng)絡(luò)設(shè)計(jì)與實(shí)現(xiàn)[J].電機(jī)與控制應(yīng)用,2017,44(7):76?79.
ZHANG Haosun. Design and realization of communication network of SCADA system in metropolitan sewage transportion [J]. Electric machines & control application, 2017, 44(7): 76?79.
[3] 李軍,李光,邸永強(qiáng),等.基于虛擬路由冗余協(xié)議和雙向轉(zhuǎn)發(fā)檢測(cè)的基層氣象通信網(wǎng)絡(luò)設(shè)計(jì)和實(shí)現(xiàn)[J].氣象科技,2017,45(2):281?284.
LI Jun, LI Guang, DI Yongqiang, et al. Design and implementation of Xian meteorological communication network based on VRRP and BFD [J]. Meteorological science and technology, 2017, 45(2): 281?284.
[4] 左韜,閔華松,張雄希.基于實(shí)時(shí)以太網(wǎng)的機(jī)器人通信總線控制系統(tǒng)[J].計(jì)算機(jī)工程與設(shè)計(jì),2016,37(5):1140?1144.
ZUO Tao, MIN Huasong, ZHANG Xiongxi. Control system of robot based on bus of real?time Ethernet [J]. Computer engineering and design, 2016, 37(5): 1140?1144.
[5] 李沫,孫鳳麗,李亞,等.基于無線網(wǎng)絡(luò)的定位與通信系統(tǒng)硬軟件設(shè)計(jì)實(shí)現(xiàn)[J].中國(guó)電子科學(xué)研究院學(xué)報(bào),2017,12(5):458?462.
LI Mo, SUN Fengli, LI Ya, et al. Hardware and software design implementation of positioning and communication system based on the wireless network [J]. Journal of China Academy of Electronics and Information Technology, 2017, 12(5): 458?462.
[6] 郭麗萍,張艷榮,林思苗.嵌入式設(shè)備電源控制系統(tǒng)的CAN通信軟硬件設(shè)計(jì)[J].中國(guó)測(cè)試,2017,43(10):109?113.
GUO Liping, ZHANG Yanrong, LIN Simiao. Software and hardware design based on CAN communication for control system of embedded device power supply [J]. China measurement & testing technology, 2017, 43(10): 109?113.
[7] 何曉冬.強(qiáng)干擾環(huán)境下網(wǎng)絡(luò)情報(bào)數(shù)據(jù)濾波通信系統(tǒng)設(shè)計(jì)[J].計(jì)算機(jī)測(cè)量與控制,2016,24(10):162?164.
HE Xiaodong. Design of network intelligence data filtering and communication system in strong interference environment [J]. Computer measurement & control, 2016, 24(10): 162?164.
[8] 吳限,陳明,馮國(guó)富.低壓電力線載波通信路由器設(shè)計(jì)仿真[J].計(jì)算機(jī)仿真,2017,34(10):194?198.
WU Xian, CHEN Ming, FENG Guofu. Design and simulation of low voltage power line carrier communication router [J]. Computer simulation, 2017, 34(10): 194?198.
[9] 陳安,王晗.基于物理人機(jī)交互的智能助行器實(shí)時(shí)控制研究[J].計(jì)算機(jī)應(yīng)用研究,2017,34(5):1362?1366.
CHEN An, WANG Han. Research of real?time control of aid walker based on physical man?machine interaction [J]. Application research of computers, 2017, 34(5): 1362?1366.
[10] 繆竟鴻,王薇,武志剛,等.基于STM32F103的無主機(jī)通信系統(tǒng)的設(shè)計(jì)[J].科學(xué)技術(shù)與工程,2017,17(4):223?229.
MIAO Jinghong, WANG Wei, WU Zhigang, et al. Design of non?central?switch calling system based on STM32F103 [J]. Science technology and engineering, 2017, 17(4): 223?229.
[11] 朱徐東,孫冬梅,徐海鵬,等.基于雙信道通信網(wǎng)絡(luò)的水文遙測(cè)系統(tǒng)設(shè)計(jì)[J].科技通報(bào),2017,33(1):129?132.
ZHU Xudong, SUN Dongmei, XU Haipeng, et al. Design of hydrological telemetering system based on dual channel communication network [J]. Bulletin of science and technology, 2017, 33(1): 129?132.