Specifications

AN93
218 Rev. 0.9
SetCommTimeouts(hCom, &sCOMMTIMEOUTS);
// Read the serial port
BOOL bError = !ReadFile(hCom, cpInputWr, 1, &ulNoOfbytes, 0); //cpInputWr has
char from the port
iCharCount += ulNoOfbytes; iCharCnt+=ulNoOfbytes;
if(bError)
{
strcat(cpErrorString, "Read Error\r\n");
exit(10); // implement a write to file
before exit(0)
}
cpInputWr += ulNoOfbytes;
// check for a timeout
sCurrentTime = clock();
iPasses++;
if( sCurrentTime > (sStartTime + sWaitTime) )
{
strcat(cpErrorString, "Timeout of "); strcat(cpErrorString, cpResponse);
printf ("\n%s\n", cpErrorString);
strncpy(cpInput_test, cpInputBuffer, iCharCnt);
cpInput_test[iCharCnt]='\0'; //copy the received bytes for late display
return cpInputBuffer; // we exit with the same input string we came in
with
// because we time out.
}
}
};
// -------------------------------------------------------------------------
void AssertRTS(bool bAssert)
{
BOOL bSuccess;
if(bAssert)
dcb.fRtsControl = RTS_CONTROL_ENABLE; // assert RTS
else
dcb.fRtsControl = RTS_CONTROL_DISABLE; // dis-assert RTS
bSuccess = SetCommState(hCom, &dcb);