01-31-2006 11:20 PM
02-01-2006 01:38 AM
I suggest you use at program start Ini_DA_Boards function to initialize your board: it the return code from this function is negative the board may be either not present or faulty, in both cases your application cannot start.
As usual, error value has a meaning that can obtained in a string using GetNIDAQErrorString function, so you can prompt your user with the exact description of the error.
02-01-2006 02:45 AM
Hello,
I am not sure how I got this code below. Probably I adapted a sample from the CVI distribution.
The code is made with (traditional) NI-DAQ. It consist of a function that returns a device type number for a NI-DAQ board. And I found a list of device type numbers in the help file for Traditional NI-DAQ C Function Reference Help with the description of Init_DA_Brds
Source:
#define BoardTypePci6110 241
#define BoardTypePci6111 244
static int previousBOLEstate; /* break on library errors */
And anywhere in your application:
DeviceType = Log611xSearchBoard(BoardType);
if (DeviceType >= 0)
{
Log611xDevice = DeviceType;
Init_DA_Brds(Log611xDevice, &BoardType);
Timeout_Config(Log611xDevice, 60);
switch (BoardType)
{
case BoardTypePci6110:
Log611xNumberChannels = 4;
break;
case BoardTypePci6111:
Log611xNumberChannels = 2;
break;
default:
Log611xNumberChannels = 0;
break;
}
... ... ...
And the search function itself:
short Log611xSearchBoard(int type)
{
unsigned short i=0;
unsigned short status;
unsigned long DT;
short ReturnValue = -1;
int Found = 0;
previousBOLEstate = GetBreakOnLibraryErrors ();
if (previousBOLEstate) DisableBreakOnLibraryErrors();
while ((i<8) && (Found == 0))
{
i += 1;
status = Get_DAQ_Device_Info (i, ND_DEVICE_TYPE_CODE, &DT);
if ((status == 0) && (DT == (unsigned long)type))
{
Found = 1;
ReturnValue = (short)i;
}
}
if (previousBOLEstate)EnableBreakOnLibraryErrors();
return(ReturnValue);
}