diff options
| author | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-05-13 13:58:45 +0300 |
|---|---|---|
| committer | Roy Ben-Shabat <Roy@Twine-s.com> | 2019-05-13 13:58:45 +0300 |
| commit | 4cc4089f36b0a9b9d754e33acb49da930f846699 (patch) | |
| tree | 314c77ca012d10ff1440a112893072943e479066 /Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs | |
| parent | 8d58d0b03648069600f8abf39dbe68b16c90559b (diff) | |
| download | Tango-4cc4089f36b0a9b9d754e33acb49da930f846699.tar.gz Tango-4cc4089f36b0a9b9d754e33acb49da930f846699.zip | |
Some fixed to TCC mobile design.
Implemented DFU reset on Machine Operator.
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs')
| -rw-r--r-- | Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index 4047ae7a2..1f01c8873 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -34,6 +34,7 @@ using Tango.PMR.FirmwareUpgrade; using Tango.Integration.Logging; using Tango.Integration.JobRuns; using Tango.FirmwareUpdateLib.WPF; +using Tango.FirmwareUpdateLib; namespace Tango.Integration.Operation { @@ -2267,6 +2268,41 @@ namespace Tango.Integration.Operation } /// <summary> + /// Resets the device through the DFU channel. + /// </summary> + /// <returns></returns> + public Task ResetDFU() + { + return Task.Factory.StartNew(() => + { + LogManager.Log("Performing device reset through DFU..."); + + FirmwareUpdateManager updateManager = new FirmwareUpdateManager(); + + LogManager.Log("Initializing DFU API..."); + updateManager.Initialize(); + + LogManager.Log("Enumerating DFU devices..."); + var device = updateManager.GetAvailableDevices(false).Where(x => !x.DeviceName.Contains("In-Circuit Debug Interface")).FirstOrDefault(); + if (device != null) + { + 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."); + } + else + { + throw LogManager.Log(new Exception("DFU device not found.")); + } + }); + } + + /// <summary> /// Creates a storage manager for managing the machine file system. /// </summary> /// <returns></returns> |
