USB-HID/README.md

42 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

## USB-HID
> 参考:[玩转USB HID系列Linux下使用C语言和libusb开发USB HID_hid c++ usb linux-CSDN博客](https://blog.csdn.net/whstudio123/article/details/104348736)
#### 1、使用用途
USB-HID是USB的人体学输入设备(USB Human Input Device)这是一种免驱动的USB通信方式适合用于数据量较小的通信例如机器人硬件驱动的控制、外置IMU、VR手柄类设备。这个仓库主要用于解决STM32和Linux、windows的通信问题。
一般来说STM32最常用的是采用串口通信但是串口有可能存在驱动不兼容、相同串口插入主机后分不清的问题。所以部分情况采用USB-HID能够解决串口驱动问题和相同串口干扰问题。
#### 2、代码编译
##### 2.1 windows
##### 2.2 Linux
##### 2.2.1 环境要求
```shell
sudo apt-get install libusb-1.0-0
```
##### 2.2.2 样例和编译
usb_test_show.cpp : 显示各个连接到主机的usb信息
```shell
# firefly RK3588已经集成libusb 1.0
gcc usb_test_show.cpp -o hid_test_show -lusb-1.0
# 运行
sudo ./hid_test_show
```
usb_test_show.cpp 读取USB信息(IMU设备DEMO)并显示
```shell
gcc usb_read_data.cpp -o hid -lusb-1.0
# 执行
sudo ./hid
```