From a679ad05f9864f932af99c80fcee465271d525b7 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Wed, 11 Dec 2024 10:17:56 +0100 Subject: [PATCH] Retry USB Aura command once https://github.com/seerge/g-helper/issues/3449 --- app/USB/AsusHid.cs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/USB/AsusHid.cs b/app/USB/AsusHid.cs index af88a756..ad5376b7 100644 --- a/app/USB/AsusHid.cs +++ b/app/USB/AsusHid.cs @@ -119,11 +119,15 @@ public static void Write(List dataList, string log = "USB") } } - public static void WriteAura(byte[] data) + public static void WriteAura(byte[] data, bool retry = true) { if (auraStream == null) auraStream = FindHidStream(AURA_ID); - if (auraStream == null) return; + if (auraStream == null) + { + Logger.WriteLine("Aura stream not found"); + return; + } try { @@ -131,8 +135,10 @@ public static void WriteAura(byte[] data) } catch (Exception ex) { + Logger.WriteLine($"Error writing data to HID device: {ex.Message} {BitConverter.ToString(data)}"); auraStream.Dispose(); - Debug.WriteLine($"Error writing data to HID device: {ex.Message} {BitConverter.ToString(data)}"); + auraStream = null; + if (retry) WriteAura(data, false); } }