diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-09-14 18:15:38 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-09-14 18:15:38 +0300 |
commit | bb4cf0755b1befd343d600ce2b0aca0c0869ea78 (patch) | |
tree | 0586d55ec06bf6a282c4fdfbef72faaaa244de18 /src/GCodes/GCodeBuffer/StringParser.cpp | |
parent | 3f5cf3a015fc3d681a37234fd4360e3fd20b3f0f (diff) |
Correction to previous fix
Diffstat (limited to 'src/GCodes/GCodeBuffer/StringParser.cpp')
-rw-r--r-- | src/GCodes/GCodeBuffer/StringParser.cpp | 36 |
1 files changed, 17 insertions, 19 deletions
diff --git a/src/GCodes/GCodeBuffer/StringParser.cpp b/src/GCodes/GCodeBuffer/StringParser.cpp index d87be4be..9205e453 100644 --- a/src/GCodes/GCodeBuffer/StringParser.cpp +++ b/src/GCodes/GCodeBuffer/StringParser.cpp @@ -294,44 +294,42 @@ bool StringParser::LineFinished() noexcept gb.buffer[gcodeLineEnd] = 0; - if (gb.bufferState != GCodeBufferState::parsingComment) // we don't checksum comment lines + if (gb.bufferState != GCodeBufferState::parsingComment) // we don't checksum or echo comment lines, but we still need to process them { + bool badChecksum, missingChecksum; if (hadChecksum) { - bool checksumOk; + missingChecksum = false; switch (checksumCharsReceived) { case 1: case 2: case 3: - checksumOk = (computedChecksum == declaredChecksum); + badChecksum = (computedChecksum != declaredChecksum); break; case 5: - checksumOk = (crc16.Get() == declaredChecksum); + badChecksum = (crc16.Get() != declaredChecksum); break; default: - checksumOk = false; + badChecksum = true; break; } + } + else + { + badChecksum = false; + missingChecksum = (checksumRequired && gb.LatestMachineState().GetPrevious() == nullptr); + } - if (!checksumOk) - { - if (reprap.GetDebugFlags(moduleGcodes).IsBitSet(gb.GetChannel().ToBaseType()) && fileBeingWritten == nullptr) - { - debugPrintf("%s bad-csum: %s\n", gb.GetChannel().ToString(), gb.buffer); - } - Init(); - return false; - } + if (reprap.GetDebugFlags(moduleGcodes).IsBitSet(gb.GetChannel().ToBaseType()) && fileBeingWritten == nullptr) + { + debugPrintf("%s%s: %s\n", gb.GetChannel().ToString(), ((badChecksum) ? "(bad-csum)" : (missingChecksum) ? "(no-csum)" : ""), gb.buffer); } - else if (checksumRequired && gb.LatestMachineState().GetPrevious() == nullptr) + + if (badChecksum || missingChecksum) { - if (reprap.GetDebugFlags(moduleGcodes).IsBitSet(gb.GetChannel().ToBaseType()) && fileBeingWritten == nullptr) - { - debugPrintf("%s no-csum: %s\n", gb.GetChannel().ToString(), gb.buffer); - } Init(); return false; } |