文件名称:20050120091918_MySerialPort[2004-01-18-01]
- 所属分类:
- 串口编程
- 资源属性:
- [Windows] [Visual C] [源码]
- 上传时间:
- 2008-10-13
- 文件大小:
- 45.32kb
- 下载次数:
- 0次
- 提 供 者:
- 刘**
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
从串口读取数据,有两种方法,1、每接收一个EV_RXCHAR,就用ReadFile读一次,这样我觉得太恐怖了。2、接收到一个EV_RXCHAR后,等一定数据量的CPU周期(GetTickCount),再一次性读取缓冲区里的数据。这样做,一般情况下不会有问题,但是,如果数据很多,过了“一定数据量的CPU周期”,还没收完数据怎么办?就会少读数据了。 我用三个线程序来完成串口数据的接收,其实就是第一种方法的变种: 一个侦听EV_RXCHAR,一个对EV_RXCHAR进行分析,其实就是超时判断。如果接收到一个消息后,一段时间没收到下一个EV_RXCHAR,就认为是一个数据包的结束。这个线程就会通知数据接收线程,进行数据接收。一般同一包数据,两个字符之间的时间间隔,应该很小了吧,而两个数据包之间的间隔,应该不会太小吧!(这个地方我不清楚,猜的:( :) )最后一个线程,是接收数据的。-read data from the serial port, there are two methods, one, each receiving a EV_RXCHAR, on the ReadFile read, I think this vote. 2, received a EV_RXCHAR after a certain volume of data, such as CPU cycles (GetTickCount), and the one-time reader, the data buffer. To do so, under normal circumstances there is no problem, but if many of the data, and after a "certain amount of data the CPU cycles," also confiscated End Data how do? Few will read the data. I used three lines to complete serial data reception, the first method is a variant : an interception EV_RXCHAR, one pair of EV_RXCHAR analysis is, in fact, overtime judgment. If a receiver to the news, some time had not received a EV_RXCHAR, it is a data packet to an end. This thread will receive notification of data threads for da
(系统自动生成,下载前可以参看下载内容)
下载文件列表
压缩包 : 17981620050120091918_myserialport[2004-01-18-01].rar 列表 MySerialPort[2004-01-18-01] MySerialPort[2004-01-18-01]\DataStruct.h MySerialPort[2004-01-18-01]\DataStructTemplate.h MySerialPort[2004-01-18-01]\MySerialPort.aps MySerialPort[2004-01-18-01]\MySerialPort.clw MySerialPort[2004-01-18-01]\MySerialPort.cpp MySerialPort[2004-01-18-01]\MySerialPort.dsp MySerialPort[2004-01-18-01]\MySerialPort.dsw MySerialPort[2004-01-18-01]\MySerialPort.h MySerialPort[2004-01-18-01]\MySerialPort.ncb MySerialPort[2004-01-18-01]\MySerialPort.opt MySerialPort[2004-01-18-01]\MySerialPort.plg MySerialPort[2004-01-18-01]\MySerialPort.rc MySerialPort[2004-01-18-01]\MySerialPortDlg.cpp MySerialPort[2004-01-18-01]\MySerialPortDlg.h MySerialPort[2004-01-18-01]\ReadMe.txt MySerialPort[2004-01-18-01]\res MySerialPort[2004-01-18-01]\res\MySerialPort.ico MySerialPort[2004-01-18-01]\res\MySerialPort.rc2 MySerialPort[2004-01-18-01]\resource.h MySerialPort[2004-01-18-01]\Serial.cpp MySerialPort[2004-01-18-01]\Serial.h MySerialPort[2004-01-18-01]\StdAfx.cpp MySerialPort[2004-01-18-01]\StdAfx.h