[En-Nut-Discussion] Cooked text mode for socket streams

Harald Kipp harald.kipp at egnite.de
Fri Sep 27 10:45:08 CEST 2013

Hi Philipp,

On 27.09.2013 09:44, Philipp Burch wrote:

> I've here an application where a board running Ethernut may be accessed
> via a Telnet connection. This works well with a Linux client, but if I
> connect from Windows, using e.g. Putty, the sent lines are displayed
> shifted like so:
> : abc
> :    def
> :       ghi

Known problem, at least to me. I have a few apps, where a configuration
menu is presented either at the RS-232 port or a telnet connection.

The problem with cooked output is, that the carriage return has to be
inserted, which introduces a lot of extra work for tiny CPUs. For the
UART driver, the best place is when the output string is copied to the
interrupt buffer. Handshake and buffer overflow processing requires
single character processing anyway.

Other interfaces like Ethernet are optimized for speed and always
transfer blocks, never checking single characters. Thus, there is no
good place available to insert single characters without significantly
reducing the transfer rate.

So far I solved this by a hack, using a flag. All linefeeds are
transmitted by a specific function, which decides by the flag, if an
additional carriage return is required. For a menu system this is no big
problem, because it is mainly based on a data structure containing the
dialogs and a few specific routines handling the user interface. In most
other cases this is a bad solution.

Another solution may be based on the Telnet protocol. In fact, Nut/OS
doesn't provide a real Telnet protocol. It's just a raw TCP connection.
A full Telnet implementation allows to transfer optional settings when
the session is started.

For a quick solution, you may check your client capabilities. Not sure
about Putty, but the command line Telnet typically allows to set a
specific option for EOL-translation.



More information about the En-Nut-Discussion mailing list