【正文】
RS232. Linux can control the serial port of the puter by POSIX termios interface. That can carry out the setting and data reading/writing of the serial port, the data transmit between puters (DTE) and MODEM (DCE), and the control from the puter to the MODEM, namely, the reading/writing of the serial port from the puter. The author of this paper acplishes the setting and reading/writing operation, using the AT mands to control the MODEM dialing, and a transport protocols for files. All of these make two PCs send and receive files from the public telephone line by using the MODEM. The design is intended to make the user who has not installed the work to transmit data with others by telephone lines using the 56k MODEM. Compared with the Inter, the telephone line is safer and widely distributed. The design makes use of the universality and the safety of the telephone line. Key words: Linux。 MODEM 目 錄 論文總頁(yè)數(shù): 24頁(yè) 1 引 言 ...................................................................................................................... 2 設(shè)計(jì)背景 ........................................................................................................ 2 本設(shè)計(jì)的意義 ................................................................................................. 2 設(shè)計(jì)方法 ........................................................................................................ 2 理論依據(jù) ........................................................................................................ 2 2 設(shè)計(jì)理論依據(jù) ............................................................................................................ 2 Linux ............................................................................................................. 2 串行端口簡(jiǎn)介 ................................................................................................. 3 串行通迅 .............................................................................................. 3 RS232C.............................................................................................. 3 異步通迅 .............................................................................................. 4 MODEM簡(jiǎn)介 ..................................................................................................... 5 MODEM ................................................................................................... 5 AT命令 ................................................................................................ 5 3 系統(tǒng)開(kāi)發(fā)環(huán)境 ............................................................................................................ 6 系統(tǒng)開(kāi)發(fā)環(huán)境 ................................................................................................. 6 gcc簡(jiǎn)介 ......................................................................................................... 6 4 程序的設(shè)計(jì) ............................................................................................................... 7 設(shè)計(jì)概要 ........................................................................................................ 7 RS232C建立與打開(kāi) ...................................................................................... 8 串口設(shè)置與讀寫(xiě) .............................................................................................. 9 c_cflag控制項(xiàng)設(shè)置 ............................................................................. 9 c_iflag、 c_lflag和 c_oflag設(shè)置 .................................................... 10 c_cc控制字符設(shè)置 ..............................................................................11 讀寫(xiě)串口 ............................................................................................ 12 MODEM的控制 ................................................................................................ 13 MODEM的兩種工作狀態(tài) ....................................................................... 13 DTE與 DCE的握手 .............................................................................. 13 MODEM撥號(hào)連接 .................................................................................. 14 文件傳輸協(xié)議的設(shè)計(jì) ..................................................................................... 15 5 編碼實(shí)現(xiàn) ................................................................................................................. 17 串口初始化實(shí)現(xiàn) ............................................................................................ 17 串口讀寫(xiě)的實(shí)現(xiàn) ............................................................................................ 18 MODEM初始化的實(shí)現(xiàn) ..................................................................................... 19 MODEM狀態(tài)讀取的實(shí)現(xiàn) .................................................................................. 21 6 程序測(cè)試 ................................................................................................................. 21 串口傳輸文件測(cè)試 ........................................................................................ 21 MODEM撥號(hào)連接并傳輸數(shù)據(jù)測(cè)試 .................................................................... 22 結(jié) 論 ........................................................................................................................ 22 參考文獻(xiàn) ........................................................................................................................ 23 致 謝 ........................................................................................................................ 24 聲 明 ........................................................................................................................ 25 第 1 頁(yè) 共 24頁(yè) 第 2 頁(yè) 共 24頁(yè) 1 引 言 設(shè)計(jì)背景 現(xiàn)在,隨著計(jì)算機(jī)網(wǎng)絡(luò)技術(shù)的發(fā)展,國(guó)民收入的提高,互聯(lián)網(wǎng)走進(jìn)了千家萬(wàn)戶,但仍有很多計(jì)算機(jī)用戶并沒(méi)有安裝寬帶或其它網(wǎng)絡(luò)設(shè)備。 本設(shè)計(jì)的意義 如果想傳送份文件給對(duì)方,卻苦惱于無(wú)法上互聯(lián)網(wǎng),那么用 MODEM 通過(guò)電話線發(fā)送文件就變得非常有用處了。 設(shè)計(jì)方法 本設(shè)計(jì)基于 Linux 操作系統(tǒng),用 POSIX termios 函數(shù)控制計(jì)算機(jī)串口,使用AT 指令操作 MODEM 進(jìn)行初始化及撥號(hào)連接,最后用一個(gè)自編的文件傳輸協(xié)議傳輸文件。此次設(shè)計(jì)之所以選擇 Linux,是因?yàn)?Linux 有著