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)
|
||||||
@ -120,16 +121,18 @@ void VeDirectFrameHandler::loop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* rxData
|
* rxData
|
||||||
* This function is called by loop() which passes a byte of serial data
|
* This function is called by loop() which passes a byte of serial data
|
||||||
* Based on Victron's example code. But using String and Map instead of pointer and arrays
|
* Based on Victron's example code. But using String and Map instead of pointer and arrays
|
||||||
*/
|
*/
|
||||||
void VeDirectFrameHandler::rxData(uint8_t inbyte)
|
void VeDirectFrameHandler::rxData(uint8_t inbyte)
|
||||||
{
|
{
|
||||||
_debugBuffer[_debugIn] = inbyte;
|
if (_verboseLogging) {
|
||||||
_debugIn = (_debugIn + 1) % _debugBuffer.size();
|
_debugBuffer[_debugIn] = inbyte;
|
||||||
if (0 == _debugIn) {
|
_debugIn = (_debugIn + 1) % _debugBuffer.size();
|
||||||
_msgOut->println("[VE.Direct] ERROR: debug buffer overrun!");
|
if (0 == _debugIn) {
|
||||||
|
_msgOut->println("[VE.Direct] ERROR: debug buffer overrun!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( (inbyte == ':') && (_state != CHECKSUM) ) {
|
if ( (inbyte == ':') && (_state != CHECKSUM) ) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user