简体   繁体   English

在Mono中使用USB设备

[英]Working with USB devices in Mono

I have a requirement where I need to detect USB port and read data from Devices. 我有一个要求,我需要检测USB端口和从设备读取数据。 I can see lot of source code for detecting USB ports, but is it possible to read data from devices connected through USB port using C# and Mono? 我可以看到许多用于检测USB端口的源代码,但是可以使用C#和Mono从通过USB端口连接的设备读取数据吗? I need this component to run on Mac and Windows. 我需要这个组件在Mac和Windows上运行。

This is possible. 这个有可能。 There is a project called SharpUSBLib that you should check out. 有一个名为SharpUSBLib的项目,你应该检查。 This a wrapper library written in C# to the USBLib for Unix & Linux which is written in C. There is also a port of USBLib to Win32. 这是一个用C#编写的用于Unix和Linux的USBLib的包装库,用C语言编写。还有一个USBLib到Win32的端口。

One of the things that you may need to be aware of is that you may not need the SharpUSBLib depending on what type of USB device you are trying to talk to. 您可能需要注意的一件事是,您可能不需要SharpUSBLib,具体取决于您尝试与之通信的USB设备类型。 For instance, most USB HIDs (Human Interface Device) like Keyboards and Mice are full Plug'n'Play capable and require no drivers or interface libs. 例如,大多数USB HID(人机接口设备)如Keyboards和Mice都是完全的Plug'n'Play功能,不需要驱动程序或接口库。 I have a small USB Unitech barcode scanner which when plugged into the USB port works like a keyboard and the system (both Linux and Win32) see it as a HID. 我有一个小型USB Unitech条形码扫描仪,当插入USB端口时就像键盘一样,系统(Linux和Win32)都将其视为HID。

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

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