Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Does vifindrsrc support alias names?

Hello,
 
I'm using the VIFindRsrc function call with an alias I have defined within MAX.  The result is that it never finds that resource.  I change the alias name to the actual connect string and it finds the device.
 
Is viFindRsrc suppose to work with alias names?
 
If not then how do I use an alias name to find if a device is there?
 
Thanks
PAA
0 Kudos
Message 1 of 6
(4,777 Views)
PAA,

I believe  viFindRsrc is supposed to work with aliases. I have a rather large setup (>35 devices & ports) and I am using aliases intensively. AND I am using the LabVIEW node 'VISA Find Resource' to get the list of availabel devices to check the operatability of the system. But I am not sure if your VIFindRsrc is actually the same basic functionality...
Greetings from Germany!<br>-- <br>Uwe
0 Kudos
Message 2 of 6
(4,754 Views)
Thanks Lul,
 
Well I'm not using the Labview interface but the C library call, so apparently the function is broken.
 
Further evidence of this is that I can "viOpen" an alias just fine, yet the viFindRsrc does not.
 
PAA
0 Kudos
Message 3 of 6
(4,750 Views)
You might want to use viFindRsrc in conjunction with viParseRsrcEx to match the resource name with an alias if it exists.  So, use one of the regular expressions in viFindRsrc to narrow down the resources you are interested in. Then call viParseRsrcEx and compare returned aliases to the one you are trying to match.
0 Kudos
Message 4 of 6
(4,746 Views)
Here is some code that I'm using to test the viFindRsrc function:
 

viFindRsrc(resManHndle, instrDescriptor, &lst, &retCnt, jnk);

if (retCnt <= 0)

{

ViUInt16 jnk1, jnk2;

ViChar jnk3[80], unAliasedName[80], jnk4[80];

ViStatus ret;

ret = viParseRsrcEx(resManHndle,

instrDescriptor,

&jnk1,

&jnk2,

jnk3,

unAliasedName,

jnk4);

if (ret == VI_SUCCESS)

{

viFindRsrc(resManHndle, unAliasedName, &lst, &retCnt, jnk);

}

}

 

The above code tries to do a viFindRsrc and when it fails it checks to see if the device name is an alias name and gets the real connection string for that.  After getting an alias string it does another viFindRsrc to determine if the device is there or not.

 

THE ABOVE CODE HAS TO WORK RIGHT!?!?!?    NOPE!!!!!

Strangely enough the MAX string for the device is:USB0::0x16AA::0x3004::141050-0002::RAW, but the return string from viParseRsrcEx returns USB0::0x16AA::0x3004::141050-0002::0::RAW.

Notice the extra ::0 in the result of viParseRsrcEx.

You pass this string back to viFindRsrc and it promptly indicates the device isn't there - even though it is.

Edit the string in the debugger to remove the ::0 and voilet it works.

Any ideas would be appreciated.

0 Kudos
Message 5 of 6
(4,734 Views)
The viParseRsrcEx actually returns the full name which includes the optional parameters for a given resource name. The ::0 that you see is the optional interface number for the USB RAW device you are using. The problem you then run into is that the FindRsrc just parses the items shown in MAX and tries to make an exact match, but it doesn't take into account the optional parameters, however if you tried to open the result that was returned from viParseRsrcEx it would open correctly.

You will need to do is take this into account for RAW devices and I would suggest always calling the Parse first if you don't know if the input will be an alias or not. Something similar to this might work.

ViUInt16 jnk1, jnk2;
ViChar jnk3[80], unAliasedName[80], jnk4[80];

status = viParseRsrcEx(defaultRM, instrDescriptor, &jnk1, &jnk2, jnk3, unAliasedName, jnk4);

if(0==strcmp(jnk3,"RAW"))
{
sprintf(strstr(unAliasedName,"RAW")-3,"?*");
}

if (status == VI_SUCCESS)
{
viFindRsrc(defaultRM, unAliasedName, &findList, &numInstrs, jnk);
}
0 Kudos
Message 6 of 6
(4,707 Views)