[TriEmbed] Is that ttyUSB0 or ttyUSB1 this time?

Scott Hall scottghall1 at gmail.com
Sat Feb 20 13:15:16 CST 2021


What a lot of people don't realize is that all entries in the /dev directory are
actually "nodes" or hooks in the various hardware device drivers -- in this case
the serial driver.   If you do a "ls -l /dev" you will notice that it shows you
both the major node ID, or device driver table entry, of the various device
drivers, and the minor node, which is the actual hook ID of the driver itself. 
So for example, if I do a "ll -l /dev/tty*" on my system I get:

    crw-rw-rw-. 1 root tty       5,  0 Feb 16 04:03 /dev/tty
    crw--w----. 1 root tty       4,  0 Feb  1 23:54 /dev/tty0
    crw--w----. 1 root tty       4,  1 Feb  1 23:54 /dev/tty1
    crw--w----. 1 root tty       4,  2 Feb  1 23:54 /dev/tty2
    crw--w----. 1 root tty       4,  3 Feb  1 23:54 /dev/tty3
    crw--w----. 1 root tty       4,  4 Feb  1 23:54 /dev/tty4
    crw--w----. 1 root tty       4,  5 Feb  1 23:54 /dev/tty5
    crw--w----. 1 root tty       4,  6 Feb  1 23:54 /dev/tty6
    crw--w----. 1 root tty       4,  7 Feb  1 23:54 /dev/tty7
    crw--w----. 1 root tty       4,  8 Feb  1 23:54 /dev/tty8
    crw--w----. 1 root tty       4,  9 Feb  1 23:54 /dev/tty9
    crw--w----. 1 root tty       4, 10 Feb  1 23:54 /dev/tty10
    crw--w----. 1 root tty       4, 11 Feb  1 23:54 /dev/tty11
    crw--w----. 1 root tty       4, 12 Feb  1 23:54 /dev/tty12
    crw--w----. 1 root tty       4, 13 Feb  1 23:54 /dev/tty13
    [...edited for brevity...]
    crw--w----. 1 root tty       4, 59 Feb  1 23:54 /dev/tty59
    crw--w----. 1 root tty       4, 60 Feb  1 23:54 /dev/tty60
    crw--w----. 1 root tty       4, 61 Feb  1 23:54 /dev/tty61
    crw--w----. 1 root tty       4, 62 Feb  1 23:54 /dev/tty62
    crw--w----. 1 root tty       4, 63 Feb  1 23:54 /dev/tty63
    crw-rw----. 1 root dialout   4, 64 Feb  1 23:54 /dev/ttyS0
    crw-rw----. 1 root dialout   4, 65 Feb  1 23:54 /dev/ttyS1
    crw-rw----. 1 root dialout   4, 66 Feb  1 23:54 /dev/ttyS2
    crw-rw----. 1 root dialout   4, 67 Feb  1 23:54 /dev/ttyS3
    crw-rw----. 1 root dialout 188,  0 Feb  1 23:54 /dev/ttyUSB0

So /dev/ttyNN are all nodes into driver 4, and the minor number pretty much
matches the hook number.
The /dev/ttySn nodes for the hardware handshaking ports have their hooks after
the first 64 minor nodes for the driver.
Note that the USB port(s) are noded against a different device driver, 188, and
the hooks into the driver pretty much line up with the /dev/ttyUSBn entries.

Pete's Freudian slip about making "hard links" is not so far off as to what you
can do with the "mknode" command.  You can make multiple node entries into the
same device driver hook.  So if I wanted to make an alias node for the first USB
serial device, I can issue the following command:

    sudo mknod /dev/smarthome_console c 188 0


And the new /dev/ special file becomes:

    crw-rw-rw-. 1 root root 188, 0 Feb 20 14:11 /dev/smarthome_console


Notice that I can change the permission of the new special file different than
the old special file, and have both exist at the same time.

- sgh

On 2/19/21 8:32 PM, Pete Soper via TriEmbed wrote:
> My memory was off: was using symlinks. The script below after === did the
> work. After --- are my udev rules. This all ran on Ubuntu (probably 16.04).
>
> Many little local files having meaningful labels. File names with the file
> contents to the right of the name:
>
> DM01L0P2 SW-GW-CELL
> DM01L2BU GW-USB2
> DM01LZ2F SW-GW-WIFI
> DO00W275 GW-USB4
> DO00WYOK GW-USB0
> DO00WYOT GW-USB3
> DO01TY7B GW-USB1
> L2000G0A X-SP1___
> L20900F01 X-SP2___
> X-NC____ DEB-NC-SERIAL
> X-NE____ DEB-NE-SERIAL
> X-NW____ DEB-NW-SERIAL
> X-SWCELL DEB-SW-CELL-SERIAL
> X-SWWIFI DEB-SW-WIFI-SERIAL
>
>

-- 
Scott G. Hall
Raleigh, NC, USA
ScottGHall1 at GMail.Com

/Although kindness is rarely a job, no matter what you do it's always an option./

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.triembed.org/pipermail/triembed_triembed.org/attachments/20210220/51ceec26/attachment.htm>


More information about the TriEmbed mailing list