⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.cpp

📁   本实例实现在VC下如何编写串口(com port)实例(与串口通信), 对初学者弄懂串口的实现过程是很好的一个实例.以及现实将串口读到的数据记录到一个testlog目录中,以做备份
💻 CPP
字号:
// Test.cpp: implementation of the CTest class.
//
//////////////////////////////////////////////////////////////////////

#include "stdafx.h"
#include "comport.h"
#include "Test.h"

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

//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////

CTest::CTest()
{
	m_testbuffer = "";

}

CTest::~CTest()
{

}

BOOL CTest::settestbuffer(CString str)
{
	m_testbuffer = str;

	return TRUE;
}

CString CTest::gettestbuffer()
{
	return m_testbuffer;
}

char* CTest::sendCom(char *buf)
{

	return buf;
}

BOOL CTest::test(char *inputcommand, CHAR* outputchar, int time)
{
	CTime starttime, endtime;
	BOOL find = FALSE;
	starttime = CTime::GetCurrentTime();
	endtime = starttime;
//	CComPortDlg* pDlg = static_cast<CComPortDlg*>(this->GetParent());


//	test_ComPort->SendCom(inputcommand,strlen(inputcommand));

	while(endtime < (starttime + time))
	{
		Sleep(1000);
		if(m_testbuffer.Find(outputchar,0)!=-1)
		{
			find = TRUE;
			break;
		}
	}
	if (find == TRUE)
		return TRUE;
	else 
		return FALSE;
}

⌨️ 快捷键说明

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