Page MenuHomeVyOS Platform

Improve serial console (add options to auto-detect or hard-set terminal size)
Open, WishlistPublicFEATURE REQUEST

Description

Add nodes under system console device ttySx named size auto and size fixed <rows>x<columns>.
auto would perform size detection by adding functions in .profile executed if $(tty) == ttyS*, via either one of the methods described here:
https://unix.stackexchange.com/questions/16578/resizable-serial-console-window
or by using xterm's resize utility (on Debian it's avaliable packaged in xterm, unfortunately it isn't available by itself like on other distros, f.e. Fedora has xterm-resize, but the source is available and under a free license if we don't want to install the whole xterm package, we can build just resize on our own).

As the xterm's resize utility is much faster than the pure bash solutions, that would be preferred, so it can be called after every command exit as a trap on DEBUG. Otherwise the size would be detected only on login and a resize would require the user to run resize by himself, or have a penalty of approx. 0.5s after each command exit. There's no way to detect a serial terminal window resize automatically, a trap on every command exit is the best solution.

The other node size <rows>x<columns> would set a fixed console size via stty.

Details

Version
-
Is it a breaking change?
Behavior change
Issue type
Feature (new functionality)

Event Timeline

jjakob triaged this task as Wishlist priority.
jjakob created this object in space S1 VyOS Public.

There is no way to send a SIGWINCH over serial - see https://unix.stackexchange.com/a/19265
We can, however, poll the terminal for its size - at login and on every command exit (bash trap DEBUG)

Note however, that of the 2 mentioned shell script methods to poll the terminal emulator for its size, the first one (res()) didn't work for me (using GNU screen as the terminal, it returned an error after timeout), the 2nd one (res2()) worked (which is the one using xterm's special escape code). Both suffer from the same 0.5s delay, so the best would be to use xterm-resize, which is almost immediate.

https://github.com/joejulian/xterm/blob/master/resize.c Not complicated to port in the vyos library, replacing the current code and therefore only run when required

I think this would be even better: https://github.com/lime45/serial/blob/master/resize.c (it's a stripped down resize.c), I haven't tested it yet though. I'm not sure where it would be best to put it, as it's a separate compiled program. Other such programs have their own repositories (vyos-utils), maybe 'vyos-xterm-resize' would be best.
I'm busy with work projects until at least next week so VyOS is on the backburner, when I get more time I'd like to rewrite the old console setup code.

erkin removed a subscriber: Global Notifications.
syncer changed the subtype of this task from "Task" to "Feature Request".
dmbaturin set Issue type to Feature (new functionality).Nov 8 2024, 10:50 AM