?? com_open.c
字號:
/*******************************************************************************
* Open RS-232 communications object. *
* Syntax: Handle = Com_Open(Com_Port, Baud_Rate) *
* *
* Input Parameters: *
* ================ *
* *
* Com_Port ----> Serial RS-232 port (string). *
* Baud_Rate ---> Serial baud rate (positive integer). *
* *
* Output Parameters: *
* ================= *
* *
* Handle ------> I/O object handle (positive integer). *
* *
* See also Com_Close(), Com_Recv(), Com_Send(). *
* *
* Compile: mex -v com_open.c cmApiCom.c *
* Version: 01-22-2005 *
* *
* (C) 2004 Stephan Hengstler, Stanford Wireless Sensor Networks Lab *
*******************************************************************************/
#include <stdio.h>
#include <windows.h>
#include "mex.h"
#include "cmApiCom.h"
void mexFunction(int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[])
{
char *com_port;
double *result;
HANDLE handle;
int baud_rate, status;
/* get the value(s) of the input variable(s) */
com_port = (char *) mxCalloc(5, sizeof(char));
status = mxGetString(prhs[0], com_port, 5);
baud_rate = (int) mxGetScalar(prhs[1]);
/* call the respective subroutine(s) */
status = cmComSet(CMCOM_TAG_BAUDRATE, baud_rate);
handle = (HANDLE) cmComOpen(com_port);
/* set the value(s) of the output variable(s) */
plhs[0] = mxCreateDoubleMatrix(1, 1, mxREAL);
result = mxGetPr(plhs[0]);
*result = (int) handle;
/* show debug information */
if (nrhs == 3)
{
printf("Debug Information\n");
printf("com_port = %s\n", com_port);
printf("baud_rate = %d\n", baud_rate);
printf("handle = %d\n", handle);
}
/* clean exit */
return;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -