The Windows version of my DAQ program is rich with Try/Catch statements to avoid crashing on errors that are not worth crashing over.
In C, however, I am struggling with handling faults. I'll give one example from last night. I wish I would have taken a picture because I don't know exactly where in the code it happened.
It was something like this:
token = strtok(buffer, "\t");
if (strstr(token, "ENGINE CONTROL"))
{
token = strtok(NULL, "\t");
CLControls[0]->FinalSetpoint = atoi(token);
token = strtok(NULL, "\t");
CLControls[1]->FinalSetpoint = atoi(token);
token = strtok(NULL, "\t");
CLControls[0]->RampLength = CLControls[1]->RampLength = atoi(token);
CLControls[0]->ThisSetpoint = EngineSpeed;
CLControls[0]->LastSetpoint = EngineSpeed; //CLControls[1]->LastSetpoint = CLControls[1]->ThisSetpoint;
CLControls[1]->ThisSetpoint = DL5.Torque;
CLControls[1]->cumError = 0;
CLControls[0]->Active = CLControls[1]->Active = 1;
}
token was null which means that the message didn't get through for some reason. While running in debugging mode (which we always do), it froze execution and threw a NULL argument to library function error.
Freezing the program is not acceptable because we are running engines and we have safeties and coolant control systems tied to the software.
The obvious answer is that I need to study up on error handling in C, however, It seems as though when I am in debug mode, even if I try to handle an error it will always throw a message box and break out of execution.
I have three questions.
1.What is the best reference for error handling in Labwindows/CVI for real time applications?
2. Can I run through the development environment and still be fault tolerant?
3. Is it possible to set up the debugger to not break/crash on some kinds of errors?
Thank you!