很简单的问题,如何在spcomm中清空缓冲区(50分)

  • 主题发起人 主题发起人 plf22
  • 开始时间 开始时间
P

plf22

Unregistered / Unconfirmed
GUEST, unregistred user!
很简单的问题,如何在spcomm中清空缓冲区
 
我是王磊,厉害吧
 
关闭,打开,OK
 
mazhayang:
sio_Flush,这句话怎么用,我要的是Spcomm的控制方法
 
Flush any data within the driver抯 input/output buffer.

Language Syntax
C/C++ int WINAPI sio_flush(int port, int func)
Visual Basic Function sio_flush (ByVal port As Long, ByVal func As Long) As Long
Delphi function sio_flush(port, func: Longint): Longint;

Argument:

port = COM port number

func = flush function

0 : flush input buffer

1 : flush output buffer

2 : flush input & output buffer

Return:

SIO_OK OK
SIO_BADPORT Port is not opened in advance
SIO_BADPARM Bad parameter
SIO_WIN32FAIL Calling Win32 function failed
Call GetLastError to get the error code

Example:

Flush COM2 input & output buffer:


C/C++

ret = sio_flush ( 2, 2 );
if (ret != SIO_OK) {
/* Fail */
}


Visual Basic

ret = sio_flush ( 2, 2 )
If ret <> SIO_OK Then
慒ail
End If


Delphi

ret := sio_flush ( 2, 2 );
if ret <> SIO_OK then
begin
{ Fail }
end;
 
PurgeComm( hCommFile, PURGE_TXABORT or PURGE_RXABORT or PURGE_TXCLEAR or PURGE_RXCLEAR )
 
后退
顶部