VE.Direct: do not use debug buffer at all if verbose logging disabled (#437)
this avoids the debug buffer being overrun if verbose logging is disabled in particular. that would happen because the buffer would only be reset if verbose logging was enabled but filled in any case.
This commit is contained in:
parent
2eeb5f1d19
commit
88a5117007
@ -78,6 +78,7 @@ VeDirectFrameHandler::VeDirectFrameHandler() :
|
|||||||
void VeDirectFrameHandler::setVerboseLogging(bool verboseLogging)
|
void VeDirectFrameHandler::setVerboseLogging(bool verboseLogging)
|
||||||
{
|
{
|
||||||
_verboseLogging = verboseLogging;
|
_verboseLogging = verboseLogging;
|
||||||
|
if (!_verboseLogging) { _debugIn = 0; }
|
||||||
}
|
}
|
||||||
|
|
||||||
void VeDirectFrameHandler::init(int8_t rx, int8_t tx, Print* msgOut, bool verboseLogging)
|
void VeDirectFrameHandler::init(int8_t rx, int8_t tx, Print* msgOut, bool verboseLogging)
|
||||||
@ -126,11 +127,13 @@ void VeDirectFrameHandler::loop()
|
|||||||
*/
|
*/
|
||||||
void VeDirectFrameHandler::rxData(uint8_t inbyte)
|
void VeDirectFrameHandler::rxData(uint8_t inbyte)
|
||||||
{
|
{
|
||||||
|
if (_verboseLogging) {
|
||||||
_debugBuffer[_debugIn] = inbyte;
|
_debugBuffer[_debugIn] = inbyte;
|
||||||
_debugIn = (_debugIn + 1) % _debugBuffer.size();
|
_debugIn = (_debugIn + 1) % _debugBuffer.size();
|
||||||
if (0 == _debugIn) {
|
if (0 == _debugIn) {
|
||||||
_msgOut->println("[VE.Direct] ERROR: debug buffer overrun!");
|
_msgOut->println("[VE.Direct] ERROR: debug buffer overrun!");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( (inbyte == ':') && (_state != CHECKSUM) ) {
|
if ( (inbyte == ':') && (_state != CHECKSUM) ) {
|
||||||
_prevState = _state; //hex frame can interrupt TEXT
|
_prevState = _state; //hex frame can interrupt TEXT
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user