Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2022-05-30 22:21:26 +0300
committerDavid Crocker <dcrocker@eschertech.com>2022-05-30 22:21:26 +0300
commitb8beb854852ac85cec7232880a351186c31d6cb5 (patch)
tree39e915b57f9874d1eeb059e526c204a01b810ed0
parent600122a46408daf81efdb8e1ac2e3c6d60ab97aa (diff)
Fix for bug with M581 and array parameters
-rw-r--r--src/GCodes/GCodeBuffer/ExpressionParser.cpp4
-rw-r--r--src/GCodes/GCodes3.cpp4
-rw-r--r--src/GCodes/TriggerItem.cpp37
3 files changed, 23 insertions, 22 deletions
diff --git a/src/GCodes/GCodeBuffer/ExpressionParser.cpp b/src/GCodes/GCodeBuffer/ExpressionParser.cpp
index 09315121..ce5e2fc5 100644
--- a/src/GCodes/GCodeBuffer/ExpressionParser.cpp
+++ b/src/GCodes/GCodeBuffer/ExpressionParser.cpp
@@ -555,7 +555,7 @@ float ExpressionParser::ParseFloat() THROWS(GCodeException)
int32_t ExpressionParser::ParseInteger() THROWS(GCodeException)
{
- ExpressionValue val = Parse();
+ const ExpressionValue val = Parse();
switch (val.GetType())
{
case TypeCode::Int32:
@@ -575,7 +575,7 @@ int32_t ExpressionParser::ParseInteger() THROWS(GCodeException)
uint32_t ExpressionParser::ParseUnsigned() THROWS(GCodeException)
{
- ExpressionValue val = Parse();
+ const ExpressionValue val = Parse();
switch (val.GetType())
{
case TypeCode::Uint32:
diff --git a/src/GCodes/GCodes3.cpp b/src/GCodes/GCodes3.cpp
index 1f09dad2..d971bfe5 100644
--- a/src/GCodes/GCodes3.cpp
+++ b/src/GCodes/GCodes3.cpp
@@ -1159,7 +1159,7 @@ GCodeResult GCodes::UpdateFirmware(GCodeBuffer& gb, const StringRef &reply)
reprap.GetHeat().SwitchOffAll(true); // turn all heaters off because the main loop may get suspended
DisableDrives(); // all motors off
- if (firmwareUpdateModuleMap.IsEmpty()) // have we worked out which modules to update?
+ if (firmwareUpdateModuleMap.IsEmpty()) // have we worked out which modules to update?
{
// Find out which modules we have been asked to update
if (gb.Seen('S'))
@@ -1182,7 +1182,7 @@ GCodeResult GCodes::UpdateFirmware(GCodeBuffer& gb, const StringRef &reply)
}
else
{
- firmwareUpdateModuleMap.SetBit(0); // no modules specified, so update module 0 to match old behaviour
+ firmwareUpdateModuleMap.SetBit(0); // no modules specified, so update module 0 to match old behaviour
}
if (firmwareUpdateModuleMap.IsEmpty())
diff --git a/src/GCodes/TriggerItem.cpp b/src/GCodes/TriggerItem.cpp
index b1282613..7fc665df 100644
--- a/src/GCodes/TriggerItem.cpp
+++ b/src/GCodes/TriggerItem.cpp
@@ -122,28 +122,29 @@ GCodeResult TriggerItem::Configure(unsigned int number, GCodeBuffer &gb, const S
const int sParam = (gb.Seen('S')) ? gb.GetIValue() : 1;
if (gb.Seen('P'))
{
- if (gb.GetIValue() == -1)
+ // We need a try..catch block here so that if we pass an array we do not abort when trying to read a single value
+ try
{
- Init(); // P-1 clears all inputs and sets condition to 0
- return GCodeResult::ok;
+ if (gb.GetIValue() == -1)
+ {
+ Init(); // P-1 clears all inputs and sets condition to 0
+ return GCodeResult::ok;
+ }
+ } catch (const GCodeException&) { }
+ gb.Seen('P');
+ seen = true;
+ uint32_t inputNumbers[MaxGpInPorts];
+ size_t numValues = MaxGpInPorts;
+ gb.GetUnsignedArray(inputNumbers, numValues, false);
+ const InputPortsBitmap portsToWaitFor = InputPortsBitmap::MakeFromArray(inputNumbers, numValues);
+ if (sParam < 0)
+ {
+ highLevelInputs &= ~portsToWaitFor;
+ lowLevelInputs &= ~portsToWaitFor;
}
else
{
- seen = true;
- gb.Seen('P');
- uint32_t inputNumbers[MaxGpInPorts];
- size_t numValues = MaxGpInPorts;
- gb.GetUnsignedArray(inputNumbers, numValues, false);
- const InputPortsBitmap portsToWaitFor = InputPortsBitmap::MakeFromArray(inputNumbers, numValues);
- if (sParam < 0)
- {
- highLevelInputs &= ~portsToWaitFor;
- lowLevelInputs &= ~portsToWaitFor;
- }
- else
- {
- ((sParam >= 1) ? highLevelInputs : lowLevelInputs) |= portsToWaitFor;
- }
+ ((sParam >= 1) ? highLevelInputs : lowLevelInputs) |= portsToWaitFor;
}
}