02-23-2010 05:34 AM
Hello all,
from reading the NIDAQmx help files I suspect this is not possible, but nevertheless I thought I'd give it a shot: I know one can use the DAQmxGetDeviceAttribute(...DAQmx_Dev_AI_PhysicalChans...) function to get a char * containing the names of input channels on the device. Is there any way to retrieve the exact number of input channels? (besides tokenizing the char * and counting the channels?)
Thank you!
02-23-2010 09:19 AM
See this recent post:
http://forums.ni.com/ni/board/message?board.id=170&thread.id=477043
-AK2DM
02-23-2010 11:11 AM
02-23-2010 11:21 AM
02-23-2010 11:32 AM
02-23-2010 02:22 PM
AK2DM and Dennis, DAQmxGetDevAIPhysicalChans() in the DAQmx ANSI C API returns a single C string via an out-parameter. It uses ", " as the delimiter between channels. It doesn't return an array of pointers to C strings. If it did, then you would have to call back into DAQmx to free them, because different DLLs have different memory allocators on Windows. Also, the DAQmx ANSI C API has no flatten/unflatten channel string functions.
Acgrama, you're right that there is no easier or more elegant way to do this through the DAQmx ANSI C API. You'll have to tokenize the string to count the number of channels. It's easy to do this with strtok(), but this modifies the string and is not thread-safe on all platforms. It's slightly less easy to count the tokens by using strcspn() to identify the end of a token and strspn() to identify the end of a delimiter, but this approach doesn't modify the string. I would also recommend going to www.ni.com/contact and submitting product feedback about this.
Brad
02-23-2010 02:41 PM - edited 02-23-2010 02:42 PM
Sorry, thought it worked the same way as LabVIEW with the AI.PhysicalChannel property.