How to toggle CR/LF in gnu screen?

36,365

Solution 1

Try stty onlcr.

The man page says it will translate newlines to carriage return / newline pairs on output, which seems to be what you need.

Solution 2

onlcr is for translating outgoing newlines to carriage returns.

stty -F /dev/ttyS0 inlcr will translate incoming newlines to carriage returns. You can run that from another terminal after starting screen to avoid any resetting that screen may do on startup. Unfortunately however, this will only change the problem. You'll then get only returns and no newlines.

What is needed is an option to append a return to an incoming newline so that the terminal receives \n\r, which is what the serial device should have output in the first place. There seems to be an onlret option to do this for outgoing data, but no inlret option as we would seem to need in this case.

I have the exact same problem (using picocom though) and I've been googling off and on for days trying to find the standard fix, but no one seems to have one. There are a number of serial devices out there which only output \n and simply can't be made to output \r\n and I refuse to believe that all of them belong to only two linux users. What gives!?

Solution 3

If you use the miniterm.py program that comes with pyserial it will interpret newlines as crlf. It is not the most fully-featured terminal emulator but for interacting with simple serial devices it gets the job done.

Usage syntax (on OSX):

miniterm.py /dev/tty.usbserial-XXXXXX 115200

Replace XXXXXX with whatever the device comes up on your system as.

Solution 4

In my case worked: stty -F /dev/ttyACM0 -icrnl

Because the serial was implicitly set to translate CR to NL. This command set it back. Notice the minus character preceding icrnl.

Share:
36,365
Patrick
Author by

Patrick

Updated on April 21, 2020

Comments

  • Patrick
    Patrick about 4 years

    I'm using screen to read the text from a serial console. The problem is the output seems to only have newline \n but not carriage return \r, so the display looks like this...

    Line1
         Line2
              Line3
    

    I wonder if there is any patch to fix this issue?