comthread.cpp

来自「通过手机数据线连接手机」· C++ 代码 · 共 58 行

CPP
58
字号
// ComThread.cpp : implementation file
//

#include "stdafx.h"
#include "MoblieX.h"
#include "ComThread.h"
#include "moblieXDoc.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CComThread

IMPLEMENT_DYNCREATE(CComThread, CWinThreadEx)

CComThread::CComThread()
{
}

CComThread::~CComThread()
{
}

BEGIN_MESSAGE_MAP(CComThread, CWinThreadEx)
	//{{AFX_MSG_MAP(CComThread)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CComThread message handlers
void CComThread::Process()
{
HANDLE hComm = m_pDoc->m_hComm;

	if( !(m_pDoc->IsCommPortOpen()) )
	{//串口都没打开, 搞什么名堂
		return;
	}

	while( !m_isAborting )
	{
		if( m_pDoc->MakeCurSendStr() )
		{//有字串要发送
			m_pDoc->CommSendCurStr();
		}

		if( m_pDoc->CommReadStr() )
		{//没有出错
			::PostMessage( m_hwndNotify, WM_COMMAND, ID_COMM_READ_OK, 0 );
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?