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

@@ -691,6 +691,10 @@ namespace Targets::Microchip::Avr8
return this->activeProgrammingSession.has_value();
}
std::string Avr8::passthroughCommandHelpText() {
return {};
}
std::optional<PassthroughResponse> Avr8::invokePassthroughCommand(const PassthroughCommand& command) {
// AVR targets do not currently support any passthrough commands
return std::nullopt;

View File

@@ -108,6 +108,7 @@ namespace Targets::Microchip::Avr8
void disableProgrammingMode() override;
bool programmingModeEnabled() override;
std::string passthroughCommandHelpText() override;
std::optional<PassthroughResponse> invokePassthroughCommand(const PassthroughCommand& command) override;
protected:

View File

@@ -351,6 +351,35 @@ namespace Targets::RiscV::Wch
return programCounter;
}
std::string WchRiscV::passthroughCommandHelpText() {
using Services::StringService;
static constexpr auto CMD_COLOR = StringService::TerminalColor::DARK_YELLOW;
static constexpr auto PARAM_COLOR = StringService::TerminalColor::BLUE;
static const auto leftPadding = std::string{std::string::size_type{3}, ' ', std::string::allocator_type{}};
auto output = std::string{};
output += StringService::applyTerminalColor("program_mode", CMD_COLOR) + "\n\n";
output += leftPadding + "Determines the target's current program mode (boot/user).\n\n";
output += StringService::applyTerminalColor("program_mode", CMD_COLOR) + " ["
+ StringService::applyTerminalColor("MODE", PARAM_COLOR) + "]\n\n";
output += leftPadding + "Changes the program mode on the target. Triggers a target reset.\n";
output += leftPadding + "Valid modes: \"boot\" and \"user\".\n\n";
output += leftPadding + "Examples:\n\n";
output += leftPadding + "mon " + StringService::applyTerminalColor("program_mode", CMD_COLOR) + " "
+ StringService::applyTerminalColor("boot", PARAM_COLOR) + "\n";
output += leftPadding + " To switch to boot mode, where the mapped program memory segment aliases the boot"
" segment (key: \"" + this->bootProgramSegmentDescriptor.key + "\").\n\n";
output += leftPadding + "mon " + StringService::applyTerminalColor("program_mode", CMD_COLOR) + " "
+ StringService::applyTerminalColor("user", PARAM_COLOR) + "\n";
output += leftPadding + " To switch to user mode, where the mapped program memory segment aliases the main"
" program segment (key: \"" + this->mainProgramSegmentDescriptor.key + "\").\n";
return output;
}
std::optional<PassthroughResponse> WchRiscV::invokePassthroughCommand(const PassthroughCommand& command) {
using Services::StringService;
@@ -362,7 +391,7 @@ namespace Targets::RiscV::Wch
auto response = PassthroughResponse{};
try {
if (arguments[0] == "pm") {
if (arguments[0] == "program_mode") {
const auto &actualAliasedSegment = this->resolveAliasedMemorySegment();
if (arguments.size() == 1) {

View File

@@ -43,6 +43,7 @@ namespace Targets::RiscV::Wch
TargetMemoryAddress getProgramCounter() override;
std::string passthroughCommandHelpText() override;
std::optional<PassthroughResponse> invokePassthroughCommand(const PassthroughCommand& command) override;
protected:

View File

@@ -155,6 +155,7 @@ namespace Targets
virtual void disableProgrammingMode() = 0;
virtual bool programmingModeEnabled() = 0;
virtual std::string passthroughCommandHelpText() = 0;
virtual std::optional<PassthroughResponse> invokePassthroughCommand(const PassthroughCommand& command) = 0;
};
}