Skip to content

Commit

Permalink
HidStream fix
Browse files Browse the repository at this point in the history
  • Loading branch information
seerge committed Feb 12, 2024
1 parent f326fa9 commit 8cf8887
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions app/USB/AsusHid.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using HidSharp;
using HidSharp.Reports;
using System.Diagnostics;
using static System.Runtime.InteropServices.JavaScript.JSType;

namespace GHelper.USB;
public static class AsusHid
Expand Down Expand Up @@ -89,18 +90,24 @@ public static void Write(List<byte[]> dataList, string log = "USB")
var devices = FindDevices(AURA_ID);
if (devices is null) return;

foreach (var device in devices)
using (var stream = device.Open())
foreach (var data in dataList)
try
{
stream.Write(data);
Logger.WriteLine($"{log} {device.ProductID.ToString("X")}: {BitConverter.ToString(data)}");
}
catch (Exception ex)
{
Logger.WriteLine($"Error writing {log} {device.ProductID.ToString("X")}: {ex.Message} {BitConverter.ToString(data)} ");
}
foreach (var device in devices)
try
{
using (var stream = device.Open())
foreach (var data in dataList)
try
{
stream.Write(data);
Logger.WriteLine($"{log} {device.ProductID.ToString("X")}: {BitConverter.ToString(data)}");
}
catch (Exception ex)
{
Logger.WriteLine($"Error writing {log} {device.ProductID.ToString("X")}: {ex.Message} {BitConverter.ToString(data)} ");
}
} catch (Exception ex)
{
Logger.WriteLine($"Error opening {log} {device.ProductID.ToString("X")}");
}

}

Expand Down

0 comments on commit 8cf8887

Please sign in to comment.