aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs')
-rw-r--r--Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs36
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>