亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? avr_usbdlg.cpp

?? usb 程序 usb通訊 仿真程序
?? CPP
?? 第 1 頁 / 共 2 頁
字號(hào):
// AVR_USBDlg.cpp : implementation file
//

#include "stdafx.h"
#include "AVR_USB.h"
#include "AVR_USBDlg.h"
#include "usbD12dll.h"
#include "Mmsystem.h"

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


static bool cOnwendu;

/////////////////////////////////////////////////////////////////////////////
// CAVR_USBDlg dialog

CAVR_USBDlg::CAVR_USBDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CAVR_USBDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CAVR_USBDlg)
	m_wendu = _T("溫度:");
	m_rsec = 0;
	m_rcol = 0;
	m_rrow = 0;
	m_wsec = 0;
	m_wcol = 0;
	m_wrow = 0;
	m_COMtoUSB = _T("");
	m_USBtoCOM = _T("");
	m_wrFlash = _T("");
	m_rdFlash = _T("");
	m_Erase = 0;
	m_Prd = 0;
	m_Pwr = 0;
	m_wrL = _T("");
	m_rL = 0;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CAVR_USBDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAVR_USBDlg)
	DDX_Text(pDX, IDC_WENDU, m_wendu);
	DDX_Text(pDX, IDC_REDIT1, m_rsec);
	DDX_Text(pDX, IDC_REDIT2, m_rcol);
	DDX_Text(pDX, IDC_REDIT3, m_rrow);
	DDX_Text(pDX, IDC_WEDIT1, m_wsec);
	DDX_Text(pDX, IDC_WEDIT2, m_wcol);
	DDX_Text(pDX, IDC_WEDIT3, m_wrow);
	DDX_Text(pDX, IDC_EDIT5, m_COMtoUSB);
	DDX_Text(pDX, IDC_EDIT6, m_USBtoCOM);
	DDX_Text(pDX, IDC_WEDIT4, m_wrFlash);
	DDX_Text(pDX, IDC_REDIT4, m_rdFlash);
	DDX_Text(pDX, IDC_Erase, m_Erase);
	DDX_Text(pDX, IDC_Prd, m_Prd);
	DDX_Text(pDX, IDC_Pwr, m_Pwr);
	DDX_Text(pDX, IDC_WEDIT5, m_wrL);
	DDX_Text(pDX, IDC_REDIT5, m_rL);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CAVR_USBDlg, CDialog)
	//{{AFX_MSG_MAP(CAVR_USBDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_WM_TIMER()
	ON_BN_CLICKED(IDC_BUTTON6, Onwendu)
	ON_BN_CLICKED(IDC_PB0, OnPb0)
	ON_BN_CLICKED(IDC_PB1, OnPb1)
	ON_BN_CLICKED(IDC_PB2, OnPb2)
	ON_BN_CLICKED(IDC_PB3, OnPb3)
	ON_BN_CLICKED(IDC_PB4, OnPb4)
	ON_BN_CLICKED(IDC_PB5, OnPb5)
	ON_BN_CLICKED(IDC_PB6, OnPb6)
	ON_BN_CLICKED(IDC_PB7, OnPb7)
	ON_BN_CLICKED(IDC_BUTTON7, OnUSBtoCOM)
	ON_BN_CLICKED(IDC_BUTTON1, OnCopyPage)
	ON_BN_CLICKED(IDC_BUTTON2, OnFlashErase)
	ON_BN_CLICKED(IDC_BUTTON5, OnWriteCOM)
	ON_BN_CLICKED(IDC_BUTTON4, OnWriteFlash)
	ON_BN_CLICKED(IDC_BUTTON3, OnReadFlash)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CAVR_USBDlg message handlers

BOOL CAVR_USBDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon

	return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CAVR_USBDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CAVR_USBDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CAVR_USBDlg::OnFlashErase() 
{
    char temp [80],cc[80],wrBuffer[16];
    CAVR_USBDlg* testDlg;
	BOOLEAN bResult = FALSE;
    ULONG nBytes;
	HANDLE hFile=NULL;
	testDlg=this;

	SetTimer(100,-1,NULL);

	UpdateData(TRUE);
	
	if(m_Erase<0 && m_Erase>65535)
	{
		strcpy(temp, "起始行應(yīng)在 0~65535 之間!");
		testDlg->MessageBox((LPCSTR)temp, "錯(cuò)誤!");
		return;
	}
	
	hFile = openUSBfile_0();
	if(hFile == INVALID_HANDLE_VALUE)
	{
		strcpy(temp, "不能寫數(shù)據(jù)到pipe_0!");
		testDlg->MessageBox((LPCSTR)temp, "打開錯(cuò)誤!");
		return;
	}
	wrBuffer[0] = 0x60;
	wrBuffer[1] = m_Erase;
	wrBuffer[2] = m_Erase>>8;
	int wrLength=3;
	bResult = WriteFile(hFile,
		&wrBuffer,
		wrLength,
		&nBytes,
		NULL);
				
	CloseHandle(hFile);
	if (bResult == TRUE)
	{
		hFile = openUSBfile_1();
		if(hFile == INVALID_HANDLE_VALUE)
		{
			strcpy(temp, "不能打開pipe_1!");
			testDlg->MessageBox((LPCSTR)temp, "打開錯(cuò)誤!");
			return;
		}
		bResult = ReadFile(hFile,
			&wrBuffer,
			wrLength,
			&nBytes,
			NULL);
		bResult = ReadFile(hFile,
			&wrBuffer,
			wrLength,
			&nBytes,
			NULL);
		if (bResult == TRUE && nBytes>0)
		{
			if(wrBuffer[0]&0x01)
			{
				strcpy (cc, "擦除失敗! ");
				testDlg->MessageBox((LPCSTR)cc, "擦除錯(cuò)誤!");
			}
		}else
		{
			strcpy (cc, "讀 pipe_1 失敗! ");
			testDlg->MessageBox((LPCSTR)cc, "讀出錯(cuò)誤!");
		}	
		
		CloseHandle(hFile);
	}else
	{
		strcpy (cc, "寫pipe_0失敗! ");
		testDlg->MessageBox((LPCSTR)cc, "寫入錯(cuò)誤!");
	}
    if(cOnwendu==1)
	{
		usb_command(0x02,0);
	}
}

void CAVR_USBDlg::OnCopyPage() 
{
    char temp [80],cc[80],wrBuffer[16];
    CAVR_USBDlg* testDlg;
	BOOLEAN bResult = FALSE;
    ULONG nBytes;
	HANDLE hFile=NULL;
	testDlg=this;

	SetTimer(100,-1,NULL);

	UpdateData(TRUE);

	if(m_Prd<0 && m_Prd>65535)
	{
		strcpy(temp, "拷貝起始行應(yīng)在 0~65535 之間!");
		testDlg->MessageBox((LPCSTR)temp, "錯(cuò)誤!");
		return;
	}
	if(m_Pwr<0 && m_Pwr>65535)
	{
		strcpy(temp, "拷貝行應(yīng)在 0~65535 之間!");
		testDlg->MessageBox((LPCSTR)temp, "錯(cuò)誤!");
		return;
	}
	
	hFile = openUSBfile_0();
	if(hFile == INVALID_HANDLE_VALUE)
	{
		strcpy(temp, "不能寫數(shù)據(jù)到pipe_0!");
		testDlg->MessageBox((LPCSTR)temp, "打開錯(cuò)誤!");
		return;
	}
	wrBuffer[0] = 0x8a;
	wrBuffer[1] = m_Prd;
	wrBuffer[2] = m_Prd>>8;
	wrBuffer[3] = m_Pwr;
	wrBuffer[4] = m_Pwr>>8;
	int wrLength=5;
	bResult = WriteFile(hFile,
		&wrBuffer,
		wrLength,
		&nBytes,
		NULL);
				
	CloseHandle(hFile);
	if (bResult == TRUE)
	{
		hFile = openUSBfile_1();
		if(hFile == INVALID_HANDLE_VALUE)
		{
			strcpy(temp, "不能打開pipe_1!");
			testDlg->MessageBox((LPCSTR)temp, "打開錯(cuò)誤!");
			return;
		}
		bResult = ReadFile(hFile,
			&wrBuffer,
			wrLength,
			&nBytes,
			NULL);
		bResult = ReadFile(hFile,
			&wrBuffer,
			wrLength,
			&nBytes,
			NULL);
		if (bResult == TRUE && nBytes>0)
		{
			if(wrBuffer[0]&0x01)
			{
				strcpy (cc, "拷貝失敗! ");
				testDlg->MessageBox((LPCSTR)cc, "拷貝錯(cuò)誤!");
			}
		}else
		{
			strcpy (cc, "讀 pipe_1 失敗! ");
			testDlg->MessageBox((LPCSTR)cc, "讀出錯(cuò)誤!");
		}	
		
		CloseHandle(hFile);
	}else
	{
		strcpy (cc, "寫pipe_0失敗! ");
		testDlg->MessageBox((LPCSTR)cc, "寫入錯(cuò)誤!");
	}
    if(cOnwendu==1)
	{
		usb_command(0x02,0);
	}
}

void CAVR_USBDlg::OnWriteFlash() 
{
    char temp [80],cc[80],cwrBuffer[16];
    CAVR_USBDlg* testDlg;
	BOOLEAN bResult = FALSE;
    ULONG nBytes = 0;
	HANDLE hFile=NULL,hFile1=NULL;
	testDlg=this;

	SetTimer(100,-1,NULL);

	hFile1 = openUSBfile_0();
	if(hFile1 == INVALID_HANDLE_VALUE)
	{
		strcpy(temp, "不能寫數(shù)據(jù)到pipe_0!");
		testDlg->MessageBox((LPCSTR)temp, "打開錯(cuò)誤!");
		return;
	}
	UpdateData(TRUE);
	
	ULONG wrLength;
	wrLength = m_wrFlash.GetLength();
	cwrBuffer[0] = 0x80;
	cwrBuffer[1] = m_wsec;//Mflash.sec 分區(qū)
	cwrBuffer[2] = m_wcol;//Mflash.col 列
	cwrBuffer[3] = m_wrow;//Mflash.row 行
	cwrBuffer[4] = m_wrow>>8;
	cwrBuffer[5] = wrLength;//Mflash.WriteLength
	cwrBuffer[6] = wrLength>>8;
	cwrBuffer[7] = wrLength>>16;
	cwrBuffer[8] = wrLength>>24;
	int cwrLength=9;
	bResult = WriteFile(hFile1,
		&cwrBuffer,
		cwrLength,
		&nBytes,
		NULL);

	hFile = openUSBfile_2();
	if(hFile == INVALID_HANDLE_VALUE)
	{
		strcpy(temp, "不能寫數(shù)據(jù)到pipe_2!");
		testDlg->MessageBox((LPCSTR)temp, "打開錯(cuò)誤!");
		CloseHandle(hFile1);
		return;
	}
	bResult = WriteFile(hFile,
		m_wrFlash,
		wrLength,
		&nBytes,
		NULL);
				
 	if (bResult == TRUE)
	{
		if(nBytes>=0)
		{
			sprintf(temp,"%d",nBytes);
			m_wrL = temp;
			UpdateData(FALSE);
		}
	}else
	{
		strcpy (cc, "寫pipe_2失敗!");
		testDlg->MessageBox((LPCSTR)cc, "寫入錯(cuò)誤!");
	}
	CloseHandle(hFile);
	CloseHandle(hFile1);

	if (bResult == TRUE)
	{
		hFile = openUSBfile_1();
		if(hFile == INVALID_HANDLE_VALUE)
		{
			strcpy(temp, "不能打開pipe_1!");
			testDlg->MessageBox((LPCSTR)temp, "打開錯(cuò)誤!");
			return;
		}
		bResult = ReadFile(hFile,
			&cwrBuffer,
			wrLength,
			&nBytes,
			NULL);
		bResult = ReadFile(hFile,
			&cwrBuffer,
			wrLength,
			&nBytes,
			NULL);
		if (bResult == TRUE && nBytes>0)
		{
			if(cwrBuffer[0]&0x01)
			{
				strcpy (cc, "寫入失敗! ");
				testDlg->MessageBox((LPCSTR)cc, "錯(cuò)誤!");
			}
		}else
		{
			strcpy (cc, "讀 pipe_1 失敗! ");
			testDlg->MessageBox((LPCSTR)cc, "讀出錯(cuò)誤!");
		}	
		
		CloseHandle(hFile);
	}
	if(cOnwendu==1)
	{
		usb_command(0x02,0);
	}
}

void CAVR_USBDlg::OnReadFlash() 
{
    char temp [80],cc[80],wrBuffer[16];
	CAVR_USBDlg* testDlg;
	BOOLEAN bResult = FALSE;
    ULONG nBytes = 0;
	HANDLE hFile=NULL,hFile1=NULL;

	testDlg=this;
	
	UpdateData(TRUE);
	if(m_rL   <0 || m_rL   >34603008)
	{
		strcpy(temp, "讀取長(zhǎng)度應(yīng)在 0~34603008 之間!");
		testDlg->MessageBox((LPCSTR)temp, "錯(cuò)誤!");
		return;
	}
	hFile1 = openUSBfile_0();
	if(hFile1 == INVALID_HANDLE_VALUE)
	{
		strcpy(temp, "不能寫數(shù)據(jù)到pipe_0!");
		testDlg->MessageBox((LPCSTR)temp, "打開錯(cuò)誤!");
		return;
	}
	wrBuffer[0] = m_rsec;//Mflash.sec 分區(qū)
	wrBuffer[1] = m_rcol;//Mflash.col 列
	wrBuffer[2] = m_rrow;//Mflash.row 行
	wrBuffer[3] = m_rrow>>8;
	wrBuffer[4] = m_rL;//Mflash.WriteL
	wrBuffer[5] = m_rL>>8;
	wrBuffer[6] = m_rL>>16;
	wrBuffer[7] = m_rL>>24;
	int wrLength=8;
	bResult = WriteFile(hFile1,
		&wrBuffer,
		wrLength,
		&nBytes,
		NULL);

	hFile = openUSBfile_3();
	if(hFile == INVALID_HANDLE_VALUE) {
		strcpy(temp, "不能從 pipe_3 讀出數(shù)據(jù)!");
		testDlg->MessageBox((LPCSTR)temp, "打開錯(cuò)誤!");
		CloseHandle(hFile1);
		return;
	}
	unsigned char rdBuffer[645];
	int rdLength=640;
	bResult = ReadFile(hFile,
		&rdBuffer,
		rdLength,
		&nBytes,
		NULL);
	if (bResult == TRUE)
	{
		bResult = ReadFile(hFile,
				&rdBuffer,
				rdLength,
				&nBytes,
				NULL);
	}
	
	if (bResult == TRUE)
	{
		if(nBytes>=0)
		{
			rdBuffer[nBytes] = 0;
			m_rdFlash = rdBuffer;
			UpdateData(FALSE);
		}
	}else
	{
		strcpy (cc, "讀 pipe_3 失敗!");
		testDlg->MessageBox((LPCSTR)cc, "讀出錯(cuò)誤!");
	}	
	
	CloseHandle(hFile);
	CloseHandle(hFile1);
}

void CAVR_USBDlg::OnTimer(UINT nIDEvent) 
{
    char temp [80],c=0;
	BOOLEAN bResult = FALSE;
    ULONG nBytes = 0;
	HANDLE hFile=NULL;
	
	long mtemp[10];
	
	mtemp[0] = m_rsec;
	mtemp[1] = m_rcol;

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲国产一区二区三区| 欧美一区二区三区四区久久| 中文字幕乱码亚洲精品一区| 国产成人日日夜夜| 国产精品毛片无遮挡高清| 99久久精品免费精品国产| 亚洲精品视频观看| 在线电影院国产精品| 捆绑调教美女网站视频一区| 久久久影视传媒| 成av人片一区二区| 亚洲成a人在线观看| 欧美不卡123| 欧美另类变人与禽xxxxx| 奇米影视7777精品一区二区| 久久九九国产精品| 一本一道综合狠狠老| 香蕉久久夜色精品国产使用方法 | 91精品国产美女浴室洗澡无遮挡| 蜜桃视频一区二区三区在线观看| 一区二区三区不卡视频| 欧美嫩在线观看| 国产美女视频91| 一区二区三区精品视频在线| 日韩久久精品一区| 色综合久久66| 麻豆久久一区二区| 亚洲欧美综合色| 91精品在线麻豆| 成人免费视频caoporn| 亚洲一区二区三区四区五区中文| 色狠狠av一区二区三区| 亚洲va天堂va国产va久| 国产女主播一区| 欧美日韩午夜在线| 国产乱一区二区| 性做久久久久久久久| 欧美韩国一区二区| 69p69国产精品| 91久久国产最好的精华液| 韩国v欧美v亚洲v日本v| 五月婷婷久久丁香| 一区在线观看免费| 日韩精品一区二区三区蜜臀| 日本韩国一区二区三区视频| 国产中文字幕精品| 日韩精品乱码免费| 亚洲最大成人网4388xx| 日本一区二区三区国色天香| 3d成人动漫网站| 91成人免费在线| 99视频在线精品| 成人综合在线观看| 韩国在线一区二区| 日本欧美一区二区三区乱码| 亚洲综合一区二区精品导航| 国产精品传媒视频| 国产精品无码永久免费888| 精品国产成人在线影院 | 亚洲欧美偷拍卡通变态| 久久久亚洲欧洲日产国码αv| 91精品福利视频| 久久新电视剧免费观看| 欧美色视频在线| 成人在线视频一区| 国产乱码字幕精品高清av| 婷婷丁香激情综合| 亚洲国产日产av| 亚洲黄色性网站| 亚洲精品免费在线| 精品夜夜嗨av一区二区三区| 香蕉影视欧美成人| 亚洲国产视频一区二区| 亚洲一区二区四区蜜桃| 亚洲综合一二区| 亚洲不卡一区二区三区| 亚洲地区一二三色| 午夜精品福利一区二区三区av| 亚洲一二三专区| 丝袜a∨在线一区二区三区不卡| 亚洲自拍偷拍av| 午夜精品福利视频网站| 三级欧美在线一区| 捆绑紧缚一区二区三区视频| 久久精品国产精品亚洲红杏| 久久99热99| 国产大片一区二区| 99天天综合性| 欧美主播一区二区三区美女| 欧美日本视频在线| 欧美mv日韩mv| 日本一区二区三区dvd视频在线| 中文字幕不卡三区| 一区二区三区视频在线看| 亚洲成年人影院| 国内精品国产成人国产三级粉色| 国产一区三区三区| 成人免费精品视频| 欧美视频一区二| 日韩一卡二卡三卡四卡| 欧美激情一区三区| 亚洲另类色综合网站| 日本美女一区二区| 国产成人av一区二区三区在线 | 99九九99九九九视频精品| 一本到一区二区三区| 51午夜精品国产| 久久久不卡网国产精品二区| 亚洲男同性视频| 麻豆免费看一区二区三区| youjizz久久| 欧美精品丝袜中出| 亚洲色图在线看| 一区在线中文字幕| 日韩成人免费看| 国产精品123| 欧美性做爰猛烈叫床潮| 日韩欧美资源站| 国产精品久久久久久福利一牛影视| 日本视频中文字幕一区二区三区| 国产福利电影一区二区三区| 在线视频亚洲一区| 国产日韩欧美一区二区三区乱码 | 国产一区免费电影| 欧美色精品在线视频| 精品日韩一区二区三区免费视频| 国产精品久久久久影院亚瑟 | 久久综合久久综合亚洲| 亚洲黄色av一区| 高清视频一区二区| 欧美日本一道本| 亚洲人成精品久久久久久| 久久se这里有精品| 欧美亚洲国产一区在线观看网站| 日本一区二区视频在线| 青青草原综合久久大伊人精品优势| 99久久99久久精品国产片果冻| 日韩精品一区二区三区在线| 亚洲一区在线播放| 91网页版在线| 国产精品无圣光一区二区| 久久99精品久久只有精品| 欧美日韩午夜影院| 亚洲精品综合在线| 成人99免费视频| 国产日产精品1区| 精品制服美女丁香| 日韩视频在线一区二区| 午夜伦理一区二区| 色噜噜狠狠成人中文综合 | 日韩精品一区二区三区在线| 午夜精品福利在线| 久久久久国产成人精品亚洲午夜| 亚洲成人一区二区| 在线观看三级视频欧美| 综合精品久久久| 99久久精品国产一区| 国产精品卡一卡二卡三| 国产成人精品1024| 国产日韩一级二级三级| 国产一区二区在线影院| 欧美一级生活片| 奇米影视一区二区三区小说| 91精品黄色片免费大全| 人妖欧美一区二区| 日韩亚洲欧美综合| 六月丁香综合在线视频| 日韩三级精品电影久久久 | youjizz久久| 亚洲色图清纯唯美| 日本电影亚洲天堂一区| 亚洲午夜久久久久中文字幕久| 91精品91久久久中77777| 亚洲综合在线观看视频| 欧美亚洲综合在线| 午夜精品久久一牛影视| 91精品国产一区二区三区蜜臀| 免费欧美高清视频| 精品久久一二三区| 国产suv精品一区二区883| 国产精品女主播av| 色先锋资源久久综合| 亚洲高清视频中文字幕| 日韩欧美中文字幕精品| 国产高清亚洲一区| 1024国产精品| 欧美精品乱码久久久久久| 亚洲成av人片在www色猫咪| 日韩一区二区三区四区| 国产一区二区三区精品视频| 中文欧美字幕免费| 欧亚洲嫩模精品一区三区| 午夜天堂影视香蕉久久| 久久久久99精品国产片| 欧美大黄免费观看| 大胆欧美人体老妇| 亚洲在线免费播放| 精品成人在线观看| 91香蕉视频黄| 久久成人麻豆午夜电影|