I bought a USB UART serial console cable during the recent Pimoroni sale https://shop.pimoroni.com/products/usb- ... =288389664; I had a spare Pi Zero and a spare sd card, so time to play. I got connected without too much trouble, using "screen" from a Debian laptop. But the console seems to be set to 80x24; its like a smaller viewport within the larger screen display. You can sort of see this when I do an "ls -l" in a full directory, see attached. . This is even more obvious when I invoke "mc" (midnight commander) - see other attached image. .
Is this configurable, and where? On the Zero, on the laptop, in screen?
-
- Posts: 687
- Joined: Wed Jun 20, 2018 12:38 am
[SOLVED] serial console more than 80x24?
Last edited by tinker2much on Mon Sep 05, 2022 9:01 pm, edited 1 time in total.
Re: serial console more than 80x24?
If that is configurable, it'll be in one of these 2 files (system vs user config)
Try this:
https://www.gnu.org/software/screen/man ... indow-Size
And user manual https://www.gnu.org/software/screen/manual/screen.htmlCustomizing Screen
Like many Linux applications, Screen uses a customizable configuration file. Find the system-wide configuration file at /etc/screenrc. The user’s configuration file is located at ~/.screenrc.
Try this:
https://www.gnu.org/software/screen/man ... indow-Size
-
- Posts: 687
- Joined: Wed Jun 20, 2018 12:38 am
Re: serial console more than 80x24?
With either of screen's width or height commands, I get "Your termcap does not specify how to change the terminal's width|height to ..."
I have the feeling that the problem is what's appearing IN the screen window, not the screen window itself. IOW, the contents not the container. Which would have to be fiddled with on the sending zero?
I have the feeling that the problem is what's appearing IN the screen window, not the screen window itself. IOW, the contents not the container. Which would have to be fiddled with on the sending zero?
Re: serial console more than 80x24?
Dumb question: did you try to change the settings of your terminal? Not just drag to corner of the window to make it longer and wider, but actually change it's default settings.
-
- Posts: 8165
- Joined: Sat Aug 18, 2012 2:33 pm
Re: serial console more than 80x24?
the problem is that the serial terminal emulator, is not informing the remote (linux on rpi) end about the resizing
so the remote linux is just stuck defaulting to 80x24
the 2 tput commands, send ansii control codes to ask the terminal emulator what the width/height are
the stty command then modifies the tty on the remote linux, to change the dimensions
you can also just run the "resize" command from the xterm package to do the same thing
so the remote linux is just stuck defaulting to 80x24
Code: Select all
echo "stty rows $(tput lines) cols $(tput cols)"
the stty command then modifies the tty on the remote linux, to change the dimensions
you can also just run the "resize" command from the xterm package to do the same thing
Re: serial console more than 80x24?
They do not. tput lines and cols just print the currently-assumed terminal size, which is the very thing we are trying to correct.cleverca22 wrote: ↑Mon Sep 05, 2022 6:46 pmthe 2 tput commands, send ansii control codes to ask the terminal emulator what the width/height are
The resize program from the xterm package, however does attempt to query the terminal emulator using escape sequences.
-
- Posts: 8165
- Joined: Sat Aug 18, 2012 2:33 pm
Re: serial console more than 80x24?
oops, right, i forgot how that command was meant to be used, and why the echo is there
you where meant to run that before you start the serial terminal program, to get the LOCAL terminal size
and it prints out an stty command, that you copy, then paste into the terminal after you connect
yep, thats far simpler, and can be used repeatedly as you resize, its just slightly confusing that its in the xterm package
-
- Posts: 687
- Joined: Wed Jun 20, 2018 12:38 am
Re: serial console more than 80x24?
I ran the following on the local terminal:
Which returned the following:
I cut that from the local terminal and pasted it into the serial terminal, and that did it. Now mc looks like this: .
You guys are great, thank you very much!
Code: Select all
echo "stty rows $(tput lines) cols $(tput cols)"
Code: Select all
stty rows 33 cols 132
You guys are great, thank you very much!
Re: [SOLVED] serial console more than 80x24?
if you install the xterm package then the command resize will set the serial console to the size of your console window. you can also put
into /etc/profile.d/serial-console.sh
and it should automatically resize/set your console window size
Code: Select all
rsz() {
if [[ -t 0 && $# -eq 0 ]];then
local IFS='[;' escape geometry x y
echo -ne '\e7\e[r\e[999;999H\e[6n\e8'
read -t 5 -sd R escape geometry
x=${geometry##*;} y=${geometry%%;*}
if [[ ${COLUMNS} -eq ${x} && ${LINES} -eq ${y} ]];then
echo "${TERM} ${x}x${y}"
else
echo "${COLUMNS}x${LINES} -> ${x}x${y}"
stty cols ${x} rows ${y}
fi
else
print 'Usage: rsz'
fi
}
case $( /usr/bin/tty ) in
/dev/ttyAMA0|/dev/ttyAMA10|/dev/ttyO0|/dev/ttyS0) export LANG=C
rsz
;;
esac
and it should automatically resize/set your console window size
-
- Posts: 2
- Joined: Mon Sep 25, 2023 12:27 pm
- Location: 75217 Birkenfeld, Germany
Re: [SOLVED] serial console more than 80x24?
If the following lines are added to /etc/bash.bashrc the columns and rows of a serial console will automatically be adjusted to the screen size. So, the Midnight Commander will fill the whole screen which it finds at start. This solution was originally posted at https://unix.stackexchange.com/a/680244
The Midnight Commander at the serial terminal will start with color and mouse support if the following line is added to /etc/bash.bashrc (see https://midnight-commander.org/wiki/doc/faq):
To enable root to use the alias the following line can be added to /etc/bash.bashrc:
I use 2023-05-03-raspios-bullseye-arm64-lite and PuTTY 0.77 under Windows 10 Pro 22H2.
Code: Select all
# resize function for connected serial console
resize() {
old=$(stty -g)
stty raw -echo min 0 time 5
printf '\0337\033[r\033[999;999H\033[6n\0338' > /dev/tty
IFS='[;R' read -r _ rows cols _ < /dev/tty
stty "$old"
#echo "cols:$cols"
#echo "rows:$rows"
stty cols "$cols" rows "$rows"
}
ALL_COMMANDS_FINISHED=1
PreCommands() {
if [ "$ALL_COMMANDS_FINISHED" = '1' ]; then
ALL_COMMANDS_FINISHED=0
resize
#echo "1->0"
fi
}
PostCommands() {
ALL_COMMANDS_FINISHED=1
}
# if login thru tty*
if [[ $(tty) == /dev/tty* ]]; then
# PreCommands is called before every single command on a command line
trap PreCommands DEBUG
# PostCommands is called after all commands on a command line are finished
PROMPT_COMMAND="PostCommands"
fi
Code: Select all
alias mc='mc -x -c'
Code: Select all
alias sudo='sudo -E '
- Attachments
-
- mcAtSerialLineUnderPuTTYmod.jpg (94.53 KiB) Viewed 426 times
Last edited by Thomas Nittel on Mon Sep 25, 2023 4:22 pm, edited 1 time in total.
-
- Posts: 8165
- Joined: Sat Aug 18, 2012 2:33 pm
Re: [SOLVED] serial console more than 80x24?
both duplicate answers, i already said the same thing back in this thread, in 2022