03-29-2017 12:22 AM - edited 03-29-2017 12:27 AM
Hello,
LabVIEW has a DAQmx System property node, which has a Device Names item. This returns a list of DAQmx devices on my system.
I was looking for an equivalent function in the ANSI C library (http://zone.ni.com/reference/en-XX/help/370471AF-01/TOC3.htm ), but couldn't find anything. Does this function exist?
Thanks!
Solved! Go to Solution.
03-30-2017 07:28 AM
You'll want to look in the "NI-DAQmx C Properties" section. The C equivalent to LabVIEW's DAQmx System→Device Names property is DAQmxGetSysDevNames.
05-30-2018 02:47 PM
Hello,
the DAQmxGetSysDevNames function uses a character pointer (char *data) as an argument. What should I use for this? Should I just define an empty character array and then use its pointer in the DAQmxGetSysDevNames function? I haven't been able to find an example ANSI C code for this function. As you can probably tell I am very new to programming.
Regards,
05-30-2018 06:37 PM - edited 05-30-2018 06:38 PM
The documentation for that function, unfortunately, is quite lacking.
The operative documentation is How Do I Dynamically Choose the Size of an Array to be Passed to a NI-DAQmx C Function?, and my answer on Why does DAQmxGetDevAOVoltageRngs return 4 values? demonstrates the approach. That example was for a function returning an array of floating point values, but the same general principle applies with a string (in C, an array of characters)-- calling with a NULL pointer and a length of 0 will return the required buffer size, when you then have to allocate.
/* NOTE: for sake of brevity, error handling has been elided in this example */
int32 status; int32 stringLength; /* get number of characters */ stringLength = DAQmxGetSysDevNames(NULL, 0); if (stringLength < 0) { /* handle error */ } else { char *deviceNames = (char *)calloc(stringLength, sizeof(char)); if (!deviceNames) { /* handle allocation failure */ } status = DAQmxGetSysDevNames(deviceNames, stringLength); if (status < 0) { /* handle failure */ } printf("Devices: %s\n", deviceNames);
free(deviceNames); }
For properties that return a list of devices or channels, as DAQmxGetSysDevNames does, the format is (loosely) documented in Physical Channel Syntax; it is a comma-and-space separated list. For example:
cDAQ3, cDAQ3Mod1, cDAQ3Mod4, cDAQ3Mod6