Определение устройств > последовательные устройства
"Определение" последовательных устройств (/dev/ttyS*) для данного интерфейса компьютера (а не устройства подключенного к нему).
The serial interfaces (RS-232) is a legacy interface. It has no enumeration process, you have to tell your application which /dev/ttyS* to use (some application do have some auto-detection features, but it's not always reliable).
About serial interfaces
Последовательный порт может иметь физический интерфейс на вашем компьютере:
- DB9 последовательный интерфейс.
- DB25 последовательный интерфейс (на старых компьютерах).
- RJ-45 последовательный интерфейс (в основном на свитчах и роутерах, а также на некоторых компьютерах, как у Sun).
Или могут быть "встроены" в другое устройства, вроде:
- Внутренний модем (ISA, PCI...).
- PC Card (pcmcia, Cardbus...), включая модем, GSM или UMTS/3G карты.
- Серийный адаптер USB.
- Docking station (для ноутбуков).
Often, the computer have an internal UART chipset, but not a physical interface : Recent laptops have the DB-9 connector on the docking station only ; Some desktop have 1 connector available, the 2nd requires an optional cable, etc. so what you see IS NOT what you have.
Which /dev/ttyS* ?
Using hal
hal in installed by default in Desktop Environment (both Gnome and Kde), but not on servers.
Take special attention to 'info.product' and 'linux.device_file' lines :
$hal-find-by-capability --capability serial | xargs -n 1 hal-device
udi = '/org/freedesktop/Hal/devices/pcmcia__1__1_serial_platform_1'
info.capabilities = {'serial'} (string list)
info.category = 'serial' (string)
info.parent = '/org/freedesktop/Hal/devices/pcmcia__1__1' (string)
info.product = 'Merlin UMTS Modem' (string)
info.udi = '/org/freedesktop/Hal/devices/pcmcia__1__1_serial_platform_1' (string)
linux.device_file = '/dev/ttyS1' (string)
linux.hotplug_type = 2 (0x2) (int)
linux.subsystem = 'tty' (string)
linux.sysfs_path = '/sys/class/tty/ttyS1' (string)
serial.device = '/dev/ttyS1' (string)
serial.originating_device = '/org/freedesktop/Hal/devices/pcmcia__1__1' (string)
serial.physical_device = '/org/freedesktop/Hal/devices/pcmcia__1__1' (string)
serial.port = 1 (0x1) (int)
serial.type = 'platform' (string)
udi = '/org/freedesktop/Hal/devices/pci_8086_2a07_serial_platform_0'
info.capabilities = {'serial'} (string list)
info.category = 'serial' (string)
info.parent = '/org/freedesktop/Hal/devices/pci_8086_2a07' (string)
info.product = 'Mobile PM965/GM965 KT Controller' (string)
info.udi = '/org/freedesktop/Hal/devices/pci_8086_2a07_serial_platform_0' (string)
linux.device_file = '/dev/ttyS0' (string)
linux.hotplug_type = 2 (0x2) (int)
linux.subsystem = 'tty' (string)
linux.sysfs_path = '/sys/class/tty/ttyS0' (string)
serial.device = '/dev/ttyS0' (string)
serial.originating_device = '/org/freedesktop/Hal/devices/pci_8086_2a07' (string)
serial.physical_device = '/org/freedesktop/Hal/devices/pci_8086_2a07' (string)
serial.port = 0 (0x0) (int)
serial.type = 'platform' (string)more example : HowToIdentifyADevice/Serial/thinkpad-a22-hal.txt ; HowToIdentifyADevice/Serial/usb-to-serial-adapter_hal.txt
Find in /sys/*
This command should work on all standard Debian installation (even minimalist ones).
$find /sys/ -name 'tty:ttyS*' /sys/devices/pci0000:00/0000:00:1e.0/0000:15:00.0/0.0/tty:ttyS1 /sys/devices/pci0000:00/0000:00:03.3/tty:ttyS0 /sys/devices/platform/serial8250/tty:ttyS3 /sys/devices/platform/serial8250/tty:ttyS2 /sys/devices/pci0000:00/0000:00:1a.1/usb4/4-1/4-1:1.0/ttyUSB0/tty:ttyUSB0 $lspci [..] 00:03.3 Serial controller: Intel Corporation Mobile PM965/GM965 KT Controller (rev 0c) [..] 00:1a.0 USB Controller: Intel Corporation 82801H (ICH8 Family) USB UHCI Contoller #4 (rev 03) [..] 00:1e.0 PCI bridge: Intel Corporation 82801 Mobile PCI Bridge (rev f3) [..] 15:00.0 CardBus bridge: Ricoh Co Ltd RL5c476 II (rev ba)
some explanations on this example :
- serial8250
- ttyS* under "serial8250" probably doesn't exist (they are present by default because it's hard to detect if they are present or not)
- 0000:00:1e.0/0000:15:00.0/0.0/tty:ttyS1
if you look at the lspci output above, pci device "00:1e.0" is a PCI bridge to the card bus controller ("15:00.0"), so ttyS1 is a PC Card device.
- pci0000:00/0000:00:03.3/tty:ttyS0
- ttyS0 is directly connected to the PCI bus. according to the PCI device name, you can assume it isn't a Modem, so it's probably a built-in serial interface.
- ttyUSB0/tty:ttyUSB0
if you look at the lspci output above, pci device "00:1a.0" is a USB Controller, so ttyUSB1 is a USB device (USB-to-serial or modem).
more example : HowToIdentifyADevice/Serial/thinkpad-a22-find-sysfs.txt
keywords:UART ; 8250 , 16550 ; 16450 ; RS232 ; RS-232 ; DB-9 ; DB9 ; DB25 ; UART ; Serial ; ttyS0 ; ttyS1 ; ttyS3 ; ttyS4 ;COM1 ; COM2 ; Com Port
