04-10-2008 09:57 AM
04-11-2008 10:01 AM
07-31-2014 08:38 AM
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...
08-01-2014 05:41 AM - edited 08-01-2014 05:44 AM
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.
08-05-2014 03:06 AM
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 - 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
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()...
08-08-2014 02:27 AM
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)