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:
-rw-r--r--src/CAN/CanInterface.cpp91
-rw-r--r--src/CAN/CanInterface.h2
-rw-r--r--src/Duet3Mini/Pins_Duet3Mini.h16
-rw-r--r--src/Heating/Heat.cpp10
-rw-r--r--src/Heating/Sensors/RemoteSensor.cpp5
-rw-r--r--src/Heating/Sensors/RemoteSensor.h1
6 files changed, 50 insertions, 75 deletions
diff --git a/src/CAN/CanInterface.cpp b/src/CAN/CanInterface.cpp
index 041226cb..acd6a891 100644
--- a/src/CAN/CanInterface.cpp
+++ b/src/CAN/CanInterface.cpp
@@ -658,6 +658,12 @@ void CanInterface::SendMotion(CanMessageBuffer *buf) noexcept
// Send a request to an expansion board and append the response to 'reply'
GCodeResult CanInterface::SendRequestAndGetStandardReply(CanMessageBuffer *buf, CanRequestId rid, const StringRef& reply, uint8_t *extra) noexcept
{
+ return SendRequestAndGetCustomReply(buf, rid, reply, extra, CanMessageType::unusedMessageType, [](const CanMessageBuffer*) { });
+}
+
+// Send a request to an expansion board and append the response to 'reply'. The response may either be a standard reply or 'replyType'.
+GCodeResult CanInterface::SendRequestAndGetCustomReply(CanMessageBuffer *buf, CanRequestId rid, const StringRef& reply, uint8_t *extra, CanMessageType replyType, std::function<void(const CanMessageBuffer*) /*noexcept*/> callback) noexcept
+{
#if USE_NEW_CAN_DRIVER
if (can0dev == nullptr)
#else
@@ -693,11 +699,8 @@ GCodeResult CanInterface::SendRequestAndGetStandardReply(CanMessageBuffer *buf,
buf->DebugPrint("Rx1:");
}
- if ( buf->id.MsgType() == CanMessageType::standardReply
- && buf->id.Src() == dest
- && (buf->msg.standardReply.requestId == rid || buf->msg.standardReply.requestId == CanRequestIdAcceptAlways)
- && buf->msg.standardReply.fragmentNumber == fragmentsReceived
- )
+ const bool matchesRequest = buf->id.Src() == dest && buf->msg.standardReply.requestId == rid;
+ if (matchesRequest && buf->id.MsgType() == CanMessageType::standardReply && buf->msg.standardReply.fragmentNumber == fragmentsReceived)
{
if (fragmentsReceived == 0)
{
@@ -725,6 +728,12 @@ GCodeResult CanInterface::SendRequestAndGetStandardReply(CanMessageBuffer *buf,
}
++fragmentsReceived;
}
+ else if (matchesRequest &&buf->id.MsgType() == replyType && fragmentsReceived == 0)
+ {
+ callback(buf);
+ CanMessageBuffer::Free(buf);
+ return GCodeResult::ok;
+ }
else
{
// We received an unexpected message. Don't tack it on to 'reply' because some replies contain important data, e.g. request for board short name.
@@ -739,59 +748,6 @@ GCodeResult CanInterface::SendRequestAndGetStandardReply(CanMessageBuffer *buf,
}
// Send a request to an expansion board and get a single reply into the same buffer. Caller must free the buffer whether a response was received or not.
-GCodeResult CanInterface::SendRequestAndGetSingleReply(CanMessageBuffer *buf, CanRequestId rid, CanMessageType replyType, const StringRef& reply) noexcept
-{
-#if USE_NEW_CAN_DRIVER
- if (can0dev == nullptr)
-#else
- if (mcan_instance.hw == nullptr)
-#endif
- {
- // Transactions sometimes get requested after we have shut down CAN, e.g. when we destroy filament monitors
- return GCodeResult::error;
- }
- const CanAddress dest = buf->id.Dst();
-#if USE_NEW_CAN_DRIVER
- can0dev->SendMessage(TxBufferIndexRequest, MaxRequestSendWait, buf);
-#else
- mcan_fd_send_ext_message(&mcan_instance, buf->id.GetWholeId(), reinterpret_cast<uint8_t*>(&(buf->msg)), buf->dataLength, TxBufferIndexRequest, MaxRequestSendWait, false);
-#endif
- const uint32_t whenStartedWaiting = millis();
- const CanMessageType msgType = buf->id.MsgType(); // save for possible error message
- for (;;)
- {
- const uint32_t timeWaiting = millis() - whenStartedWaiting;
-#if USE_NEW_CAN_DRIVER
- if (!can0dev->ReceiveMessage(RxBufferIndexResponse, CanResponseTimeout - timeWaiting, buf))
-#else
- if (!GetMessageFromFifo(&mcan_instance, buf, RxFifoIndexResponse, CanResponseTimeout - timeWaiting))
-#endif
- {
- break;
- }
-
- if (reprap.Debug(moduleCan))
- {
- buf->DebugPrint("Rx1:");
- }
-
- if ( buf->id.MsgType() == replyType
- && buf->id.Src() == dest
- && (buf->msg.standardReply.requestId == rid || buf->msg.standardReply.requestId == CanRequestIdAcceptAlways)
- )
- {
- return (GCodeResult)buf->msg.standardReply.resultCode;
- }
-
- // We received an unexpected message. Don't tack it on to 'reply' because some replies contain important data, e.g. request for board short name.
- reprap.GetPlatform().MessageF(WarningMessage, "Discarded msg src=%u typ=%u RID=%u exp %u\n",
- buf->id.Src(), (unsigned int)buf->id.MsgType(), (unsigned int)buf->msg.standardReply.requestId, rid);
- }
-
- reply.lcatf("Response timeout: CAN addr %u, req type %u, RID=%u", dest, (unsigned int)msgType, (unsigned int)rid);
- return GCodeResult::error;
-}
-
// Send a response to an expansion board and free the buffer
void CanInterface::SendResponseNoFree(CanMessageBuffer *buf) noexcept
{
@@ -1139,16 +1095,15 @@ GCodeResult CanInterface::ReadRemoteHandles(CanAddress boardAddress, RemoteInput
auto msg = buf->SetupRequestMessage<CanMessageReadInputsRequest>(rid, CanId::MasterAddress, boardAddress);
msg->mask = mask;
msg->pattern = pattern;
- const GCodeResult rslt = SendRequestAndGetSingleReply(buf, rid, CanMessageType::readInputsReply, reply);
- if (rslt == GCodeResult::ok)
- {
- auto response = buf->msg.readInputsReply;
- for (unsigned int i = 0; i < response.numReported; ++i)
- {
- callback(response.results[i].handle, response.results[i].value);
- }
- }
- CanMessageBuffer::Free(buf);
+ const GCodeResult rslt = SendRequestAndGetCustomReply(buf, rid, reply, nullptr, CanMessageType::readInputsReply,
+ [callback](const CanMessageBuffer *buf)
+ {
+ auto response = buf->msg.readInputsReply;
+ for (unsigned int i = 0; i < response.numReported; ++i)
+ {
+ callback(response.results[i].handle, response.results[i].value);
+ }
+ });
return rslt;
}
diff --git a/src/CAN/CanInterface.h b/src/CAN/CanInterface.h
index 9454a120..31b4c565 100644
--- a/src/CAN/CanInterface.h
+++ b/src/CAN/CanInterface.h
@@ -71,7 +71,7 @@ namespace CanInterface
inline CanAddress GetCanAddress() noexcept { return CanId::MasterAddress; }
CanRequestId AllocateRequestId(CanAddress destination) noexcept;
GCodeResult SendRequestAndGetStandardReply(CanMessageBuffer *buf, CanRequestId rid, const StringRef& reply, uint8_t *extra = nullptr) noexcept;
- GCodeResult SendRequestAndGetSingleReply(CanMessageBuffer *buf, CanRequestId rid, CanMessageType replyType, const StringRef& reply) noexcept;
+ GCodeResult SendRequestAndGetCustomReply(CanMessageBuffer *buf, CanRequestId rid, const StringRef& reply, uint8_t *extra, CanMessageType replyType, std::function<void(const CanMessageBuffer*) /*noexcept*/> callback) noexcept;
void SendResponseNoFree(CanMessageBuffer *buf) noexcept;
void SendBroadcastNoFree(CanMessageBuffer *buf) noexcept;
void SendMessageNoReplyNoFree(CanMessageBuffer *buf) noexcept;
diff --git a/src/Duet3Mini/Pins_Duet3Mini.h b/src/Duet3Mini/Pins_Duet3Mini.h
index c8a7cc4b..4b634ea1 100644
--- a/src/Duet3Mini/Pins_Duet3Mini.h
+++ b/src/Duet3Mini/Pins_Duet3Mini.h
@@ -13,15 +13,19 @@
#define DEFAULT_BOARD_TYPE BoardType::Duet3Mini_Unknown
#ifdef DUET3MINI_V02
-#define BOARD_SHORT_NAME "Mini5plus_v02"
-#define BOARD_NAME "Duet 3 Mini 5+ prototype v0.2"
-#define FIRMWARE_NAME "RepRapFirmware for Duet 3 Mini 5+ prototype v0.2"
+# define BOARD_SHORT_NAME "Mini5plus_v02"
+# define BOARD_NAME "Duet 3 Mini 5+ prototype v0.2"
+# define FIRMWARE_NAME "RepRapFirmware for Duet 3 Mini 5+ prototype v0.2"
#endif
#ifdef DUET3MINI_V04
-#define BOARD_SHORT_NAME "Mini5plus"
-#define BOARD_NAME "Duet 3 Mini 5+"
-#define FIRMWARE_NAME "RepRapFirmware for Duet 3 Mini 5+"
+# define BOARD_SHORT_NAME "Mini5plus"
+# define BOARD_NAME "Duet 3 Mini 5+"
+# ifdef DUET3_ATE
+# define FIRMWARE_NAME "RepRapFirmware for Duet 3 Mini 5+ ATE"
+# else
+# define FIRMWARE_NAME "RepRapFirmware for Duet 3 Mini 5+"
+# endif
#endif
constexpr size_t NumFirmwareUpdateModules = 2; // main module and WiFi module
diff --git a/src/Heating/Heat.cpp b/src/Heating/Heat.cpp
index ce24563c..bd8bd733 100644
--- a/src/Heating/Heat.cpp
+++ b/src/Heating/Heat.cpp
@@ -41,6 +41,10 @@ Licence: GPL
# include "CAN/CanInterface.h"
#endif
+#ifdef DUET3_ATE
+# include <Duet3Ate.h>
+#endif
+
constexpr uint32_t HeaterTaskStackWords = 400; // task stack size in dwords, must be large enough for auto tuning
static Task<HeaterTaskStackWords> heaterTask;
@@ -1181,6 +1185,12 @@ void Heat::ProcessRemoteSensorsReport(CanAddress src, const CanMessageSensorTemp
{
ts->UpdateRemoteTemperature(src, msg.temperatureReports[index]);
}
+# ifdef DUET3_ATE
+ else
+ {
+ Duet3Ate::ProcessOrphanedSensorReport(src, sensor, msg.temperatureReports[index]);
+ }
+# endif
}
++index;
}
diff --git a/src/Heating/Sensors/RemoteSensor.cpp b/src/Heating/Sensors/RemoteSensor.cpp
index d2f8373e..26443d70 100644
--- a/src/Heating/Sensors/RemoteSensor.cpp
+++ b/src/Heating/Sensors/RemoteSensor.cpp
@@ -20,6 +20,11 @@ RemoteSensor::RemoteSensor(unsigned int sensorNum, CanAddress pBoardAddress) noe
{
}
+RemoteSensor::~RemoteSensor()
+{
+ //TODO delete the remote sensor
+}
+
GCodeResult RemoteSensor::Configure(GCodeBuffer& gb, const StringRef& reply, bool& changed)
{
TryConfigureSensorName(gb, changed);
diff --git a/src/Heating/Sensors/RemoteSensor.h b/src/Heating/Sensors/RemoteSensor.h
index d9ade703..7a0a87d7 100644
--- a/src/Heating/Sensors/RemoteSensor.h
+++ b/src/Heating/Sensors/RemoteSensor.h
@@ -16,6 +16,7 @@ class RemoteSensor : public TemperatureSensor
{
public:
RemoteSensor(unsigned int sensorNum, CanAddress pBoardAddress) noexcept;
+ ~RemoteSensor();
GCodeResult Configure(GCodeBuffer& gb, const StringRef& reply, bool& changed) override THROWS(GCodeException);
CanAddress GetBoardAddress() const noexcept override { return boardAddress; }