NI DIGITAL PATTERN DRIVER Error Handling Functions - ni/grpc-device GitHub Wiki

Error Handling Functions

niDigital_GetError

Returns the error information associated with the digital pattern instrument handle. This function retrieves and then clears the error information for the session. If vi is VI_NULL, this function retrieves and then clears the error information for the current thread.

You must provide a ViChar array to serve as a buffer for the value. You pass the number of bytes in the buffer as the buffer size. If the current value of the error description, including the terminating NULL byte, is larger than the size you indicate in the buffer size, the function copies (buffer size -1) bytes into the buffer, places an ASCII NULL byte at the end of the buffer, and returns the buffer size you must pass to get the entire value. For example, if the value is "123456" and the buffer size is 4, the function places "123" into the buffer and returns 7. If you want to call this function just to get the required buffer size, you can pass 0 for the buffer size and VI_NULL for errorDescription.

C Function Prototype: ViStatus niDigital_GetError (ViSession vi, ViStatus* errorCode, ViInt32 errorDescriptionBufferSize, ViChar[] errorDescription)

Parameter Description
vi The specified instrument session the niDigital_init or niDigital_InitWithOptions function returns.
Output
errorCode The returned error code for the session or execution thread.
errorDescriptionBufferSize The number of elements in the ViChar array you specify for errorDescription.
errorDescription

The returned error description for the IVI session or execution thread.

If there is no description, the function returns an empty string. The buffer must contain at least as many elements as the value you specify with the buffer size parameter.

If you pass 0 for errorDescriptionBufferSize, you can pass VI_NULL for this parameter.

Return value: Reports the status of the operation. If the buffer size is 0 or too small for the error description, the buffer size needed for the full description is returned.

niDigital_ClearError

Clears the error information for the current execution thread and the IVI session you specify. If you pass VI_NULL for the vi parameter, this function clears the error information only for the current execution thread.

C Function Prototype: ViStatus niDigital_ClearError (ViSession vi)

Parameter Description
vi The specified instrument session the niDigital_init or niDigital_InitWithOptions function returns.

Return value: Reports the status of the operation.

niDigital_error_message

Takes the error code returned by the digital pattern instrument driver functions, interprets it, and returns it as a user readable string.

C Function Prototype: ViStatus niDigital_error_message (ViSession vi, ViStatus errorCode, ViChar[] errorMessage)

Parameter Description
vi The specified instrument session the niDigital_init or niDigital_InitWithOptions function returns. You may also specify VI_NULL as the instrument session to retrieve the error message even when the niDigital_init function or the niDigital_InitWithOptions function fails.
errorCode The specified error code.
Output
errorMessage The error information formatted as a string. The array must contain at least 256 characters.

Return value: Reports the status of the operation.

⚠️ **GitHub.com Fallback** ⚠️