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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? filetransferdlg.cpp

?? cp2102 官方usb開發包
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
	if (m_hUSBDevice != INVALID_HANDLE_VALUE)
	{
		// Close the USBXpress device
		SI_Close(m_hUSBDevice);
		m_hUSBDevice = INVALID_HANDLE_VALUE;
	}
	
	// Unregister for device notification
	UnregisterNotification();

	CDialog::OnOK();
}

void CFileTransferDlg::OnUpdateDeviceList() 
{
	FillDeviceList();
}

void CFileTransferDlg::FillDeviceList()
{
	SI_DEVICE_STRING	devStr;
	DWORD				dwNumDevices	= 0;
	CComboBox*			pDevList		= (CComboBox*)GetDlgItem(IDC_DEVICE_SELECT);

	// Make sure that pDevList is not NULL
	if (pDevList)
	{
		// Delete all the strings in the list
		for (int i = 0; i < pDevList->GetCount(); i++)
		{
			pDevList->DeleteString(0);
		}

		// Get the number of USBXpress devices connected
		SI_STATUS status = SI_GetNumDevices(&dwNumDevices);

		if (status == SI_SUCCESS)
		{
			// Go through each device and add their serial numbers to the list
			for (DWORD d = 0; d < dwNumDevices; d++)
			{
				status = SI_GetProductString(d, devStr, SI_RETURN_SERIAL_NUMBER);

				if (status == SI_SUCCESS)
				{
					if (pDevList)
						pDevList->AddString(devStr);
				}
			}
		}

		//Set the current selection to the first item
		pDevList->SetCurSel(0);
	}
}

BOOL CFileTransferDlg::WriteFileData()
{
	BOOL success = TRUE;

	// Make sure a file is specified in the dialog
	if (m_sTXFileName.GetLength() > 0)
	{
		CFile file;

		// Open the file for reading
		if (file.Open(m_sTXFileName, CFile::modeRead | CFile::shareDenyNone))
		{
			// Make sure the file size is 4KB or less
			if (1)//(file.GetLength() && (file.GetLength() <= MAX_PACKET_SIZE_READ))
			{
				DWORD		size			= file.GetLength();
				DWORD		dwBytesWritten	= 0;
				DWORD		dwBytesRead		= 0;
				BYTE		buf[MAX_PACKET_SIZE_WRITE];

				// Set up the write message command with the file size
				buf[0] = FT_WRITE_MSG;
				buf[1] = (BYTE)(size & 0x000000FF);
				buf[2] = (BYTE)((size & 0x0000FF00) >> 8);

				// Send write file size message with a 1 second timeout
				if (DeviceWrite(buf, FT_MSG_SIZE, &dwBytesWritten, 1000))
				{
					if (dwBytesWritten == FT_MSG_SIZE)
					{
						DWORD numPkts		= (size / MAX_PACKET_SIZE_WRITE) + (((size % MAX_PACKET_SIZE_WRITE) > 0)? 1 : 0);
						DWORD numLoops		= (numPkts / MAX_WRITE_PKTS) + (((numPkts % MAX_WRITE_PKTS) > 0)? 1 : 0);
						DWORD counterPkts	= 0;
						DWORD counterLoops	= 0;
						DWORD totalWritten	= 0;

						// Now write data to board
						// After each 512-byte packet, the device will send an 0xFF ACK signal
						while ((counterLoops < numLoops) && success)
						{
							int	i = 0;

							while ((i < MAX_WRITE_PKTS) && (counterPkts < numPkts) && success)
							{
								DWORD dwWriteLength	= 0;

								// Determine if the size is the maximum, or a partial packet
								if ((size - totalWritten) < MAX_PACKET_SIZE_WRITE)
								{
									dwWriteLength = size - totalWritten;
								}
								else
								{
									dwWriteLength = MAX_PACKET_SIZE_WRITE;
								}

								// Read in the data for the packet from the file
								memset(buf, 0, dwWriteLength);
								file.Read(buf, dwWriteLength);
								dwBytesWritten = 0;

								//Write to the device with a 1 second timeout
								success = DeviceWrite(buf, dwWriteLength, &dwBytesWritten, 1000);
								totalWritten += dwWriteLength;
								counterPkts++;
								i++;
							}

							if (success)
							{
								memset(buf, 0, 1);

								// Check for ACK packet after writing 512 bytes or after last packet
								// with a 3 second timeout
								while ((buf[0] != 0xFF) && success)
								{
									success = DeviceRead(buf, 1, &dwBytesRead, 3000);
								}
							}

							counterLoops++;
						}
						
						if (!success)
						{
							AfxMessageBox("Target device failure while sending file data.\nCheck file size.");
							success = FALSE;
						}
					}
					else
					{
						AfxMessageBox("Incomplete write file size message sent to device.");
						success = FALSE;
					}
				}
				else
				{
					AfxMessageBox("Target device failure while sending file size information.");
					success = FALSE;
				}
			}
			else
			{
				AfxMessageBox("Limit for file size is 4KB");
				success = FALSE;
			}

			file.Close();
		}
		else
		{
			CString err;
			err.Format("Failed opening file:\n%s", m_sTXFileName);
			AfxMessageBox(err);
			success = FALSE;
		}
	}
	else
	{
		AfxMessageBox("Error:  No file selected.");
		success = FALSE;
	}

	return success;
}

BOOL CFileTransferDlg::ReadFileData()
{
	BOOL success = TRUE;
    DWORD	length;
	if ((length = m_sRXFileName.GetLength()) > 0)
	{
		CFile	file;

		// Open the temporary file for writing
		if (file.Open(m_sRXFileName, CFile::modeWrite | CFile::modeCreate | CFile::shareDenyNone))
		{
			DWORD		dwBytesRead		= 0;
			DWORD		dwBytesWritten	= 0;
			BYTE		buf[MAX_PACKET_SIZE_READ];
			BYTE		msg[FT_MSG_SIZE];

			// Setup the read command buffer
			msg[0] = FT_READ_MSG;
			msg[1] = (BYTE)0xFF;
			msg[2] = (BYTE)0xFF;

			// Send the read command buffer to the device with a 1 second timeout
			if (DeviceWrite(msg, FT_MSG_SIZE, &dwBytesWritten, 1000))
			{
				DWORD size			= 0;
				DWORD counterPkts	= 0;
				DWORD numPkts		= 0;
				DWORD totalRead		= 0;

				// Reset the message buffer
				memset(msg, 0, FT_MSG_SIZE);

				// Read the response containing the size with a 3 second timeout
				if (DeviceRead(buf, FT_MSG_SIZE, &dwBytesRead, 3000))
				{
					size	= (buf[1] & 0x000000FF) | ((buf[2] << 8) & 0x0000FF00);
					numPkts	= (size/MAX_PACKET_SIZE_READ) + (((size % MAX_PACKET_SIZE_READ) > 0)? 1 : 0);

					// Now read data from board
					while ((counterPkts < numPkts) && success)
					{
						DWORD dwReadLength = 0;
						dwBytesRead = 0;

						// Determine if the size is the max or a partial packet
						if ((size - totalRead) < MAX_PACKET_SIZE_READ)
						{
							dwReadLength = size - totalRead;
						}
						else
						{
							dwReadLength = MAX_PACKET_SIZE_READ;
						}
						
						memset(buf, 0, dwReadLength);
						
						//Read the packet from the device with a 3 second timeout
						if (DeviceRead(buf, dwReadLength, &dwBytesRead, 3000))
						{
							totalRead += dwBytesRead;
							file.Write(buf, dwBytesRead);
							if (dwBytesRead == dwReadLength)
							{
								counterPkts++;
							}
						}
						else
						{
							AfxMessageBox("Failed reading file packet from target device.");
							success = FALSE;
						}


					}
					
				}
				else
				{
					AfxMessageBox("Failed reading file size message from target device.");
					success = FALSE;
				}
			}
			else
			{
				AfxMessageBox("Failed sending read file message to target device.");
				success = FALSE;
			}

			if (file.GetLength() == 0)
			{
				CString err;
				err.Format("File has 0 length:\n%s", m_sRXFileName);
				AfxMessageBox(err);
			}

			file.Close();
		}
		else
		{
			CString err;
			err.Format("Failed opening file:\n%s", m_sRXFileName);
			AfxMessageBox(err);
			success = FALSE;
		}
	}
	else
	{
		AfxMessageBox("Error:  No file selected.");
		success = FALSE;
	}

	return success;
}

BOOL CFileTransferDlg::DeviceRead(BYTE* buffer, DWORD dwSize, DWORD* lpdwBytesRead, DWORD dwTimeout)
{
	DWORD		tmpReadTO, tmpWriteTO;
	SI_STATUS	status			= SI_SUCCESS;

	// Save timeout values.
	SI_GetTimeouts(&tmpReadTO, &tmpWriteTO);

	// Set a timeout for the read
	SI_SetTimeouts(dwTimeout, 0);

	// Read the data
	status = SI_Read(m_hUSBDevice, buffer, dwSize, lpdwBytesRead);
	
	// Restore timeouts
	SI_SetTimeouts(tmpReadTO, tmpWriteTO);

	return (status == SI_SUCCESS);
}

BOOL CFileTransferDlg::DeviceWrite(BYTE* buffer, DWORD dwSize, DWORD* lpdwBytesWritten, DWORD dwTimeout)
{
	DWORD		tmpReadTO, tmpWriteTO;
	SI_STATUS	status	= SI_SUCCESS;

	// Save timeout values.
	SI_GetTimeouts(&tmpReadTO, &tmpWriteTO);

	// Set a timeout for the write
	SI_SetTimeouts(0, dwTimeout);

	// Write the data
	status = SI_Write(m_hUSBDevice, buffer, dwSize, lpdwBytesWritten);

	// Restore timeouts
	SI_SetTimeouts(tmpReadTO, tmpWriteTO);

	return (status == SI_SUCCESS);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产在线一区观看| 日韩欧美成人一区| 国产亚洲精品7777| 国产精品69久久久久水密桃| 国产三级欧美三级日产三级99| 日韩黄色片在线观看| 久久色.com| 欧美午夜电影一区| 中文字幕一区二区三区四区| 91精品国产综合久久久蜜臀图片| 欧美特级限制片免费在线观看| 国产网站一区二区| 7777精品伊人久久久大香线蕉经典版下载 | 国产欧美日韩三级| 国产精品日韩成人| 91精品国产高清一区二区三区蜜臀 | 日韩成人午夜电影| 欧美国产综合一区二区| 欧美日韩中文字幕一区二区| 成人免费av网站| 日本亚洲免费观看| 黄色资源网久久资源365| 成人在线视频首页| 欧美乱妇23p| 欧美午夜免费电影| 日韩精品一区二区三区蜜臀| 国产偷国产偷亚洲高清人白洁| 亚洲乱码一区二区三区在线观看| 日韩女优毛片在线| 国产欧美日韩久久| 一区二区三区不卡视频| 亚洲欧洲国产日本综合| 婷婷开心激情综合| 一个色在线综合| 黄页网站大全一区二区| 91国内精品野花午夜精品 | 亚洲电影一级黄| 一区二区三区四区亚洲| 日本aⅴ亚洲精品中文乱码| 亚洲午夜久久久久久久久电影院| 国产精品久久久久国产精品日日| 国产女同互慰高潮91漫画| 亚洲午夜在线视频| 懂色av一区二区在线播放| 成人深夜福利app| 欧美一级欧美一级在线播放| 国产精品国产三级国产三级人妇| 免费人成精品欧美精品| 色噜噜狠狠成人网p站| 2023国产精品视频| 五月婷婷色综合| 91在线精品一区二区| jlzzjlzz亚洲日本少妇| 不卡的av在线播放| 色综合激情五月| 欧美日产国产精品| 欧美高清www午色夜在线视频| 中文字幕在线不卡一区| 国产一区二区成人久久免费影院| 不卡的av在线播放| 国产欧美日韩三级| 国产精品一二三在| 久久综合精品国产一区二区三区| 天天综合网 天天综合色| 在线观看精品一区| 欧美xxxxx牲另类人与| 国产精品久久久久影视| 成人丝袜视频网| 欧美国产精品v| 国产精品 欧美精品| 在线观看中文字幕不卡| 综合在线观看色| 老色鬼精品视频在线观看播放| 精品午夜一区二区三区在线观看| 不卡一卡二卡三乱码免费网站| 国产三级精品视频| bt7086福利一区国产| 国产精品高清亚洲| 色94色欧美sute亚洲线路二| 亚洲国产欧美在线| 日韩欧美资源站| 亚洲一区视频在线观看视频| 国产一区二区三区四区在线观看| 久久综合久久综合久久| 国产精品一区在线| 综合色天天鬼久久鬼色| 欧美日韩免费观看一区三区| 日本亚洲免费观看| 2023国产精品| 99精品国产一区二区三区不卡| 亚洲欧美偷拍另类a∨色屁股| 国产成人亚洲综合a∨婷婷| 国产亚洲欧美色| 99久久精品国产导航| 午夜精品福利视频网站| 欧美成人艳星乳罩| 99久久婷婷国产综合精品| 亚洲国产欧美一区二区三区丁香婷| 欧美另类videos死尸| 国产九九视频一区二区三区| 国产精品卡一卡二| 欧美日韩一级视频| 国产成人鲁色资源国产91色综| 亚洲人快播电影网| 欧美一区二区三区白人| 波多野结衣一区二区三区| 五月天中文字幕一区二区| 久久久久久久久伊人| 国产美女娇喘av呻吟久久| 中文字幕一区二| 日韩精品一区二区三区中文不卡 | 高清不卡在线观看| 一级日本不卡的影视| 久久蜜桃香蕉精品一区二区三区| 色综合久久中文综合久久牛| 久热成人在线视频| 亚洲日本青草视频在线怡红院| 欧美成人一区二区三区| 欧美亚洲愉拍一区二区| 国产福利一区在线观看| 日韩二区三区四区| 亚洲欧美成aⅴ人在线观看| 精品国产网站在线观看| 国产成人99久久亚洲综合精品| 亚洲午夜在线观看视频在线| 国产精品护士白丝一区av| 91精品国产91综合久久蜜臀| 欧美综合视频在线观看| 成人一区二区三区| 国内欧美视频一区二区| 午夜久久久影院| 一区二区三区电影在线播| 国产精品免费av| 国产日产欧美一区二区三区| 日韩女优制服丝袜电影| 欧美一区二区三区四区高清| 欧美日韩精品电影| 精品一区二区三区在线视频| 亚洲国产三级在线| 国产一区二区精品在线观看| 91一区二区三区在线播放| 国产剧情一区二区| 91玉足脚交白嫩脚丫在线播放| 欧美日韩国产一区| 久久一区二区三区国产精品| 亚洲天堂av一区| 喷水一区二区三区| www.欧美日韩| 日本成人中文字幕| 国产精品久久久久永久免费观看| 国产午夜精品久久| 中文字幕成人av| 亚洲三级久久久| 亚洲精品中文在线观看| 亚洲一区二区三区四区不卡| 亚洲成人免费在线观看| 日本欧美韩国一区三区| 麻豆国产精品777777在线| 亚洲特黄一级片| 玉米视频成人免费看| 午夜成人免费电影| 麻豆精品在线播放| 精品亚洲欧美一区| 99视频国产精品| 欧美男人的天堂一二区| 91精品国产一区二区| 久久综合久色欧美综合狠狠| 国产精品丝袜久久久久久app| 亚洲人妖av一区二区| 亚洲自拍偷拍av| 91色视频在线| 欧美精品久久一区| 国产亚洲精品aa| 亚洲黄色在线视频| 日本不卡一区二区| 国产精品香蕉一区二区三区| 99久久国产综合色|国产精品| 在线视频你懂得一区| 精品国产一区二区三区久久久蜜月| 国产精品伦一区二区三级视频| 夜夜亚洲天天久久| 国产在线视视频有精品| 91精品福利在线| 久久久精品天堂| 午夜精品一区二区三区三上悠亚| 国产主播一区二区| 91久久精品一区二区三区| 亚洲精品在线三区| 亚洲综合一二区| 福利一区二区在线| 日韩欧美高清在线| 亚洲女女做受ⅹxx高潮| 国产精品系列在线播放| 欧美系列在线观看| 国产精品久久久久三级| 日日夜夜一区二区| 91免费观看在线| 国产欧美一区二区三区鸳鸯浴| 午夜精品成人在线| 97国产一区二区|