1

I'm building an embedded system that talks RS-232 to a serial terminal, "full-duplex" style, so the host echos what the terminal sends.

I know printables (at least ASCII 0x20 to 0x7E) are normally echoed, but which control characters (if any) are normally echoed in a case like this?

Is there some Posix or other standard for this? How does Linux do it?

For example, if I type a ^C at the terminal, should the ^C be echoed by the host? What about ^G (bell)? Etc?

Thomas Dickey
  • 51,086
  • 7
  • 70
  • 105
nerdfever.com
  • 1,652
  • 1
  • 20
  • 41
  • 1
    You've conflated echoplex and full-duplex. – JdeBP Dec 29 '15 at 20:25
  • @JdeBP Yes, I know, but more people are familiar with calling it "full duplex". I did put it in "quote marks". – nerdfever.com Dec 29 '15 at 23:56
  • 1
    The question leaves out the intended use, e.g., whether the embedded system is monolithic or whether you're planning to provide a shell which could run programs interactively. There are lots of possible answers for the question as it is currently given. – Thomas Dickey Dec 30 '15 at 00:50
  • @ThomasDickey I know there are lots of possible answers - that's why I'm asking how it's usually done. It's not a Unix; it's a rather simple embedded system that can be controlled by a terminal. I just want to know if there are formal or informal standards re echoing control characters. (Beyond the obvious - CR is echoed as CR LF, backspace as "/b /b" to erase last character...) – nerdfever.com Dec 30 '15 at 04:12

1 Answers1

-1

I'll try to answer my own question. Here's what I'm planning to do:

  • Printables (ASCII 0x20 to 0x7E) are echoed.
  • CR is echoed as CR LF (because the Enter key on terminals normally sends CR, and an ANSI terminal requires CR to move the cursor to the left, and LF to move it to the next line).
  • BS (backspace, 0x08) and DEL (0x7F) are treated identically and are echoed as "\b \b" (in C syntax) - that is, backspace, space, backspace, to erase the last character on the terminal.

All other control characters are not echoed. (Not to say they're not processed, but they're not automatically echoed. What they do is outside the scope of what I'm asking about.)

My reasoning is that the remaining control characters are usually meant to do something, and that something is meant to happen at the host, not at the terminal.

For example DC1/DC3 (^Q/^S) are often used as flow control ("XON/XOFF") - it doesn't make sense to echo the ^S (XOFF) back to the terminal, since the purpose is to flow control the host. Echoing XOFF back to the terminal would flow control the terminal, clearly not what was intended. So echoing this makes no sense.

Similarly, ANSI escape sequences sent by the terminal (cursor up/down/left/right, etc.) should not be echoed.

Bottom line - echo printables only. Control characters as a rule should not be echoed, except on a case-by-case basis depending on their function (carriage return, backspace, etc.).

I'd like comments on whether or not this is the right thing to do (and why).

nerdfever.com
  • 1,652
  • 1
  • 20
  • 41