How can I make screen go down a line AND start at the beginning when receiving only CR from a serial device?
4
votes
1
answer
2840
views
I am connecting to a serial port using screen:
screen /dev/cu.usbserial-A703XAOG
. The device on the other end sends only a carriage return to separate lines. Screen only starts at the beginning of the line when receiving a carriage return, and does not go down a line, and thus overwrites the last line of output with the next line of output.
I can change the icrnl
setting of the serial port, and it will convert the carriage return to a line feed. Although screen now goes down a line before writing the next line of output, it doesn't start at the beginning when receiving only a line feed.
I dumped the .termcap file using the Ctrl-A, Ctrl+.. I read up on termcap and I learned that:
> If the terminal has a command that moves to the first column of the next line, that command can be given as nw (newline).
[source](https://www.freebsd.org/cgi/man.cgi?query=termcap&sektion=5&manpath=4.3BSD+Reno)
So this is my current ~/.screenrc
file:
termcap SC nw=^M
Where SC
matches the name in the dumped .termcap file.
This does not give the effect that I hoped for. Maybe the termcap
command is not the way to go?
How can I make screen go down a line AND start at the beginning when receiving only CR from a serial device?
Edit:
Here is the output of sudo stty -f /dev/cu.usbserial-A703XAOG -a
when screen is connected to the serial port:
speed 9600 baud; 0 rows; 0 columns;
lflags: -icanon -isig iexten -echo echoe echok echoke -echonl echoctl
-echoprt -altwerase -noflsh -tostop -flusho -pendin -nokerninfo
-extproc
iflags: -istrip -icrnl -inlcr -igncr -ixon -ixoff -ixany -imaxbel -iutf8
-ignbrk brkint -inpck ignpar -parmrk
oflags: -opost -onlcr -oxtabs -onocr -onlret
cflags: cread cs8 -parenb -parodd -hupcl clocal -cstopb -crtscts -dsrflow
-dtrflow -mdmbuf
cchars: discard = ^O; dsusp = ^Y; eof = ^D; eol = ^@; eol2 = ^@;
erase = ^?; intr = ^C; kill = ^H; lnext = ^V; min = 100;
quit = ^\; reprint = ^R; start = ^Q; status = ^T; stop = ^S;
susp = ^Z; time = 2; werase = ^W;
Edit:
I understand some software may solve this, for example, in [PuTTY](https://putty.org) I would need to enable the "implicit LF in every CR" setting, and in [Serial](https://www.decisivetactics.com/products/serial/) I would need to enable "Interpret Standalone CR as CRLF". But my question is specifically about screen
, because that is the software I am using currently to connect to the serial port.
Edit:
Screen emulates the VT100 terminal, and it should recognize control sequences ([source](https://www.gnu.org/software/screen/manual/html_node/Control-Sequences.html)) . I need to set "Automatic Linefeed Mode" (also known as [new line mode](https://vt100.net/docs/vt100-ug/chapter3.html#LNM)) . This should be done using the set mode control sequence with the parameter value 20: ESC [ 20 h
.
How can I pass this control sequence to screen?
Asked by Michiel van Oosterhout
(175 rep)
Aug 12, 2019, 08:56 PM
Last activity: Aug 15, 2019, 05:52 PM
Last activity: Aug 15, 2019, 05:52 PM