Search code examples
ubuntuterminaluart

How to clear screen of minicom terminal using serial UART


I want to clear minicom terminal screen from UART connected to PC /dev/ttyUSB0. I know how to do it in PC by using shortcut Ctrl + A then Z and select C or Ctrl + A then C. Now I wanted to do the same by using UART. How to do this?


Solution

  • Now I wanted to do the same by using UART.

    The UART is employed to simply transfer data. The UART has no access nor can it clear or control a minicom terminal screen/window.
    Perhaps you are asking how the remote side of the serial connection can clear the screen, e.g. by sending a command sequence?

    That answer would depend on which terminal emulation (e.g. ANSI or VT102) is configured for the minicom terminal, and if that terminal definition has a erase screen command string (aka escape sequence).
    Turns out that the erase screen escape sequence is the same for both ANSI and VT102 terminals.

    Esc[2J  Erase Display:
            Clears the screen and moves the cursor to the home position (line 0, column 0). 
    

    When the minicom terminal receives (from the remote side or when local echo is enabled) the 4-byte character sequence of Esc[2J, this escape sequence is intercepted, not displayed, and then the terminal window will be cleared.

    The four characters are:

     Esc     the ASCII Escape character, value 0x1B.  
     [       the ASCII left square brace character, value 0x5B.  
     2       the ASCII character for numeral 2, value 0x32.  
     J       the ASCII character for the letter J, value 0x4A.  
    

    References
    ANSI Escape sequences
    ANSI/VT100 Terminal Control Escape Sequences.