-
Notifications
You must be signed in to change notification settings - Fork 2
/
CloseCommunication.c
48 lines (41 loc) · 1.17 KB
/
CloseCommunication.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* This a library for communication with Maxon EPOS4 motor controllers
* using MATLAB.
*
* Copyright, Eugenio Yime Rodriguez, 2015
*
*/
#include "mex.h"
#include "Definitions.h"
#ifdef _LINUX_
#include "Win2Linux.h"
#endif
void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) {
DWORD ErrCode = 0;
BOOL Output = FALSE;
HANDLE mHandle;
WORD NodeID;
long lHandle;
char ErrorInfo[255];
/* Examine input (right-hand-side) arguments. */
if (nrhs != 1) {
mexPrintf("Error: this function should be use with one input arguments\n");
return;
}
/* Check first input */
if (mxGetM(prhs[0]) != 1 || mxGetM(prhs[0]) != 1) {
mexPrintf("Error: this function requires one input scalar\n");
return;
}
/* create output matrix */
plhs[0] = mxCreateDoubleScalar(0.0);
/* first input */
lHandle = (long) *mxGetPr(prhs[0]);
mHandle = LongToHandle(lHandle);
/* Close Device */
Output = VCS_CloseDevice(mHandle, &ErrCode);
if (ErrCode) {
VCS_GetErrorInfo(ErrCode, ErrorInfo, 255);
mexPrintf("Error: %s \n", ErrorInfo);
*mxGetPr(plhs[0]) = 1;
}
}