NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling IVI/Visa drivers from TestStand

I want to call directly to IVI or Visa driver DLLs using the DLL Flexible Prototype Adapter (because not every instrument in the world is a power-supply, dmm, scope, function-generator or switch). So far, straightforward. But when an error happens, I want it to automatically call the XXXX_error_message() function, to set the Step.Result.Error.Msg string.

The Flexible Prototype Adapter won't do that by itself. I was thinking of adding that functionality to it (making what I would call an "IVI/Visa Driver Adapter"), but I can't find the source code for the adapter. Is it not included with TestStand? I've been amazed by how much source code is included, maybe I'm just missing this one. Is it even possible to write user-defined
step adapters?

- Ron
0 Kudos
Message 1 of 2
(3,302 Views)
I had a brainwave, a fairly elegant solution to my problem that doesn't involve modifying the DLL Flexible Prototype Adapter.

I knew Post Expressions wouldn't cut it, but it just occurred to me to use a Post substep. It works well. So, now I just need to create a custom step type for each instrument driver I'll use, and add a Post substep that calls a bit of code like this:

void __declspec(dllexport) TX_TEST Handle_age1962_error(ViStatus error_code, char error_message[] )
{
if( error_code != 0 ) {
age1962_error_message( VI_NULL, error_code, error_message );
}
}

Just make the Post substep call that using the DLL Flexible Prototype Adapter:
Handle_age1962_error( Step.Result.Error.Code, Step.Result.Error.Msg )

Now the run-time
errors returned by the age1962 driver will have nice human-readable message strings associated with them. And it's a whole lot easier than writing a wrapper and step-type for every single instrument function.

- Ron
0 Kudos
Message 2 of 2
(3,302 Views)