如何在 Ubuntu 中使用 C++ 获取 USB 端口信息?
How to get USB ports information using C++ in Ubuntu?
众所周知,我们可以使用终端通过命令 lsusb 找到 USB 端口:
$ lsusb
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 5986:02d2 Acer, Inc
Bus 001 Device 005: ID 054c:0688 Sony Corp.
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 034: ID 13fe:4100 Kingston Technology Company Inc. Flash drive
Bus 003 Device 033: ID 2500:0020
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
我也访问了这些网站并获得了很多建议,但它们并没有像我上面预期的那样工作。
- Getting USB Device path from USB port
- https://unix.stackexchange.com/questions/61484/find-the-information-of-usb-devices-in-c
- https://askubuntu.com/questions/503928/missing-usb-h-file-what-is-it-where-do-i-get-it
- http://www.linux-usb.org/
- http://www.dreamincode.net/forums/topic/148707-introduction-to-using-libusb-10/
.....等等。
我想了解如何 link USB 输入到 C++,但我越来越困惑,对它一无所知。
在 Linux 上,the libusb library 提供了一个用于使用 USB 设备的 C 库 API,它应该也可以与 C++ 一起使用。 libusb
是所有主要 Linux 发行版的一部分。
众所周知,我们可以使用终端通过命令 lsusb 找到 USB 端口:
$ lsusb
Bus 002 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 004: ID 5986:02d2 Acer, Inc
Bus 001 Device 005: ID 054c:0688 Sony Corp.
Bus 001 Device 002: ID 8087:0024 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 003 Device 034: ID 13fe:4100 Kingston Technology Company Inc. Flash drive
Bus 003 Device 033: ID 2500:0020
Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
我也访问了这些网站并获得了很多建议,但它们并没有像我上面预期的那样工作。
- Getting USB Device path from USB port
- https://unix.stackexchange.com/questions/61484/find-the-information-of-usb-devices-in-c
- https://askubuntu.com/questions/503928/missing-usb-h-file-what-is-it-where-do-i-get-it
- http://www.linux-usb.org/
- http://www.dreamincode.net/forums/topic/148707-introduction-to-using-libusb-10/
.....等等。
我想了解如何 link USB 输入到 C++,但我越来越困惑,对它一无所知。
在 Linux 上,the libusb library 提供了一个用于使用 USB 设备的 C 库 API,它应该也可以与 C++ 一起使用。 libusb
是所有主要 Linux 发行版的一部分。