LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

how to automate the DAQmx device name search?

Hello all!!!

I am about to begin writing a dll that will use the a PCI-6509 board for some digital communciations.  I am fairly comrfortable using National Instruments hardware and software "CVI" so this task is not a problem.   My issue  comes  in with making the dll robust.   Several of the  C Functions, like this one -  "DAQmxCreateDOChan" calls for the NI-DAQmx Device name that is generated using the MAX Software.  The name that MAX called the PCI-6509 is called "Dev2".  The text "Dev2/port1/line3:0" or something close to it will be set to the constant char array lines "See below".  I have no problem hard coding this value, but as sure as the sun shines, somebody will end up sticking another card into the pc and connect up stuff backwards.  SO..................... I would like to to pull all the names for all the NI-DAQmx devices make some sort of decision in code there. Any and all suggestions are welcome!!!

int32 DAQmxCreateDOChan (TaskHandle taskHandle, const char lines[ ], const char nameToAssignToLines[ ], int32 lineGrouping);
0 Kudos
Message 1 of 6
(5,027 Views)

You can use these functions to get the list of available devices in the system:

size = DAQmxGetSystemInfoAttribute (DAQmx_Sys_DevNames, NULL, 0);   // Get the buffer size
// Allocate the buffer
DAQmxGetSystemInfoAttribute (DAQmx_Sys_DevNames, buffer, size);    // Get the list of devices

The first instruction returns the size of the buffer to allocate and pass to the following instruction to get the list of devices in the system. After this is done, with DAQmxGetDeviceAttribute you can retrieve all desired attributes of a device: here for example how to retrieve device type:

DAQmxGetDeviceAttribute ("Dev1", DAQmx_Dev_ProductType, msg, 1024);

 



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?
Message 2 of 6
(5,011 Views)
I also once used the function Roberto suggested (DAQmxGetSystemInfoAttribute) to get the device names in our PXI chasis.
 
Even if you pull out a PXI card the function does not recognize it is missing. I think it is because the entry in MAX is still there.
And for this function to change its list of devices (I think) you need to manually delete the device from MAX.
 
When I opened MAX after I took out the card, the device name still can be seen in the list, but its icon on the left of its name is different.
 
But I did not try the DAQmxGetDeviceAttribute function. It may fail since it cannot connect to the device. But in case MAX stores the card info locally after it is first detected, you will still get a valid answer altough there is no card in the slot.
 
I 'd also appreciate more comments on this.


Message Edited by ebalci on 03-07-2008 11:31 AM
S. Eren BALCI
IMESTEK
0 Kudos
Message 3 of 6
(4,984 Views)

I never used a PXI system so this is only a guess... Could it be that after removing a device from the chassis it is still listed in max as a "simulated" device? If so, you can query the appropriate property and verify it:

DAQmxGetDeviceAttribute ("Dev1", DAQmx_Dev_IsSimulated, &simulated);

 



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
(4,979 Views)

Hi all,

I know from experience that MAX will store the name of a device.  If the device is remove and put back in the pc, MAX will restore its previous name to it.  Well, at least that is what I've notice with the NI USB 8451.  I can only guess that MAX stores device names by the ID / serial number.  Those numbers will be unique to each device and allow for such flexibility.

I did not see either of those functions DAQmxGetSystemInfoAttribute or DAQmxGetDeviceAttribute in the NI-DAQmx C Reference Help.

Or I am not looking good enough, but I do see them present in the .h file so that is good enough for me. I probably should start using the Libraries box in CVI. 

 

 

 

0 Kudos
Message 5 of 6
(4,965 Views)

I just tried this out, and it works!!!

Would have been sooner, but sleep kept getting in the way.

Thanks everyone!!!

0 Kudos
Message 6 of 6
(4,916 Views)