Look RS232 > RS232C Hardware  

Before starting your work with the port it is desirable to clear the buffers; sometimes there's also need to clear the buffers when working with ports. For these purposes PurgeComm function can be used. This function can also stop read and write operations.

Function syntax:

BOOL PurgeComm(HANDLE hFile, DWORD dwFlags);

Parameters specifications:

hFile - descriptor of the open communication port file;

dwFlags - task to be performed.

This function can perform two tasks: clear the I/O queue in the driver or finish all the I/O operations. The tasks to be performed are specified by the following parameters:

  • PURGE_TXABORT immediately stops all write operations even if they are not finished;
  • PURGE_RXABORT immediately stops all read operations even if they are not finished;
  • PURGE_TXCLEAR clears the out -queue in the driver;
  • PURGE_RXCLEAR clears the in -queue in the driver.


These values can be combined with the help of bitwise OR operation. It is recommended to clear the buffers when I/O errors occur and after the work with the port is finished.
  Contact us
fCoder © 1998 - 2002