diff options
author | David Crocker <dcrocker@eschertech.com> | 2020-12-27 17:06:26 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2020-12-27 17:06:26 +0300 |
commit | c8d3ab8be56bbbc9e4ced2234392353606f1b891 (patch) | |
tree | a258beb68b1b23541a37a2af4d63ad01ae083bcc | |
parent | 0a46d5ad95faadd5c023cf52db06a9aa184b12b8 (diff) |
Added SUPPORT_REMOTE_COMMANDS
-rw-r--r-- | src/CAN/CommandProcessor.cpp | 8 | ||||
-rw-r--r-- | src/Hardware/IoPorts.cpp | 4 | ||||
-rw-r--r-- | src/Hardware/IoPorts.h | 2 | ||||
-rw-r--r-- | src/InputMonitors/InputMonitor.cpp | 2 | ||||
-rw-r--r-- | src/InputMonitors/InputMonitor.h | 2 | ||||
-rw-r--r-- | src/Movement/DDA.cpp | 4 | ||||
-rw-r--r-- | src/Movement/DDA.h | 6 | ||||
-rw-r--r-- | src/Movement/DDARing.cpp | 2 | ||||
-rw-r--r-- | src/Movement/DDARing.h | 2 | ||||
-rw-r--r-- | src/Movement/Move.h | 2 | ||||
-rw-r--r-- | src/Movement/StepTimer.cpp | 2 | ||||
-rw-r--r-- | src/Movement/StepTimer.h | 4 | ||||
-rw-r--r-- | src/Pins.h | 4 | ||||
-rw-r--r-- | src/Platform.h | 5 |
14 files changed, 33 insertions, 16 deletions
diff --git a/src/CAN/CommandProcessor.cpp b/src/CAN/CommandProcessor.cpp index 201b188b..304beb57 100644 --- a/src/CAN/CommandProcessor.cpp +++ b/src/CAN/CommandProcessor.cpp @@ -287,7 +287,7 @@ static void HandleInputStateChanged(const CanMessageInputChanged& msg, CanAddres } } -#ifndef DUET3_ATE +#if SUPPORT_REMOTE_COMMANDS static GCodeResult EutGetInfo(const CanMessageReturnInfo& msg, const StringRef& reply, uint8_t& extra) { @@ -311,9 +311,7 @@ static GCodeResult EutGetInfo(const CanMessageReturnInfo& msg, const StringRef& case CanMessageReturnInfo::typeM408: // For now we ignore the parameter and always return the same set of info // This command is currently only used by the ATE, which needs the board type and the voltages - reply.copy("{\"firmwareElectronics\":\"Duet 3 "); - reply.cat(BOARD_NAME); - reply.cat("\""); + reply.printf("{\"firmwareElectronics\":\"Duet 3 %.0s\"", BOARD_NAME); #if HAS_VOLTAGE_MONITOR { const MinMaxCurrent voltages = reprap.GetPlatform().GetPowerVoltages(); @@ -380,7 +378,7 @@ void CommandProcessor::ProcessReceivedMessage(CanMessageBuffer *buf) noexcept if (buf->id.Src() != CanInterface::GetCanAddress()) // I don't think we should receive our own broadcasts, but in case we do... { const CanMessageType id = buf->id.MsgType(); -#ifndef DUET3_ATE +#if SUPPORT_REMOTE_COMMANDS if (CanInterface::InEutMode()) { String<StringLength500> reply; diff --git a/src/Hardware/IoPorts.cpp b/src/Hardware/IoPorts.cpp index 4039df02..4453ab6e 100644 --- a/src/Hardware/IoPorts.cpp +++ b/src/Hardware/IoPorts.cpp @@ -181,11 +181,15 @@ void IoPort::DetachInterrupt() const noexcept } } +#if SUPPORT_REMOTE_COMMANDS + bool IoPort::SetAnalogCallback(AnalogInCallbackFunction fn, CallbackParameter cbp, uint32_t ticksPerCall) noexcept { return AnalogIn::SetCallback(GetAnalogChannel(), fn, cbp, ticksPerCall, false); } +#endif + // Allocate the specified logical pin, returning true if successful bool IoPort::Allocate(const char *pn, const StringRef& reply, PinUsedBy neededFor, PinAccess access) noexcept { diff --git a/src/Hardware/IoPorts.h b/src/Hardware/IoPorts.h index 0bbfbedb..f775e935 100644 --- a/src/Hardware/IoPorts.h +++ b/src/Hardware/IoPorts.h @@ -41,7 +41,9 @@ public: bool ReadDigital() const noexcept; bool AttachInterrupt(StandardCallbackFunction callback, InterruptMode mode, CallbackParameter param) const noexcept; void DetachInterrupt() const noexcept; +#if SUPPORT_REMOTE_COMMANDS bool SetAnalogCallback(AnalogInCallbackFunction fn, CallbackParameter cbp, uint32_t ticksPerCall) noexcept; +#endif uint16_t ReadAnalog() const noexcept; diff --git a/src/InputMonitors/InputMonitor.cpp b/src/InputMonitors/InputMonitor.cpp index 25f1ff74..a59ce075 100644 --- a/src/InputMonitors/InputMonitor.cpp +++ b/src/InputMonitors/InputMonitor.cpp @@ -7,7 +7,7 @@ #include "InputMonitor.h" -#if SUPPORT_CAN_EXPANSION +#if SUPPORT_REMOTE_COMMANDS #include <CanMessageFormats.h> #include <Hardware/IoPorts.h> diff --git a/src/InputMonitors/InputMonitor.h b/src/InputMonitors/InputMonitor.h index ac43f2ea..3e127c93 100644 --- a/src/InputMonitors/InputMonitor.h +++ b/src/InputMonitors/InputMonitor.h @@ -10,7 +10,7 @@ #include <RepRapFirmware.h> -#if SUPPORT_CAN_EXPANSION +#if SUPPORT_REMOTE_COMMANDS #include <Hardware/IoPorts.h> #include <GCodes/GCodeResult.h> diff --git a/src/Movement/DDA.cpp b/src/Movement/DDA.cpp index 61a29164..0ac49b5b 100644 --- a/src/Movement/DDA.cpp +++ b/src/Movement/DDA.cpp @@ -625,6 +625,8 @@ bool DDA::InitAsyncMove(DDARing& ring, const AsyncMove& nextMove) noexcept #endif +#if SUPPORT_REMOTE_COMMANDS + // Set up a remote move. Return true if it represents real movement, else false. bool DDA::InitFromRemote(const CanMessageMovement& msg) noexcept { @@ -740,6 +742,8 @@ bool DDA::InitFromRemote(const CanMessageMovement& msg) noexcept return true; } +#endif + // Return true if this move is or might have been intended to be a deceleration-only move // A move planned as a deceleration-only move may have a short acceleration segment at the start because of rounding error inline bool DDA::IsDecelerationMove() const noexcept diff --git a/src/Movement/DDA.h b/src/Movement/DDA.h index e9dc5dfa..b8a29677 100644 --- a/src/Movement/DDA.h +++ b/src/Movement/DDA.h @@ -71,10 +71,14 @@ public: #if SUPPORT_CAN_EXPANSION uint32_t InsertHiccup(uint32_t whenNextInterruptWanted) noexcept; - bool InitFromRemote(const CanMessageMovement& msg) noexcept; #else void InsertHiccup(uint32_t whenNextInterruptWanted) noexcept; #endif + +#if SUPPORT_REMOTE_COMMANDS + bool InitFromRemote(const CanMessageMovement& msg) noexcept; +#endif + const int32_t *DriveCoordinates() const noexcept { return endPoint; } // Get endpoints of a move in machine coordinates void SetDriveCoordinate(int32_t a, size_t drive) noexcept; // Force an end point void SetFeedRate(float rate) noexcept { requestedSpeed = rate; } diff --git a/src/Movement/DDARing.cpp b/src/Movement/DDARing.cpp index c0aac98d..164ad83e 100644 --- a/src/Movement/DDARing.cpp +++ b/src/Movement/DDARing.cpp @@ -864,7 +864,7 @@ uint32_t DDARing::ManageLaserPower() const noexcept #endif -#if SUPPORT_CAN_EXPANSION +#if SUPPORT_REMOTE_COMMANDS // Add a move from the ATE to the movement queue void DDARing::AddMoveFromRemote(const CanMessageMovement& msg) noexcept diff --git a/src/Movement/DDARing.h b/src/Movement/DDARing.h index 544dc5a8..0979088e 100644 --- a/src/Movement/DDARing.h +++ b/src/Movement/DDARing.h @@ -85,7 +85,7 @@ public: GCodeResult ConfigureMovementQueue(GCodeBuffer& gb, const StringRef& reply) noexcept; -#if SUPPORT_CAN_EXPANSION +#if SUPPORT_REMOTE_COMMANDS void AddMoveFromRemote(const CanMessageMovement& msg) noexcept; // add a move from the ATE to the movement queue #endif diff --git a/src/Movement/Move.h b/src/Movement/Move.h index f92bea5d..7037be8a 100644 --- a/src/Movement/Move.h +++ b/src/Movement/Move.h @@ -199,7 +199,7 @@ public: static void WakeLaserTaskFromISR() noexcept; // wake up the laser task, called at the start of a new move #endif -#if SUPPORT_CAN_EXPANSION +#if SUPPORT_REMOTE_COMMANDS void AddMoveFromRemote(const CanMessageMovement& msg) noexcept // add a move from the ATE to the movement queue { mainDDARing.AddMoveFromRemote(msg); diff --git a/src/Movement/StepTimer.cpp b/src/Movement/StepTimer.cpp index bdb6761c..5b19c78f 100644 --- a/src/Movement/StepTimer.cpp +++ b/src/Movement/StepTimer.cpp @@ -18,7 +18,7 @@ StepTimer * volatile StepTimer::pendingList = nullptr; -#if SUPPORT_CAN_EXPANSION +#if SUPPORT_REMOTE_COMMANDS volatile uint32_t StepTimer::localTimeOffset = 0; volatile uint32_t StepTimer::whenLastSynced; volatile bool StepTimer::synced = false; diff --git a/src/Movement/StepTimer.h b/src/Movement/StepTimer.h index 4beec8e0..c05491df 100644 --- a/src/Movement/StepTimer.h +++ b/src/Movement/StepTimer.h @@ -72,7 +72,7 @@ public: static constexpr float StepClocksToMillis = 1000.0/(float)StepClockRate; static constexpr uint32_t MinInterruptInterval = 6; // about 6us -#if SUPPORT_CAN_EXPANSION +#if SUPPORT_REMOTE_COMMANDS static uint32_t GetLocalTimeOffset() { return localTimeOffset; } //TODO change this to a PLL static void SetLocalTimeOffset(uint32_t offset) { localTimeOffset = offset; synced = true; whenLastSynced = millis(); } @@ -89,7 +89,7 @@ private: static StepTimer * volatile pendingList; // list of pending callbacks, soonest first -#if SUPPORT_CAN_EXPANSION +#if SUPPORT_REMOTE_COMMANDS static volatile uint32_t localTimeOffset; // local time minus master time static volatile uint32_t whenLastSynced; // the millis tick count when we last synced static volatile bool synced; @@ -202,4 +202,8 @@ # define MCU_HAS_TRUERANDOM 0 #endif +// Define SUPPORT_REMOTE_COMMANDS according to whether this hardware accepts commands over CAN +// For now we exclude Duet 3 MB6HC because CoreNG doesn't support analog callbacks +#define SUPPORT_REMOTE_COMMANDS (SUPPORT_CAN_EXPANSION && !defined(DUET3_ATE) && !defined(DUET3_V06)) + #endif // PINS_H__ diff --git a/src/Platform.h b/src/Platform.h index 60bd06ec..778137db 100644 --- a/src/Platform.h +++ b/src/Platform.h @@ -629,13 +629,14 @@ public: #if SUPPORT_CAN_EXPANSION void HandleRemoteGpInChange(CanAddress src, uint8_t handleMajor, uint8_t handleMinor, bool state) noexcept; GCodeResult UpdateRemoteStepsPerMmAndMicrostepping(AxesBitmap axesAndExtruders, const StringRef& reply) noexcept; -# ifndef DUET3_ATE +#endif + +#if SUPPORT_REMOTE_COMMANDS GCodeResult EutHandleM950Gpio(const CanMessageGeneric& msg, const StringRef& reply) noexcept; GCodeResult EutHandleGpioWrite(const CanMessageWriteGpio& msg, const StringRef& reply) noexcept; GCodeResult EutSetMotorCurrents(const CanMessageMultipleDrivesRequest<float>& msg, size_t dataLength, const StringRef& reply) noexcept; GCodeResult EutSetStepsPerMmAndMicrostepping(const CanMessageMultipleDrivesRequest<StepsPerUnitAndMicrostepping>& msg, size_t dataLength, const StringRef& reply) noexcept; GCodeResult EutHandleSetDriverStates(const CanMessageMultipleDrivesRequest<DriverStateControl>& msg, const StringRef& reply) noexcept; -# endif #endif #if VARIABLE_NUM_DRIVERS |