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-12-13 17:39:58 +0300
committerDavid Crocker <dcrocker@eschertech.com>2021-12-13 17:39:58 +0300
commit2133c443728f7ed9a1764697551f1d5ff4a42a42 (patch)
tree18b0b422409b7a925a2e78bf62fc9bb22add84bf
parentbed0c8f161569415e4d5ceac4fe8ed7dcc6c5290 (diff)
Added support for M957
-rw-r--r--src/FilamentMonitors/FilamentMonitor.cpp4
-rw-r--r--src/GCodes/GCodes.h1
-rw-r--r--src/GCodes/GCodes2.cpp8
-rw-r--r--src/GCodes/GCodes3.cpp33
-rw-r--r--src/Heating/LocalHeater.cpp3
-rw-r--r--src/Platform/Event.cpp12
-rw-r--r--src/Platform/Event.h5
-rw-r--r--src/Platform/Platform.cpp2
-rw-r--r--src/Version.h2
9 files changed, 58 insertions, 12 deletions
diff --git a/src/FilamentMonitors/FilamentMonitor.cpp b/src/FilamentMonitors/FilamentMonitor.cpp
index 9cf6b686..9c2d15e2 100644
--- a/src/FilamentMonitors/FilamentMonitor.cpp
+++ b/src/FilamentMonitors/FilamentMonitor.cpp
@@ -335,9 +335,7 @@ bool FilamentMonitor::IsValid(size_t extruderNumber) const noexcept
}
else
{
- va_list dummy;
- Event::AddEvent(EventType::filament_error, (uint16_t)fst.ToBaseType(), extruder, CanInterface::GetCanAddress(), "", dummy);
-// gCodes.FilamentError(extruder, fst);
+ Event::AddEvent(EventType::filament_error, (uint16_t)fst.ToBaseType(), extruder, CanInterface::GetCanAddress(), "");
}
}
}
diff --git a/src/GCodes/GCodes.h b/src/GCodes/GCodes.h
index 093c1511..af4eebbe 100644
--- a/src/GCodes/GCodes.h
+++ b/src/GCodes/GCodes.h
@@ -473,6 +473,7 @@ private:
GCodeResult SendI2c(GCodeBuffer& gb, const StringRef &reply) THROWS(GCodeException); // Handle M260
GCodeResult ReceiveI2c(GCodeBuffer& gb, const StringRef &reply) THROWS(GCodeException); // Handle M261
GCodeResult WaitForPin(GCodeBuffer& gb, const StringRef &reply) THROWS(GCodeException); // Handle M577
+ GCodeResult RaiseEvent(GCodeBuffer& gb, const StringRef &reply) THROWS(GCodeException); // Handle M957
#if HAS_WIFI_NETWORKING || HAS_AUX_DEVICES || HAS_MASS_STORAGE || HAS_SBC_INTERFACE
GCodeResult UpdateFirmware(GCodeBuffer& gb, const StringRef &reply) THROWS(GCodeException); // Handle M997
diff --git a/src/GCodes/GCodes2.cpp b/src/GCodes/GCodes2.cpp
index dee5ea47..40400a87 100644
--- a/src/GCodes/GCodes2.cpp
+++ b/src/GCodes/GCodes2.cpp
@@ -4515,15 +4515,19 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx
#endif
#if SUPPORT_ACCELEROMETERS
- case 955:
+ case 955: // configure accelerometer
result = Accelerometers::ConfigureAccelerometer(gb, reply);
break;
- case 956:
+ case 956: // start accelerometer
result = Accelerometers::StartAccelerometer(gb, reply);
break;
#endif
+ case 957: // raise event
+ result = RaiseEvent(gb, reply);
+ break;
+
#if HAS_WIFI_NETWORKING || HAS_AUX_DEVICES || HAS_MASS_STORAGE || HAS_SBC_INTERFACE
case 997: // Perform firmware update
result = UpdateFirmware(gb, reply);
diff --git a/src/GCodes/GCodes3.cpp b/src/GCodes/GCodes3.cpp
index 0db8487a..c534b5bc 100644
--- a/src/GCodes/GCodes3.cpp
+++ b/src/GCodes/GCodes3.cpp
@@ -1868,7 +1868,38 @@ bool GCodes::ProcessWholeLineComment(GCodeBuffer& gb, const StringRef& reply) TH
return true;
}
-// Process and event. The autoPauseGCode buffer calls this when there is a new event to be processed.
+// Handle M957
+GCodeResult GCodes::RaiseEvent(GCodeBuffer& gb, const StringRef &reply) THROWS(GCodeException)
+{
+ String<StringLength50> temp;
+ gb.MustSee('E');
+ gb.GetQuotedString(temp.GetRef(), false);
+ const EventType et(temp.c_str());
+ if (!et.IsValid())
+ {
+ reply.copy("Invalid event type");
+ return GCodeResult::error;
+ }
+
+ const unsigned int devNum = gb.GetLimitedUIValue('D', 256);
+ const unsigned int param = (gb.Seen('P')) ? gb.GetUIValue() : 0;
+ const unsigned int boardAddress = (gb.Seen('B')) ? gb.GetUIValue() : CanInterface::GetCanAddress();
+ temp.Clear();
+ if (gb.Seen('S'))
+ {
+ gb.GetQuotedString(temp.GetRef(), true);
+ }
+
+ const bool added = Event::AddEvent(et, param, boardAddress, devNum, "%s", temp.c_str());
+ if (added)
+ {
+ return GCodeResult::ok;
+ }
+ reply.copy("a similar event is already queued");
+ return GCodeResult::warning;
+}
+
+// Process an event. The autoPauseGCode buffer calls this when there is a new event to be processed.
// This is a separate function because it allocates strings on the stack.
void GCodes::ProcessEvent(GCodeBuffer& gb) noexcept
{
diff --git a/src/Heating/LocalHeater.cpp b/src/Heating/LocalHeater.cpp
index 4f21b246..fbc3be32 100644
--- a/src/Heating/LocalHeater.cpp
+++ b/src/Heating/LocalHeater.cpp
@@ -933,10 +933,9 @@ void LocalHeater::RaiseHeaterFault(HeaterFaultType type, const char *_ecv_array
else
#endif
{
- Event::AddEvent(EventType::heater_fault, (uint16_t)type, GetHeaterNumber(), CanInterface::GetCanAddress(), format, vargs);
+ Event::AddEventV(EventType::heater_fault, (uint16_t)type, GetHeaterNumber(), CanInterface::GetCanAddress(), format, vargs);
}
va_end(vargs);
-// reprap.GetGCodes().HandleHeaterFault();
}
}
diff --git a/src/Platform/Event.cpp b/src/Platform/Event.cpp
index 825caf03..4757bbe8 100644
--- a/src/Platform/Event.cpp
+++ b/src/Platform/Event.cpp
@@ -18,9 +18,19 @@ inline Event::Event(Event *_ecv_null pnext, EventType et, uint16_t p_param, uint
text.vprintf(format, vargs);
}
+// Queue an event, or release it if we have a similar event pending already. Returns true if the event was added, false if it was released.
+/*static*/ bool Event::AddEvent(EventType et, uint16_t p_param, CanAddress p_ba, uint8_t devNum, const char *_ecv_array format, ...) noexcept
+{
+ va_list vargs;
+ va_start(vargs, format);
+ const bool ret = AddEventV(et, p_param, p_ba, devNum, format, vargs);
+ va_end(vargs);
+ return ret;
+}
+
// Queue an event unless we have a similar event pending already. Returns true if the event was added.
// The event list is held in priority order, lowest numbered (highest priority) events first.
-/*static*/ bool Event::AddEvent(EventType et, uint16_t p_param, uint8_t devNum, CanAddress p_ba, const char *_ecv_array format, va_list vargs) noexcept
+/*static*/ bool Event::AddEventV(EventType et, uint16_t p_param, uint8_t devNum, CanAddress p_ba, const char *_ecv_array format, va_list vargs) noexcept
{
// Search for similar events already pending or being processed.
// An event is 'similar' if it has the same type, device number and parameter even if the text is different.
diff --git a/src/Platform/Event.h b/src/Platform/Event.h
index 3f10b4af..edeb12b2 100644
--- a/src/Platform/Event.h
+++ b/src/Platform/Event.h
@@ -43,7 +43,10 @@ public:
static MessageType GetTextDescription(const StringRef& str) noexcept;
// Queue an event, or release it if we have a similar event pending already. Returns true if the event was added, false if it was released.
- static bool AddEvent(EventType et, uint16_t p_param, CanAddress p_ba, uint8_t devNum, const char *_ecv_array format, va_list vargs) noexcept;
+ static bool AddEvent(EventType et, uint16_t p_param, CanAddress p_ba, uint8_t devNum, const char *_ecv_array format, ...) noexcept;
+
+ // Queue an event, or release it if we have a similar event pending already. Returns true if the event was added, false if it was released.
+ static bool AddEventV(EventType et, uint16_t p_param, CanAddress p_ba, uint8_t devNum, const char *_ecv_array format, va_list vargs) noexcept;
// Get the highest priority event if there is one start processing it
static bool StartProcessing() noexcept;
diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp
index 7e32200b..cda05c8e 100644
--- a/src/Platform/Platform.cpp
+++ b/src/Platform/Platform.cpp
@@ -1162,7 +1162,7 @@ void Platform::Spin() noexcept
# endif
if (eventOnStallDrivers.Intersects(mask))
{
- Event::AddEvent(EventType::driver_stall, 0, CanInterface::GetCanAddress(), nextDriveToPoll, "", va_list());
+ Event::AddEvent(EventType::driver_stall, 0, CanInterface::GetCanAddress(), nextDriveToPoll, "");
}
else if (logOnStallDrivers.Intersects(mask))
{
diff --git a/src/Version.h b/src/Version.h
index 7ad8e8df..fa5b9479 100644
--- a/src/Version.h
+++ b/src/Version.h
@@ -10,7 +10,7 @@
#ifndef VERSION
// Note: the complete VERSION string must be in standard version number format and must not contain spaces! This is so that DWC can parse it.
-# define MAIN_VERSION "3.4.0beta6+2"
+# define MAIN_VERSION "3.4.0beta6+3"
# ifdef USE_CAN0
# define VERSION_SUFFIX "(CAN0)"
# else