Solvline PB2xxxUG User Manual

Page 92

Advertising
background image

4) Source Code

BOOL CExample1Dlg::OnInitDialog()

{

// Opens the COM3 port.

hComm = CreateFile(“\\\\.\\COM3”, GENERIC_READ |

GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

If(hComm == INVALID_HANDLE_VALUE) { // In case the port is not valid

AfxMessageBox(" Failed Open !");

return;

}

// Sets the input time.

COMMTIMEOUTS cto;

cto.ReadIntervalTimeout = 0;

SetCommTimeouts(hComm, &cto);

// Obtains the existing communication specifications.

GetCommState(hComm, &dcb);

// Decides the communication Spec of the port.

dcb.BaudRate = 9600;

92

Advertising