简体   繁体   English

在USB,C#上读/写

[英]Read/Write on USB, C#

I use LibUsbDotNet to read data from USB with following code: 我使用LibUsbDotNet通过以下代码从USB读取数据:

public static UsbDeviceFinder MyUsbFinder = new UsbDeviceFinder(Convert.ToInt32(0x046D), Convert.ToInt32(0xC06A));  
public static UsbDevice MyUsbDevice;  
MyUsbDevice = UsbDevice.OpenUsbDevice(MyUsbFinder);  

it doesn't work. 它不起作用。 can not find my USB device. 找不到我的USB设备。
can you help me?! 你能帮助我吗?!
you can download library and samples from here 您可以从此处下载库和样本

Have you installed the necessary drivers? 您是否安装了必要的驱动程序? The help file for LibUsbDotNet says: LibUsbDotNet的帮助文件说:

Before LibUsbDotNet can access a usb device on a Windows operating system the device must be installed with either WinUSB or libusb-win32 usb drivers. 在LibUsbDotNet可以访问Windows操作系统上的USB设备之前,该设备必须已安装WinUSB或libusb-win32 USB驱动程序。

Otherwise I can't see anything wrong with your code when compared to the examples. 否则,与示例相比,我的代码不会出现任何问题。


As an aside your use of Convert.ToInt32() is redundant. Convert.ToInt32()您对Convert.ToInt32()是多余的。 This will do the same thing: 这将做同样的事情:

public static UsbDeviceFinder MyUsbFinder = new UsbDeviceFinder(0x046D, 0xC06A);

But that has nothing to do with your problem. 但这与您的问题无关。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM