简体   繁体   English

使用 USB 设备的 VID/PID 查找 /dev 条目

[英]Find /dev entry with VID/PID of USB device

I'd like to make a program that will detect which /dev/sd* entry is linked to a known USB VID/PID pair.我想制作一个程序来检测哪个/dev/sd*条目链接到一个已知的 USB VID/PID 对。

Do you know how I can get the VID/PID of a USB stick that would appear as /dev/sd* ?你知道我怎样才能得到一个显示为/dev/sd*的 U 盘的 VID/PID 吗?

you can use udevadm for this您可以为此使用udevadm

in the output of udevadm info -q property -n /dev/sd* the VID is in the ID_VENDOR_ID field and the PID is in the ID_MODEL_ID fieldudevadm info -q property -n /dev/sd*的输出中,VID 在ID_VENDOR_ID字段中,PID 在ID_MODEL_ID字段中

you can extract this using grep / sed ...您可以使用grep / sed提取它...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM