I am using the following code to read characters back from a Device via an RS232 ComPort. When in one project, this code will error -99 with a Non_Fatal RunTime error dialog box, if the RS232 cable is left disconnected. The Break occurs on the ComRdByte statement. But when placed in a second (different) project, the same code section will return a -99 without the Error Dialog box. What makes the response different? How can I perform a ComRdByte that will safely return the Error Code so that I can create Error handling routines? The Help section on the COmRdByte command mentions MultiThreading, could this be where the different responses are originating from? If so, how would I change the code to insure MultiThreading does occur?
int UUT_
Unlock( void )
{
char buf[200], end_char;
int index, control, panel, status = UUT_UNLOCK_FAIL;
char * Serial;
FlushInQ (HW_COM1_LP20);
ComWrt (HW_COM1_LP20, "Unlock\r", 7);
Delay(.5);
index = 0;
end_char = 0;
while (end_char != '%' && end_char != -99 && index < UUT_MAX_RESPONSE-1)
{
buf[index] = ComRdByte (HW_COM1_LP20);
end_char = buf[index];
index++;
}
buf[index] = 0;
if ((strstr(buf, "UNLOCKED") != NULL) || (strstr(buf, "Unlock") != NULL))
{
status = UUT_UNLOCK_PASS;
ComWrt (HW_COM1_LP20, "WTAWHSS\r", 8);
Delay (0.2);
while (end_char != '%' && end_char != -99 && index < UUT_MAX_RESPONSE-1)
{
buf[index] = ComRdByte (HW_COM1_LP20);
end_char = buf[index];
index++;
}
}
return status;
}