KsSetCommState

The availability of this function depends on what the device supports.

Configures a communications device according to the specifications in a device-control block (a DCB structure). The function reinitializes all hardware and control settings, but it does not empty output or input queues.

Syntax

BOOL KsSetCommState(
     HANDLE hFile,
     LPDCB lpDCB
);

Parameters

hFile: a handle to the communications device. The KsCreateComm function returns this handle.

lpDCB: a pointer to a DCB structure that contains the configuration information for the specified communications device.

Return value

If the function succeeds, it returns TRUE, otherwise FALSE. To get extended error information, call GetLastError.

Remarks

The KsSetCommState function uses a DCB structure to specify the desired configuration. The KsGetCommState function returns the current configuration.

To set only a few members of the DCB structure, you should modify a DCB structure that has been filled in by a call to KsGetCommState. This ensures that the other members of the DCB structure have appropriate values.

The KsSetCommState function fails if the XonChar member of the DCB structure is equal to the XoffChar member.

When KsSetCommState is used to configure the 8250, the following restrictions apply to the values for the DCB structure's ByteSize and StopBits members:

The number of data bits must be 5 to 8 bits.

Example

N/A

Requirements

  RT Win32
Minimum supported version 4.0 4.0
Header kscom.h kscom.h
Library KsApi_Rtss.lib ksapi.h

See also

KsCreateComm

KsGetCommMask

KsGetCommState

KsSetCommMask