登录
首页 » Com Port » 从串口读取数据,有两种方法,1、每接收一个EV_RXCHAR,就用ReadFile读一次,这样我觉得太恐怖了。2、接收到一个EV_RXCHAR后,等一定数据量的...

从串口读取数据,有两种方法,1、每接收一个EV_RXCHAR,就用ReadFile读一次,这样我觉得太恐怖了。2、接收到一个EV_RXCHAR后,等一定数据量的...

于 2023-03-23 发布 文件大小:45.33 kB
0 164
下载积分: 2 下载次数: 1

代码说明:

从串口读取数据,有两种方法,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 analys

下载说明:请别用迅雷下载,失败请重下,重下不扣分!

发表评论

0 个回复

  • 从串口读取数据,有两种方法,1、每接收一个EV_RXCHAR,就用ReadFile读一次,这样我觉得太恐怖了。2、接收到一个EV_RXCHAR后,等一定数据量的...
    从串口读取数据,有两种方法,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 analys
    2023-03-23 09:55:03下载
    积分:1
  • 利用MSComm进行pc串口编程。好用
    利用MSComm进行pc串口编程。好用-MSComm to pc using serial programming. Easy to use. . . .
    2023-03-10 09:50:03下载
    积分:1
  • Below is a serial communication part of the original development of the code, wr...
    下面是串口通信开发的部分原码,自己写的,可能有些错误,希望大大家指教.-Below is a serial communication part of the original development of the code, wrote it myself, may be some mistakes and we hope that the shortage.
    2023-03-19 05:30:04下载
    积分:1
  • C++ Builder模仿RS232设备发出XONXOFF软体流量控制信号,包括…
    C++ Builder模拟RS232设备XONXOFF软件流量控制信号,包括源代码可以更基本为7。
    2022-08-20 14:54:14下载
    积分:1
  • 实现两台机器之间的串口通信!可以对串口进行调试!
    实现两台机器之间的串口通信!可以对串口进行调试!-achieved between the two machines serial communications! Can serial debugging!
    2022-09-30 11:10:02下载
    积分:1
  • 实现函数发生器产生的波形能够在电脑显示器上显示。函数发生器通过GPIB卡与电脑连接并传输数据,电脑上通过LABVIEW软件环境完成与GPIB卡的数据通信。在LA...
    实现函数发生器产生的波形能够在电脑显示器上显示。函数发生器通过GPIB卡与电脑连接并传输数据,电脑上通过LABVIEW软件环境完成与GPIB卡的数据通信。在LABVIEW环境下完成了对虚拟仪器前面板以及后台程序框图的设计与编程。在LABVIEW开发环境下,实现对GPIB控制时,采用VISA模块驱动的方法进行编程。设计结果在LABVIEW环境下的虚拟示波器能够实现示波器的功能,能够显示函数发生器所产生的任意波形。- achieve the waveform can be displayed on the screen of the computer which send out by the function generator. The function generator connect to computer through a GPIB card and transfer data. Labview can be communicated with GPIB card and save data on computer. The virtual instrument front panel design and background process diagram programming can achieved under Labview software environment. The realization of GPIB control, using VISA module-driven approach to program in Labview. The result of the design is that the virtual oscilloscope is able to complete the Real oscilloscope function in Labview.
    2022-07-12 01:20:57下载
    积分:1
  • 自己做串口通讯介绍(VC平台) 一个很vc上的
    自己做串口通讯介绍(VC平台) 一个很vc上的-done on serial communication (VC) is one of the Eastern vc
    2023-08-27 21:15:04下载
    积分:1
  • 单片机的通用串口接收和发送无线信息,无线接收…
    单片机通用串口uart接收与发送无线信息,实现无线接收。-MCU Universal Serial uart receive and transmit a wireless message, wireless receiver.
    2022-03-14 09:56:41下载
    积分:1
  • HP 8163A power meter GPIB programming reference 技术文件
    HP 8163A power meter GPIB programming reference 技术文件-HP 8163A power meter GPIB programming reference technical documents
    2022-04-01 01:40:50下载
    积分:1
  • Zebra 热传打印机控制 串口ActiveX控件 My email: richardlzl@163.com...
    Zebra 热传打印机控制 串口ActiveX控件 My email: richardlzl@163.com -Zebra thermal printer-control serial ActiveX My email : richardlzl@163.com
    2023-07-31 03:20:03下载
    积分:1
  • 696516资源总数
  • 106914会员总数
  • 0今日下载