读取USB中断数据

发布于 2024-10-19 23:32:39 字数 254 浏览 1 评论 0原文

我有一个使用 libusb WIN32 驱动程序的 USB 设备

中断数据可从 通过 USB-HID 的加速度计 接口端点83(在EP83中)。数据 是小结尾格式 以下字段(x、y、z、Vbat、CpuTemp。) 每 62.5 毫秒 (16 Hz) 采集一次数据。 有一些USB HID“得到”和 “设置”可用报告(通过 ep0)

如何通过 .NET 和 C# 访问此数据?

I have a USB device which which uses the libusb WIN32 drivers and

Interrupt data is available from the
accelerometer through the USB-HID
interface endpoint 83 (in EP83). Data
is in little end-in format with the
following fields (x,y,z,Vbat,CpuTemp.)
Data are acquired every 62.5ms (16Hz).
There a number of USB HID "get" and
"set" Reports available (through ep0)

How can I access this data via .NET and C#?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

§对你不离不弃 2024-10-26 23:32:39

libusb32 是通用 USB 驱动程序的 C/C++ 库。它有 2 层。内核模式下的低层是您更改的通用客户端驱动程序 libusb0.sys + .inf 文件,它告诉什么设备上传此通用 USB 驱动程序。他们有 inf-wizard.exe 工具可以帮助您制作此 .inf 文件为您的设备。用户空间的上层是与 libusb 驱动程序通信的 libusb.lib (也可以创建静态链接)。您可以在 usb.h 源代码中找到它,它实际上定义了您的代码和 USB(USB 驱动程序)之间的接口。要访问非托管代码,或者您应该用 c# 或 c++/cli 编写互操作层,或者使用某人制作的现成层。这里是其中一个项目的链接,http://sourceforge.net/projects/libusbdotnet/
如何使用 libusb 库我建议您查看其中的一些示例。通常就像您打开 USB 总线句柄,然后通过 VendorId & 找到您的设备。 ProductId,获取它的句柄。然后对设备的端点进行写入/读取。

libusb32 is c/c++ library of generic usb driver. it comes in 2 layers. low layer in kernel mode is generic client driver libusb0.sys + .inf file that you change and it tells to what device to upload this generic usb driver.They have inf-wizard.exe tool that helps for you to make this .inf file for your device. Upper layer in user space is libusb.lib (you can make also static link) that talks to libusb driver. You can find in sources usb.h that actually defines interface between you code and usb (usb driver). To access unmanaged code or you should write your layer of interop in c# or in c++/cli or use ready layer that been made by somebody. Here the link to one of the projects, http://sourceforge.net/projects/libusbdotnet/
How to use libusb library i advice you to see some example from them. Usually it like you open handle to usb bus, then find there your device by VendorId & ProductId, get it's handle. Then make write/read to endpoints of device.

我不在是我 2024-10-26 23:32:39

如果是HID设备我建议你使用Windows的默认驱动——hid.dll,我用过,没问题。这样您就不必关心还要部署驱动程序,无论如何它都在那里,您只需要了解 API 并使用它即可。为此,我向您推荐 Jan Axelson 的书 USB Complete,她在那里有很好的解释和示例,它是 C/C++ 和 C# 的混合体,但趋势是 .net 她还有一个 HID 页面 在她的网站上,您可以找到您所需要的代码示例。

If it is HID device I recommend you to use Windows's default driver - hid.dll, I used it and it was ok. This way you should not care about deploying also a driver, it's there anyway and you just have to understand the API and use it. For this I recommend you Jan Axelson book USB Complete, she has pretty good explanation and samples there, it is a mixture of C/C++ and C# but the trend is for .net Also she has a HID Page on her website and there you find the code samples you just need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文