ramlog: Add overwrite option to ramlog
Enable overwrite of circular buffer. If RAMLOG buffer overflows, overwrite it from the top of buffer and always keep the latest log.
This commit is contained in:
parent
e249a2f82f
commit
27835c8c0a
|
@ -59,6 +59,13 @@ config RAMLOG_NPOLLWAITERS
|
|||
---help---
|
||||
The maximum number of threads that may be waiting on the poll method.
|
||||
|
||||
config RAMLOG_OVERWRITE
|
||||
bool "RAMLOG overwrite circular buffer"
|
||||
default n
|
||||
---help---
|
||||
Enable overwrite of circular buffer. If RAMLOG buffer overflows,
|
||||
overwrite it from the top of buffer and always keep the latest log.
|
||||
|
||||
endif
|
||||
|
||||
config DRIVER_NOTE
|
||||
|
|
|
@ -227,10 +227,20 @@ static ssize_t ramlog_addchar(FAR struct ramlog_dev_s *priv, char ch)
|
|||
|
||||
if (nexthead == priv->rl_tail)
|
||||
{
|
||||
#ifdef CONFIG_RAMLOG_OVERWRITE
|
||||
/* Yes... Overwrite with the latest log in the circular buffer */
|
||||
|
||||
priv->rl_tail += 1;
|
||||
if (priv->rl_tail >= priv->rl_bufsize)
|
||||
{
|
||||
priv->rl_tail = 0;
|
||||
}
|
||||
#else
|
||||
/* Yes... Return an indication that nothing was saved in the buffer. */
|
||||
|
||||
leave_critical_section(flags);
|
||||
return -EBUSY;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* No... copy the byte and re-enable interrupts */
|
||||
|
|
Loading…
Reference in New Issue