My tty0tty (https://github.com/freemed/tty0tty) fork and minimal modify!
mytty0tty is a Linux kernel module derived from the original tty0tty project.
It creates linked virtual serial port pairs and adds external per-pair control for the CD/DCD and RI modem signals through sysfs.
The original project is available here: https://github.com/freemed/tty0tty
Original author: Luis Claudio Gamboa Lopes lcgamboa@yahoo.com
Special thanks to Luis Claudio Gamboa Lopes for the original tty0tty project and for the codebase this project is based on.
This project is licensed under GPL v2.
Because this project is a modified derivative of the original GPL-based tty0tty code, this modified version is also distributed under GPL v2.
- Original author: Luis Claudio Gamboa Lopes lcgamboa@yahoo.com
- Current modified version author: Novarobot
This module creates linked virtual null-modem style serial port pairs, for example:
/dev/mytnt0↔/dev/mytnt1/dev/mytnt2↔/dev/mytnt3/dev/mytnt4↔/dev/mytnt5/dev/mytnt6↔/dev/mytnt7
Data written to one side appears on the paired side.
Original tty0tty behavior, in short:
RTS→ peerCTSDTR→ peerDSRDTR→ peerCD/DCD
Modified mytty0tty behavior:
RTS→ peerCTSDTR→ peerDSRCD/DCDno longer automatically followsDTRRIandCD/DCDcan be controlled externally, per pair, through sysfs- separate module name and separate device prefix are used, so it can coexist with the original
tty0ttymodule
Each serial port pair has its own mask file:
/sys/kernel/mytty0tty/mytnt0_mytnt1_mask/sys/kernel/mytty0tty/mytnt2_mytnt3_mask/sys/kernel/mytty0tty/mytnt4_mytnt5_mask/sys/kernel/mytty0tty/mytnt6_mytnt7_mask
The mask is a 4-bit value from 0 to 15:
- bit0 = first side
CD/DCD - bit1 = first side
RI - bit2 = second side
CD/DCD - bit3 = second side
RI
For example, for mytnt0_mytnt1_mask:
0= all low1= onlymytnt0sideCD/DCD2= onlymytnt0sideRI3=mytnt0sideCD/DCD + RI4= onlymytnt1sideCD/DCD8= onlymytnt1sideRI12=mytnt1sideCD/DCD + RI15= both sidesCD/DCD + RI
Example command:
printf '15\n' | sudo tee /sys/kernel/mytty0tty/mytnt0_mytnt1_maskThis version was tested on Debian 12.
Required packages on Debian 12:
sudo apt install build-essential linux-headers-$(uname -r)Build the module:
makeExample: create 4 linked serial port pairs:
sudo insmod ./mytty0tty.ko pairs=4Check that it is loaded:
lsmod | grep mytty0tty
ls -l /dev/mytnt*
find /sys/kernel/mytty0tty -maxdepth 1 -type f | sortInstall the module into the system module tree:
sudo make installEnable automatic loading at boot by editing /etc/modules or by creating a modules-load configuration file:
echo mytty0tty | sudo tee /etc/modules-load.d/mytty0tty.confAlternatively, you can add the module name manually to /etc/modules.
echo 'mytty0tty' /etc/modulesLoad the installed module manually:
sudo modprobe mytty0ttyTerminal 1:
cat /dev/mytnt1Terminal 2:
echo HELLO > /dev/mytnt0cat /sys/kernel/mytty0tty/mytnt0_mytnt1_maskprintf '15\n' | sudo tee /sys/kernel/mytty0tty/mytnt0_mytnt1_maskcat /sys/kernel/mytty0tty/mytnt0_mytnt1_maskEnable CD/DCD + RI only on the mytnt0 side:
printf '3\n' | sudo tee /sys/kernel/mytty0tty/mytnt0_mytnt1_maskEnable CD/DCD + RI only on the mytnt1 side:
printf '12\n' | sudo tee /sys/kernel/mytty0tty/mytnt0_mytnt1_maskEnable CD/DCD + RI on both sides:
printf '15\n' | sudo tee /sys/kernel/mytty0tty/mytnt0_mytnt1_maskDisable everything:
printf '0\n' | sudo tee /sys/kernel/mytty0tty/mytnt0_mytnt1_maskIf the module was loaded manually or with modprobe, unload it from the running kernel with:
sudo modprobe -r mytty0ttyAlternative:
sudo rmmod mytty0ttyIf the module was also installed into the system module tree, remove the installed files too:
sudo modprobe -r mytty0tty
sudo rm -f /lib/modules/$(uname -r)/extra/mytty0tty.ko
sudo rm -f /etc/modules-load.d/mytty0tty.conf
sudo depmod -aIf you added the module name manually to /etc/modules, remove that line from /etc/modules as well.
The goal of this project is to preserve the useful behavior of the original tty0tty driver while adding:
- a separate module name
- a separate device prefix
- external shell-based control of the
CD/DCDandRIlines
A mytty0tty egy Linux kernel modul, amely az eredeti tty0tty projekt módosított változata.
Összekapcsolt virtuális soros port párokat hoz létre, és páronként külső vezérlést ad a CD/DCD és RI modemjelekhez sysfs-en keresztül.
Az eredeti projekt itt érhető el: https://github.com/freemed/tty0tty
Eredeti szerző: Luis Claudio Gamboa Lopes lcgamboa@yahoo.com
Külön köszönet Luis Claudio Gamboa Lopesnek az eredeti tty0tty projektért és azért a kódbázisért, amelyre ez a projekt épül.
Ez a projekt GPL v2 licenc alatt érhető el.
Mivel ez a projekt az eredeti GPL alapú tty0tty kód módosított származéka, ezért ez a változat is GPL v2 alatt kerül közzétételre.
- Eredeti szerző: Luis Claudio Gamboa Lopes lcgamboa@yahoo.com
- Jelenlegi módosított változat szerzője: Novarobot
A modul összekapcsolt virtuális nullmodem-szerű soros port párokat hoz létre, például:
/dev/mytnt0↔/dev/mytnt1/dev/mytnt2↔/dev/mytnt3/dev/mytnt4↔/dev/mytnt5/dev/mytnt6↔/dev/mytnt7
Az egyik oldalon küldött adat a pár másik oldalán jelenik meg.
Az eredeti tty0tty viselkedése röviden:
RTS→ túloldaliCTSDTR→ túloldaliDSRDTR→ túloldaliCD/DCD
A módosított mytty0tty viselkedése:
RTS→ túloldaliCTSDTR→ túloldaliDSR- a
CD/DCDmár nem követi automatikusan aDTRjelet - az
RIésCD/DCDjelek külsőleg, páronként állíthatók sysfs fájlokon keresztül - külön modulnevet és külön eszközprefixet használ, ezért az eredeti
tty0ttymodullal együtt is betölthető
Minden portpárhoz tartozik egy külön mask fájl:
/sys/kernel/mytty0tty/mytnt0_mytnt1_mask/sys/kernel/mytty0tty/mytnt2_mytnt3_mask/sys/kernel/mytty0tty/mytnt4_mytnt5_mask/sys/kernel/mytty0tty/mytnt6_mytnt7_mask
A mask egy 4 bites érték 0 és 15 között:
- bit0 = első oldal
CD/DCD - bit1 = első oldal
RI - bit2 = második oldal
CD/DCD - bit3 = második oldal
RI
Például a mytnt0_mytnt1_mask esetén:
0= minden alacsony1= csakmytnt0oldalonCD/DCD2= csakmytnt0oldalonRI3=mytnt0oldalonCD/DCD + RI4= csakmytnt1oldalonCD/DCD8= csakmytnt1oldalonRI12=mytnt1oldalonCD/DCD + RI15= mindkét oldalonCD/DCD + RI
Példa parancs:
printf '15\n' | sudo tee /sys/kernel/mytty0tty/mytnt0_mytnt1_maskEz a változat Debian 12 alatt lett tesztelve.
Szükséges csomagok Debian 12 alatt:
sudo apt install build-essential linux-headers-$(uname -r)A modul fordítása:
makePélda: 4 összekapcsolt portpár létrehozása:
sudo insmod ./mytty0tty.ko pairs=4Ellenőrzés:
lsmod | grep mytty0tty
ls -l /dev/mytnt*
find /sys/kernel/mytty0tty -maxdepth 1 -type f | sortA modul telepítése a rendszer modul könyvtárába:
sudo make installAutomatikus betöltés engedélyezése rendszerindításkor az /etc/modules szerkesztésével vagy egy modules-load konfigurációs fájl létrehozásával:
echo mytty0tty | sudo tee /etc/modules-load.d/mytty0tty.confAlternatív megoldásként a modul neve kézzel is beírható az /etc/modules fájlba.
echo 'mytty0tty' /etc/modulesA telepített modul kézi betöltése:
sudo modprobe mytty0tty- terminál:
cat /dev/mytnt1- terminál:
echo HELLO > /dev/mytnt0cat /sys/kernel/mytty0tty/mytnt0_mytnt1_maskprintf '15\n' | sudo tee /sys/kernel/mytty0tty/mytnt0_mytnt1_maskcat /sys/kernel/mytty0tty/mytnt0_mytnt1_maskCsak a mytnt0 oldalon CD/DCD + RI:
printf '3\n' | sudo tee /sys/kernel/mytty0tty/mytnt0_mytnt1_maskCsak a mytnt1 oldalon CD/DCD + RI:
printf '12\n' | sudo tee /sys/kernel/mytty0tty/mytnt0_mytnt1_maskMindkét oldalon CD/DCD + RI:
printf '15\n' | sudo tee /sys/kernel/mytty0tty/mytnt0_mytnt1_maskMinden kikapcsolása:
printf '0\n' | sudo tee /sys/kernel/mytty0tty/mytnt0_mytnt1_maskHa a modult kézzel vagy modprobe-bal töltötted be, így távolítsd el a futó kernelből:
sudo modprobe -r mytty0ttyAlternatív megoldás:
sudo rmmod mytty0ttyHa a modul telepítve is lett a rendszer modul könyvtárába, akkor a telepített fájlokat is törölni kell:
sudo modprobe -r mytty0tty
sudo rm -f /lib/modules/$(uname -r)/extra/mytty0tty.ko
sudo rm -f /etc/modules-load.d/mytty0tty.conf
sudo depmod -aHa a modul neve kézzel lett hozzáadva az /etc/modules fájlhoz, akkor onnan is törölni kell a megfelelő sort.
A projekt célja az eredeti tty0tty hasznos működésének megtartása úgy, hogy közben hozzáadja:
- a külön modulnevet
- a külön eszközprefixet
- a
CD/DCDésRIvonalak külső, shellből vezérelhető kezelését