The puzzle I am trying to solve for is where larger outputs of text eventually fall apart into scrambled text.

For context I am working on an older machine (EPSON PX-8) connected to Pi3 over RS232 using terminal emulation software on the PX-8 called TEL

TEL Settings - Baud: 9600, Char Bits: 8, Parity: NONE, Stop Bits: 2, RTS: ON, Flow Control: ON

Initially I had observed this issue between the PX-8 and Pi3. I was able to resolve it by enabling flow control for XON/XOFF signaling. However, when I attempt to telnet or ssh to another Linux host from the Pi3 is where I get scrambled text again when attempting to output larger blocks of text.

The text output below is an example of what happens when I attempt to print my command history.

    1  sudo rasp-config
    2  sudo raspi-config
    3  sudo nano /boot/cmdline.txt
    4  tail /boot/cmdline.txt
    5  sudo shutdown -r now
    6  sudo vim ~/boot/cmdline.txt
    7  cd /./boot
    8  dir
    9  sudo vim cmdline.txt
   10  sudo vim config.txt
   11  sudo shutdown -r now
   12  dfgdf
   13  vim
   14  sudo vim cmdline.txt
   15  cd /./boot
   16  sudo vim cmdline.txt
   17  sudo shutdown -r now
   18  cd /./boot
   19  sudo vim cmdline.txt
   20  sudo shutdown -r now
   21  ping
   2 xprt TEM=Vvj9s9ds9j3oin so nat1 machine
  x Rom =vos cngas-2goses9g3
-xtiet n n5
-s oiy

1 Answer 1


I presume you have something like a serial-to-usb adapter on the pi, and have setup a getty so you can login to this tty from your PX-8. Once logged in, an stty ixon from the shell will enable xon/xoff flow control for output from the pi. If you now ssh from the shell to login to some remote, the flow control is inadequate to stem large output from the remote.

What seems to be happening (do strace -v -f -o /tmp/trace ssh and look for ioctl(0,...)) is that ssh deliberately puts the terminal into a raw mode, which includes switching off the ixon setting. This is usually what is desired; you want every character typed to go to the remote, which has its own pty to handle flow control and so on.

Unfortunately, output from the remote is sent in large buffers, so an xoff character from the PX-8 will have little effect as by the time it gets to the remote, all of the large buffer already received by the pi will continue to be output, probably causing overflow and loss of data.

What you could try is re-issuing an stty ixon on the pi after the ssh connection has been made. One way of doing this automatically is to add to your ~/.ssh/config the 2 option lines

PermitLocalCommand yes
LocalCommand sleep 10 && stty ixon -F /dev/tty &

PermitLocalCommand is off by default for security; see man ssh_config.

  • Excellent. This worked! Thank you! Jun 25, 2021 at 20:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .