From 9aca4b69b22a08d01b12e358eb198f3fbe92ff2a Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Mon, 13 May 2019 14:24:00 +0300 Subject: Added DFU reset to PPC. --- .../Tango.Integration/Operation/MachineOperator.cs | 25 +++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs') diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 1f01c8873..f8e632fa5 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -2277,6 +2277,10 @@ namespace Tango.Integration.Operation { LogManager.Log("Performing device reset through DFU..."); + //LogManager.Log("Disconnecting Operator..."); + //Disconnect().Wait(); + //LogManager.Log("Operator disconnected."); + FirmwareUpdateManager updateManager = new FirmwareUpdateManager(); LogManager.Log("Initializing DFU API..."); @@ -2289,11 +2293,22 @@ namespace Tango.Integration.Operation LogManager.Log($"DFU device found: '{device.DeviceName}'."); LogManager.Log("Switching to DFU mode..."); device.SwitchToDFUMode(); - Thread.Sleep(3000); - LogManager.Log("Resetting device..."); - device.Reset(); - Thread.Sleep(1000); - LogManager.Log("Reset completed."); + Thread.Sleep(6000); + + LogManager.Log("Reattaching to DFU device..."); + device = updateManager.GetAvailableDevices(false).Where(x => !x.DeviceName.Contains("In-Circuit Debug Interface")).FirstOrDefault(); + + if (device != null) + { + LogManager.Log("Resetting device..."); + device.Reset(); + Thread.Sleep(1000); + LogManager.Log("Reset completed."); + } + else + { + throw LogManager.Log(new Exception("DFU device not found.")); + } } else { -- cgit v1.3.1