Help text for target driver passthrough commands

This commit is contained in:
Nav
2024-12-16 21:36:47 +00:00
parent 6873b2f53a
commit 9486cc0163
14 changed files with 119 additions and 2 deletions

View File

@@ -31,6 +31,7 @@ namespace TargetController::Commands
GET_TARGET_PROGRAM_COUNTER,
ENABLE_PROGRAMMING_MODE,
DISABLE_PROGRAMMING_MODE,
GET_TARGET_PASSTHROUGH_HELP_TEXT,
INVOKE_TARGET_PASSTHROUGH_COMMAND,
};
}

View File

@@ -0,0 +1,19 @@
#pragma once
#include "Command.hpp"
#include "src/TargetController/Responses/TargetPassthroughHelpText.hpp"
namespace TargetController::Commands
{
class GetTargetPassthroughHelpText: public Command
{
public:
using SuccessResponseType = Responses::TargetPassthroughHelpText;
static constexpr CommandType type = CommandType::GET_TARGET_PASSTHROUGH_HELP_TEXT;
static const inline std::string name = "GetTargetPassthroughHelpText";
[[nodiscard]] CommandType getType() const override {
return GetTargetPassthroughHelpText::type;
}
};
}

View File

@@ -17,6 +17,7 @@ namespace TargetController::Responses
TARGET_STACK_POINTER,
TARGET_PROGRAM_COUNTER,
PROGRAM_BREAKPOINT,
TARGET_PASSTHROUGH_HELP_TEXT,
TARGET_PASSTHROUGH_RESPONSE,
};
}

View File

@@ -0,0 +1,24 @@
#pragma once
#include <string>
#include "Response.hpp"
namespace TargetController::Responses
{
class TargetPassthroughHelpText: public Response
{
public:
static constexpr ResponseType type = ResponseType::TARGET_PASSTHROUGH_RESPONSE;
std::string text;
explicit TargetPassthroughHelpText(std::string&& text)
: text(std::move(text))
{}
[[nodiscard]] ResponseType getType() const override {
return TargetPassthroughHelpText::type;
}
};
}

View File

@@ -51,6 +51,7 @@ namespace TargetController
using Commands::GetTargetProgramCounter;
using Commands::EnableProgrammingMode;
using Commands::DisableProgrammingMode;
using Commands::GetTargetPassthroughHelpText;
using Commands::InvokeTargetPassthroughCommand;
using Responses::Response;
@@ -61,6 +62,7 @@ namespace TargetController
using Responses::TargetStackPointer;
using Responses::TargetProgramCounter;
using Responses::ProgramBreakpoint;
using Responses::TargetPassthroughHelpText;
using Responses::TargetPassthroughResponse;
TargetControllerComponent::TargetControllerComponent(
@@ -264,6 +266,10 @@ namespace TargetController
std::bind(&TargetControllerComponent::handleDisableProgrammingMode, this, std::placeholders::_1)
);
this->registerCommandHandler<GetTargetPassthroughHelpText>(
std::bind(&TargetControllerComponent::handleTargetPassthroughHelpText, this, std::placeholders::_1)
);
this->registerCommandHandler<InvokeTargetPassthroughCommand>(
std::bind(&TargetControllerComponent::handleTargetPassthroughCommand, this, std::placeholders::_1)
);
@@ -1180,6 +1186,12 @@ namespace TargetController
return std::make_unique<Response>();
}
std::unique_ptr<TargetPassthroughHelpText> TargetControllerComponent::handleTargetPassthroughHelpText(
GetTargetPassthroughHelpText& command
) {
return std::make_unique<TargetPassthroughHelpText>(this->target->passthroughCommandHelpText());
}
std::unique_ptr<TargetPassthroughResponse> TargetControllerComponent::handleTargetPassthroughCommand(
InvokeTargetPassthroughCommand& command
) {

View File

@@ -45,6 +45,7 @@
#include "Commands/GetTargetProgramCounter.hpp"
#include "Commands/EnableProgrammingMode.hpp"
#include "Commands/DisableProgrammingMode.hpp"
#include "Commands/GetTargetPassthroughHelpText.hpp"
#include "Commands/InvokeTargetPassthroughCommand.hpp"
// Responses
@@ -58,6 +59,7 @@
#include "Responses/TargetStackPointer.hpp"
#include "Responses/TargetProgramCounter.hpp"
#include "Responses/ProgramBreakpoint.hpp"
#include "Responses/TargetPassthroughHelpText.hpp"
#include "Responses/TargetPassthroughResponse.hpp"
#include "src/DebugToolDrivers/DebugTools.hpp"
@@ -381,6 +383,9 @@ namespace TargetController
);
std::unique_ptr<Responses::Response> handleEnableProgrammingMode(Commands::EnableProgrammingMode& command);
std::unique_ptr<Responses::Response> handleDisableProgrammingMode(Commands::DisableProgrammingMode& command);
std::unique_ptr<Responses::TargetPassthroughHelpText> handleTargetPassthroughHelpText(
Commands::GetTargetPassthroughHelpText& command
);
std::unique_ptr<Responses::TargetPassthroughResponse> handleTargetPassthroughCommand(
Commands::InvokeTargetPassthroughCommand& command
);