Application notes
Version 8 dated 15.03.00 189
Siemens Information and Communication Products
A
8.4.2.14 int SetCommState(lpdcb)
const DCB FAR* lpdcb; /* address of device control block */
The SetCommState function sets a communications device to the state specified by a device control block.
int SetCommState(lpdcb)
Parameter Description
lpdcb Indicates a DCB structure that contains the desired communications settings for the device. The
ID member of the DCB structure must identify the device.
Return value 0 if the function is successful.
Otherwise < 0
Example The following example uses the BuildCommDCB and SetCommState functions to set up COM1
at 9600 baud, no parity, 8 data bits, and 1 stop bit:
idComDev = OpenComm("COM1", 1024, 128);
if (idComDev < 0)
{ ShowError(idComDev, "OpenComm");
return 0;
}
err = BuildCommDCB("COM1:9600,n,8,1", &dcb);
if (err < 0)
{ ShowError(err, "BuildCommDCB");
return 0;
}
err = SetCommState(&dcb);
if (err < 0)
{ ShowError(err, "SetCommState");
return 0;
}
Comments This function reinitializes all hardware and controls as defined by the DCB structure, but it does
not empty transmission or receiving queues.
See also GetCommState, DCB