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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? serialport.cpp

?? 能夠?qū)Υ谶M(jìn)行讀寫
?? CPP
?? 第 1 頁(yè) / 共 2 頁(yè)
字號(hào):
				WriteChar(port);
				break;
			}

		} // end switch

	} // close forever loop

	return 0;
}

//
// start comm watching
//
BOOL CSerialPort::StartMonitoring()
{
	if (!(m_Thread = AfxBeginThread(CommThread, this)))
		return FALSE;
	TRACE("Thread started\n");
	return TRUE;	
}

//
// Restart the comm thread
//
BOOL CSerialPort::RestartMonitoring()
{
	TRACE("Thread resumed\n");
	m_Thread->ResumeThread();
	return TRUE;	
}


//
// Suspend the comm thread
//
BOOL CSerialPort::StopMonitoring()
{
	TRACE("Thread suspended\n");
	m_Thread->SuspendThread(); 
	return TRUE;	
}


//
// If there is a error, give the right message
//
void CSerialPort::ProcessErrorMessage(char* ErrorText)
{
	char *Temp = new char[200];
	
	LPVOID lpMsgBuf;

	FormatMessage( 
		FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
		NULL,
		GetLastError(),
		MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
		(LPTSTR) &lpMsgBuf,
		0,
		NULL 
	);

	sprintf(Temp, "WARNING:  %s Failed with the following error: \n%s\nPort: %d\n", (char*)ErrorText, lpMsgBuf, m_nPortNr); 
	MessageBox(NULL, Temp, "Application Error", MB_ICONSTOP);

	LocalFree(lpMsgBuf);
	delete[] Temp;
}

//
// Write a character.
//
void CSerialPort::WriteChar(CSerialPort* port)
{
	BOOL bWrite = TRUE;
	BOOL bResult = TRUE;

	DWORD BytesSent = 0;

	ResetEvent(port->m_hWriteEvent);

	// Gain ownership of the critical section
	EnterCriticalSection(&port->m_csCommunicationSync);

	if (bWrite)
	{
		// Initailize variables
		port->m_ov.Offset = 0;
		port->m_ov.OffsetHigh = 0;

		// Clear buffer
		PurgeComm(port->m_hComm, PURGE_RXCLEAR | PURGE_TXCLEAR | PURGE_RXABORT | PURGE_TXABORT);

		bResult = WriteFile(port->m_hComm,							// Handle to COMM Port
							port->m_szWriteBuffer,					// Pointer to message buffer in calling finction
							strlen((char*)port->m_szWriteBuffer),	// Length of message to send
							&BytesSent,								// Where to store the number of bytes sent
							&port->m_ov);							// Overlapped structure

		// deal with any error codes
		if (!bResult)  
		{
			DWORD dwError = GetLastError();
			switch (dwError)
			{
				case ERROR_IO_PENDING:
					{
						// continue to GetOverlappedResults()
						BytesSent = 0;
						bWrite = FALSE;
						break;
					}
				default:
					{
						// all other error codes
						port->ProcessErrorMessage("WriteFile()");
					}
			}
		} 
		else
		{
			LeaveCriticalSection(&port->m_csCommunicationSync);
		}
	} // end if(bWrite)

	if (!bWrite)
	{
		bWrite = TRUE;
	
		bResult = GetOverlappedResult(port->m_hComm,	// Handle to COMM port 
									  &port->m_ov,		// Overlapped structure
									  &BytesSent,		// Stores number of bytes sent
									  TRUE); 			// Wait flag

		LeaveCriticalSection(&port->m_csCommunicationSync);

		// deal with the error code 
		if (!bResult)  
		{
			port->ProcessErrorMessage("GetOverlappedResults() in WriteFile()");
		}	
	} // end if (!bWrite)

	// Verify that the data size send equals what we tried to send
	if (BytesSent != strlen((char*)port->m_szWriteBuffer))
	{
		TRACE("WARNING: WriteFile() error.. Bytes Sent: %d; Message Length: %d\n", BytesSent, strlen((char*)port->m_szWriteBuffer));
	}
}

//
// Character received. Inform the owner
//
void CSerialPort::ReceiveChar(CSerialPort* port, COMSTAT comstat,char* RXbuff,DWORD ByteRead)
{
	BOOL  bRead = TRUE; 
	BOOL  bResult = TRUE;
	DWORD dwError = 0;
	//DWORD BytesRead = 0;
	//unsigned char RXBuff;
	char* buff;

	buff=RXbuff;

	for (;;) 
	{ 
		// Gain ownership of the comm port critical section.
		// This process guarantees no other part of this program 
		// is using the port object. 
		
		EnterCriticalSection(&port->m_csCommunicationSync);

		// ClearCommError() will update the COMSTAT structure and
		// clear any other errors.
		
		bResult = ClearCommError(port->m_hComm, &dwError, &comstat);

		LeaveCriticalSection(&port->m_csCommunicationSync);

		// start forever loop.  I use this type of loop because I
		// do not know at runtime how many loops this will have to
		// run. My solution is to start a forever loop and to
		// break out of it when I have processed all of the
		// data available.  Be careful with this approach and
		// be sure your loop will exit.
		// My reasons for this are not as clear in this sample 
		// as it is in my production code, but I have found this 
		// solutiion to be the most efficient way to do this.
		
		if (comstat.cbInQue == 0)
		{
			// break out when all bytes have been read
			break;
		}
						
		EnterCriticalSection(&port->m_csCommunicationSync);

		if (bRead)
		{
			bResult = ReadFile(port->m_hComm,		// Handle to COMM port 
							   buff,				// RX Buffer Pointer
							   70,					// Read one byte
							   &ByteRead,			// Stores number of bytes read
							   &port->m_ov);		// pointer to the m_ov structure
			// deal with the error code 
			if (!bResult)  
			{ 
				switch (dwError = GetLastError()) 
				{ 
					case ERROR_IO_PENDING: 	
						{ 
							// asynchronous i/o is still in progress 
							// Proceed on to GetOverlappedResults();
							bRead = FALSE;
							ByteRead=0;
							break;
						}
					default:
						{
							// Another error has occured.  Process this error.
							port->ProcessErrorMessage("ReadFile()");
							break;
						} 
				}
			}
			else
			{
				// ReadFile() returned complete. It is not necessary to call GetOverlappedResults()
				bRead = TRUE;
			}
		}  // close if (bRead)

		if (!bRead)
		{
			bRead = TRUE;
			bResult = GetOverlappedResult(port->m_hComm,	// Handle to COMM port 
										  &port->m_ov,		// Overlapped structure
										  &ByteRead,		// Stores number of bytes read
										  TRUE); 			// Wait flag

			// deal with the error code 
			if (!bResult)  
			{
				port->ProcessErrorMessage("GetOverlappedResults() in ReadFile()");
			}	
		}  // close if (!bRead)
				
		LeaveCriticalSection(&port->m_csCommunicationSync);

		// notify parent that a byte was received
		::SendMessage((port->m_pOwner)->m_hWnd, WM_COMM_RXCHAR, (WPARAM)(* buff), (LPARAM) port->m_nPortNr);
	} // end forever loop

}

//
// Write a string to the port
//
void CSerialPort::WriteToPort(char string)
{		
	assert(m_hComm != 0);

	memset(m_szWriteBuffer, 0, sizeof(m_szWriteBuffer));
	strcpy(m_szWriteBuffer, &string);

	// set event for write
	SetEvent(m_hWriteEvent);
}

//
// Return the device control block
//
DCB CSerialPort::GetDCB()
{
	return m_dcb;
}

//
// Return the communication event masks
//
DWORD CSerialPort::GetCommEvents()
{
	return m_dwCommEvents;
}

//
// Return the output buffer size
//
DWORD CSerialPort::GetWriteBufferSize()
{
	return m_nWriteBufferSize;
}


//--------------------------------------------------------
//dataprocess connect with the database
void CSerialPort::DataProcess(char* RXbuff,DWORD ByteRead)
{
	int i; 
	char*  str=RXbuff;
	char a1[2];
	char a2[3];
	CData* m_pSet;

	switch (ByteRead)
	{
	case(60):
		{
			if(!m_pSet->IsBOF())
			{
				m_pSet->MoveLast();
				m_pSet->AddNew();
				for(i=0;i<2;i++)
				{
					a1[i]=(*str);
					str++;
				}
				m_pSet->m_Au_ID=atol(a1);
				for(i=0;i<3;i++)
				{
					a2[i]=(*str);
					str++;
				}
				m_pSet->m_Author=a2;
				m_pSet->Update();
				if(!m_pSet->Update())
					assert("cannot write to the database");


				//this is the normal data process
		};
	case(50):
		{
			//this is the quanlity data process
		}
	default:
		{
			ASSERT("THE BYTE'S NUMBER IS NOT WRIGHT");
			//something wrong with the data process
		}
	}
	}
}



?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
黑人精品欧美一区二区蜜桃| 亚洲手机成人高清视频| 久久人人超碰精品| 欧美极品美女视频| 亚洲一区二区三区视频在线播放| 首页综合国产亚洲丝袜| 国产精品一区2区| 91福利国产精品| 久久久噜噜噜久噜久久综合| 亚洲视频一区二区免费在线观看| 日韩高清在线不卡| 成人免费视频app| 91精品在线观看入口| 国产午夜亚洲精品午夜鲁丝片| 亚洲综合av网| 懂色av一区二区三区免费观看| 欧美性三三影院| 国产精品五月天| 日韩不卡一区二区| 91在线高清观看| 欧美xxxxx牲另类人与| 一区二区三区中文字幕电影| 九一久久久久久| 欧美午夜电影一区| 国产精品久线在线观看| 免费一区二区视频| 日本大香伊一区二区三区| 久久久久国产免费免费| 亚洲第一成人在线| 白白色 亚洲乱淫| 欧美mv和日韩mv国产网站| 亚洲国产精品久久艾草纯爱| 成人午夜精品在线| 久久综合九色综合97婷婷女人| 亚洲成国产人片在线观看| 国产欧美视频一区二区三区| 免费观看日韩av| 色琪琪一区二区三区亚洲区| 国产精品美女久久久久久久久| 久久精品国产第一区二区三区| 91亚洲精华国产精华精华液| 国产视频一区二区三区在线观看| 日日噜噜夜夜狠狠视频欧美人| 91在线视频观看| 国产视频一区在线播放| 久久成人免费网| 8v天堂国产在线一区二区| 亚洲综合久久av| 日本韩国欧美在线| 中文字幕亚洲不卡| 白白色亚洲国产精品| 久久久精品人体av艺术| 精品伊人久久久久7777人| 69成人精品免费视频| 亚洲一区视频在线| 欧美色成人综合| 欧美日韩一级片网站| 亚洲精品中文字幕在线观看| 不卡视频一二三| 中文成人综合网| 国产成人精品影视| 国产三级久久久| 国产精品99久久久久久似苏梦涵| 欧美第一区第二区| 黑人精品欧美一区二区蜜桃| 精品毛片乱码1区2区3区| 麻豆精品一区二区综合av| 91精品国产综合久久小美女| 午夜av电影一区| 日韩一区二区在线免费观看| 日本伊人色综合网| 日韩一区二区在线免费观看| 麻豆精品视频在线观看| 26uuu另类欧美亚洲曰本| 国产精品原创巨作av| 国产日韩av一区| caoporm超碰国产精品| 亚洲精品中文在线影院| 欧美在线观看你懂的| 亚洲图片自拍偷拍| 日韩视频123| 国产一区中文字幕| 欧美激情一区在线| 91免费在线视频观看| 亚洲综合精品久久| 欧美一区二区三区在线电影| 捆绑变态av一区二区三区| 欧美成人女星排名| 国产成人免费在线视频| 97se亚洲国产综合自在线观| 亚洲一区在线观看视频| 日韩一卡二卡三卡国产欧美| 韩国女主播成人在线观看| 国产欧美日韩激情| 在线观看不卡一区| 麻豆91在线播放| 国产精品每日更新| 欧美性生活久久| 激情欧美日韩一区二区| 国产精品污污网站在线观看| 91免费在线看| 免费精品视频最新在线| 国产婷婷色一区二区三区在线| 99久久99久久综合| 视频一区中文字幕| 国产午夜精品一区二区三区视频| 91免费版在线看| 琪琪一区二区三区| 亚洲国产精品成人综合| 日本韩国欧美三级| 久久精品国产精品亚洲综合| 国产精品欧美精品| 欧美欧美欧美欧美首页| 国产精品白丝av| 亚洲成人777| 中文一区二区在线观看| 欧美日韩一级片在线观看| 国产一区二区精品久久| 亚洲国产视频直播| 国产人成一区二区三区影院| 在线观看91精品国产入口| 韩国成人在线视频| 亚洲图片欧美综合| 欧美国产综合一区二区| 欧美日韩一级大片网址| 国产精品88888| 国产成人av电影在线播放| 91丨九色丨国产丨porny| 另类小说图片综合网| 日本一区二区综合亚洲| 欧美在线免费播放| 国产精品一级二级三级| 婷婷久久综合九色综合绿巨人 | 一区二区三区成人| 精品免费视频.| 在线视频一区二区三区| 国产精品18久久久久久久久久久久| 亚洲午夜av在线| 中文字幕永久在线不卡| 精品欧美乱码久久久久久1区2区| 一本到不卡精品视频在线观看| 激情综合五月婷婷| 婷婷久久综合九色综合绿巨人| 中文字幕一区二区视频| 久久综合色播五月| 日韩一区二区三区高清免费看看 | 亚洲精品国产一区二区精华液| 2023国产精品视频| 69堂成人精品免费视频| 91视频观看视频| 成熟亚洲日本毛茸茸凸凹| 理论电影国产精品| 日本中文字幕一区二区视频| 夜夜爽夜夜爽精品视频| 日韩伦理电影网| 欧美国产一区在线| 久久天天做天天爱综合色| 91精品国产丝袜白色高跟鞋| 91久久精品日日躁夜夜躁欧美| 不卡的av网站| 成人性视频免费网站| 国产资源在线一区| 免费在线观看不卡| 日av在线不卡| 日韩一区精品视频| 欧美日本不卡视频| 欧美自拍偷拍午夜视频| 91老师国产黑色丝袜在线| 波多野结衣中文字幕一区| 成人一道本在线| 高清国产一区二区| 成人激情图片网| 本田岬高潮一区二区三区| 成人中文字幕在线| 成人app软件下载大全免费| 国产.欧美.日韩| 暴力调教一区二区三区| 成人app在线观看| 91看片淫黄大片一级| 91亚洲永久精品| 色婷婷综合视频在线观看| 色婷婷综合久久久中文一区二区| 色欧美日韩亚洲| 欧美图片一区二区三区| 日本韩国欧美在线| 欧美日韩mp4| 欧美va在线播放| 久久夜色精品国产噜噜av | 国产一区高清在线| 国产电影精品久久禁18| 成人国产视频在线观看| 91麻豆蜜桃一区二区三区| 91黄视频在线| 欧美肥大bbwbbw高潮| 日韩精品一区二区三区四区 | 亚洲国产精品二十页| 亚洲人精品一区| 亚洲高清不卡在线观看| 美女视频一区二区| 福利一区福利二区|