anszom / vtty Goto Github PK
View Code? Open in Web Editor NEWVirtual serial port driver for Linux
License: Other
Virtual serial port driver for Linux
License: Other
Seems missing:
#include <linux/sched/signal.h>
I created two simple test programs in Python to send and receive data:
Write to master send.py
:
#!/usr/bin/env python3
import serial
import time
if __name__ == '__main__':
# causes: termios.error: (25, 'Inappropriate ioctl for device')
# serial_port = serial.Serial(
# port='/dev/vtmx',
# baudrate=100000,
# parity=serial.PARITY_EVEN,
# stopbits=serial.STOPBITS_TWO,
# bytesize=serial.EIGHTBITS)
serial_port = open('/dev/vtmx', 'w')
while True:
try:
for i in range(10):
msg = str(i)
serial_port.write(msg)
serial_port.flush()
print(f"sent {msg}")
time.sleep(0.5)
except KeyboardInterrupt:
break
serial_port.close()
Read from slave recv.py
:
#!/usr/bin/env python3
import serial
if __name__ == '__main__':
serial_port = serial.Serial(
port='/dev/ttyV0',
baudrate=100000,
parity=serial.PARITY_EVEN,
stopbits=serial.STOPBITS_TWO,
bytesize=serial.EIGHTBITS)
print(f"serial port open: {serial_port.is_open}")
while True:
byte = serial_port.read()
print(chr(byte))
serial_port.close()
However, instantiating the serial port gets stuck somewhere at termios.tcsetattr
.
How do I configure the master device such that I can read from the slave like a regular serial device?
Running make
successfully builds the module /vtty.ko
, but installing via make modules_install
fails:
$ sudo make modules_install
make -C /lib/modules/6.2.0-32-generic/build M= modules
make[1]: Verzeichnis „/usr/src/linux-headers-6.2.0-32-generic“ wird betreten
make[2]: *** Keine Regel vorhanden, um das Ziel „arch/x86/entry/syscalls/syscall_32.tbl“,
benötigt von „arch/x86/include/generated/uapi/asm/unistd_32.h“, zu erstellen. Schluss.
make[1]: *** [arch/x86/Makefile:248: archheaders] Fehler 2
make[1]: Verzeichnis „/usr/src/linux-headers-6.2.0-32-generic“ wird verlassen
make: *** [Makefile:5: modules] Fehler 2
That is more or less saying:
*** No rule exists to create target 'arch/x86/entry/syscalls/syscall_32.tbl' required by 'arch/x86/include/generated/uapi/asm/unistd_32.h'. Ending.
Are there instructions on how to build the module?
You need to unregister tty driver (tty_unregister_driver) before module exit to prevent kernel panic.
I don't recall the exact circumstances, this is just a note to myself to test and fix this one day
First error is
vtty.c:283:24: error: initialization of ‘void (*)(struct tty_struct *, const struct ktermios *)’ from incompatible pointer type ‘void (*)(struct tty_struct *, struct ktermios *)’ [-Werror=incompatible-pointer-types]
283 | .set_termios = vtty_set_termios,
Signature of set_termios
in struct tty_operations
changed since 6.0.0. It can be easily fixed with this PR.
Second error is
vtty.c:449:54: error: implicit declaration of function ‘kernel_termios_to_user_termios’ [-Werror=implicit-function-declaration]
449 | copystatus = kernel_termios_to_user_termios((struct termios2 __user*)ptr, &port->oob_data.termios);
#include <linux/termios_internal.h>
doesn't fix it because the symbol seems no longer exported. Trying to figure out how to solve it.
Hello,
I was trying out your driver to use it with a gps using gpsd, and another serial device, so I can choose which data gets sent to a real serial device port. The baudrate of the serial device, in my case called /dev/ttyTHS1 is 9600 baud. So now I mirror the port into ttyV0 and ttyV1. If I let gpsd connect to the "fake" serial port ttyV0, it autodetects that V0 is 38400 baud. The original ttyTHS1 port is 9600 when I start the mirror program. How can I force ttyV0 to return 9600 baud?
Best regards
[...]/vtty/vtty.c: In function ‘vtmx_read’:
[...]/vtty/vtty.c:454:54: error: implicit declaration of function ‘kernel_termios_to_user_termios’ [-Werror=implicit-function-declaration]
454 | copystatus = kernel_termios_to_user_termios((struct termios2 __user*)ptr, &port->oob_data.termios);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.