/* * Function accepts a slot number and returns a value representing the type of National * Instruments card in that slot. * * Allen W. Ingling 7/23/99 */ // includes for mex API #include "mex.h" // includes for NIDaq API // #include #include #include #include "nidaq.h" #include "utility.h" /* mexFunction is the gateway routine for the MEX-file. */ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { int mrows,ncols,i; double *rsltPntr1; double niDeviceNumber, niPort, niPattern; i32 error; // check to be sure that valid arguments were passed if (nrhs !=3) { mexErrMsgTxt("Three inputs required."); } for (i=0;i<3;i++) { mrows = mxGetM(prhs[i]); ncols = mxGetN(prhs[i]); if (!mxIsDouble(prhs[i]) || mxIsComplex(prhs[i]) || !(mrows == 1 && ncols == 1)) { mexErrMsgTxt("Inputs must be a noncomplex scalar doubles"); } } // create matrices for the return arguments plhs[0] = mxCreateDoubleMatrix(1,1,mxREAL); rsltPntr1 = mxGetPr(plhs[0]); // call the NIDaq function and load results into return variables. niDeviceNumber = mxGetScalar(prhs[0]); niPort = mxGetScalar(prhs[1]); niPattern = mxGetScalar(prhs[2]); error = DIG_Out_Port((u32)niDeviceNumber, (u32)niPort, (u32)niPattern); *rsltPntr1 = (double)error; }