




版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、串行設(shè)備驅(qū)動(dòng)第1頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日主要內(nèi)容1、Windows CE.net串行設(shè)備簡(jiǎn)介2、串口設(shè)備驅(qū)動(dòng)3、串行設(shè)備API簡(jiǎn)介4、串口設(shè)備操作5、紅外設(shè)備簡(jiǎn)介第2頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日1、Windows CE.net串行設(shè)備簡(jiǎn)介第3頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日Windows CE.net串行設(shè)備Windows CE.net的串行設(shè)備應(yīng)用十分廣泛GPRS通信智能數(shù)據(jù)終端GPS定位系統(tǒng)紅外通訊設(shè)備第4頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日使用通用碼流進(jìn)行數(shù)據(jù)傳輸,與標(biāo)準(zhǔn)串口完全兼容支持3線/
2、9線串口方式串口模型基本延續(xù)了桌面系統(tǒng)的風(fēng)格和基本的API,但未封裝成類第5頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日串口的7層結(jié)構(gòu)第6頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日第7頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日Netarm2410-S串行設(shè)備情況UART0(3線) 標(biāo)準(zhǔn)格式化信息輸出串口;基本通訊串口UART1(3線) 基本通訊串口(未使用)UART2(3線) 紅外通訊串口;基本通訊串口第8頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日2、串口設(shè)備驅(qū)動(dòng)第9頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日串口設(shè)備驅(qū)動(dòng)是一種流驅(qū)動(dòng)BS
3、P中提供的串口驅(qū)動(dòng)模型較為復(fù)雜,在結(jié)構(gòu)上也分層為MDD和PDD層第10頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日第11頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日第12頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日3、串行設(shè)備API簡(jiǎn)介第13頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日串口的APICreateFileOpens a serial port.GetCommStateFills in a device-control block DCB structure with the current control settings for a spe
4、cified communication device.SetCommStateConfigures a communication device according to the specifications in a DCB structure. The function reinitializes all hardware and control settings, but does not empty I/O queues.GetCommTimeoutsRetrieves the time-out parameters for all read/write operations on
5、a specified communication device.SetCommTimeoutsSets the time-out parameters for all read/write operations on a specified communication device.WriteFileWrites data to a serial port, which transfers data to the device at the other end of a serial connection.ReadFileReads data from a serial port, whic
6、h receives data from a device at the other end of a serial connection.第14頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日串口的APISetCommMaskSpecifies a set of events to monitor for a communication device.GetCommMaskRetrieves the value of the event mask for a specified communication device.WaitCommEventWaits for an event t
7、o occur for a specified communication device. The set of events monitored by WaitCommEvent is contained in the event mask associated with the device handle.EscapeCommFunctionDirects a specified communication device to perform an extended function. Often used to set a serial port to IR mode.ClearComm
8、BreakRestores character transmission for a specified communication device and places the transmission line in a non-break state.ClearCommErrorRetrieves communication error data and reports the current status of a specified communication device.第15頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日4、串口設(shè)備操作第16頁(yè),共35頁(yè),2022年,5月
9、20日,6點(diǎn)1分,星期日打開(kāi)串口/ Open the serial port. hPort = CreateFile (lpszPortName, / Pointer to the name of the port GENERIC_READ | GENERIC_WRITE, / Access (read-write) mode 0, / Share mode NULL, / Pointer to the security attribute OPEN_EXISTING,/ How to open the serial port 0, / Port attributes NULL); / Han
10、dle to port with attribute / to copy第17頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日配置串口/ Initialize the DCBlength member. PortDCB.DCBlength = sizeof (DCB); / Get the default port setting information.GetCommState (hPort, &PortDCB);/ Change the DCB structure settings.PortDCB.BaudRate = 9600; / Current baud PortDCB.fBi
11、nary = TRUE; / Binary mode; no EOF check PortDCB.fParity = TRUE; / Enable parity checking PortDCB.fOutxCtsFlow = FALSE; / No CTS output flow control PortDCB.fOutxDsrFlow = FALSE; / No DSR output flow control PortDCB.fDtrControl = DTR_CONTROL_ENABLE; / DTR flow control type PortDCB.fDsrSensitivity =
12、FALSE; / DSR sensitivity PortDCB.fTXContinueOnXoff = TRUE; / XOFF continues Tx PortDCB.fOutX = FALSE; / No XON/XOFF out flow control PortDCB.fInX = FALSE; / No XON/XOFF in flow control PortDCB.fErrorChar = FALSE; / Disable error replacement PortDCB.fNull = FALSE; / Disable null stripping PortDCB.fRt
13、sControl = RTS_CONTROL_ENABLE; / RTS flow control PortDCB.fAbortOnError = FALSE; / Do not abort reads/writes on errorPortDCB.ByteSize = 8; / Number of bits/byte, 4-8 PortDCB.Parity = NOPARITY; / 0-4=no,odd,even,mark,space PortDCB.StopBits = ONESTOPBIT; / 0,1,2 = 1, 1.5, 2 / Configure the port accord
14、ing to the specifications of the DCB structure.if (!SetCommState (hPort, &PortDCB) / Could not configure the serial port. dwError = GetLastError (); MessageBox (hMainWnd, TEXT(Unable to configure the serial port), TEXT(Error), MB_OK); return FALSE;第18頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日設(shè)置超時(shí)值/ Retrieve the ti
15、me-out parameters for all read and write operations on the port. COMMTIMEOUTS CommTimeouts;GetCommTimeouts (hPort, &CommTimeouts);/ Change the COMMTIMEOUTS structure settings.CommTimeouts.ReadIntervalTimeout = MAXDWORD; CommTimeouts.ReadTotalTimeoutMultiplier = 0; CommTimeouts.ReadTotalTimeoutConsta
16、nt = 0; CommTimeouts.WriteTotalTimeoutMultiplier = 10; CommTimeouts.WriteTotalTimeoutConstant = 1000; / Set the time-out parameters for all read and write operations on the port. if (!SetCommTimeouts (hPort, &CommTimeouts) / Could not set the time-out parameters. MessageBox (hMainWnd, TEXT(Unable to
17、 set the time-out parameters), TEXT(Error), MB_OK); dwError = GetLastError (); return FALSE;第19頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日寫(xiě)串口DWORD dwError, dwNumBytesWritten;WriteFile (hPort, / Port handle &Byte, / Pointer to the data to write 1, / Number of bytes to write &dwNumBytesWritten, / Pointer to the numbe
18、r of bytes / written NULL / Must be NULL for Windows CE);第20頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日讀串口BYTE Byte;DWORD dwBytesTransferred;ReadFile (hPort, / Port handle &Byte, / Pointer to data to read 1, / Number of bytes to read &dwBytesTransferred, / Pointer to number of bytes / read NULL / Must be NULL for W
19、indows CE);第21頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日使用通訊事件BYTE Byte;DWORD dwBytesTransferred;/ Specify a set of events to be monitored for the port.SetCommMask (hPort, EV_RXCHAR | EV_CTS | EV_DSR | EV_RLSD | EV_RING);while (hPort != INVALID_HANDLE_VALUE) / Wait for an event to occur for the port. WaitCommEvent
20、 (hPort, &dwCommModemStatus, 0); / Re-specify the set of events to be monitored for the port. SetCommMask (hPort, EV_RXCHAR | EV_CTS | EV_DSR | EV_RING); if (dwCommModemStatus & EV_RXCHAR) / Loop for waiting for the data. do / Read the data from the serial port. ReadFile (hPort, &Byte, 1, &dwBytesTr
21、ansferred, 0); / Display the data read. if (dwBytesTransferred = 1) ProcessChar (Byte); while (dwBytesTransferred = 1); 第22頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日通訊事件簡(jiǎn)介EventDescriptionEV_BREAKA break occurred on input.EV_CTSThe CTS signal changed state.EV_DSRThe DSR signal changed state.EV_ERRA line-status erro
22、r occurred. Line-status errors are CE_FRAME, CE_OVERRUN, and CE_RXPARITY.EV_RINGA ring indicator was detected.EV_RLSDThe receive-line-signal-detect signal changed state.EV_RXCHARA character was received and placed in the input buffer.EV_RXFLAGThe event character was received and placed in the input
23、buffer.EV_TXEMPTYThe last character in the output buffer was sent.第23頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日關(guān)閉串口BOOL CloseHandle( HANDLE hObject ); 關(guān)閉一個(gè)已經(jīng)打開(kāi)的對(duì)象句柄,使用這種方法來(lái)關(guān)閉串口參數(shù):待關(guān)閉的句柄返回值:是否關(guān)閉成功第24頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日5、紅外設(shè)備簡(jiǎn)介第25頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日紅外通訊紅外線是波長(zhǎng)在750nm至1mm之間的電磁波,其頻率高于微波而低于可見(jiàn)光,是一種人的眼眼看不到的光線。目前無(wú)線電波和微波已被廣泛應(yīng)用在長(zhǎng)距離的無(wú)線通信中,但由于紅外線的波長(zhǎng)較短,對(duì)障礙物的衍射能力差,所以更適合應(yīng)用在需要短距離無(wú)線通信場(chǎng)合點(diǎn)對(duì)點(diǎn)的直接線數(shù)據(jù)傳輸。第26頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日紅外協(xié)議棧第27頁(yè),共35頁(yè),2022年,5月20日,6點(diǎn)1分,星期日各模塊解釋物理層協(xié)議(Ph
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 單位招聘合同范本
- 勞務(wù)會(huì)議合同范本
- 單位職工集資合同范例
- 住建部咨詢編制合同范本
- 單位托管食堂合同范本
- 買(mǎi)賣(mài)珠寶合同范本
- 前期類工程合同范例
- 分公司簽合同范本
- 副食品采購(gòu)合同范本
- 冷庫(kù)竣工合同范例
- 臺(tái)灣長(zhǎng)庚文化村
- 藥理學(xué)免疫器官和組織
- 禮儀與溝通完整版
- 2023年超齡員工承諾書(shū) 60歲以上員工承諾書(shū)(八篇)
- 失業(yè)證明模板(通用6篇)
- 001 比較思想政治教育(第二版) 第一章
- 股骨粗隆間骨折PPT
- 供應(yīng)商年度評(píng)審記錄表
- 飲用水源地保護(hù)區(qū)環(huán)境整治工程項(xiàng)目可行性論證報(bào)告建議書(shū)
- 第五部分茶藝館的經(jīng)營(yíng)與管理
- 《習(xí)作:那一刻-我長(zhǎng)大了》課件ppt
評(píng)論
0/150
提交評(píng)論