📄 readcmd.cpp
字号:
// ReadCmd.cpp: CReadCmd Implementation.
//
// This software can be offered for free and used as necessary to aid
// in your program developments.
//
// RENESAS TECHNOLOGY CORPORATION, RENESAS SOLUTIONS CORPORATION,
// and related original software developers assume no responsibility
// for any damage or infringement of any third-party's rights, originating
// in the use of the following software.
// Please use this software under the agreement and acceptance of these conditions.
//
// Copyright(C)1998(2003) RENESAS TECHNOLOGY CORPORATION AND RENESAS SOLUTIONS CORPORATION
// ALL RIGHTS RESERVED
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "M16Cflsh.h"
#include "ReadCmd.h"
#include "PrgssDlg.h"
#include "defining.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CReadCmd::CReadCmd()
{
}
CReadCmd::~CReadCmd()
{
}
BOOL CReadCmd::exec(void)
{
BOOL bResult = FALSE;
CM16CflshApp* pApp = (CM16CflshApp*)AfxGetApp();
MSG msg;
// Get Comm Object.
CSerialComm& comObj = GetSerialComm();
// Get verify address range.
unsigned int nStartAddress = 0;
unsigned int nEndAddress = 0;
// default丅
// if(!GetAddressFromDialg(&nStartAddress, &nEndAddress, ADDRESS_SIZE))
// Get File Address.
if(!GetFileAddress(&nStartAddress, &nEndAddress, ADDRESS_SIZE))
{
return FALSE;
}
// If a start address is larger than an end address, it will end.
if(!ChkStartToEnd(nStartAddress, nEndAddress))
{
AfxGetMainWnd()->MessageBox(GetResString(IDS_SMALESTART), GetResString(IDS_FLASH_TITLE), MB_ICONWARNING);
return FALSE;
}
// Progress dialog setting.
CProgressDlg* pDlg;
BOOL bCancel = FALSE;
pDlg = CProgressDlg::Instance(&bCancel, NULL);
pDlg->InitialDialog("Read check.", "Read check.",
0, (nEndAddress - nStartAddress - 0x0100) / TO_INT, 0);
// verify address range.
for(int nSendAddress = nStartAddress; (long)nSendAddress < (long)nEndAddress;
nSendAddress += 0x0100)
{
// read data.
comObj.CleanUp(NULL);
BYTE receive[PAGE_SIZE];
if(!DoRead(&comObj, receive, nSendAddress))
{
pDlg->Done();
return FALSE;
}
// Get Hex Data.
BYTE byteData[PAGE_SIZE];
ClearPage(byteData);
int nPage = nSendAddress / 0x0100;
GetPage(byteData, nPage);
// verify
CString strOther;
for(int nIndex = 0; PAGE_SIZE > nIndex; nIndex++)
{
if( byteData[nIndex] != receive[nIndex])
{
// The difference was found.
CString strFindMsg = GetResString(IDS_FIND_NFILES);
strFindMsg += HexToStr(nSendAddress + nIndex);
AfxGetMainWnd()->MessageBox(strFindMsg, GetResString(IDS_FLASH_TITLE));
pDlg->Done();
return bResult;
}
}
// Progress Bar Update.
pDlg->SetProgressPos((nSendAddress - nStartAddress) / TO_INT);
// Event Loop
while (::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) {
if (!pApp->PumpMessage()) {
::PostQuitMessage(0);
break;
}
}
if(bCancel)
{
break;
}
Sleep(10);
}
pDlg->Done();
return bResult;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -