Ich versuche, ein USB-Gerät-Handle in MonoLibUsb (unter Linux) zu öffnen, aber jedes Mal, wenn ich es öffne, bekomme ich IsInvalid == true
auf dem Gerätehandle.USB-Gerät nicht in MonoLibUsb
Das USB-Gerät ist definitiv mit LibUsb kompatibel, da ich es an meinen Windows-PC angeschlossen habe und LibUsbDotNet erfolgreich verwenden kann, um mit ihm zu kommunizieren. Wenn ich versuche, LibUsbDotNet in Mono zu verwenden, hängt die Anwendung, wenn ich versuche, es zu öffnen, also dachte ich, LibUsbDotNet ist für Windows und MonoLibUsb ist für Mono (der Name gibt es weg). Aber auch MonoLibUsb kann das Gerät nicht ordnungsgemäß verwenden.
Warum wird das Handle des Geräts als ungültig zurückgegeben?
-Code
private void UsbInit() {
var sessionHandle = new MonoUsbSessionHandle();
var profileList = new MonoUsbProfileList();
profileList.Refresh(sessionHandle);
List<MonoUsbProfile> usbList = profileList.GetList().FindAll(MyVidPidPredicate);
foreach(MonoUsbProfile profile in usbList) {
var deviceHandle = profile.OpenDeviceHandle();
if (deviceHandle.IsInvalid) {
Console.WriteLine(string.Format("IsInvalid: {0} - {1}", MonoUsbSessionHandle.LastErrorCode, MonoUsbSessionHandle.LastErrorString));
}
}
}
private bool MyVidPidPredicate(MonoUsbProfile profile) {
if (profile.DeviceDescriptor.VendorID == 0xabcd && profile.DeviceDescriptor.ProductID == 0x1234)
return true;
return false;
}
Ausgabe
IsInvalid: Success -