C++ 使用 Qt 进行 USB 编程

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16450160/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-27 20:22:30  来源:igfitidea点击:

USB Programming with Qt

c++windowsqtusblibusb

提问by Lemon Juice

Is there anyway I can do USB programming in Qt? I am using Qt Creator 2.6 which is based on Qt version 5.0.0 and it is the latest Qt Creator which works with the Microsoft Visual Studio 2010 compiler.

无论如何我可以在Qt中进行USB编程吗?我使用的是基于 Qt 5.0.0 版的 Qt Creator 2.6,它是最新的 Qt Creator,可与 Microsoft Visual Studio 2010 编译器配合使用。

I have the toy called "Dreamcheeky Thunder Missile Launcher" and I need to program this USB based device.

我有一个名为“ Dreamcheeky Thunder Missile Launcher”的玩具,我需要对这个基于 USB 的设备进行编程。

I have tried LibUSB but it messed up everything. It even renamed the device port and I had to undo everything using USBDviewsoftware. But I guess I installed it incorrectly. I followed these instructions. It is instructions for 64 bit, but I got 32 bit and since the instructions seems not to have big difference (instead the download file) I followed it. This is what I downloaded - libusb-win32-bin-1.2.6.0.zip

我尝试过 LibUSB,但它搞砸了一切。它甚至重命名了设备端口,我不得不使用USBDview软件撤消所有操作。但我想我安装不正确。我遵循了这些说明。它是 64 位的说明,但我得到了 32 位,并且由于说明似乎没有太大区别(而不是下载文件),因此我遵循了它。这是我下载的——libusb-win32-bin-1.2.6.0.zip

Whatever the API you recommend it doesn't matter, even libusb, but please be kind enough to tell me how to install it properly.

无论您推荐什么 API,都没有关系,甚至是 libusb,但请告诉我如何正确安装它。

My OS is windows 7 ultimate 32 bit.

我的操作系统是 Windows 7 Ultimate 32 位。

采纳答案by ollo

There's another good instruction for libusbhere: http://www.dreamincode.net/forums/topic/148707-introduction-to-using-libusb-10/

这里有另一个关于libusb的很好的说明:http: //www.dreamincode.net/forums/topic/148707-introduction-to-using-libusb-10/

If you stay on windows you can use

如果你留在窗户上,你可以使用

For windows you can use both, but if your program has to be cross-platform you should use libusb.

对于 Windows,您可以同时使用两者,但如果您的程序必须是跨平台的,您应该使用libusb

回答by Timmmm

ollo's answer is out of date. TL;DR is use libusb.info. A bit of explanation:

ollo 的答案已过时。TL;DR 是使用libusb.info。一点解释:

Originally there was libusb-0.1. Later they updated the API to libusb-1.0, but since libusb-0.1 had been around so long many projects didn't bother switching (kind of like Python 2/3). libusb-0.1 was not available for Windows, but libusb-1.0 is now available for all major platforms.

最初有 libusb-0.1。后来他们将 API 更新为 libusb-1.0,但由于 libusb-0.1 已经存在了很长时间,许多项目都没有打扰切换(有点像 Python 2/3)。libusb-0.1 不适用于 Windows,但 libusb-1.0 现在可用于所有主要平台。

libusb-win32is a port of libusb-0.1 to Windows. You shouldn'tuse it for new code.

libusb-win32是 libusb-0.1 到 Windows 的端口。您不应该将它用于新代码。

libusb.orgis the old website for libusb. The latest release is from 2012 and there are no Windows downloads.

libusb.org是 libusb 的旧网站。最新版本是 2012 年的,没有 Windows 下载。

libusb.infois the current website for libusb. It contains libusb-1.0 downloads for all platforms and you should use this for new code.

libusb.info是 libusb 的当前网站。它包含适用于所有平台的 libusb-1.0 下载,您应该将其用于新代码

To further confuse things, the sourceforge libusb-win32 mailing listis still used for libusb.info's development.

更令人困惑的是,libusb.info 的开发仍然使用sourceforge libusb-win32 邮件列表