EasyManua.ls Logo

SystemBase Portbase-3010 - Page 103

SystemBase Portbase-3010
118 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Portbase User Guide
displayed on the edit box at 3 second Intervals.
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;
dcb.ByteSize = 8;
dcb.Parity = NOPARITY;
dcb.StopBits = ONESTOPBIT;
103

Table of Contents