Compartir a través de


ClearCommError (Compact 2013)

3/28/2014

This function retrieves information about a communications error and reports the current status of a communications device.

The function is called when a communications error occurs, and it clears the error flag of the device to enable additional I/O operations.

Syntax

BOOL ClearCommError(
  HANDLE hFile,
  LPDWORD lpErrors,
  LPCOMSTAT lpStat
);

Parameters

  • hFile
    [in] Handle to the communications device, returned by the CreateFile function.
  • lpErrors
    [out] Long pointer to a 32-bit variable to be filled with a mask indicating the type of error.

    The following are values for this parameter.

    Value

    Description

    CE_BREAK

    The hardware detected a break condition.

    CE_FRAME

    The hardware detected a framing error. Returned when the SERIAL_LSR_FE bit is detected in the LSR hardware register.

    This is the framing error indicator. It is set whenever the hardware detects that the incoming serial data unit does not have a valid stop bit. This bit is cleared by reading this register:

    #define SERIAL_LSR_FE 0x08

    CE_IOE

    An I/O error occurred during communications with the device.

    CE_MODE

    The requested mode is not supported, or the hFile parameter is invalid.

    If this value is specified, it is the only valid error.

    CE_OVERRUN

    A character-buffer overrun has occurred.

    The next character is lost.

    CE_RXOVER

    An input buffer overflow has occurred.

    There is either no room in the input buffer, or a character was received after the end-of-file (EOF) character.

    CE_RXPARITY

    The hardware detected a parity error.

    CE_TXFULL

    The application tried to transmit a character, but the output buffer was full.

  • lpStat
    [out] Long pointer to a COMSTAT structure in which the device's status information is returned.

    If lpStat is NULL, no status information is returned.

Return Value

Nonzero indicates success. Zero indicates failure. To obtain extended error information, call the GetLastError function.

Remarks

If a communications port is set up with a TRUE value for the fAbortOnError member of the setup DCB structure, the communications software will terminate all read and write operations on the communications port when a communications error occurs.

No new read or write operations are accepted until the application acknowledges the communications error by calling the ClearCommError function.

The ClearCommError function fills the status buffer pointed to by the lpStat parameter with the current status of the communications device specified by the hFile parameter.

The framing error indicator CE_FRAME is set whenever the hardware detects that the incoming serial data unit does not have a valid stop bit. This bit is cleared by reading this register: #define SERIAL_LSR_FE 0x08

Windows Embedded Compact does not support the CE_DNS, CE_OPP, and CE_PTO error codes.

Requirements

Header

winbase.h

Library

Serdev.lib

See Also

Reference

Serial Communications Functions
ClearCommBreak
COMSTAT
DCB

Other Resources

CreateFile