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>2021-03-10 16:21:38 +0300
committerDavid Crocker <dcrocker@eschertech.com>2021-03-10 16:21:38 +0300
commita49bbb4575b535207121bbcdde98ebf4c3531cd7 (patch)
tree58f2838cf2095c9af260041057ea418e42e31790
parente4802d867632ae26f702b5e3f9ab27c97ce175a2 (diff)
parentb762535a3ce77c6fb7dd23d845b8231c9632d272 (diff)
Merge remote-tracking branch 'origin/wil-extend-m111' into 3.3-dev3.3beta2
-rw-r--r--src/GCodes/GCodeBuffer/BinaryParser.cpp2
-rw-r--r--src/GCodes/GCodeBuffer/StringParser.cpp2
-rw-r--r--src/GCodes/GCodes2.cpp55
-rw-r--r--src/Platform/RepRap.cpp25
-rw-r--r--src/Platform/RepRap.h10
5 files changed, 58 insertions, 36 deletions
diff --git a/src/GCodes/GCodeBuffer/BinaryParser.cpp b/src/GCodes/GCodeBuffer/BinaryParser.cpp
index 842381f9..47f696ad 100644
--- a/src/GCodes/GCodeBuffer/BinaryParser.cpp
+++ b/src/GCodes/GCodeBuffer/BinaryParser.cpp
@@ -43,7 +43,7 @@ void BinaryParser::DecodeCommand() noexcept
{
if (gb.bufferState == GCodeBufferState::parsingGCode)
{
- if (reprap.Debug(moduleGcodes))
+ if (reprap.GetDebugFlags(moduleGcodes).IsBitSet(gb.GetChannel().ToBaseType()))
{
String<MaxCodeBufferSize> buf;
AppendFullCommand(buf.GetRef());
diff --git a/src/GCodes/GCodeBuffer/StringParser.cpp b/src/GCodes/GCodeBuffer/StringParser.cpp
index 643a58a9..dad4f3e6 100644
--- a/src/GCodes/GCodeBuffer/StringParser.cpp
+++ b/src/GCodes/GCodeBuffer/StringParser.cpp
@@ -290,7 +290,7 @@ bool StringParser::LineFinished()
{
const bool badChecksum = (hadChecksum && computedChecksum != declaredChecksum);
const bool missingChecksum = (checksumRequired && !hadChecksum && gb.LatestMachineState().GetPrevious() == nullptr);
- if (reprap.Debug(moduleGcodes) && fileBeingWritten == nullptr)
+ 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);
}
diff --git a/src/GCodes/GCodes2.cpp b/src/GCodes/GCodes2.cpp
index 49535836..46889909 100644
--- a/src/GCodes/GCodes2.cpp
+++ b/src/GCodes/GCodes2.cpp
@@ -1583,32 +1583,55 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx
break;
case 111: // Debug level
- if (gb.Seen('S'))
{
- const bool dbv = (gb.GetIValue() != 0);
+ bool seen = false;
+ uint32_t flags = 0;
+ Module module = Module::noModule;
+ if (gb.Seen('S'))
+ {
+ flags = gb.GetUIValue();
+ if (flags != 0)
+ {
+ flags = 0xFFFFFFFF;
+ }
+ seen = true;
+ }
+ else if (gb.Seen('D'))
+ {
+ flags = gb.GetUIValue();
+ seen = true;
+ }
if (gb.Seen('P'))
{
- reprap.SetDebug(static_cast<Module>(gb.GetIValue()), dbv);
- reprap.PrintDebug(gb.GetResponseMessageType());
- return true;
+ module = static_cast<Module>(gb.GetLimitedUIValue('P', Module::numModules));
+ seen = true;
}
- if (dbv)
+ if (seen)
{
- // Repetier Host sends M111 with various S parameters to enable echo and similar features, which used to turn on all out debugging.
- // But it's not useful to enable all debugging anyway. So we no longer allow debugging to be enabled without a P parameter.
- reply.copy("Use P parameter to specify which module to debug");
+ if (module != Module::noModule)
+ {
+ reprap.SetDebug(module, flags);
+ reprap.PrintDebug(gb.GetResponseMessageType());
+ return true;
+ }
+ else if (flags != 0)
+ {
+ // Repetier Host sends M111 with various S parameters to enable echo and similar features, which used to turn on all out debugging.
+ // But it's not useful to enable all debugging anyway. So we no longer allow debugging to be enabled without a P parameter.
+ reply.copy("Use P parameter to specify which module to debug");
+ }
+ else
+ {
+ // M111 S0 still clears all debugging
+ reprap.ClearDebug();
+ }
}
else
{
- // M111 S0 still clears all debugging
- reprap.ClearDebug();
+ reprap.PrintDebug(gb.GetResponseMessageType());
+ return true;
}
}
- else
- {
- reprap.PrintDebug(gb.GetResponseMessageType());
- return true;
- }
break;
case 112: // Emergency stop - acted upon in Webserver, but also here in case it comes from USB etc.
diff --git a/src/Platform/RepRap.cpp b/src/Platform/RepRap.cpp
index 007b2c3c..23a630ff 100644
--- a/src/Platform/RepRap.cpp
+++ b/src/Platform/RepRap.cpp
@@ -410,7 +410,7 @@ RepRap::RepRap() noexcept
networkSeq(0), scannerSeq(0), sensorsSeq(0), spindlesSeq(0), stateSeq(0), toolsSeq(0), volumesSeq(0),
toolList(nullptr), currentTool(nullptr), lastWarningMillis(0),
activeExtruders(0), activeToolHeaters(0), numToolsToReport(0),
- ticksInSpinState(0), heatTaskIdleTicks(0), debug(0),
+ ticksInSpinState(0), heatTaskIdleTicks(0),
beepFrequency(0), beepDuration(0), beepTimer(0),
previousToolNumber(-1),
diagnosticsDestination(MessageType::NoDestinationMessage), justSentDiagnostics(false),
@@ -420,6 +420,7 @@ RepRap::RepRap() noexcept
// because a disconnected SBC interface can generate noise which may trigger interrupts and DMA
#endif
{
+ ClearDebug();
// Don't call constructors for other objects here
}
@@ -927,24 +928,20 @@ void RepRap::EmergencyStop() noexcept
platform->StopLogging();
}
-void RepRap::SetDebug(Module m, bool enable) noexcept
+void RepRap::SetDebug(Module m, uint32_t flags) noexcept
{
if (m < numModules)
{
- if (enable)
- {
- debug |= (1u << m);
- }
- else
- {
- debug &= ~(1u << m);
- }
+ debugMaps[m].SetFromRaw(flags);
}
}
void RepRap::ClearDebug() noexcept
{
- debug = 0;
+ for (DebugFlags& dm : debugMaps)
+ {
+ dm.Clear();
+ }
}
void RepRap::PrintDebug(MessageType mt) noexcept
@@ -952,16 +949,16 @@ void RepRap::PrintDebug(MessageType mt) noexcept
platform->Message((MessageType)(mt | PushFlag), "Debugging enabled for modules:");
for (size_t i = 0; i < numModules; i++)
{
- if ((debug & (1u << i)) != 0)
+ if (debugMaps[i].IsNonEmpty())
{
- platform->MessageF((MessageType)(mt | PushFlag), " %s(%u)", GetModuleName(i), i);
+ platform->MessageF((MessageType)(mt | PushFlag), " %s(%u - %#" PRIx32 ")", GetModuleName(i), i, debugMaps[i].GetRaw());
}
}
platform->Message((MessageType)(mt | PushFlag), "\nDebugging disabled for modules:");
for (size_t i = 0; i < numModules; i++)
{
- if ((debug & (1u << i)) == 0)
+ if (debugMaps[i].IsEmpty())
{
platform->MessageF((MessageType)(mt | PushFlag), " %s(%u)", GetModuleName(i), i);
}
diff --git a/src/Platform/RepRap.h b/src/Platform/RepRap.h
index 9e07bf3a..766c1855 100644
--- a/src/Platform/RepRap.h
+++ b/src/Platform/RepRap.h
@@ -54,6 +54,8 @@ struct MessageBox
MessageBox() noexcept : active(false), seq(0) { }
};
+typedef Bitmap<uint32_t> DebugFlags;
+
class RepRap INHERIT_OBJECT_MODEL
{
public:
@@ -68,8 +70,9 @@ public:
void DeferredDiagnostics(MessageType mtype) noexcept { diagnosticsDestination = mtype; }
void Timing(MessageType mtype) noexcept;
- bool Debug(Module module) const noexcept;
- void SetDebug(Module m, bool enable) noexcept;
+ bool Debug(Module module) const noexcept { return debugMaps[module].IsNonEmpty(); }
+ DebugFlags GetDebugFlags(Module m) const noexcept { return debugMaps[m]; }
+ void SetDebug(Module m, uint32_t flags) noexcept;
void ClearDebug() noexcept;
void PrintDebug(MessageType mt) noexcept;
Module GetSpinningModule() const noexcept;
@@ -273,7 +276,7 @@ private:
uint16_t heatTaskIdleTicks;
uint32_t fastLoop, slowLoop;
- uint32_t debug;
+ DebugFlags debugMaps[Module::numModules];
String<RepRapPasswordLength> password;
String<MachineNameLength> myName;
@@ -306,7 +309,6 @@ private:
// A single instance of the RepRap class contains all the others
extern RepRap reprap;
-inline bool RepRap::Debug(Module m) const noexcept { return debug & (1u << m); }
inline Module RepRap::GetSpinningModule() const noexcept { return spinningModule; }
inline Tool* RepRap::GetCurrentTool() const noexcept { return currentTool; }