3

I am running Debian Wheezy and my laptop does not have serial port. Why do I have /dev/ttyS*, and what will happen when I try to read/write to them?

My config:

└──> ll /dev/ttyS*
crw-rw---T 1 root dialout 4, 64 Apr 30 09:21 /dev/ttyS0
crw-rw---T 1 root dialout 4, 65 Apr 30 09:21 /dev/ttyS1
crw-rw---T 1 root dialout 4, 66 Apr 30 09:21 /dev/ttyS2
crw-rw---T 1 root dialout 4, 67 Apr 30 09:21 /dev/ttyS3

└──> sudo cat /proc/tty/driver/serial
serinfo:1.0 driver revision:
0: uart:16550A port:000003F8 irq:4 tx:0 rx:0
1: uart:unknown port:000002F8 irq:3
2: uart:unknown port:000003E8 irq:4
3: uart:unknown port:000002E8 irq:3

└──> stty -g
6d02:5:4bf:8a3b:3:1c:7f:15:4:0:1:ff:11:13:1a:ff:12:f:17:16:ff:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0

└──> dmesg | grep tty
[    0.000000] console [tty0] enabled
[    0.653544] serial8250: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A
[    0.712718] 00:02: ttyS0 at I/O 0x3f8 (irq = 4) is a 16550A

PS: Here is mentioned case when user has one port and under /dev he has 4 but I have none.

4

It is very probable that the ttyS0 port actually exists on your motherboard. And very possibly there is also a connector on the motherboard to use it too! When I bought my last board, I came to that conclusion too (by seeing the port listed), I then looked up all connectors in the board's manual. There was no direct connector to the outside, just a small 'header'. So I ran a cable to a db9 outside connector, and all is working!

The following three (ttyS1-S3) most probably do NOT exist, but are listed because the serial port driver tested them, which is the default action in many Linuxes. See the manual page for setserial, which is the function called when Linux is booted up. It says:

During the normal bootup process, only COM ports 1-4 are initialized, using the default I/O ports and IRQ values, as listed below

EDIT: By the way, it's easy to see if the ttyS* work as files or not. Just try to send something to them by console command:

cat <some_short_file> > /dev/ttyS1

will probably give an I/O error, because there is no driver connected. The same for ttyS0 will work normally. The > in the command redirects the output of the cat command to the serial port. cp shortfile /dev/ttyS0 works too.

EDIT: ttyS1-S3 are not physically there, so no, you can't use them. There are other devices you can use as virtual ports, such as pseudoterminals (pty) and loop devices. Check Wikipedia and the man pages for ptys. Where ptys are character devices, you can use loop devices for block transfer (eg. for virtual disks). Wikipedia and man page documentation.

0
4

These ports actually exist on your motherboard. They are just not connected to an external port like they are in (some) desktops.

4
  • Can i use them somehow? I mean some virtual forwarding etc not physical wiring. – Wakan Tanka May 3 '15 at 8:25
  • As long as they're not connected to anything, they're useless. But you can try… – redbeam_ May 3 '15 at 10:43
  • How? I have seen some socat com1 forwarding for example – Wakan Tanka May 3 '15 at 11:45
  • Download and install minicom: sudo apt-get install minicom and then just launch it: minicom. Press Ctrl + A, select serial port setup, and to the serial port window write ttyS0 or what you want. – redbeam_ May 3 '15 at 12:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.