From 11e9b0c731495eebf75cb17cf29169541d40787a Mon Sep 17 00:00:00 2001 From: Nav Date: Sat, 29 Mar 2025 02:03:26 +0000 Subject: [PATCH] Removed redundant programming mode events and updated TC documentation. These events were made redundant by the introduction of the `TargetState` struct, and the `TargetStateChanged` event. --- src/EventManager/Events/Events.hpp | 2 - .../Events/ProgrammingModeDisabled.hpp | 23 --------- .../Events/ProgrammingModeEnabled.hpp | 23 --------- src/Insight/Insight.cpp | 16 ------ src/Insight/Insight.hpp | 2 - src/TargetController/README.md | 50 ++----------------- 6 files changed, 5 insertions(+), 111 deletions(-) delete mode 100644 src/EventManager/Events/ProgrammingModeDisabled.hpp delete mode 100644 src/EventManager/Events/ProgrammingModeEnabled.hpp diff --git a/src/EventManager/Events/Events.hpp b/src/EventManager/Events/Events.hpp index 578c7f1a..6313d8bb 100644 --- a/src/EventManager/Events/Events.hpp +++ b/src/EventManager/Events/Events.hpp @@ -15,8 +15,6 @@ #include "TargetStateChanged.hpp" #include "MemoryWrittenToTarget.hpp" #include "TargetReset.hpp" -#include "ProgrammingModeEnabled.hpp" -#include "ProgrammingModeDisabled.hpp" #ifndef EXCLUDE_INSIGHT #include "InsightActivationRequested.hpp" diff --git a/src/EventManager/Events/ProgrammingModeDisabled.hpp b/src/EventManager/Events/ProgrammingModeDisabled.hpp deleted file mode 100644 index fbce1109..00000000 --- a/src/EventManager/Events/ProgrammingModeDisabled.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include - -#include "Event.hpp" - -namespace Events -{ - class ProgrammingModeDisabled: public Event - { - public: - static constexpr EventType type = EventType::PROGRAMMING_MODE_DISABLED; - static const inline std::string name = "ProgrammingModeDisabled"; - - [[nodiscard]] EventType getType() const override { - return ProgrammingModeDisabled::type; - } - - [[nodiscard]] std::string getName() const override { - return ProgrammingModeDisabled::name; - } - }; -} diff --git a/src/EventManager/Events/ProgrammingModeEnabled.hpp b/src/EventManager/Events/ProgrammingModeEnabled.hpp deleted file mode 100644 index 6f101539..00000000 --- a/src/EventManager/Events/ProgrammingModeEnabled.hpp +++ /dev/null @@ -1,23 +0,0 @@ -#pragma once - -#include - -#include "Event.hpp" - -namespace Events -{ - class ProgrammingModeEnabled: public Event - { - public: - static constexpr EventType type = EventType::PROGRAMMING_MODE_ENABLED; - static const inline std::string name = "ProgrammingModeEnabled"; - - [[nodiscard]] EventType getType() const override { - return ProgrammingModeEnabled::type; - } - - [[nodiscard]] std::string getName() const override { - return ProgrammingModeEnabled::name; - } - }; -} diff --git a/src/Insight/Insight.cpp b/src/Insight/Insight.cpp index ee6a5b69..30f65c91 100644 --- a/src/Insight/Insight.cpp +++ b/src/Insight/Insight.cpp @@ -49,14 +49,6 @@ Insight::Insight( std::bind(&Insight::onTargetMemoryWrittenEvent, this, std::placeholders::_1) ); - this->eventListener.registerCallbackForEventType( - std::bind(&Insight::onProgrammingModeEnabledEvent, this, std::placeholders::_1) - ); - - this->eventListener.registerCallbackForEventType( - std::bind(&Insight::onProgrammingModeDisabledEvent, this, std::placeholders::_1) - ); - QApplication::setQuitOnLastWindowClosed(false); QApplication::setStyle(new BloomProxyStyle{}); @@ -226,11 +218,3 @@ void Insight::onTargetMemoryWrittenEvent(const Events::MemoryWrittenToTarget& ev Targets::TargetMemoryAddressRange{event.startAddress, event.startAddress + (event.size - 1)} ); } - -void Insight::onProgrammingModeEnabledEvent(const Events::ProgrammingModeEnabled& event) { - emit this->insightSignals->programmingModeEnabled(); -} - -void Insight::onProgrammingModeDisabledEvent(const Events::ProgrammingModeDisabled& event) { - emit this->insightSignals->programmingModeDisabled(); -} diff --git a/src/Insight/Insight.hpp b/src/Insight/Insight.hpp index 75b6813f..1ccb75c4 100644 --- a/src/Insight/Insight.hpp +++ b/src/Insight/Insight.hpp @@ -91,6 +91,4 @@ private: void onTargetResetEvent(const Events::TargetReset& event); void onTargetRegistersWrittenEvent(const Events::RegistersWrittenToTarget& event); void onTargetMemoryWrittenEvent(const Events::MemoryWrittenToTarget& event); - void onProgrammingModeEnabledEvent(const Events::ProgrammingModeEnabled& event); - void onProgrammingModeDisabledEvent(const Events::ProgrammingModeDisabled& event); }; diff --git a/src/TargetController/README.md b/src/TargetController/README.md index 448c6142..00a05fb2 100644 --- a/src/TargetController/README.md +++ b/src/TargetController/README.md @@ -333,56 +333,16 @@ void onTargetStateChanged(const Events::TargetStateChanged& event) { ### Programming mode -When a component needs to write to the target's program memory, it must enable programming mode on the target. This can -be done by issuing the `EnableProgrammingMode` command to the TargetController (see +When a component needs to write to the target's program memory, it must enable programming mode. This can be done by +issuing the `EnableProgrammingMode` command to the TargetController (see `TargetControllerService::enableProgrammingMode()`). Once programming mode has been enabled, standard debugging operations such as program flow control and RAM access will become unavailable. The TargetController will reject any commands that involve these operations, until programming mode -has been disabled. The [`Command::requiresDebugMode()`](./Commands/Command.hpp) virtual member function communicates a -particular command's requirement for the target to **not** be in programming mode. +has been disabled. -For example, the `ResumeTargetExecution` command returns `true` here, as it attempts to control program flow on the -target, which can only be done when the target is not in programming mode: - -```c++ -class ResumeTargetExecution: public Command -{ -public: - // ... - [[nodiscard]] bool requiresDebugMode() const override { - return true; - } -}; -``` - -On the other hand, the `ReadTargetMemory` command will only return `true` if we're reading from RAM, as RAM is the -only memory which isn't accessible when the target is in programming mode: - -```c++ -class ReadTargetMemory: public Command -{ -public: - Targets::TargetMemoryType memoryType; - Targets::TargetMemoryAddress startAddress; - Targets::TargetMemorySize bytes; - - // ... - - [[nodiscard]] bool requiresDebugMode() const override { - return this->memoryType == Targets::TargetMemoryType::RAM; - } -}; -``` - -The TargetController will emit `ProgrammingModeEnabled` and `ProgrammingModeDisabled` events when it enables/disables -programming mode. Components should listen for these events to ensure that they disable any means for the user to trigger -debugging operations whilst programming mode is enabled. For example, the Insight component will disable much of its -GUI components when programming mode is enabled. - -It shouldn't be too much of a problem if a component attempts to perform a debug operation on the target whilst -programming mode is enabled, as the TargetController will just respond with an error. But still, it would be best to -avoid doing this where possible. +The TargetController will emit a `TargetStateChanged` event when programming mode is enabled/disabled. See +[`TargetState::mode`](../Targets/TargetState.hpp) for more. ---