Linux应用程序开发笔记:解决USB设备无权限问题

Step1

通过 lsusb 指令查看USB设备的 Vendor ID 和 Product ID

lsusb

Bus 001 Device 034: ID 0483:374b STMicroelectionics ST-LINK/V2.1

Vendor ID: 0483

Product ID: 374b

Step2

在 /etc/udev/rules.d 文件夹中创建 80-usb.rules 并写入如下内容(将Step1中记录的ID分别写入):

# Copy this file to /etc/udev/rules.d/
# If rules fail to reload automatically, you can refresh udev rules
# with the command "udevadm control --reload"

ACTION!="add|change", GOTO="selfdefine_rules_end"

# Please keep this list sorted by VID:PID

# STLINK-V2.1
ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", MODE="660", GROUP="plugdev", TAG+="uaccess"

LABEL="selfdefine_rules_end"

Step3

执行 sudo udevadm control --reload 指令

Step4

拔插你的USB设备,默认用户状态下也可以操作该USB设备

猜你喜欢

转载自blog.csdn.net/u010018991/article/details/107557566