inport.c

来自「MATLAB扩展编程by 孙永康.ZIP.有需要的朋友请来下载.」· C语言 代码 · 共 24 行

C
24
字号
#include "mex.h"
#include "conio.h"

void mexFunction( int nlhs, mxArray *plhs[],
				  int nrhs, const mxArray*prhs[] )
{
	unsigned short port;
	unsigned char  ch;
	double   *ptr;

	if (nrhs != 1)
		mexErrMsgTxt("Need one parameter\n");

	if (!mxIsNumeric(prhs[0]))
		mexErrMsgTxt("Port should be numeric\n");

	ptr     = mxGetPr(prhs[0]);
	port    = (unsigned short) (*ptr);
	ch      = _inp(port);
	
	plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
	ptr     = mxGetPr(plhs[0]);
	*ptr    = (double)ch;
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?