Make rubout packet in output function optional

This commit is contained in:
Dominic Höglinger 2025-05-15 20:08:37 +02:00
parent bf27293543
commit 0e068e764d
3 changed files with 10 additions and 6 deletions

View File

@ -59,9 +59,9 @@ void loop()
else sawtooth = 0;
set_u32trace("Main.Sawtooth", sawtooth, false);
if (sawtooth == 4711) Serial.write("I can still be used with regular text.");
if (sawtooth == 4711) Serial.println("I can still be used with regular text.");
set_output(0, true); //send unlimited traces compressed
set_output(0, true, true); //send unlimited traces, compressed and clear console
set_diagtrace(); // add diagnostic traces
}
````

5
set.c
View File

@ -153,7 +153,7 @@ size_t set_tty_rubout(char buffer[], const size_t buffer_size)
return buffer_pos;
}
size_t set_output(size_t n, const bool compress)
size_t set_output(size_t n, const bool compress, const bool rubout)
{
const size_t render_number_items = 4;
const size_t render_max_size = SET_MAX_RENDER_SIZE(render_number_items);
@ -170,8 +170,11 @@ size_t set_output(size_t n, const bool compress)
set_out(packet_bytes, packet_size);
}
if (rubout)
{
packet_size = set_tty_rubout(packet_bytes, render_max_size);
set_out(packet_bytes, packet_size);
}
return i;
}

3
set.h
View File

@ -126,9 +126,10 @@ void set_clear(void);
* This function is for basic usage where the output function writes into a managed stream such as stdout
* @param[in] n Number of tracebuffer items to render, or 0 for the current size of the tracebuffer
* @param[in] compress if true, render the packets compressed
* @param[in] rubout if true, sends a rubout packet at the end clearing the trace output on a terminal
* @return None
*/
size_t set_output(size_t n, const bool compress);
size_t set_output(size_t n, const bool compress, const bool rubout);
/** @brief Render a set amount of tracebuffer items and store them in the provided buffer
* This advanced function is intended to be used with DMA buffers.