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

📄 idcheckdlg.cpp

📁 m16c flash startor 源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
					{
						m_strID4 = strIdNum;
					}	
					if(GetResString(IDS_5_80) == strIdAddress)
					{
						m_strID5 = strIdNum;
					}
					if(GetResString(IDS_6_80) == strIdAddress)
					{
						m_strID6 = strIdNum;
					}
					if(GetResString(IDS_7_80) == strIdAddress)
					{
						m_strID7 = strIdNum;
					}	
				}else if(s_MpuIndex == 2){
					CString strIdAddress = strId.Left(ID_ADDRESS_380);
					CString strIdNum = strId.Right(2);
#if _DEBUG
					printf( "strIdAddress = %s \n", strIdAddress );
#endif
					if(GetResString(IDS_1_380) == strIdAddress)
					{
						m_strID1 = strIdNum;
					}	
					if(GetResString(IDS_2_380) == strIdAddress)
					{
						m_strID2 = strIdNum;
					}else 	if(GetResString(IDS_3_380) == strIdAddress)
					{
						m_strID3 = strIdNum;
					}
					if(GetResString(IDS_4_380) == strIdAddress)
					{
						m_strID4 = strIdNum;
					}	
					if(GetResString(IDS_5_380) == strIdAddress)
					{
						m_strID5 = strIdNum;
					}
					if(GetResString(IDS_6_380) == strIdAddress)
					{
						m_strID6 = strIdNum;
					}
					if(GetResString(IDS_7_380) == strIdAddress)
					{
						m_strID7 = strIdNum;
					}	
				}else if(s_MpuIndex == 3){
					CString strIdAddress = strId.Left(ID_ADDRESS_R8C);
					CString strIdNum = strId.Right(2);
#if _DEBUG
					printf( "strIdAddress = %s \n", strIdAddress );
#endif
					if(GetResString(IDS_1_R8C) == strIdAddress)
					{
						m_strID1 = strIdNum;
					}	
					if(GetResString(IDS_2_R8C) == strIdAddress)
					{
						m_strID2 = strIdNum;
					}else 	if(GetResString(IDS_3_R8C) == strIdAddress)
					{
						m_strID3 = strIdNum;
					}
					if(GetResString(IDS_4_R8C) == strIdAddress)
					{
						m_strID4 = strIdNum;
					}	
					if(GetResString(IDS_5_R8C) == strIdAddress)
					{
						m_strID5 = strIdNum;
					}
					if(GetResString(IDS_6_R8C) == strIdAddress)
					{
						m_strID6 = strIdNum;
					}
					if(GetResString(IDS_7_R8C) == strIdAddress)
					{
						m_strID7 = strIdNum;
					}	
				}else {
					CString strIdAddress = strId.Left(ID_ADDRESS);
					CString strIdNum = strId.Right(2);
#if _DEBUG
					printf( "strIdAddress = %s \n", strIdAddress );
#endif
					if(GetResString(IDS_1) == strIdAddress)
					{
						m_strID1 = strIdNum;
					}	
					if(GetResString(IDS_2) == strIdAddress)
					{
						m_strID2 = strIdNum;
					}
					if(GetResString(IDS_3) == strIdAddress)
					{
						m_strID3 = strIdNum;
					}
					if(GetResString(IDS_4) == strIdAddress)
					{
						m_strID4 = strIdNum;
					}	
					if(GetResString(IDS_5) == strIdAddress)
					{
						m_strID5 = strIdNum;
					}
					if(GetResString(IDS_6) == strIdAddress)
					{
						m_strID6 = strIdNum;
					}
					if(GetResString(IDS_7) == strIdAddress)
					{
						m_strID7 = strIdNum;
					}	
				}
			}
			UpdateData(FALSE);
		}
		//When there is not the id file.
		CATCH(CFileException, e)
		{
			CWnd::MessageBox(GetResString(IDS_NFIND_ID), GetResString(IDS_FLASH_TITLE), MB_ICONWARNING);
		}
		END_CATCH
	}
}

void CIDCheckDlg::OnOK() 
{

	// TODO: Add the cords for other inspections to this position.
	BeginWaitCursor();
	UpdateData(TRUE);

	s_MpuIndex = m_MpuIndex;

	//It is when the file name is designated.  
	if(!m_strFilename.IsEmpty())
	{
	    MakeImage(m_strFilename);
//		unsigned int nStartAddress = 0;
//		unsigned int nEndAddress = 0;
//		GetAddressOnly(&nStartAddress, &nEndAddress);
//		if( nEndAddress == IDS_PROTECT_80){
//			s_MpuIndex = 1;
//			m_MpuIndex = s_MpuIndex;
//			UpdateData(FALSE);
//		}

/*		//I acquire the communication object.  
		CSerialComm& comObj = GetSerialComm();

		//It does a status registration the clear.  
		BYTE send[SEND_ID];
		send[0] = 0x50;
		GetSerialComm().Write(&send[0], 1);
		Sleep(SLEEP_IN);
*/
		
		// ID Match Pre Check.   
		BYTE byteSRD[2];
		BYTE byteSend = 0x70;
		byteSRD[0] = byteSRD[1] = 0;
		GetSerialComm().Write(&byteSend, 1);
		if(!GetSerialComm().Read(byteSRD, 2))
		{				// Comm Error.
			((CM16CflshApp*)AfxGetApp())->CommError();
		}
		//It confirms whether ID is passing.  
		// Check ID status.
		int nStateID = 3 & (byteSRD[1] >> 2);
		if(nStateID == 3 && id_send_flg == FALSE )
		{			// ID Match!
			//ID is passing.  
			SetAcceptedID(TRUE);
			//I make the transmission image.  
			MakeImage(m_strFilename);
	
			EndWaitCursor();
			CDialog::OnOK();
		}
		else
		{			// ID Not Match!
			//It is when the ID is input.  
			if(2 == m_strID1.GetLength() && 2 == m_strID2.GetLength() && 2 == m_strID3.GetLength() && 2 == m_strID4.GetLength() && 2 == m_strID5.GetLength() && 2 == m_strID6.GetLength() && 2 == m_strID7.GetLength())
			{
				//I acquire the communication object.  
				CSerialComm& comObj = GetSerialComm();
	
				//I make transmission data.
//				BYTE send[SEND_ID];
				if(s_MpuIndex == 2 ){
					g_send[0] = 0xf5;
					g_send[1] = ID_ADDRE_LO_380;
					g_send[2] = ID_ADDRE_MID_380;
					g_send[3] = ID_ADDRE_HI_380;
				} else if(s_MpuIndex == 3 ){
					g_send[0] = 0xf5;
					g_send[1] = ID_ADDRE_LO_R8C;
					g_send[2] = ID_ADDRE_MID_R8C;
					g_send[3] = ID_ADDRE_HI_R8C;
				} else {
					g_send[0] = 0xf5;
					g_send[1] = ID_ADDRE_LO;
					g_send[2] = ID_ADDRE_MID;
					//send[3] = ID_ADDRE_HI;
					if(s_MpuIndex == 1){
						g_send[3] = ID_ADDRE_HI_80;
					}else{
						g_send[3] = ID_ADDRE_HI;
					}
				}
				g_send[4] = ID_SIZE;
				g_send[5] = BLANK;
				strToByte(&g_send[5], m_strID1);
				g_send[6] = BLANK;
				strToByte(&g_send[6], m_strID2);
				g_send[7] = BLANK;
				strToByte(&g_send[7], m_strID3);
				g_send[8] = BLANK;
				strToByte(&g_send[8], m_strID4);
				g_send[9] = BLANK;
				strToByte(&g_send[9], m_strID5);
				g_send[10] = BLANK;
				strToByte(&g_send[10], m_strID6);
				g_send[11] = BLANK;
				strToByte(&g_send[11], m_strID7);
	
				//A command is transmitted.  
				comObj.Write(g_send, 12);
				Sleep(SLEEP_IN);
	
				int nCheck = checkID();
				//Communication confirmation   
				if(nCheck < 0)
				{
					((CM16CflshApp*)AfxGetApp())->CommError();
				}
				//It confirms whether ID passed.  
				if(nCheck == 0)
				{
					//ID is not passing.  
					comObj.CleanUp(NULL);
					SetAcceptedID(FALSE);
					MessageBox(GetResString(IDS_NID), GetResString(IDS_FLASH_TITLE), MB_ICONWARNING);
				}
				else
				{
					//ID is passing.  
					SetAcceptedID(TRUE);
					//I make the transmission image.  
					MakeImage(m_strFilename);
	
					EndWaitCursor();
					CDialog::OnOK();
				}
			}

			//It is when the ID is not input.  
			else
			{
				MessageBox(GetResString(IDS_NID_STYLE), GetResString(IDS_FLASH_TITLE), MB_ICONWARNING);
			}
		}
	}
	//It is when the file name is not designated.  
	else
	{
		MessageBox(GetResString(IDS_NFILE), GetResString(IDS_FLASH_TITLE), MB_ICONWARNING);
	}
	EndWaitCursor();
}
void CIDCheckDlg::GetAddressOnly(unsigned int* nStartAddress, unsigned int* nEndAddress)
{
	BYTE byteDummy[PAGE_SIZE];
	CLineImage* ptrIs;
	bool	first_time = true;

	unsigned int nAddress = 0;
	for(int nIndex = 0; NUM_PAGE2 > nIndex; nIndex++)		// I decide it.
	{
		ptrIs = GetPage(byteDummy, nIndex);
		if(NULL != ptrIs)
		{
			nAddress = (unsigned int)(nIndex * 0x0100);
			if(first_time)
			{
				first_time = false;
				*nStartAddress = nAddress;
			}
			*nEndAddress = nAddress + 0x0100 - 1;
		}
	}
	if(first_time)
	{
		*nStartAddress = DEF_START_ADDRESS;
		*nEndAddress = DEF_END_ADDRESS;
	}

}

void CIDCheckDlg::OnCancel() 
{
	//I acquire the communication object.  
	CSerialComm& comObj = GetSerialComm();

	// Check ID status.
	if( id_send_flg == TRUE )
	{
		//I make transmission data.
		BYTE send[SEND_ID];
		send[0]	 = 0xf5;
		send[1]  = 0x00;
		send[2]  = 0x00;
		send[3]  = 0x00;
		send[4]  = ID_SIZE;
		send[5]  = 0x00;
		send[6]  = 0x00;
		send[7]  = 0x00;
		send[8]  = 0x00;
		send[9]  = 0x00;
		send[10] = 0x00;
		send[11] = 0x00;
	
		//A command is transmitted.  
		comObj.Write(send, 12);
		Sleep(SLEEP_IN);
		SetAcceptedID(FALSE);
	}
	
	CDialog::OnCancel();

}



⌨️ 快捷键说明

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