LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

resource name programatically

Solved!
Go to solution

I am trying to obtain the PXI resource name "PXI1Slot2" programatically.

How to obtain object handle whch viGetAttribute() requires?

viOpenDefaultRM (&rsrcHandle); returns ViSession.

 

Is there a attribute to obtain the Slot number?

 

 

int CVICALLBACK FindResources (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
ViSession rsrcHandle;
ViUInt32 numFound;
char InstrDescriptor[256];
ViFindList MyFindList;
int i;
int chassisNumber;

switch (event)
{
case EVENT_COMMIT:

// First, open a VISA session.
viOpenDefaultRM (&rsrcHandle);

// Now, do an initial search. viFindRsrc returns the instrument descriptor
// of the first instrument found and the number of total resources found.
viFindRsrc (rsrcHandle, "?*PXI?*INSTR", &MyFindList, &numFound, InstrDescriptor);
viGetAttribute (rsrcHandle, VI_ATTR_PXI_CHASSIS, chassisNumber);

// When finished, close the VISA session.
viClose (rsrcHandle);

break;
}
return 0;
}

0 Kudos
Message 1 of 8
(3,791 Views)

Hi sonotk,

 

This document may be helpful: http://digital.ni.com/public.nsf/allkb/2342900AED02975A86256BD800764C8B?OpenDocument. I believe you can use VI_ATTR_SLOT.

Humphrey H.
Applications Engineer
National Instruments
0 Kudos
Message 2 of 8
(3,771 Views)

Thanks. How to get the object that is required by viGetAttribute (rsrcHandle, VI_ATTR_PXI_CHASSIS, chassisNumber);

To use VI_ATTR_SLOT the viGetAttribute will need object and from the snippet I only have ViSession.

This is where I get error.

TIA.

0 Kudos
Message 3 of 8
(3,763 Views)
Solution
Accepted by sonotk

According to the function panel, the Object Handle is a unique logical identifier to a session, find list, or event. So, ViSession should be okay. But it looks like rsrcHandle is a session to the Resource Manager. You'll need to use ViOpen to establish a connection to your device.

Humphrey H.
Applications Engineer
National Instruments
0 Kudos
Message 4 of 8
(3,739 Views)

I am working to get something that would identify the existence of the PXI or PXIe, or lack of existence on the system where my app is running.

This looks promising, but throws all sorts of error when I run it.

 

First, let me say I have an app that runs on a PC, PXI or PXIe system. The PXI has an embedded controller, the PXIe has an MXI Express controller.

 

I would like to have something that would verify the chassis that I have.

 

So, I'm using the code from above:

// First, open a VISA session.
viOpenDefaultRM (&rsrcHandle);

// Now, do an initial search. viFindRsrc returns the instrument descriptor
// of the first instrument found and the number of total resources found.
viFindRsrc (rsrcHandle, "?*PXI?*INSTR", &MyFindList, &numFound, InstrDescriptor);
viGetAttribute (rsrcHandle, VI_ATTR_PXI_CHASSIS, &chassisNumber);
// When finished, close the VISA session.
viClose (rsrcHandle);

 

viFindRsrc give an error "insufficient location information or the device ir resoure is not present in the system"

viGetAttribute gives an error "the specific attribute is not defined or supported by the reference resource"

 

0 Kudos
Message 5 of 8
(3,545 Views)

Do you see the instrument listed in MAX?

*************************************************
CLD
*************************************************
0 Kudos
Message 6 of 8
(3,538 Views)

Yes, I see the chassis and all the cards in that chassis.

0 Kudos
Message 7 of 8
(3,526 Views)

Hi Ken,

 

This thread is a bit older and solved. It may be advantageous to start a new thread with your issue in order to make sure that more forum members see it.

Evan See
National Instruments
0 Kudos
Message 8 of 8
(3,491 Views)