internal HarnessExecutionResult Execute() { aTimer = new System.Timers.Timer(); aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent); aTimer.Interval = m_timeOut; aTimer.Start(); HarnessExecutionResult harnessExecutionResult = this.m_harness.Run(m_test, m_log); aTimer.Stop(); aTimer.Dispose(); if (HarnessExecutionResult.Exception == harnessExecutionResult) { KillProcesses(true); } if (m_didTestTimeOut) { harnessExecutionResult = HarnessExecutionResult.TimeOut; } if (m_didEmulatorCrash) { harnessExecutionResult = HarnessExecutionResult.Success; } return(harnessExecutionResult); }
private string PingDevice(HarnessExecutionResult prevResult) { MFDeploy mfDeploy = new MFDeploy(); PingConnectionType pct = PingConnectionType.NoConnection; bool usbFound = false; int retries = 0; while (!usbFound && retries++ < 2) { foreach (MFPortDefinition pd in mfDeploy.DeviceList) { if (string.Equals(pd.Transport.ToString(), m_transport, StringComparison.InvariantCultureIgnoreCase)) { usbFound = true; Utils.WriteToEventLog("Previous result from harness: " + prevResult); int attempts = 0; while ((PingConnectionType.NoConnection == pct || PingConnectionType.TinyBooter == pct) && (attempts++ < 5)) { try { using (MFDevice dev = mfDeploy.Connect(pd)) { pct = dev.Ping(); Utils.WriteToEventLog("MFDevice.Ping() resulted in a " + pct.ToString()); if (PingConnectionType.TinyBooter == pct) { // Clear the bootloader flag so that the device gets // back into tinyclr. dev.Execute(0); } dev.Dispose(); } if (PingConnectionType.NoConnection == pct) { Utils.WriteToEventLog("Attempting to reset power since we have a " + "NoConnection status from device.."); ResetDevicePower(); } } catch { Utils.WriteToEventLog("An exception was thrown when attempting a ping. " + "Reseting power contoller directly..."); MFPowerController.Reset(); System.Threading.Thread.Sleep(5000); } System.Threading.Thread.Sleep(1000); } break; } } if (!usbFound) { Utils.WriteToEventLog("USB not found after the attempt#: " + retries); MFPowerController.Reset(); System.Threading.Thread.Sleep(5000); } } return pct.ToString(); }
private string DeviceStatus(HarnessExecutionResult prevResult) { string pingResponse = String.Empty; if (null != m_transport) { // Continue running the next test if the device ping returns a tinyclr. // Else, reset power to the device and continue. pingResponse = PingDevice(prevResult); } return pingResponse; }