diff options
author | David Crocker <dcrocker@eschertech.com> | 2022-09-28 14:20:44 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2022-09-28 14:20:44 +0300 |
commit | c4e578875eb3e64a99f076993468ee26c1578188 (patch) | |
tree | 327921c43ff81ab87ad41ac1ec5b86c6e1615057 | |
parent | bfbc06255f316df1d83d9c767cbdd48cb160b438 (diff) |
Handle M292 result expression
-rw-r--r-- | src/GCodes/GCodeBuffer/ExpressionParser.cpp | 10 | ||||
-rw-r--r-- | src/GCodes/GCodeBuffer/GCodeBuffer.cpp | 6 | ||||
-rw-r--r-- | src/GCodes/GCodeBuffer/GCodeBuffer.h | 3 | ||||
-rw-r--r-- | src/GCodes/GCodeMachineState.h | 1 |
4 files changed, 17 insertions, 3 deletions
diff --git a/src/GCodes/GCodeBuffer/ExpressionParser.cpp b/src/GCodes/GCodeBuffer/ExpressionParser.cpp index 32ae040f..fdc112dd 100644 --- a/src/GCodes/GCodeBuffer/ExpressionParser.cpp +++ b/src/GCodes/GCodeBuffer/ExpressionParser.cpp @@ -32,7 +32,7 @@ namespace StackUsage } // These can't be declared locally inside ParseIdentifierExpression because NamedEnum includes static data -NamedEnum(NamedConstant, unsigned int, _false, iterations, line, _null, pi, _result, _true); +NamedEnum(NamedConstant, unsigned int, _false, iterations, line, _null, pi, _result, _true, input); NamedEnum(Function, unsigned int, abs, acos, asin, atan, atan2, cos, datetime, degrees, exists, floor, isnan, max, min, mod, radians, random, sin, sqrt, tan); const char * const InvalidExistsMessage = "invalid 'exists' expression"; @@ -1134,6 +1134,10 @@ void ExpressionParser::ParseIdentifierExpression(ExpressionValue& rslt, bool eva res = 1; break; + case GCodeResult::m291Cancelled: + res = -1; + break; + default: res = 2; break; @@ -1146,6 +1150,10 @@ void ExpressionParser::ParseIdentifierExpression(ExpressionValue& rslt, bool eva rslt.SetInt((int32_t)gb.GetLineNumber()); return; + case NamedConstant::input: + rslt = gb.GetM291Result(); + return; + default: THROW_INTERNAL_ERROR; } diff --git a/src/GCodes/GCodeBuffer/GCodeBuffer.cpp b/src/GCodes/GCodeBuffer/GCodeBuffer.cpp index cd5dd5ed..91a7369c 100644 --- a/src/GCodes/GCodeBuffer/GCodeBuffer.cpp +++ b/src/GCodes/GCodeBuffer/GCodeBuffer.cpp @@ -1122,7 +1122,11 @@ void GCodeBuffer::MessageAcknowledged(bool cancelled, ExpressionValue rslt) noex ms->waitingForAcknowledgement = false; ms->messageAcknowledged = true; ms->messageCancelled = cancelled; - ms->m291Result = rslt; + m291Result = rslt; + if (cancelled) + { + lastResult = GCodeResult::m291Cancelled; + } #if HAS_SBC_INTERFACE messageAcknowledged = !cancelled || !ms->DoingFile(); reprap.GetSbcInterface().EventOccurred(); diff --git a/src/GCodes/GCodeBuffer/GCodeBuffer.h b/src/GCodes/GCodeBuffer/GCodeBuffer.h index 22fb6774..4fc40cbc 100644 --- a/src/GCodes/GCodeBuffer/GCodeBuffer.h +++ b/src/GCodes/GCodeBuffer/GCodeBuffer.h @@ -71,6 +71,7 @@ public: bool IsLastCommand() const noexcept; GCodeResult GetLastResult() const noexcept { return lastResult; } void SetLastResult(GCodeResult r) noexcept { lastResult = r; } + ExpressionValue GetM291Result() const noexcept { return m291Result; } bool Seen(char c) noexcept SPEED_CRITICAL; // Is a character present? void MustSee(char c) THROWS(GCodeException); // Test for character present, throw error if not @@ -327,6 +328,7 @@ private: StringParser stringParser; GCodeMachineState *machineState; // Machine state for this gcode source + ExpressionValue m291Result; // the value entered or choice selected in response to a M291 command uint32_t whenTimerStarted; // When we started waiting uint32_t whenReportDueTimerStarted; // When the report-due-timer has been started @@ -335,6 +337,7 @@ private: const GCodeChannel codeChannel; // Channel number of this instance GCodeBufferState bufferState; // Idle, executing or paused GCodeResult lastResult; + bool timerRunning; // true if we are waiting bool motionCommanded; // true if this GCode stream has commanded motion since it last waited for motion to stop diff --git a/src/GCodes/GCodeMachineState.h b/src/GCodes/GCodeMachineState.h index 77a8617d..0f85869a 100644 --- a/src/GCodes/GCodeMachineState.h +++ b/src/GCodes/GCodeMachineState.h @@ -239,7 +239,6 @@ public: #endif ; - ExpressionValue m291Result; // the value entered or choice selected in response to a M291 command uint16_t stateParameter; // a parameter, the meaning of which depends on what state we are in Compatibility compatibility; // which firmware we are emulating |