private void RestartButton_Click(object sender, EventArgs e) { if (!ValidateConnectionStatus()) { return; } try { m_usbConnector.RestartDevice(); } catch (Exception ex) { s_logger.Warn(ex); InfoBox.Show(GetErrorMessage("restarting device")); } }
private void UpdateFirmwareAsyncWorker(BackgroundWorker worker, byte[] firmware) { var isSuccess = false; try { UpdateUI(() => UpdateStatusLabel.Text = @"Reading dataflash..."); var dataflash = m_connector.ReadDataflash(worker); if (dataflash.LoadFromLdrom == false && dataflash.FirmwareVersion > 0) { dataflash.LoadFromLdrom = true; UpdateUI(() => UpdateStatusLabel.Text = @"Writing dataflash..."); m_connector.WriteDataflash(dataflash, worker); m_connector.RestartDevice(); UpdateUI(() => UpdateStatusLabel.Text = @"Waiting for device after reset..."); Thread.Sleep(2000); } UpdateUI(() => UpdateStatusLabel.Text = @"Uploading firmware..."); m_connector.WriteFirmware(firmware, worker); UpdateUI(() => { UpdateStatusLabel.Text = string.Empty; worker.ReportProgress(0); }); isSuccess = true; Thread.Sleep(500); } catch (Exception ex) { InfoBox.Show("An exception occured during firmware update.\n" + ex.Message); } finally { if (isSuccess) { InfoBox.Show("Firmware successfully updated."); } } }