Problems with ML API GetFault

GetFault is returning the wrong values. I execute the following code using the ML API:

...
        ml_fault_t fault;
        int error = ml_GetFault(device_hdl, &fault);
        if(fault.value == ML_FAULT_TYPE_CLEAR)
        {
             faultString = "ml_GetFault: ML_FAULT_TYPE_CLEAR\n";
        }
        if((fault.value & ML_FAULT_TYPE_SENSOR_OUT_OF_RANGE) != 0)
        {
            faultString += "ml_GetFault: ML_FAULT_TYPE_SENSOR_OUT_OF_RANGE\n";
        }
        if((fault.value & ML_FAULT_TYPE_COIL_OVERTEMP) != 0)
        {
            faultString += "ml_GetFault: ML_FAULT_TYPE_COIL_OVERTEMP\n";
        }
        if((fault.value & ML_FAULT_TYPE_COIL_OVERCURRENT) != 0)
        {
            faultString += "ml_GetFault: ML_FAULT_TYPE_COIL_OVERCURRENT\n";
        }
        if((fault.value & ML_FAULT_TYPE_FLOTOR_OVERSPEED) != 0)
        {
            faultString += "ml_GetFault: ML_FAULT_TYPE_FLOTOR_OVERSPEED\n";
        }
        printf("The fault status is %s\n", faultString.c_str());
...

I deliberately set the flotor so that the sensors were out of range. The result was:

ml_GetFault: ML_FAULT_TYPE_SENSOR_OUT_OF_RANGE
ml_GetFault: ML_FAULT_TYPE_FLOTOR_OVERSPEED

The fault value was 9. (out of range = 1, overspeed = 8...  faults are stored bitwise in "value"~so the demo code that comes with the device will only work if there's only one fault!)

Now, the flotor wasn't floating, much less moving, so the flotor definitely wasn't overspeed. Then I realized that on the previous test of one of my programs, the flotor might have gone overspeed. In between the previous test and the current test, the PID controller and the ML device were completely shut down. Yet, somehow, the fault condition was saved from the previous test and was appended to the current fault condition. Is that supposed to happen?

I reset the faults using the monitor program and got the correct result (Sensors out of range).

I added a ResetFault call before the getfault. According to the API, "The ml_ResetFault() call will succeed only if all of the prevailing fault conditions have been removed."

Then the result was:

ml_GetFault: ML_FAULT_TYPE_CLEAR (the value is 0)

(the sensors, mind you, are still out of range)

Is there a way to call get fault without getting the previous faults? and why does reset fault clear even the current faults?

Um...in the meantime, I'm going to do a work-around and check all of the sensors one by one instead of relying on this getFault function. :/

jen