11

I have an annoying problem with minicom connected to a serial console to a Yocto Linux machine.

The command that I enter wraps around on the same line after 80th character. This becomes very inconvenient to work with. Everything I entered at the beginning of the line gets overwritten by the last chars of that line.

A SSH connection to the same machine works just fine. After 80th characters ssh go to the next line.

This is the stty setting:

stty -a
speed 115200 baud; rows 24; columns 80; line = 0;
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = <undef>;
eol2 = <undef>; swtch = <undef>; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;
-parenb -parodd cs8 hupcl -cstopb cread clocal -crtscts
-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon ixoff
-iuclc -ixany -imaxbel iutf8
opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0
isig icanon -iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt
echoctl echoke

The -w option of minicom has no effect. Still the same behavior

minicom -w

The resize command is not available on that machine. To which package does it belong? Maybe I can install it.

How can I fix that behavior?

Oliver G.
  • 263
  • 3
  • 12

2 Answers2

9

This worked for me. The target shell needs to be set to check window size and to be set to the correct size of your console gui. After connecting via serial with either putty or minicom:

shopt -s checkwinsize
resize
4

When you are connected via a serial line, there is no way for the system to negotiate the window size with the terminal (NAWS - Negotiate About Window Size is RFC 1073). In that case you can get either a system default for the size, or even just zeros. Either would confuse the shell's line editor, which needs to know the actual width of the terminal to work with its wraparound feature.

bash gets confused, thinking it has wrapped due to terminal's autowrap feature and moves to the beginning of the current (wrong) line as part of the line-editing/display.

As a workaround, most of the terminals (including minicom — see source) which you would use with a serial interface can respond to the cursor position report escape sequence used by resize to find the window size — and as a side effect set the system's idea of how large your terminal window is.

Thomas Dickey
  • 75,040
  • 9
  • 171
  • 268
  • 1
    I'd still be curious why it wraps around on the same line, instead of into the next line. – dirkt Oct 20 '16 at 05:13