Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ: Init_DA_Brds resets digital lines, Init_DA_Brds2 crashes

The first DAQ function called automatically calls Init_DA_Brds, which has the nasty sideffect of resetting the digital lines on the DAQ card. It has been posted that the undocumented function Init_DA_Brds2 can be used to prevent Init_DA_Brds from being called. I could not find the function in the .lib file associated with nidaq32.dll, so instead called the .dll directly:

HINSTANCE LibHnd = LoadLibrary("nidaq32.dll");
typedef i16 (WINAPI *Init_DA_Brds2_Type)(i16, i16 FAR *);
Init_DA_Brds2_Type prcPtr = (Init_DA_Brds2_Type) GetProcAddress(LibHnd,"Init_DA_Brds2");
int result = -1;
if(prcPtr != NULL)
result = prcPtr(m_deviceNumber, &m_deviceCode);
FreeLibrary(LibHnd);

Unfortunately,
Init_DA_Brds2 causes a stack corruption (which the compiler suggests is because of using the wrong calling convention). However, replacing "Init_DA_Brds2" by "Init_DA_Brds" works.
My concern is not having the digital lines reset. What's the best workaround?
(I'm using NI-DAQ 6.9.3 and Measurement Studio .NET for Windows XP)
0 Kudos
Message 1 of 2
(2,587 Views)
The Init_DA_Brds2 function has a slightly different prototype.

prototype for Init_DA_Brds2:

status = Init_DA_Brds2 (short board, short *boardCode, short hardInit)

board and boardCode behave as described in Init_DA_Brds function documentation.

hardInit controls wheter or not the hardware of the board is initialized:
0- the hardware is not initialized
1- the hardware is initialized (operation of function is identical to Init_DA_Brds)

If Init_DA_Brds2 is called with hardInit = 0 as the first call in a program, the hardware will not be initialized.
WARNING: The hardware must be initalized at least once after power-up of the computer. This function should be used with great care. If hardInit = 0, the software is initialized while the hardware remai
ns uninitialized. Therefore, the software copy of the hardware state will not match the actual hardware state.

Init_DA_Brds2 is really only useful in a DOS application, since Init_DA_Brds is autmatically called when the NI-DAQ DLL loads in Windows 95 and NT.
0 Kudos
Message 2 of 2
(2,587 Views)