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

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? comport.cpp

?? 利用串口讀寫(xiě)數(shù)據(jù)實(shí)現(xiàn)的識(shí)幣器驅(qū)動(dòng)程序
?? CPP
字號(hào):
#include <StdAfx.h>
#include "ComPort.h"
#include <stdio.h>
char S_COM9600[]="9600,n,8,1";	//!<Comunnication format string setting 9600 bps, no parity, 8 databits, 1 stop bit
char S_COM19200[]="19200,n,8,1";//!<Comunnication format string setting 19200 bps, no parity, 8 databits, 1 stop bit
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

/**	Default class constructor
	
	The default constructor performs initialization of sensitive member variables and enumeration of the 
	COM ports inthe system
*/ 
CCOMPort::CCOMPort()
{
	hCOMPort=INVALID_HANDLE_VALUE;
//	FindCOM();
    iTimeOut=1500;	
}

/**	Default class destructor
	
	The default destructor calls CloseCOM() function to close the COM port and free associated resources
*/ 
CCOMPort::~CCOMPort()
{
	CloseCOM();

}

/**	\brief	The CCOMPort::IsEnable function returning state of the selected COM port
	
	The function returns error code received during enumeratuion process for the specified COM port

	\param	iPort	a parameter of type int specifying COM port number to request error code for

	\return	DWORD - error code returned by GetLastError() function after CreateFile API function call:
					\n 0 - port is operational and free
					\n 2 - port is not present in the system
					\n otherwise - port is busy with other application or malfunctioning

	
*/
DWORD CCOMPort::IsEnable(int iPort)
{
	return EnablePorts[iPort];
}

/**	\brief	The CCOMPort::OpenCOM function is used to open the COM port specified by parameter

	\param	COMi	a parameter of type int specifiying which port to open

	\return	HANDLE - file handle associated with the open port returned by CreateFile API call

	
*/
BOOL CCOMPort::OpenCOM(int COMi)
{
  DWORD dwError;
  char strCOM[10]="";
  //strCOM[3]+=(iCOM=COMi);
  sprintf(strCOM,"COM%d",COMi);
  _SECURITY_ATTRIBUTES Security;
  Security.bInheritHandle=true;
  Security.lpSecurityDescriptor=NULL;
  Security.nLength=sizeof(Security);
  hCOMPort = CreateFile(strCOM, GENERIC_READ | GENERIC_WRITE,
              0,NULL, OPEN_EXISTING,
	          FILE_ATTRIBUTE_NORMAL,
	          NULL);
	if (hCOMPort == INVALID_HANDLE_VALUE)
	{
		dwError = GetLastError();
		return false;
	}
	else dwError=0;
  EnablePorts[COMi]=dwError;
  return true;

}

/**	\brief	The CCOMPort::CloseCOM function closes the communication resource


	\return	void

	
*/
void CCOMPort::CloseCOM()
{
 if (hCOMPort != INVALID_HANDLE_VALUE) 
	PurgeComm(hCOMPort,-1);
 CloseHandle(hCOMPort);
 hCOMPort=INVALID_HANDLE_VALUE;
}



/**	\brief	The CCOMPort::InitCOM function initializes specified COM port

  
	The function opens the specified port and performs initialization of it using supplied 
	communication format string and timeout value. If the object is associated with COM port,
	which is already open, it will close the port first using CCOMPort::CloseCOM() function call

	\param	COMi	a parameter of type int specifiying COM port number to initialize
	\param	Str	a parameter of type LPSTR containing pointer to a communication format string
	\param	iTimeOut	a parameter of type int specifiying communication timeout value

	\return	BOOL - port initialization result. TRUE in the case of success, otherwise FALSE

	
*/
BOOL CCOMPort::InitCOM(int COMi, LPSTR Str,int iTimeOut=300)
{
	DCB dcb;
	COMMTIMEOUTS CommTimeOuts;
	if(COMi<0) return FALSE;
	if(EnablePorts[COMi])
		return FALSE;
	PurgeComm(hCOMPort,-1);
//	CloseCOM();
	SetupComm(hCOMPort,65535,0xffff);
	GetCommState(hCOMPort, &dcb);
	if(!BuildCommDCB(Str,&dcb))
		return FALSE;
	// Filling in the DCB
	dcb.BaudRate = CBR_9600;
	dcb.ByteSize = 8;
	dcb.Parity = NOPARITY;
	dcb.StopBits = ONESTOPBIT; 
	dcb.fBinary=1;          // binary mode, no EOF check
	dcb.fParity=0;          // enable parity checking
	dcb.fAbortOnError=FALSE; // abort reads/writes on error
	dcb.fDtrControl=DTR_CONTROL_DISABLE;
	dcb.fRtsControl=RTS_CONTROL_DISABLE;
	dcb.fOutxCtsFlow=FALSE;
	dcb.fOutxDsrFlow=FALSE;
	dcb.fDsrSensitivity=FALSE;
	dcb.fOutX=FALSE;
	//---------------
	if(!SetCommState(hCOMPort, &dcb))return FALSE;
	CommTimeOuts.ReadTotalTimeoutConstant=iTimeOut;
	CommTimeOuts.ReadTotalTimeoutMultiplier=11;
	CommTimeOuts.WriteTotalTimeoutConstant=200;
	CommTimeOuts.WriteTotalTimeoutMultiplier=11;
	return SetCommTimeouts( hCOMPort, &CommTimeOuts ) ;

 //------------------------
}

/**	\brief	The CCOMPort::Send function transmits specifiying number of bytes via COM port

	\param	Data	a parameter of type LPBYTE containing pointer to BYTE array with the data,
			which needs to be transmitted
	\param	Number	a parameter of type int containing number of bytes to transmit

	\return	BOOL - operation result. TRUE if specified number of bytes successfully transmitted, otherwise FALSE

	
*/
BOOL CCOMPort::Send(LPBYTE Data, int Number)
{
 
 BOOL bError;
 DWORD wBytes;
 bError=WriteFile(hCOMPort,Data,Number,&wBytes,NULL);

 bError=bError&&((DWORD)Number==wBytes);
 return bError;
}

/**	\brief	The CCOMPort::Recieve function receives specified number of bytes from the COM port

	\param	Buffer	a parameter of type LPBYTE - pointer to the BYTE array receiving data
	\param	Length	a parameter of type int - number of bytes to receive

	\return	BOOL - operation result. TRUE if specified number of bytes successfully received, otherwise FALSE

	
*/
BOOL CCOMPort::Recieve(LPBYTE Buffer, int Length)
{
 BOOL res;
 DWORD dwBytes;
 res=ReadFile(hCOMPort,Buffer,Length,&dwBytes,NULL);
 res=res&(dwBytes==(DWORD)Length);
 return res;
}

/**	\brief	The CCOMPort::FindCOM function performs enumeration of available COM ports

	The funcion opens and then closes consequently firs 16 COM ports and records received error codes into 
	the EnablePorts array. The obtained error codes can be later requested using CCOMPort::IsEnable(int iPort)
	function call in order to determine availability of the certain ports.

	\return	void

	
*/
void CCOMPort::FindCOM()
{
	  for (char i=0; i<16; i++)
	  {
		  OpenCOM(i);
		  CloseCOM();
	  }
}

/**	\brief	The CCOMPort::GetHandle function returns a file handle associated with the COM port


	\return	HANDLE - a file handle associated with the COM port or INVALID_HANDLE_VALUE 
					if the port is not open

	
*/
HANDLE CCOMPort::GetHandle()
{
	return hCOMPort;
}

/**	\brief	The CCOMPort::InitCOM function initializes currently open COM port

  
	The function performs reinitialization of the COM port associated with the object using supplied 
	communication format string and timeout value. 

	\param	Str	a parameter of type LPSTR containing pointer to a communication format string
	\param	TimeOut	a parameter of type int specifiying communication timeout value

	\return	BOOL - port initialization result. TRUE in the case of success, otherwise FALSE

	
*/
BOOL CCOMPort::InitCOM(LPSTR Str,int TimeOut)
{
   if(hCOMPort==INVALID_HANDLE_VALUE)return FALSE;
   return InitCOM(iCOM,Str,TimeOut);
}

/**	\brief	The CCOMPort::InitCOM function initializes specified COM port

  
	The function opens the specified port and performs initialization of it using supplied 
	communication format string and default timeout value. If the object is associated with COM port,
	which is already open, it will close the port first using CCOMPort::CloseCOM() function call

	\param	COMi	a parameter of type int specifiying COM port number to initialize
	\param	Str	a parameter of type LPSTR containing pointer to a communication format string

	\return	BOOL - port initialization result. TRUE in the case of success, otherwise FALSE

	
*/
BOOL CCOMPort::InitCOM(int COMi, LPSTR Str)
{
	return InitCOM(COMi,Str,iTimeOut); 
}

/**	\brief	The CCOMPort::DTR function sets DTR line to the state specified by parameter

	\param	bDTR	a parameter of type bool specifiying whether to set the line into the active state

	\return	void

	
*/
void CCOMPort::DTR(bool bDTR)
{
	EscapeCommFunction(hCOMPort,(bDTR)?SETDTR:CLRDTR);
	Sleep(1);
}
/**	\brief	The CCOMPort::RTS function sets RTS line to the state specified by parameter

	\param	bRTS	a parameter of type bool specifiying whether to set the line into the active state

	\return	void

	
*/
void CCOMPort::RTS(bool bRTS)
{
	EscapeCommFunction(hCOMPort,(bRTS)?SETRTS:CLRRTS);
	Sleep(1);
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
天堂成人国产精品一区| 欧美日韩精品欧美日韩精品一| 免费亚洲电影在线| 亚洲成人一区二区在线观看| 亚洲精品视频在线| 一区二区三区色| 性做久久久久久| 亚洲一区二区三区激情| 亚洲自拍与偷拍| 天天操天天色综合| 日本中文字幕一区| 国产伦精品一区二区三区在线观看| 美女尤物国产一区| 国产成a人无v码亚洲福利| 成人网在线播放| 色哟哟日韩精品| 欧美日韩黄色影视| 日韩午夜av一区| 国产色产综合色产在线视频| 国产精品久久免费看| 亚洲精品你懂的| 首页综合国产亚洲丝袜| 国内精品写真在线观看| www.在线欧美| 这里只有精品视频在线观看| 精品久久久久久久久久久久久久久久久 | 91蜜桃免费观看视频| 色婷婷久久久久swag精品| 欧美一区二区在线免费播放| 欧美一级日韩免费不卡| 国产精品污污网站在线观看| 亚洲电影视频在线| 国产伦精品一区二区三区免费迷 | 免费成人在线视频观看| 国产精品99久久久久久久vr| 91福利社在线观看| 精品国产欧美一区二区| 亚洲男女毛片无遮挡| 九九**精品视频免费播放| 成年人午夜久久久| 日韩美一区二区三区| 亚洲男人的天堂在线aⅴ视频| 美女视频一区二区三区| 在线中文字幕一区二区| 国产日韩精品一区| 日韩电影免费在线观看网站| 99久久久久久99| 久久免费午夜影院| 亚洲成人av在线电影| 成人av在线网站| 日韩免费在线观看| 亚洲视频一区在线| 国产白丝网站精品污在线入口| 色综合久久久久久久| 国产欧美综合在线| 日本aⅴ亚洲精品中文乱码| 99re热视频精品| 久久久一区二区三区| 午夜激情一区二区| 国产麻豆一精品一av一免费| 欧美一级爆毛片| 自拍偷拍欧美精品| 国产91在线看| 国产女人18水真多18精品一级做 | 日韩美女在线视频| 午夜精品成人在线视频| 91精品91久久久中77777| 国产日韩精品久久久| 老司机精品视频在线| 欧美三日本三级三级在线播放| 久久精品夜夜夜夜久久| 免费一级欧美片在线观看| 欧美色网站导航| 亚洲精品自拍动漫在线| 99综合影院在线| 中文久久乱码一区二区| 国产凹凸在线观看一区二区| 精品国产免费视频| 国产老女人精品毛片久久| 精品国产自在久精品国产| 美女视频黄免费的久久| 欧美不卡视频一区| 黑人巨大精品欧美黑白配亚洲 | 麻豆一区二区99久久久久| 在线不卡中文字幕| 亚洲不卡av一区二区三区| 欧美日韩一级视频| 婷婷夜色潮精品综合在线| 日本高清成人免费播放| 亚洲激情综合网| 欧美性感一区二区三区| 亚洲va中文字幕| 欧美在线观看一区| 日本麻豆一区二区三区视频| 精品久久久久久久久久久久久久久久久| 久久国产成人午夜av影院| 国产亚洲一区二区在线观看| www.亚洲色图.com| 亚洲午夜久久久| 欧美不卡在线视频| 成人av综合在线| 午夜国产不卡在线观看视频| 精品国产成人在线影院| 大白屁股一区二区视频| 亚洲一区二区在线免费看| 日韩无一区二区| 99国产精品久久久久久久久久久| 一区二区三区日本| 精品剧情在线观看| 色综合色综合色综合| 丝袜美腿高跟呻吟高潮一区| 久久精品男人的天堂| 欧美在线观看视频一区二区三区 | 91精品视频网| 国产一区二区三区蝌蚪| 亚洲人成网站色在线观看| 日韩午夜激情av| 色婷婷综合久久久久中文一区二区 | www精品美女久久久tv| 99精品视频一区| 日韩电影在线一区二区三区| 国产欧美日韩三级| 91精品国产色综合久久不卡蜜臀| 国产成人在线免费| 日韩av电影免费观看高清完整版| 欧美高清在线精品一区| 日韩一区二区在线播放| 色88888久久久久久影院野外| 国产一区在线观看视频| 夜夜嗨av一区二区三区中文字幕 | 亚洲国产精品自拍| 久久久国产一区二区三区四区小说| 成人永久免费视频| 美女网站色91| 五月天激情综合| 亚洲精品视频观看| 中文在线免费一区三区高中清不卡| 91精品国产综合久久久久| 91伊人久久大香线蕉| 国产黄人亚洲片| 麻豆久久久久久久| 丝袜a∨在线一区二区三区不卡| 亚洲欧洲日韩av| 国产欧美久久久精品影院| 精品剧情v国产在线观看在线| 91麻豆精品91久久久久同性| 在线精品视频一区二区| 91女厕偷拍女厕偷拍高清| 国产999精品久久久久久| 国产精品一区免费在线观看| 久久66热偷产精品| 精品中文字幕一区二区| 日本亚洲视频在线| 久久99精品久久只有精品| 日韩经典一区二区| 蜜臀av一区二区| 青青草国产精品亚洲专区无| 日本不卡一区二区| 日韩中文字幕一区二区三区| 五月天激情综合网| 日本v片在线高清不卡在线观看| 日韩成人午夜电影| 蜜臀99久久精品久久久久久软件| 丝袜美腿成人在线| 国产一区二区看久久| 国产成人日日夜夜| 不卡一区在线观看| 欧洲精品一区二区三区在线观看| 欧美性受xxxx| 91精品国产综合久久婷婷香蕉| 欧美精品自拍偷拍动漫精品| 日韩一区二区三区视频在线观看| 日韩一级视频免费观看在线| 日韩一级片在线观看| 亚洲国产精品99久久久久久久久| 国产精品网站导航| 一区二区三区欧美日| 轻轻草成人在线| 国产精品香蕉一区二区三区| 成人在线视频首页| 欧美老肥妇做.爰bbww| 国产日韩精品久久久| 亚洲一区日韩精品中文字幕| 久久国产生活片100| aaa亚洲精品| 欧美高清视频在线高清观看mv色露露十八| 欧美精品乱人伦久久久久久| 国产欧美精品一区二区色综合 | 久久国产精品色| 99麻豆久久久国产精品免费| 欧美群妇大交群中文字幕| 亚洲精品一区二区三区精华液| 国产精品久久看| 老司机精品视频导航| 91丨porny丨中文| 精品久久99ma| 一区二区三区高清在线| 激情丁香综合五月| 欧美色男人天堂| 一区视频在线播放|