📄 settingcmd.cpp
字号:
// SettingCmd.cpp: CSettingCmd 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 "SettingCmd.h"
#include "SetCommDlg.h"
#include "SaveIni.h"
#include "firstSetDlg.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
//////////////////////////////////////////////////////////////////////
// Construction/Destruction.
//////////////////////////////////////////////////////////////////////
CSettingCmd::CSettingCmd()
{
}
CSettingCmd::~CSettingCmd()
{
}
///////////////////////////////////////////////////////////////////////
DWORD CSettingCmd::exec(void)
{
DWORD dwResult = 0;
// Get communication object.
CSerialComm& comObj = GetSerialComm();
CSetCommDlg dlg;
DWORD dwBaudrate = DEFAULT_BAUDRATE;
BYTE btByteSize = DEFAULT_BYTESIZE;
BYTE btParity = DEFAULT_PARITY;
BYTE btStopBits = DEFAULT_STOPBITS;
CSaveIni objInit;
if(NULL != objInit.LoadComm())
{
objInit.GetComm(&dwBaudrate, &btByteSize, &btParity, &btStopBits);
dlg.SetDispOut(dwBaudrate, btByteSize, btParity, btStopBits);
}
else
{
dlg.SetDispOut(DEF_BAUDRATE, DEF_BYTE_SIZE, DEF_PARITY, DEF_STOP_BITS);
}
int nResponse = dlg.DoModal();
if(IDOK == nResponse)
{
// show wait cursor.
CWaitCursor cursorWait;
dlg.GetSetting(&dwBaudrate, &btByteSize, &btParity, &btStopBits);
dwBaudrate = ((CM16CflshApp*)AfxGetApp())->SetSerialState(comObj, dwBaudrate, btByteSize, btParity, btStopBits, IDS_SET_BAUDRATE);
// communication check.
if(!dwBaudrate)
{
SetAcceptedComm(FALSE);
comObj.CleanUp(NULL);
}
else
{
dwResult = dwBaudrate;
SetAcceptedComm(TRUE);
objInit.SetComm(dwBaudrate, btByteSize, btParity, btStopBits);
objInit.SaveComm();
// Internal Flash memory
if(!GetFlashType()){
// confirm ID.
// check ID status
BYTE btSRD[2];
BYTE btSend = 0x70;
comObj.CleanUp(NULL);
comObj.Write(&btSend, 1);
comObj.Read(btSRD, 2);
int nStateID = 3 & (btSRD[1] >> 2);
if(0 == nStateID)
{
SetAcceptedID(FALSE);
}
else if(1 == nStateID)
{
SetAcceptedID(FALSE);
}
else if(3 == nStateID)
{
SetAcceptedID(TRUE);
}
}else{
SetAcceptedID(TRUE);
}
}
}
return dwResult;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -