LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

CVI ComRdByte Error -99

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;
}
0 Kudos
Message 1 of 2
(3,724 Views)
I'm pretty sure what you are seeing in the CVI environment warning you that a libary error is returned while you were debugging. CVI does this so that when you are debugging you will know when library functions are returning errors, even if you aren't handling them. This should NOT happen when running a release executable and you can turn this off while debugging in CVI by unchecking Options->Run Options->Break on Library Errors in the Project window menu.

Best Regards,

Chris Matthews
National Instruments
Message 2 of 2
(3,724 Views)