I'm currently working on a serial port library which already uses special frameworks to get information about serial ports on the system. Though serial ports are a fundamental design in Unix—as an answer such as this one proves—I thought that a good way to test whether a file is a serial port is by testing the major mode of the character device
and check whether this is actually a TTY
or not.
Crawling on Internet, I could not find any documentation talking about the major modes of TTY
s across unices. Well, there's only one Linux man page stating that ptmx has major mode 5.
Though I already asked about the implementation details of tty character device based on this Stack Overflow question, I thought I might ask the Unix Stack Exchange community to find out how stable the tty values are across Unix flavors.
So, I'm asking your help to build a knowledge base of the Major mode of all your tty files on your system(s), i.e.: what's the major mode of
- real serial ports?
- pseudo terminal (
PTS
) ports? FTDI USB
Serial ports?- other
USB
Serial ports?
To get the values for major mode of a character device, you shall look using:
% stat -f " * %N: %Hr%n" /dev/tty* /dev/pts/*
* /dev/ttys001: 16
^^- major mode
or using good old ls
:
% ls -l /dev/ttys001
crw--w---- 1 <user> tty 16, 1 Apr 30 03:25 /dev/ttys001
major mode -^^ ^^- minor mode
You can put information in answer of your own, or extend the community wiki answer with additional information.