⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 inport.c

📁 直接通过DLL实现端口读写操作的mex程序
💻 C
字号:
#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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -