initial commit
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
using LibUsbDotNet;
|
||||
using LibUsbDotNet.LibUsb;
|
||||
using RTCSync.Utils;
|
||||
|
||||
namespace RTCSync.Services;
|
||||
|
||||
public abstract class DeviceDispatcher
|
||||
{
|
||||
public static IUsbDevice? SetUpDevice()
|
||||
{
|
||||
var context = new UsbContext();
|
||||
context.SetDebugLevel(LogLevel.Info); // уровень логгирования winusb
|
||||
|
||||
var list = context.List();
|
||||
Console.WriteLine($"Всего USB устройств: {list.Count}");
|
||||
|
||||
foreach (var d in list)
|
||||
Console.WriteLine($" VID={d.VendorId:X4} PID={d.ProductId:X4}");
|
||||
|
||||
var device = list.FirstOrDefault(d => d.VendorId == 0x1A86 && d.ProductId == 0x5512);
|
||||
if (device == null)
|
||||
{
|
||||
Console.WriteLine("Не найдено");
|
||||
return null;
|
||||
}
|
||||
Console.WriteLine("Найдено, открываем...");
|
||||
device.Open();
|
||||
device.ClaimInterface(0);
|
||||
Console.WriteLine("Открыто успешно");
|
||||
I2CUtils.CH341Init(device);
|
||||
return device;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user