该
/sys文件系统应该包含你的追求大量的信息。我的系统(2.6.32-40-通用#87-Ubuntu)建议:
/sys/class/tty
其中提供了系统已知的所有TTY设备的描述。精简示例:
# ll /sys/class/tty/ttyUSB*lrwxrwxrwx 1 root root 0 2012-03-28 20:43 /sys/class/tty/ttyUSB0 -> ../../devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.4/2-1.4:1.0/ttyUSB0/tty/ttyUSB0/lrwxrwxrwx 1 root root 0 2012-03-28 20:44 /sys/class/tty/ttyUSB1 -> ../../devices/pci0000:00/0000:00:1d.0/usb2/2-1/2-1.3/2-1.3:1.0/ttyUSB1/tty/ttyUSB1/
遵循以下链接之一:
# ll /sys/class/tty/ttyUSB0/insgesamt 0drwxr-xr-x 3 root root 0 2012-03-28 20:43 ./drwxr-xr-x 3 root root 0 2012-03-28 20:43 ../-r--r--r-- 1 root root 4096 2012-03-28 20:49 devlrwxrwxrwx 1 root root 0 2012-03-28 20:43 device -> ../../../ttyUSB0/drwxr-xr-x 2 root root 0 2012-03-28 20:49 power/lrwxrwxrwx 1 root root 0 2012-03-28 20:43 subsystem -> ../../../../../../../../../../class/tty/-rw-r--r-- 1 root root 4096 2012-03-28 20:43 uevent
此
dev文件包含以下信息:
# cat /sys/class/tty/ttyUSB0/dev188:0
这是主要/次要节点。可以在
/dev目录中搜索这些名称以获得用户友好名称:
# ll -R /dev |grep "188, *0"crw-rw---- 1 root dialout 188, 0 2012-03-28 20:44 ttyUSB0
该
/sys/class/tty目录包含所有TTY设备,但您可能要排除那些讨厌的虚拟终端和伪终端。我建议您仅检查那些具有
device/driver条目的条目:
# ll /sys/class/tty/*/device/driverlrwxrwxrwx 1 root root 0 2012-03-28 19:07 /sys/class/tty/ttyS0/device/driver -> ../../../bus/pnp/drivers/serial/lrwxrwxrwx 1 root root 0 2012-03-28 19:07 /sys/class/tty/ttyS1/device/driver -> ../../../bus/pnp/drivers/serial/lrwxrwxrwx 1 root root 0 2012-03-28 19:07 /sys/class/tty/ttyS2/device/driver -> ../../../bus/platform/drivers/serial8250/lrwxrwxrwx 1 root root 0 2012-03-28 19:07 /sys/class/tty/ttyS3/device/driver -> ../../../bus/platform/drivers/serial8250/lrwxrwxrwx 1 root root 0 2012-03-28 20:43 /sys/class/tty/ttyUSB0/device/driver -> ../../../../../../../../bus/usb-serial/drivers/ftdi_sio/lrwxrwxrwx 1 root root 0 2012-03-28 21:15 /sys/class/tty/ttyUSB1/device/driver -> ../../../../../../../../bus/usb-serial/drivers/ftdi_sio/
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)