什么决定了 /dev 条目?

什么决定了 /dev 条目?

我正在尝试使用名为“linux-gpib”的软件包与 USB-GPIB 适配器连接。我安装了驱动程序,没有出现任何错误,然后插入我的设备。

Python 中有一个 C API 的包装器,因此我尝试使用该函数来打开我的设备,但出现错误:

libgpib: ibBoardOpen failed to open device file /dev/gpib0

我检查了/dev,果然该设备不存在。确实存在一个名为“usb_gpib”的文件。所以看起来我的设备正在由系统以某种方式注册,但它没有创建正确的 /dev 文件。我不确定,但“usb_gpib”文件可能就是我正在寻找的文件,并且由于某种原因被错误命名。什么决定了 dev 文件的命名方式?


经过一些额外的搜索,我找到了 /etc/udev/rules.d/ 目录。

这里有一个 GPIB 的 .rules 文件,其中有以下行:

KERNEL=="gpib[0-9]*", ACTION=="add", MODE="660", GROUP=="plugdev"

这看起来像是在说创建的设备是应该是gpib0,但情况仍然不是这样。


根据要求,这是当我拔下并重新插入设备两次时“udevadm监视器”打印出来的内容:

monitor will print the received events for:
UDEV - the event which udev sends out after rule processing

UDEV  [32.214427] add      /devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3 (usb)
ACTION=add
BUSNUM=001
DEVLINKS=/dev/usb_gpib
DEVNAME=/dev/bus/usb/001/004
DEVNUM=004
DEVPATH=/devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3
DEVTYPE=usb_device
ID_BUS=usb
ID_MODEL=702b
ID_MODEL_ENC=702b
ID_MODEL_FROM_DATABASE=GPIB-USB-B
ID_MODEL_ID=702b
ID_REVISION=0001
ID_SERIAL=3923_702b
ID_USB_INTERFACES=:ffffff:
ID_VENDOR=3923
ID_VENDOR_ENC=3923
ID_VENDOR_FROM_DATABASE=National Instruments Corp.
ID_VENDOR_ID=3923
MAJOR=189
MINOR=3
PRODUCT=3923/702b/1
SEQNUM=1077
SUBSYSTEM=usb
TYPE=255/255/255
USEC_INITIALIZED=941557

UDEV  [32.228951] add      /devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3/1-1.3:1.0 (usb)
ACTION=add
DEVPATH=/devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3/1-1.3:1.0
DEVTYPE=usb_interface
ID_MODEL_FROM_DATABASE=GPIB-USB-B
ID_USB_CLASS_FROM_DATABASE=Vendor Specific Class
ID_USB_PROTOCOL_FROM_DATABASE=Vendor Specific Protocol
ID_USB_SUBCLASS_FROM_DATABASE=Vendor Specific Subclass
ID_VENDOR_FROM_DATABASE=National Instruments Corp.
INTERFACE=255/255/255
MODALIAS=usb:v3923p702Bd0001dcFFdscFFdpFFicFFiscFFipFFin00
PRODUCT=3923/702b/1
SEQNUM=1078
SUBSYSTEM=usb
TYPE=255/255/255
USEC_INITIALIZED=2645

UDEV  [32.347470] remove   /devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3/1-1.3:1.0 (usb)
ACTION=remove
DEVPATH=/devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3/1-1.3:1.0
DEVTYPE=usb_interface
ID_MODEL_FROM_DATABASE=GPIB-USB-B
ID_USB_CLASS_FROM_DATABASE=Vendor Specific Class
ID_USB_PROTOCOL_FROM_DATABASE=Vendor Specific Protocol
ID_USB_SUBCLASS_FROM_DATABASE=Vendor Specific Subclass
ID_VENDOR_FROM_DATABASE=National Instruments Corp.
INTERFACE=255/255/255
MODALIAS=usb:v3923p702Bd0001dcFFdscFFdpFFicFFiscFFipFFin00
PRODUCT=3923/702b/1
SEQNUM=1079
SUBSYSTEM=usb
TYPE=255/255/255
USEC_INITIALIZED=2645

UDEV  [32.361405] remove   /devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3 (usb)
ACTION=remove
BUSNUM=001
DEVLINKS=/dev/usb_gpib
DEVNAME=/dev/bus/usb/001/004
DEVNUM=004
DEVPATH=/devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3
DEVTYPE=usb_device
ID_BUS=usb
ID_MODEL=702b
ID_MODEL_ENC=702b
ID_MODEL_FROM_DATABASE=GPIB-USB-B
ID_MODEL_ID=702b
ID_REVISION=0001
ID_SERIAL=3923_702b
ID_USB_INTERFACES=:ffffff:
ID_VENDOR=3923
ID_VENDOR_ENC=3923
ID_VENDOR_FROM_DATABASE=National Instruments Corp.
ID_VENDOR_ID=3923
MAJOR=189
MINOR=3
PRODUCT=3923/702b/1
SEQNUM=1080
SUBSYSTEM=usb
TYPE=255/255/255
USEC_INITIALIZED=941557

UDEV  [34.314071] add      /devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3 (usb)
ACTION=add
BUSNUM=001
DEVLINKS=/dev/usb_gpib
DEVNAME=/dev/bus/usb/001/005
DEVNUM=005
DEVPATH=/devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3
DEVTYPE=usb_device
ID_BUS=usb
ID_MODEL=702a
ID_MODEL_ENC=702a
ID_MODEL_ID=702a
ID_REVISION=0001
ID_SERIAL=3923_702a
ID_USB_INTERFACES=:ff0000:
ID_VENDOR=3923
ID_VENDOR_ENC=3923
ID_VENDOR_FROM_DATABASE=National Instruments Corp.
ID_VENDOR_ID=3923
MAJOR=189
MINOR=4
PRODUCT=3923/702a/1
SEQNUM=1081
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=1346

UDEV  [34.368446] add      /devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3/1-1.3:1.0 (usb)
ACTION=add
DEVPATH=/devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3/1-1.3:1.0
DEVTYPE=usb_interface
ID_VENDOR_FROM_DATABASE=National Instruments Corp.
INTERFACE=255/0/0
MODALIAS=usb:v3923p702Ad0001dc00dsc00dp00icFFisc00ip00in00
PRODUCT=3923/702a/1
SEQNUM=1082
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=2286

UDEV  [39.006199] remove   /devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3/1-1.3:1.0 (usb)
ACTION=remove
DEVPATH=/devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3/1-1.3:1.0
DEVTYPE=usb_interface
ID_VENDOR_FROM_DATABASE=National Instruments Corp.
INTERFACE=255/0/0
MODALIAS=usb:v3923p702Ad0001dc00dsc00dp00icFFisc00ip00in00
PRODUCT=3923/702a/1
SEQNUM=1083
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=2286

UDEV  [39.013553] remove   /devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3 (usb)
ACTION=remove
BUSNUM=001
DEVLINKS=/dev/usb_gpib
DEVNAME=/dev/bus/usb/001/005
DEVNUM=005
DEVPATH=/devices/soc0/amba@0/e0002000.usb/ci_hdrc.0/usb1/1-1/1-1.3
DEVTYPE=usb_device
ID_BUS=usb
ID_MODEL=702a
ID_MODEL_ENC=702a
ID_MODEL_ID=702a
ID_REVISION=0001
ID_SERIAL=3923_702a
ID_USB_INTERFACES=:ff0000:
ID_VENDOR=3923
ID_VENDOR_ENC=3923
ID_VENDOR_FROM_DATABASE=National Instruments Corp.
ID_VENDOR_ID=3923
MAJOR=189
MINOR=4
PRODUCT=3923/702a/1
SEQNUM=1084
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=1346

相关内容