LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Can't get IVI Power Meter error query to work properly.

I have been trying to use the IviPwrMeter Error-Query.vi to read possible errors coming from the Power Meter.  However, I have found that no errors can be detected using this vi.  This is because the returned value 'status' is wired over to the 'error code' input of 'IviPwrMeter Error Converter.vi' and the status value will always be equal to VI_SUCCESS as the attached code signifies.
All of this code was generated by either LabWindows/CVI and/or LabView.
If I wire the error code output of 'IviPwrMeter_error_query' function to the error code input of 'IviPwrMeter IVI error converter.vi', the errors on the Power Meter is at least detected.
Am I doing something wrong here or are there other work arounds?

Source listing of driver call:
ViStatus _VI_FUNC age4418b_error_query (ViSession vi, ViInt32 *errCode,
                                        ViChar errMessage[])
{
    ViStatus    error = VI_SUCCESS;
   
    checkErr( Ivi_LockSession (vi, VI_NULL));
   
    if (errCode == VI_NULL)
        viCheckParm( IVI_ERROR_INVALID_PARAMETER, 2, "Null address for Error Code");
    if (errMessage == VI_NULL)
        viCheckParm( IVI_ERROR_INVALID_PARAMETER, 3, "Null address for Error Message");
 if (!Ivi_Simulating(vi))                /* call only when locked */
     {
     ViSession   io = Ivi_IOSession(vi); /* call only when locked */
 
     checkErr( Ivi_SetNeedToCheckStatus (vi, VI_TRUE));
     viCheckErr( viPrintf(io, ":SYST:ERR?"));
 
  viCheckErr( viScanf (io, "%ld,\"%256[^\"]", errCode, errMessage));
 
     }
 else
     {
         /* Simulate Error Query */
     *errCode = 0;
     strcpy (errMessage, "No error.");
     }
Error:
    Ivi_UnlockSession(vi, VI_NULL);
    return error;
}
0 Kudos
Message 1 of 6
(2,701 Views)
I don't use IVI class drivers often but I don't think the purpose of the error query is to set the error out indicator if the instrument has an error. The purpose of wiring the status to the error out is to indicate that the function that tried to read the instrument had an error. Say that you tried to run the function when the instrument was turned off. The status would indicate a failure of the driver. If the drive is successful in querying the instrument, there should not be an error but the error code and message would be valid. You can use Error Message function and wire the error code output of Error-Query to it. The Error Message will set it's error out cluster if there is an instrument error.
0 Kudos
Message 2 of 6
(2,693 Views)
You may be right in your assumption, however, how can a this function fail.  Status will always be equal to VI_SUCCESS under any and all circumstances because the variable "error" is declared and preset and no other call alters its state before it is returned as status.
 
0 Kudos
Message 3 of 6
(2,690 Views)
It returns a non-zero status for me when I run it because I have no power meter. I get -1074130544 which means the session handle is invalid.
0 Kudos
Message 4 of 6
(2,682 Views)
Dennis,
 
I get the same results as you if I don't have a power meter connected.  However, this doesn't supprise me because the session handle is probably checked at a higher level.
The calling hiearchy is as follows (I think, because I don't have all of the code)  IviPwrMeter Error Query.vi -> IviPwrMeter_error_query (IviPwrMeter.dll) ->age4418b_error_query (age4418b.dll).  I would guess that the session is validated in the second layer and not the bottom layer where the actual instrument error query is happening.
 
Something you may try.  If you have any instrument, write a simple program to get a valid handle then call the error query using the error cluster to link them together.  Set a breakpoint before the error query, run the program, use MAX to send an invalid command and create an error.  Then resume your original program and see if an error is reported in the error cluster after executing the IVI error query.
 
Bob
 
0 Kudos
Message 5 of 6
(2,676 Views)
If the function successfully returns an error code, then I can live without it setting the error cluster. It is inconsistent with the way non-IVI error queries are done in native LabVIEW drivers. I'm not sure where this inconsistency arose. It's possible it's something defined by the IVI foundation. This would be a good question to post over in the Instrument Control forum or to http://www.ivifoundation.org/.
0 Kudos
Message 6 of 6
(2,672 Views)