reusable
reusable copied to clipboard
Console: a full buffer without an ENDLINE breaks the console
In ConsoleProcess, if the buffer is completely full, the call to ConsoleIoReceive will return 0 and no command parsing/processing will be done, and the buffer will remain full. https://github.com/eleciawhite/reusable/blob/22fe5a390a181338b0e21dac6c8d35101d78880d/source/console.c#L139
This can happen if you enter a single line longer than the buffer size (256).
The fix could take several routes with different implications.
The special "buffer full without an ENDLINE" condition could be detected and take of these actions:
- Remove the oldest character e.g. with
ConsoleResetBuffer(mReceiveBuffer, mReceivedSoFar, 1)
- Clear the whole buffer e.g. with
ConsoleResetBuffer(mReceiveBuffer, mReceivedSoFar, mReceivedSoFar)
- Assume that characters on this line received now and in the future are in a state that is not recoverable, and enter a line purge mode. Emit an error message, then the buffer would be cleared continuously without command processing until an ENDLINE appeared and started a new line, and line purge mode would end and normal processing would continue.