I have a small device currently that can be communicated with windows platform with Dot Net C# (HID) based application. I wanted it to communicate with Linux or Raspberry Pi4 device using usb. I have created the small application and using the “LibUsbDotNet” library (Cross Platform). But my application fails to OpenUsbDevice.
I have searched a lot the solution, but I did not get any success. Is there any suitable Dot Net 6.0 based USB library for Linux platform.
Getting the error as error CS0117: 'UsbDevice' does not contain a definition for 'OpenUsbDevice'
using System;
using LibUsbDotNet;
using LibUsbDotNet.Main;
using Usb.Net;
namespace Usb.Net.WindowsSample
{
using System;
using LibUsbDotNet.Main;
class Program
{
static void Main(string[] args)
{
// Find and open the USB device
UsbDeviceFinder finder = new UsbDeviceFinder(0x1234, 0x5678); // Replace with your device's Vendor ID and Product ID
UsbDevice usbDevice = UsbDevice.OpenUsbDevice(finder);
if (usbDevice == null)
{
Console.WriteLine("USB device not found.");
return;
}
// Perform operations on the USB device
// Close the device when done
usbDevice.Close();
}
}
Or
UsbDeviceFinder usbDeviceFinder = null;
if (deviceDefinition.VendorId.HasValue)
{
if (deviceDefinition.ProductId.HasValue)
{
usbDeviceFinder = new UsbDeviceFinder((int)deviceDefinition.VendorId.Value, (int)deviceDefinition.ProductId.Value);
}
else
{
usbDeviceFinder = new UsbDeviceFinder((int)deviceDefinition.VendorId.Value);
}
}
var usbDevice = UsbDevice.OpenUsbDevice(usbDeviceFinder);