Please add a new command Serial.clear()

Hi,
Serial monitor has a 'Clear output' button.
And why is there no such command from Arduino?
For example: Serial.Clear();
(command: 'FF' code: 0C = 'form feed')
This will allow you to observe a static inscription
in several lines, as on the display without shifting them.
Now you can output only one line by disabling NL&CR,
but what if you need 10 lines?

Best regards.

Which the user can press when useful.

See Processing or some other GUI program for establishing any application specific interface.

Serial.print() (that is, the default UART serial output) is often used to communicate with other devices, and a Serial.clear() command would make no sense for most of those.

I want Arduino to do this (clear the buffer).

And that is not possible with UART, a low-level protocol intended for sending arbitrary data.

Serial.flush() clears the buffer

Which is not even remotely what OP asked for.

OP wants to be able to clear the serial monitor via a Serial.clear() command on the Arduino. They are very clear on that in their original post and if you do not understand that, it is your problem.

It is very inconvenient to track information when it is constantly creeping up
and you have to enable disable Autoscroll.

Waits for the transmission of outgoing serial data to complete.

Use a terminal program instead of the serial monitor, and log the data to a file. That way you can review the data at any time, and any way you like.

You don't have to enable it again to see more; you can simply scroll with e.g. the scroll-bar. There is a buffer that limits how much the Serial Monitor can display, it will start scrolling again once the buffer is full.
Note that there was a time that there wasn't even an option to disable scrolling.

If you use a different terminal program, you can make use of ansi escape codes - Google Search.

It would be nice if Serial Monitor was a full fletched terminal program but it isn't. The only advantage of Serial Monitor is that it can be controlled by the IDE so the COM port that it uses can be closed by the IDE before an upload.

Your topic has been moved to a more suitable location on the forum.

1 Like

So a sketch using Serial.Clear(); would only run on updated Arduino installs ?

And to keep programs 'universal' the change would be needed across all current platforms ?

Sounds fun.

Required is a terminal program that reacts on commands sent by Serial. If that program recognizes a CLEAR character then every Arduino can send that character.

The following codes will clear the Serial buffer for you. Incorporating the clear() method would risk the deleting the whole message (which could not be recovered) by accident?

while(Serial.available() != 0)
{
      (void)Serial.read();
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.