Switch Hardware and Software

cancel
Showing results for 
Search instead for 
Did you mean: 

niSE_GetError returns empty string

I am trying to programatically retrieve error information from niSE using the niSE_GetError function, and the error string returned is always empty.  I hacked up the VB example code to demonstrate the problem:
 
Private Sub cmdConnect_Click()
Dim errNo As Long
Dim errDesc As String
Dim errSize As Long
    ' connect the route specified in txtRoute
    stat = niSE_Connect(session, txtRoute.Text, NISE_VAL_USE_DEFAULT_MODE, True)
    stat = niSE_Connect(session, txtRoute.Text, NISE_VAL_USE_DEFAULT_MODE, True) <-- cause an error
    If (stat <> 0) Then
        stat = niSE_GetError(session, errNo, errDesc, errSize)  <-- errDesc comes back empty
    End If
    ' NOTE:  this would be a logical place to put a measurement task
   
    ' disconnect the route
    niSECheckErr niSE_Disconnect(session, txtRoute.Text), session
End Sub
0 Kudos
Message 1 of 2
(6,413 Views)

Mark,

If you look at your code, you'll notice that it is different from the example code that retrieves the error. (look at the niSECheckErr and niSECheckErr2 functions for proper error handling).

I also pasted the description of niSE_GetError function below.


In a nutshell, the function will only return required buffer size when called with the error description size of 0. (I don't see you passing a value other than 0 to it - it is uninitialized, but it is reasonable to expect VB to initialize it to zero.

I hope this helps!


-Serge


Queries for and returns the most recent error.

Function Prototype

Function niSE_GetError( sessionHandle As NISESession,

errorNumber As Long,

errorDescription As String,

errorDescriptionSize As Long) As NISEStatus

Parameters

Input

Name Type Description
sessionHandle NISESession The session referencing this NI Switch Executive virtual device session.

Input/Output

Name Type Description
errorDescriptionSize Long The errorDescriptionSize is a Long that is passed by reference into the function.

As an input, it is the size of the error description buffer being passed. If the error description is larger than the error description buffer being passed, only the portion of the error description that can fit in the error description buffer is copied into it.

On return from the function, errorDescriptionSize holds the size required to hold the entire error description.
Note  errorDescriptionSize may be larger than the buffer size as the function always returns the size needed to hold the entire buffer.


You can pass NULL for this parameter if you are not interested in the return value for errorDescriptionSize and errorDescription.

Output

Name Type Description
errorNumber Long The error code.
errorDescription String Description of the error.

To dynamically allocate space for the errorDescription buffer, call niSE_GetError twice. The first call should specify a errorDescriptionSize of 0 and then use the returned errorDescriptionSize to allocate the correct buffer size.

0 Kudos
Message 2 of 2
(6,408 Views)