I have a laptop which has only one serial port.
I went into:
directory, and I found:
ttyS0 ttyS1 ttyS2 ttyS3
How do I know which of those "ttyS" refers to my serial port?
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
See which UARTs where detected in
/proc/tty/driver/serial. A line with
uart:unknown means: nothing detected (and likely not existent).
# cat /proc/tty/driver/serial serinfo:1.0 driver revision: 0: uart:16550A port:000003F8 irq:4 tx:0 rx:0 1: uart:16550A port:000002F8 irq:3 tx:111780 rx:1321 RTS|DTR|DSR 2: uart:unknown port:000003E8 irq:4 3: uart:unknown port:000002E8 irq:3
If something is connected and driving the lines CTS, DSR or CD (these are input lines) you can even be pretty sure that there actually is something... Same is true for the rx-byte-count.
If you need to do this programmatically reading the output from dmesg can be troublesome, instead the folder /dev/serial/by-id has sym links that are named after identifiable data of your device and point to the specific /dev/tty* they are connected to.
I'm not sure if this is some special udev rule that is distribution specific, but it works well in Ubuntu, let me know if it works.
There is also the command
setserial which uses
/proc/tty/driver/serial to get it's data.
# setserial -g /dev/ttyS /dev/ttyS0, UART: 16550A, Port: 0x03f8, IRQ: 4 /dev/ttyS1, UART: 16550A, Port: 0x02f8, IRQ: 3 /dev/ttyS2, UART: unknown, Port: 0x03e8, IRQ: 4 /dev/ttyS3, UART: unknown, Port: 0x02e8, IRQ: 3