/* Function accepts a slot number, a port number, and a value. It sets the port to the value. See file DIG_Out_Port.m for more documentation. Allen W. Ingling 7/23/99 History: 7/23/99 awi created file 4/27/00 awi moved to CW pro 5, fixed description, removed #include for utility.h . */ // includes for mex API #include "mex.h" // includes for NIDaq API #include #include #include "nidaq.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; }