LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way to query whether a visa alias exists?

I have software that can use one of two instruments. I would like to determine which one is being used by searching for the Visa Alias that is set up in the Automation explorer. Is there a way to query in CVI whether a visa alias is assigned other than trying to use it and waiting for the instrument to error out? 
0 Kudos
Message 1 of 6
(3,727 Views)
Steve,

I would check out the "Finding Resources" section of the NI-VISA help, it outlines exactly how to do this with C examples.  Here is a short except from there:

"[When] you need to know the exact location (address) of the resource you want to open. To find out what resources are currently available at a given point in time, you can use the search services provided by the viFindRsrc() operation.

Post back if you have any additional questions.
-Marshall R
0 Kudos
Message 2 of 6
(3,703 Views)

Hi,

 

i can't manage to get resources from their alias name by using the function viFindRsrc(). Can anyone give me an example how to do that?

 

...if i fill in the alias name (as it is set in the max explorer) for parameter 2 (Expression),

eg. viFindRsrc (Session, "COM1", &FindList, &Cnt, description);

i always get the error that the device can not be found...

0 Kudos
Message 3 of 6
(3,286 Views)

That's why VISA resource is named differently: correct syntax is ASRL1::INSTR for COM1.

To find all serial devices in your system you can use viFindRsrc (vH, "ASRL?*INSTR", &list, &count, msg);

 

Refer to the help for 'Expression' parameter for a detailed description of the syntax name and available possibilities for searching VISA resources.



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 4 of 6
(3,270 Views)

I know how to get resources by their types... i wanted a way to get resources by their alias, but it seem CVI doesn't support that Smiley Indifferent - on LabView there is an additional parameter for the function wheter to search for aliases: search mode determines how the function returns found interfaces in the find list output, either by canonical names or aliases. The default is 0. --- why is it so difficult to give the same functionality to LabWindows Smiley Frustrated

In addition i found a forum entry: http://forums.ni.com/t5/Instrument-Control-GPIB-Serial/Does-vifindrsrc-support-alias-names/td-p/3058...

 

SO, i made a workaround: searching for the given alias in the visaconf.ini and getting the resource type from there, then using viFindRsrc()...

 

Smiley HappySmiley Tongue

0 Kudos
Message 5 of 6
(3,238 Views)

I cannot give you the same functionality of the LV version of viFindRsrc; as a workaround you can use some additional lines to list all visa resources and obtain their aliases: it's a longer route but can be used to locate a specific resource by alias.

These lines can be pasted and executed in the Interactive Execution window:

 

#include <visa.h>
#include <utility.h>
static ViFindList list;
static char msg[512];
static ViUInt32 cnt;
static ViSession vH;
static int		i;
static ViUInt16 type;
static ViUInt16 num;
static ViChar class[256];
static ViChar unAliasName[256];
static ViChar Alias[256];

viOpenDefaultRM (&vH);
viFindRsrc (vH, "?*", &list, &cnt, msg);
viParseRsrcEx (vH, msg, &type, &num, class, unAliasName, Alias);
DebugPrintf ("%d resources found\n", cnt);
DebugPrintf ("1: %s (%s)\n", msg, Alias);
for (i = 1; i < cnt; i++) {
	viFindNext (list, msg);
	viParseRsrcEx (vH, msg, &type, &num, class, unAliasName, Alias);
	DebugPrintf ("%d: %s (%s)\n", i + 1, msg, Alias);
}

On my laptop it gives the following output:

3 resources found
1: ASRL1::INSTR (COM1)
2: ASRL3::INSTR (COM3)
3: ASRL5::INSTR (COM2)

 

 

 



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 6 of 6
(3,206 Views)