PurgeComm The PurgeComm function discards all characters from the output or input buffer of a specified communications resource. It can also terminate pending read or write operations on the resource. PurgeComm的意思并不是销毁缓冲区,他的一层意思是memset(p,0,size),另外就是取消读写操作,问当打开com1端口后,系统是为其分配了缓冲区 ///////////////////////////////////////// 注意这里并没有分配缓冲区,串口缓冲区是启动操作系统后就有的,他由驱动程序管理,不可能会被销毁的
The PurgeComm function discards all characters from the output or input buffer of a specified communications resource. It can also terminate pending read or write operations on the resource.
PurgeComm的意思并不是销毁缓冲区,他的一层意思是memset(p,0,size),另外就是取消读写操作,问当打开com1端口后,系统是为其分配了缓冲区
/////////////////////////////////////////
注意这里并没有分配缓冲区,串口缓冲区是启动操作系统后就有的,他由驱动程序管理,不可能会被销毁的
///////////////////////////////////////////////////////////////////////////////
那么我前面发出去的数据不是被memset(p,0,size),那为什么后面用ReadFile()函数还是读的到数据呢?注意这里并没有分配缓冲区,串口缓冲区是启动操作系统后就有的
//////////////////////////////////////////////////////////////////
那为什么还要SetupComm(hComDev,1024,512)诸如这样的分配缓冲区呢?
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
WriteFile操作完成后,(异步的话需要等待)数据已经发到对方的串口了,PurgeComm一般都是等数据发送完或者在发送数据之前才会调用,这是为了清除一些错误并且保险期间,把缓冲区轻零,这样来保证每一次读或者写都能与上一次不相干,