|
| 1 | +/* This a library for communication with Maxon Motors EPOS2 motor controllers |
| 2 | + * using MATLAB. |
| 3 | + * |
| 4 | + * Copyright, Eugenio Yime Rodr�guez, 2015 |
| 5 | + * |
| 6 | + */ |
| 7 | + |
| 8 | +#include "mex.h" |
| 9 | +#include "Definitions.h" |
| 10 | + |
| 11 | +#ifdef _LINUX_ |
| 12 | +#include "Win2Linux.h" |
| 13 | +#endif |
| 14 | + |
| 15 | +void |
| 16 | +mexFunction(int nlhs,mxArray *plhs[],int nrhs,const mxArray *prhs[]) |
| 17 | +{ |
| 18 | + DWORD ErrCode = 0; |
| 19 | + BOOL Fault = FALSE; |
| 20 | + HANDLE mHandle; |
| 21 | + WORD NodeID; |
| 22 | + long lHandle; |
| 23 | + int IdMode; |
| 24 | + char ErrorInfo[255]; |
| 25 | + |
| 26 | + /* Examine input (right-hand-side) arguments. */ |
| 27 | + if (nrhs != 2) { |
| 28 | + mexPrintf("Error: this function should be use with two input arguments\n"); |
| 29 | + return; |
| 30 | + } |
| 31 | + /* Check first input, handle */ |
| 32 | + if (mxGetM(prhs[0]) != 1 || mxGetM(prhs[0]) != 1 ) { |
| 33 | + mexPrintf("Error: this function requires two input scalar\n"); |
| 34 | + return; |
| 35 | + } |
| 36 | + /* Check second input, nodeID */ |
| 37 | + if (mxGetM(prhs[1]) != 1 || mxGetM(prhs[1]) != 1 ) { |
| 38 | + mexPrintf("Error: this function requires two input scalar\n"); |
| 39 | + return; |
| 40 | + } |
| 41 | + |
| 42 | + /* Examine output (left-hand-side) arguments. */ |
| 43 | + if (nlhs > 1) { |
| 44 | + mexPrintf("Error: this function should be use with only one output argument\n"); |
| 45 | + return; |
| 46 | + } |
| 47 | + |
| 48 | + /* create output matrix */ |
| 49 | + plhs[0] = mxCreateDoubleScalar(0.0); |
| 50 | + |
| 51 | + /* first input */ |
| 52 | + lHandle = (long) *mxGetPr(prhs[0]); |
| 53 | + mHandle = LongToHandle(lHandle); |
| 54 | + /* second input */ |
| 55 | + NodeID = (WORD) *mxGetPr(prhs[1]); |
| 56 | + |
| 57 | + /* Set State to Disable */ |
| 58 | + if (!VCS_SetDisableState(mHandle, NodeID, &ErrCode)) { |
| 59 | + VCS_GetErrorInfo(ErrCode, ErrorInfo, 255); |
| 60 | + mexPrintf("Error: %s \n", ErrorInfo); |
| 61 | + *mxGetPr(plhs[0]) = 1; |
| 62 | + } |
| 63 | +} |
0 commit comments