亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? cmapicom.c

?? MATSNL is a package of MATLAB M-files for computing wireless sensor node lifetime/power budget and
?? C
字號:
/* * File: cmApiCom.c  * * Description:  Communications Interface with the camera module. * * WARNING: This library is not thread-safe. * */#include "cmApiCom.h"#include <stdio.h>// global declarationsint com_debug = 0;              /* debug flag */int delayMs = 0;			// inter-character delay argumentint sendOption = 9;int breakOption = 1;        // use break signal eventint g_baudrate = CBR_115200;    /* baud rate for interface *//* *  Function: cmComOpen * *  Description: Open a communications port to the camera module  * *				The communications is done via an RS-232 serial port. * *	Input Arguments: *			comName_p		Pointer to a zero terminated character string *							that has an ASCII representation of the port *							name. For example:  "COM1".  It has to be  *							one recognized by the Win32 API. *  Output Arguments: *			None. *	Returns: *			comHandle		A handle required for all other interface  *							function. It references the port that was  *							opened. * * Design Notes: *      - For the camera module, the timeout between characters should be  *        set to the break signal duration. However, this duration is  *        12 bit times, which is about 100 us. we will use 1. */HANDLE cmComOpen (char *comName_p) {	HANDLE comh;						// communications port handle	char bResult;	DCB	comPortDCB;						// Device control block	COMMTIMEOUTS comPortTimeout;	if (com_debug > 0) printf ("Opening COM port %s\n", comName_p);	comh = CreateFile (					comName_p,		// device name					GENERIC_WRITE|GENERIC_READ,	// desired access					0,				// exclusive access					NULL,			// security access					OPEN_EXISTING,	// creation disposition
					0,					NULL);	if (comh == INVALID_HANDLE_VALUE) {		return comh;	}	// Read in port parameters	bResult = GetCommState (comh, &comPortDCB);	if (!bResult) {        printf ("Error Retrieving COM port info = %d\n", GetLastError());		CloseHandle (comh);		return INVALID_HANDLE_VALUE;	}	if (com_debug > 0) {		// debug print out of relevant values        printf ("\n\nORIGINAL SERIAL PORT SETTINGS\n");        printf ("Baud Rate = %d\n", comPortDCB.BaudRate);        printf ("Parity (0-4=no,odd,even,mark,space) = %d\n", comPortDCB.Parity);        printf ("Stop Bit (0,1,2 = 1, 1.5, 2) = %d\n", comPortDCB.StopBits);        printf ("Parity Checking Enable         = %d\n", comPortDCB.fParity);        printf ("Number of bits/byte            = %d\n", comPortDCB.ByteSize);        printf ("CTS output flow control Enable = %d\n", comPortDCB.fOutxCtsFlow);        printf ("DSR output flow control Enable = %d\n", comPortDCB.fOutxDsrFlow);        printf ("DTR flow control type          = %d\n", comPortDCB.fDtrControl);        printf ("XON/XOFF out flow control      = %d\n", comPortDCB.fOutX);        printf ("XON/XOFF in flow control       = %d\n", comPortDCB.fInX);        printf ("RTS flow control               = %d\n", comPortDCB.fRtsControl);	}	// Put in new settings.	//		19200, 8, N, 1    NO flow control (HW or SW)	comPortDCB.BaudRate = g_baudrate;	comPortDCB.ByteSize = 8;				// bits/byte	comPortDCB.fParity = FALSE;	comPortDCB.Parity = NOPARITY;	comPortDCB.StopBits = ONESTOPBIT;	comPortDCB.fOutxCtsFlow = FALSE;	comPortDCB.fOutxDsrFlow = FALSE;	comPortDCB.fDtrControl = FALSE;	comPortDCB.fAbortOnError = FALSE;	comPortDCB.fOutX = FALSE;	comPortDCB.fInX = FALSE;	comPortDCB.fRtsControl = FALSE;		if (com_debug > 0) printf ("Setting Serial Port Settings\n"); 	bResult = SetCommState (comh, &comPortDCB);	if (!bResult) {		printf ("Error Setting COM port info = %d\n", GetLastError());		CloseHandle (comh);		return INVALID_HANDLE_VALUE;	}	if (com_debug > 0) {		bResult = GetCommState (comh, &comPortDCB);		if (!bResult) {			printf ("Error Retrieving COM port info = %d\n", GetLastError());			CloseHandle (comh);			return INVALID_HANDLE_VALUE;		}		printf ("\n\nNEW SERIAL PORT SETTINGS\n");		printf ("Baud Rate = %d\n", comPortDCB.BaudRate);		printf ("Parity (0-4=no,odd,even,mark,space) =  %d\n", comPortDCB.Parity); 		printf ("Stop Bit (0,1,2 = 1, 1.5, 2) = %d\n", comPortDCB.StopBits);		printf ("Parity Checking Enable         = %d\n", comPortDCB.fParity);		printf ("Number of bits/byte = %d\n", comPortDCB.ByteSize);		printf ("CTS output flow control Enable = %d\n", comPortDCB.fOutxCtsFlow);		printf ("DSR output flow control Enable = %d\n", comPortDCB.fOutxDsrFlow);		printf ("DTR flow control type          = %d\n", comPortDCB.fDtrControl);		printf ("XON/XOFF out flow control      = %d\n", comPortDCB.fOutX);		printf ("XON/XOFF in flow control       = %d\n", comPortDCB.fInX);		printf ("RTS flow control               = %d\n", comPortDCB.fRtsControl);	}	// Port timeout parameters	if (com_debug > 0) {		printf ("Retrieving COM port timeouts.\n");		bResult = GetCommTimeouts (comh, &comPortTimeout);		if (!bResult) {			printf ("Error Retrieving COM port timeouts = %d\n", GetLastError());			CloseHandle (comh);			return INVALID_HANDLE_VALUE;		}		printf ("COM PORT TIMEOUTS\n");		printf ("Write total timeout multiplier = %d\n", comPortTimeout.WriteTotalTimeoutMultiplier);		printf ("Write total timeout constant = %d\n", comPortTimeout.WriteTotalTimeoutConstant);		printf ("Read Interval timeout = %d\n", comPortTimeout.ReadIntervalTimeout);		printf ("Read total timeout constant = %d\n", comPortTimeout.ReadTotalTimeoutConstant);		printf ("Read total timeout multiplier = %d\n", comPortTimeout.ReadTotalTimeoutMultiplier);	}    // The following settings will cause ReadFile to return immediately.     // Therefore, you must use the WaitEventComm    // MAXDWORD/0/0  means that if there is no character in the     // buffer, then the call returns immediately with 0 bytes read.    //comPortTimeout.ReadIntervalTimeout = MAXDWORD;    //comPortTimeout.ReadTotalTimeoutMultiplier = 0;    //comPortTimeout.ReadTotalTimeoutConstant = 0;    comPortTimeout.ReadIntervalTimeout = 20;            /* ms */    comPortTimeout.ReadTotalTimeoutMultiplier = 1;      /* ms */    comPortTimeout.ReadTotalTimeoutConstant = 1;        /* ms */    comPortTimeout.WriteTotalTimeoutMultiplier = 0;    comPortTimeout.WriteTotalTimeoutConstant = 0;	bResult = SetCommTimeouts (comh, &comPortTimeout);    if (!bResult) {			printf ("Error Setting COM port timeouts = %d\n", GetLastError());			CloseHandle (comh);			return INVALID_HANDLE_VALUE;    }
	SetCommMask (comh, EV_BREAK|EV_RXCHAR);	return comh;			// successful completion}/* *  Function: cmComSend * *  Description: Send a command packet to the camera module.  * *	Input Arguments: *			comh			The handle to the port returned by the m2ComOpen. *			cmd_p			A pointer to a zero terminated ASCII string that *						    represents the command.  There is no limit on the *							length, but it has to be zero terminated. *          nb              Number of bytes to write from the buffer. * *  Output Arguments: *			None. * *	Returns: *			0 = success *			-1 = Error * */int cmComSend (HANDLE comh, unsigned char *cmd_p, int nb){	int length;					// string length	int i;						// loop index	unsigned long nBytes;	char bResult;
	char cbuf;	//length = strlen (cmd_p);    length = nb;    if (com_debug == 5) printf ("Tx: ");	// Write out the command string	for (i = 0; i < length; ++i) {        nBytes = 0;		bResult = WriteFile (comh, &cmd_p[i], 1, &nBytes, NULL);		if (!bResult) {			printf ("cmComSend: Error writing to serial port = %d\n", GetLastError());			printf ("cmComSend: TERMINATING COMMAND.\n");            break;      /* out of the loop */		}        if (com_debug == 5) printf ("%3x ", cmd_p[i]);        // inter-character delay		//if (debug > 1) cout << "cmComSend: Delaying " << delayMs << "Ms" << endl;		//Sleep (delayMs);	} 		// end for	// Write out CR and LF    if (sendOption == cmcomioctl_send_opt_cr_lf) {        cbuf = 0x0d;	    if (com_debug > 0) printf ("cmComSend: Sending <cr>\n");	    bResult = WriteFile (comh, &cbuf, 1, &nBytes, NULL);	    if (!bResult) {		    printf ("cmComSend: Error writing to serial port = %d\n" , GetLastError());		    printf ("cmComSend: TERMINATING COMMAND.%d\n");            goto quit_send;	    }	    //if (debug > 1) cout << "cmComSend: Delaying " << delayMs << "Ms" << endl;	    //Sleep (delayMs);	    cbuf = 0x0a;	    if (com_debug > 0) printf ("cmComSend: Sending <lf>\n");	    bResult = WriteFile (comh, &cbuf, 1, &nBytes, NULL);	    if (!bResult) {		    printf ("cmComSend: Error writing to serial port = %d\n", GetLastError()); 		    printf ("cmComSend: TERMINATING COMMAND.\n");             goto quit_send;	    }		if (com_debug > 1) printf ("cmComSend: Delaying %d Ms\n");		    Sleep (delayMs);    }quit_send:    if (com_debug == 5) printf ("\n"); 	return 0;		// OK}/* *  Function: cmComRecv * *  Description: Read the response packet from the camera module  * *	Input Arguments: *  *			comh			The handle to the port returned by the cmComOpen. *          buffer_p        Pointer to the buffer to read bytes into *          bufferlen       Size of the buffer in bytes *          nbytes_p        Number of bytes to read * *  Output Arguments: * *			buffer_p		A pointer to a zero terminated ASCII string that *						    represents the response packet.    *          nbytes_p        The number of bytes written * *	Returns: * *			>0  success  Returns the number of bytes read. *			-1 = Error */int cmComRecv (HANDLE comh, unsigned char *buffer_p, int bufferlen, int *nbytes_p){    int status = 0;    BOOL bResult = 0;    int i;    if (com_debug == 5) printf ("Rx: ");    bResult = ReadFile (comh, buffer_p, (unsigned long)bufferlen, nbytes_p, NULL);    if (!bResult) {        printf ("cmComRead: Error %d while reading\n", GetLastError());        status = -1;    }    if (com_debug == 5) {        for (i = 0; i < *nbytes_p; ++i) {            printf ("%3x ", buffer_p[i]);        }        fflush(NULL);    }    return status;}/* *  Function: cmComClose * *  Description: Close a commnications port to the camera module  * *	Input Arguments: *			comh			Communications handle obtained from call to  *							cmComOpen. * *  Output Arguments: * *			None. * *	Returns: *			Void */void cmComClose (HANDLE comh){	if (com_debug > 0) printf ("cmComClose: Closing handle. \n"); 	CloseHandle (comh);}/* *  Function: cmComIoctl * *  Description: Set up com parameters * * *	Input Arguments: * *			mode			Read or Write. Currently ignored (only write *							supported). *			tag				Enumerated value for the parameter. *			value_p			Pointer to an integer that contains the  *							value of the parameter. If the pointer is  *  Output Arguments: * *			None. * *	Returns: *			0		Success *			-1		Failure */int cmComIoctl (int tag, int *value_p) {	int	status = 0;	switch (tag) {		case CMCOMIOCTL_TAG_BREAK:			breakOption = *value_p;			break;		case CMCOMIOCTL_TAG_DBG:			com_debug = *value_p;			break;		case CMCOMIOCTL_TAG_DELAY:			delayMs = *value_p;			break;        case CMCOMIOCTL_TAG_SEND_OPT:            sendOption = *value_p;            break;		default:			// ignore			break;	}	return status;} /* *  Function: h16toa * *  Description: Convert a 16-bit hex number to ASCII hex * *	Input Arguments: * *			n		A 4-byte integer. Only the lower 2 bytes are significant. * *  Output Arguments: * *			buf		A pointer to a character buffer that is at least 5  *					characters long. The string that is returned is zero  *					terminated. *	Returns: *			VOID */const char hexstring[17] = "0123456789ABCDEF";		// for both functionsvoid h16toa (int n, char *buf){	buf[4] = '\0';	buf[3] = hexstring[(n & 0x0F)];				// low order nibble	buf[2] = hexstring[((n >> 4) & 0x0F)];		// next nibble	buf[1] = hexstring[((n >> 8) & 0x0F)];		// next nibble	buf[0] = hexstring[((n >> 12) & 0x0F)];		// next nibble}/* *  Function: h8toa * *  Description: Convert a 8-bit hex number to ASCII hex * *	Input Arguments: * *			n		A 4-byte integer. Only the lowest byte is significant. * *  Output Arguments: * *			buf		A pointer to a character buffer that is at least 3  *					characters long. The string that is returned is zero  *					terminated. *	Returns: *			VOID */void h8toa (int n, char *buf){	buf[2] = '\0';	buf[1] = hexstring[(n & 0x0F)];				// low order nibble	buf[0] = hexstring[((n >> 4) & 0x0F)];		// next nibble}/* * Function: cmComSet  * * Description: Set up Communication parameters * * Input parameters: * * Output parameters: * * Returns: */int cmComSet (int tag, int value){    int status = 0;    switch (tag) {        case CMCOM_TAG_BAUDRATE:            switch (value) {                case 9600:                    g_baudrate = CBR_9600;                    break;                case 115200:                    g_baudrate = CBR_115200;                    break;                default:                    g_baudrate = CBR_115200;                    break;            }            break;        default:            /* ignore */            break;    }    return status;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区欧美视频| 日韩一区二区免费高清| 欧美国产一区二区| 欧美成人r级一区二区三区| 色综合久久66| www.视频一区| 国产福利一区二区| 国产在线播放一区二区三区| 裸体一区二区三区| 亚洲午夜在线视频| 成人免费在线观看入口| 国产日韩欧美精品电影三级在线| 日韩欧美成人一区| 91精品久久久久久久99蜜桃| 欧美日韩亚洲另类| 欧美日韩国产首页| 欧美色综合影院| 欧美视频在线不卡| 成人av资源站| 91在线视频免费观看| 在线亚洲一区二区| 欧美日韩一级片在线观看| 欧美日韩一区三区| 91麻豆精品国产91久久久| 欧美一区二区久久| 日韩欧美一区电影| 久久久激情视频| 国产精品美女久久久久久2018| 欧美变态tickle挠乳网站| 欧美日韩免费在线视频| 在线电影院国产精品| 欧美电影在线免费观看| 日韩欧美亚洲一区二区| 久久亚洲免费视频| 国产精品麻豆欧美日韩ww| 中文字幕亚洲精品在线观看 | 精品视频全国免费看| 在线观看av一区二区| 欧美日韩国产另类不卡| 日韩一区二区三区视频在线| 精品久久国产老人久久综合| 久久久久高清精品| 亚洲精品视频一区二区| 婷婷久久综合九色国产成人| 午夜私人影院久久久久| 国产精品影视网| 色综合网站在线| 欧美日韩精品一区二区| 欧美精品乱码久久久久久按摩 | 午夜婷婷国产麻豆精品| 日本成人在线视频网站| 国产成人免费视频网站| 色综合久久久久综合| 日韩久久免费av| 国产精品久久精品日日| 日本成人中文字幕| 成人黄色综合网站| 欧美在线看片a免费观看| 欧美在线999| 久久久久久日产精品| 视频一区二区欧美| av激情成人网| 久久综合狠狠综合久久综合88| 亚洲欧美在线高清| 久久97超碰色| 欧美嫩在线观看| 亚洲欧洲日产国码二区| 国产一区二区看久久| 欧美性猛交xxxxxxxx| 国产日韩v精品一区二区| 亚洲一区二区三区四区在线免费观看| 久久成人综合网| 欧美日韩激情一区二区| 国产精品国产三级国产专播品爱网| 图片区小说区国产精品视频| 日本精品一区二区三区四区的功能| 欧美xxx久久| 日日摸夜夜添夜夜添亚洲女人| 激情欧美一区二区| 538在线一区二区精品国产| 亚洲精品水蜜桃| 成人高清伦理免费影院在线观看| 日韩一区二区三区视频在线| 亚洲午夜精品网| 91国偷自产一区二区三区成为亚洲经典| 91精品国产综合久久久久久久久久| 国内精品第一页| 一区二区三区中文字幕在线观看| 国产精品女同一区二区三区| 亚洲国产日韩在线一区模特| 色悠悠亚洲一区二区| 精品电影一区二区三区| 国产在线精品免费| 久久久精品综合| 成人免费不卡视频| 国产精品二三区| 99久久99久久久精品齐齐| 一区二区三区四区国产精品| 日本韩国一区二区三区视频| 国产亚洲精品久| 成人免费黄色大片| 亚洲色图19p| 欧美精品少妇一区二区三区| 美女网站色91| 国产日韩亚洲欧美综合| 北岛玲一区二区三区四区| 一区二区久久久久| 欧美日韩激情在线| 久久国产综合精品| 欧美国产一区二区在线观看| av午夜一区麻豆| 一区二区日韩av| 91精品福利在线一区二区三区| 久久99久久久欧美国产| 国产网红主播福利一区二区| 97精品电影院| 午夜精品久久久久久久99水蜜桃 | 国产精品99久| 中文字幕在线不卡| 欧美群妇大交群的观看方式| 亚洲在线视频免费观看| 欧美探花视频资源| 久久激情综合网| 亚洲人成网站影音先锋播放| 欧美年轻男男videosbes| 老司机精品视频在线| 国产精品天天看| 91麻豆精品国产91久久久久久| 久久国产精品第一页| 欧美不卡一二三| 不卡视频免费播放| 美女视频黄久久| 中文字幕日韩一区| 欧美一区二区三区人| 久久精品国产亚洲a| 亚洲欧美日韩一区二区| 日韩欧美一区二区不卡| 色婷婷香蕉在线一区二区| 久久99精品久久久久久久久久久久| 欧美激情一区二区三区不卡 | 久久久91精品国产一区二区三区| www.成人在线| 久久成人免费电影| 亚洲成国产人片在线观看| 久久免费午夜影院| 欧美日本乱大交xxxxx| eeuss国产一区二区三区| 日韩中文字幕1| 一本一本大道香蕉久在线精品| 久久午夜国产精品| 日韩欧美一区在线| 欧美理论电影在线| 欧美日韩在线播放三区四区| 欧美日韩你懂的| 777a∨成人精品桃花网| 欧美一级片在线看| 精品三级在线看| 久久午夜老司机| 国产色一区二区| 中文字幕av不卡| 亚洲一区在线免费观看| 亚洲免费观看高清在线观看| 亚洲图片激情小说| 亚洲综合精品自拍| 日韩av中文字幕一区二区| 极品少妇一区二区三区精品视频| 久久 天天综合| 国产成人在线视频免费播放| 成人国产精品免费网站| 色综合亚洲欧洲| 欧美伦理视频网站| 日韩一级片网站| 久久久久国产成人精品亚洲午夜 | 日韩精品一区二区三区在线 | 麻豆专区一区二区三区四区五区| 久久精品国产亚洲一区二区三区| 国产精品一级在线| 一本大道久久a久久精品综合| 欧美影院一区二区三区| 日韩一区二区在线看片| 国产午夜精品一区二区三区视频 | 在线观看区一区二| 欧美一级二级三级乱码| 久久久久亚洲蜜桃| 亚洲最大的成人av| 久久国产精品色| 91在线国产观看| 欧美精品一区二区三区久久久| 国产女主播一区| 亚洲r级在线视频| 国产91精品欧美| 在线综合+亚洲+欧美中文字幕| 国产精品素人视频| 午夜天堂影视香蕉久久| www.日韩av| 精品久久人人做人人爱| 亚洲国产精品一区二区尤物区| 麻豆精品久久精品色综合| 色www精品视频在线观看| 精品奇米国产一区二区三区|