void swdownloadevent(object sender, string information) { QC.QMSLPhone.Phone PhoneCallbackInfo = new QC.QMSLPhone.Phone(); int Index = 0;// PhoneCallbackInfo.Index; this.Invoke((EventHandler)delegate { TextMessage[Index].AppendText(information + "\r\n"); progb[Index]++; if (progb[Index] < prgb_pr[Index].Maximum) { prgb_pr[Index].Value = progb[Index]; } } ); }
public void StartProgram(object o) { tPara p; p = (tPara)o; int Index = p.Index; this.Invoke((EventHandler)delegate { TextMessage[Index].Text = ""; } ); string numstr = ""; for (int j = 0; j < p.strPort.Length; j++) { if (p.strPort[j] <= '9' & p.strPort[j] >= '0') { numstr += p.strPort[j]; } } Para[Index].iPort = System.Int32.Parse(numstr); SetResult(txtResults[Index], Index, 1); SetText(TextMessage[Index], Index, "CheckIfPortExists:" + Para[Index].strPort + "md"+Para[Index].iPort); phone[Index] = new QC.QMSLPhone.Phone(); phone[Index].SetLibraryMode(QC.QMSLPhone.LibraryModeEnum.QPhoneMS); //phone[Index].OnSwDownloadEvent += swdownloadevent; #region upgrade if (swInfo.SwType == "SoftwareUpgrade") //SoftwareUpgrade { uint iTimeout = 2000; int ipCont = 0; SetText(TextMessage[Index], Index, "ConnectToPhone \r\n"); do { SetText(TextMessage[Index], Index, "ConnectToPhone times: " + ipCont.ToString() + "\r\n"); phone[Index].ConnectToServer(Para[Index].iPort, iTimeout); // ipCont++; Thread.Sleep(2000); } while (!phone[Index].IsPhoneConnected() && ipCont <= 10); if (ipCont >= 10) { SetText(TextMessage[Index], Index, "ConnectToPhone failed\r\n"); SetResult(txtResults[Index], Index, 3); return; } string swVersion, swComplie; phone[Index].GetPhoneVersionInfo(out swVersion, out swComplie); if (swVersion == "") { SetText(TextMessage[Index], Index, "GetPhoneVersionInfo: NULL\r\n"); SetResult(txtResults[Index], Index, 3); return; } SetText(TextMessage[Index], Index, "GetPhoneVersionInfo: " + swVersion + "\r\n"); // GetPhysicalPortAddress string PhyAdd = dev.GetHardWareIdFromPortName(p.strPort); phone[Index].QPHONEMS_SwitchToEDL(); Thread.Sleep(500); phone[Index].DisconnectServer(); Thread.Sleep(500); int iCont = 0; while (iCont <= 10) { WaitForDevice(Index, 5); //Util_GetPortAfterPowerCycleByPhysicalAddress string[] DlPort; // int count = dev.GetAdbdevices(PhyAdd, out DlPort); //// if (count < 1) // continue; if (CheckIfPortExists(Index, 7))//Int32.Parse(DlPort[0]))) break; if (iCont >= 10) { SetText(TextMessage[Index], Index, "Failed, to find port in the CheckIfPortExists Test \r\n"); SetResult(txtResults[Index], Index, 3); return; } iCont++; } ulong sVersion; if (!QPHONEMS_SaharaOpenPort(Index, out sVersion, 7, SaharaDownloadMode.Download, 200))//Para[Index].iPort { phone[Index].DisconnectServer(); phone[Index].DisconnectAllServers(); SetText(TextMessage[Index], Index, "DisconnectServer...\r\n"); SetResult(txtResults[Index], Index, 3); return; } Thread.Sleep(500); } #endregion if (swInfo.SwType == "SoftwareDownload") { ulong MSM_ID = 0x00; ulong sWer = 0x00; //SaharaOpenPort if (!QPHONEMS_SaharaOpenPortWithChipValidation(Index, Para[Index].iPort, SelectOption.No, 8392929, out MSM_ID, out sWer, SaharaDownloadMode.Upgrade, 300)) { DisconnectFromServer_Sahara(Index); SetText(TextMessage[Index], Index, "QPHONEMS_SaharaOpenPortWithChipValidation fail DisconnectServer...\r\n"); SetResult(txtResults[Index], Index, 3); return; } Thread.Sleep(500); } //download MBN file if (!QPHONEMS_SaharaArmPrgDownload(Index, swInfo.ProgramPath, swInfo.MbnName)) { DisconnectFromServer_Sahara(Index); SetText(TextMessage[Index], Index, "QPHONEMS_SaharaArmPrgDownload fail DisconnectServer...\r\n"); SetResult(txtResults[Index], Index, 3); return; } //disconnect sahara if (!DisconnectFromServer_Sahara(Index)) { phone[Index].DisconnectServer(); phone[Index].DisconnectAllServers(); SetText(TextMessage[Index], Index, "DisconnectFromServer_Sahara fail DisconnectServer...\r\n"); SetResult(txtResults[Index], Index, 3); return; } // wait for device int sCont = 0; while (sCont <= 5) { WaitForDevice(Index, 5); if (CheckIfPortExists(Index, Para[Index].iPort)) break; if (sCont >= 5) { SetText(TextMessage[Index], Index, "Failed, to find port in the CheckIfPortExists Test \r\n"); SetResult(txtResults[Index], Index, 3); return; } sCont++; } // firehose open port if (!QPHONEMS_FireHoseOpenPort(Index, Para[Index].iPort)) { phone[Index].DisconnectServer_FireHose(); SetText(TextMessage[Index], Index, "QPHONEMS_FireHoseOpenPort fail DisconnectServer...\r\n"); SetResult(txtResults[Index], Index, 3); return; } //firehosenop if (!QPHONEMS_FireHoseNOP(Index)) { phone[Index].DisconnectServer_FireHose(); SetText(TextMessage[Index], Index, "QPHONEMS_FireHoseNOP fail DisconnectServer...\r\n"); SetResult(txtResults[Index], Index, 3); return; } // QPHONEMS_FireHoseConfigure if (!QPHONEMS_FireHoseConfigure(Index, "49152", "eMMC", swInfo.ProName, "100", false, false, false, false, false)) { phone[Index].DisconnectServer_FireHose(); SetText(TextMessage[Index], Index, "QPHONEMS_FireHoseConfigure fail DisconnectServer...\r\n"); SetResult(txtResults[Index], Index, 3); return; } //phone[Index].SetLogFlags(); // phone[Index].StartLogging(Para[Index].iPort + ".log"); if(!QPHONEMS_EnableDataLogToFile_Firehose(Index,false)) { phone[Index].DisconnectServer_FireHose(); SetText(TextMessage[Index], Index, "QPHONEMS_EnableDataLogToFile_Firehose fail DisconnectServer...\r\n"); SetResult(txtResults[Index], Index, 3); return; } byte mode = 0; phone[Index].QPHONEMS_EnableReadDataValidation_FireHose(mode); float imageSizeInMB = 0, throughput = 0; // start download ----QPHONEMS_UploadEmmcImage_FireHose if (!QPHONEMS_UploadEmmcImage_FireHose(Index, swInfo.RawProName, swInfo.PathName, out imageSizeInMB, out throughput)) { phone[Index].DisconnectServer_FireHose(); SetText(TextMessage[Index], Index, "QPHONEMS_UploadEmmcImage_FireHose fail DisconnectServer...\r\n"); SetResult(txtResults[Index], Index, 3); return; } phone[Index].DisconnectServer_FireHose(); phone[Index].DisconnectServer(); phone[Index].DisconnectAllServers(); SetText(TextMessage[Index], Index, "Success DisconnectServer...\r\n"); SetResult(txtResults[Index], Index, 2); }