Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Get a list of physical channels

Dear community,
I am using DAQmx8.3  C API under VS.net.
I need to acquire a list of physical channels of a device to make a user able to select a channel.
 
After extensive navigation through discussion forums, I found a reference to DAQmxGetDeviceAttribute function.
This function is not listed in the C API help, but its prototype can be found in NIDAQmx.h, which means the library supports it.
 

int32 __CFUNC_C DAQmxGetDeviceAttribute (const char deviceName[], int32 attribute, void *value, ...);

Can anyone provide a description how to use it?
I am not familiar with LabView where, as I understand, attribute is a key concept. 
As for the device, I will be using cDAQ9170, (until it arrives USB-6009), but I think this function does not care.
 
thanks,
Oksana
 
 
0 Kudos
Message 1 of 3
(5,574 Views)
Oksana,

You can get a list of physical channels using the following functions:

DAQmxGetSysDevNames(char *data, uInt32 bufferSize); - this gives you all the devices that are configured under DAQmx on your system
data is the string that contains all the device names

DAQmxGetDevAIPhysicalChans(const char device[], char *data, uInt32 bufferSize); - this gives you all the physical channels on a device
device[] input is a device name from the first function
data is the string that contains all the physical channels

I wrote the following code as an example:

    char        devices[11];
    char        devName[4];
    char        channels[1000];
    DAQmxErrChk (DAQmxGetSysDevNames(devices, 11));
    printf("%s\n",devices);
    for (i;i<4;i++)
        devName[i] = devices[i];
    DAQmxErrChk (DAQmxGetDevAIPhysicalChans(devName, channels, 1000));
    printf("%s\n",channels);  

Hope this helps!

Abhinav T.
Applications Engineer
National Instruments
Abhinav T.
Applications Engineering
National Instruments India

LabVIEW Introduction Course - Six Hours
Getting Started with NI-DAQmx
Measurement Fundamentals
0 Kudos
Message 2 of 3
(5,564 Views)
Hello Abhinav,
It did help! And it works.
I would define  devName[5]; to include \0 character, and accommodate the for loop appropriately in the example.
In my case, it doesn't really matter, I have only one device anyway.
Thanks a lot!
Oksana
0 Kudos
Message 3 of 3
(5,556 Views)