How do I format/send VISA commands to a PXI Switch device such as
- niSwitch_InitWithTopology(instr, topology, VI_FALSE, VI_TRUE, &switchSession); using ANSI C ? How do I query the result ?
I am able to use VISA commands to Open, Find Resources etc., but I would like to use VISA (message based) commands to perform various functions such as Self-Test, MakeConnection etc. I am using ANSI C under VC++. I am new to PXI and VISA and I tried to make this work using the following snippet, but get nonsensical results.
viPrintf (instr, "niSwitch_InitWithTopology(instr, topology, VI_FALSE, VI_TRUE, &switchSession)\n");
viPrintf (instr,"niSwitch_self_test (instr, &SelfTestResult, testMessage)\n");
viScanf (instr, "%s", testMessage);
Thanks in advance for any help.
A function with a C Function Prototype such as:
ViStatus niSwitch_InitWithTopology (ViRsrc resourceName, ViConstString topology, ViBoolean simulate, ViBoolean resetDevice, ViSession* vi);
returns whether or not the function was successful. This is stored in a ViStatus variable. This, I am guessing, is what you are interested in.
Please check out some C Examples to see how we perform error handling. Normally, in our example VIs, we will use the method outlined in niSwitchErrorHandler. Please view this program and then another that shows its use. I would recommend the C programs located in the following folders:
In the end, the function will look something like below:
niSwitchCheckErr(niSwitch_InitWithTopology(resourceName, topology, VI_FALSE, VI_TRUE, &switchSession));
If this does not assist you, please let me know what the results you are currently getting look like. Thanks!