New TC shutdown command
This commit is contained in:
@@ -25,7 +25,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
if (Services::ProcessService::isManagedByClion()) {
|
if (Services::ProcessService::isManagedByClion()) {
|
||||||
// TODO: Force the TC to shutdown.
|
targetControllerService.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
debugSession.connection.writePacket(OkResponsePacket());
|
debugSession.connection.writePacket(OkResponsePacket());
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include "src/TargetController/Commands/GetTargetProgramCounter.hpp"
|
#include "src/TargetController/Commands/GetTargetProgramCounter.hpp"
|
||||||
#include "src/TargetController/Commands/EnableProgrammingMode.hpp"
|
#include "src/TargetController/Commands/EnableProgrammingMode.hpp"
|
||||||
#include "src/TargetController/Commands/DisableProgrammingMode.hpp"
|
#include "src/TargetController/Commands/DisableProgrammingMode.hpp"
|
||||||
|
#include "src/TargetController/Commands/Shutdown.hpp"
|
||||||
|
|
||||||
namespace Bloom::Services
|
namespace Bloom::Services
|
||||||
{
|
{
|
||||||
@@ -44,6 +45,7 @@ namespace Bloom::Services
|
|||||||
using TargetController::Commands::GetTargetProgramCounter;
|
using TargetController::Commands::GetTargetProgramCounter;
|
||||||
using TargetController::Commands::EnableProgrammingMode;
|
using TargetController::Commands::EnableProgrammingMode;
|
||||||
using TargetController::Commands::DisableProgrammingMode;
|
using TargetController::Commands::DisableProgrammingMode;
|
||||||
|
using TargetController::Commands::Shutdown;
|
||||||
|
|
||||||
using Targets::TargetDescriptor;
|
using Targets::TargetDescriptor;
|
||||||
using Targets::TargetState;
|
using Targets::TargetState;
|
||||||
@@ -239,4 +241,11 @@ namespace Bloom::Services
|
|||||||
this->defaultTimeout
|
this->defaultTimeout
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TargetControllerService::shutdown() const {
|
||||||
|
this->commandManager.sendCommandAndWaitForResponse(
|
||||||
|
std::make_unique<Shutdown>(),
|
||||||
|
this->defaultTimeout
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,6 +187,11 @@ namespace Bloom::Services
|
|||||||
*/
|
*/
|
||||||
void disableProgrammingMode() const;
|
void disableProgrammingMode() const;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces the TargetController to shutdown
|
||||||
|
*/
|
||||||
|
void shutdown() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TargetController::CommandManager commandManager = TargetController::CommandManager();
|
TargetController::CommandManager commandManager = TargetController::CommandManager();
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace Bloom::TargetController::Commands
|
|||||||
enum class CommandType: std::uint8_t
|
enum class CommandType: std::uint8_t
|
||||||
{
|
{
|
||||||
GENERIC,
|
GENERIC,
|
||||||
|
SHUTDOWN,
|
||||||
GET_TARGET_DESCRIPTOR,
|
GET_TARGET_DESCRIPTOR,
|
||||||
STOP_TARGET_EXECUTION,
|
STOP_TARGET_EXECUTION,
|
||||||
RESUME_TARGET_EXECUTION,
|
RESUME_TARGET_EXECUTION,
|
||||||
|
|||||||
21
src/TargetController/Commands/Shutdown.hpp
Normal file
21
src/TargetController/Commands/Shutdown.hpp
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Command.hpp"
|
||||||
|
|
||||||
|
namespace Bloom::TargetController::Commands
|
||||||
|
{
|
||||||
|
class Shutdown: public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr CommandType type = CommandType::SHUTDOWN;
|
||||||
|
static const inline std::string name = "Shutdown";
|
||||||
|
|
||||||
|
[[nodiscard]] CommandType getType() const override {
|
||||||
|
return Shutdown::type;
|
||||||
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] bool requiresDebugMode() const override {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ namespace Bloom::TargetController
|
|||||||
using Commands::CommandIdType;
|
using Commands::CommandIdType;
|
||||||
|
|
||||||
using Commands::Command;
|
using Commands::Command;
|
||||||
|
using Commands::Shutdown;
|
||||||
using Commands::GetTargetDescriptor;
|
using Commands::GetTargetDescriptor;
|
||||||
using Commands::GetTargetState;
|
using Commands::GetTargetState;
|
||||||
using Commands::StopTargetExecution;
|
using Commands::StopTargetExecution;
|
||||||
@@ -139,6 +140,10 @@ namespace Bloom::TargetController
|
|||||||
EventManager::registerListener(this->eventListener);
|
EventManager::registerListener(this->eventListener);
|
||||||
|
|
||||||
// Register command handlers
|
// Register command handlers
|
||||||
|
this->registerCommandHandler<Shutdown>(
|
||||||
|
std::bind(&TargetControllerComponent::handleShutdown, this, std::placeholders::_1)
|
||||||
|
);
|
||||||
|
|
||||||
this->registerCommandHandler<GetTargetDescriptor>(
|
this->registerCommandHandler<GetTargetDescriptor>(
|
||||||
std::bind(&TargetControllerComponent::handleGetTargetDescriptor, this, std::placeholders::_1)
|
std::bind(&TargetControllerComponent::handleGetTargetDescriptor, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
@@ -640,6 +645,11 @@ namespace Bloom::TargetController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Response> TargetControllerComponent::handleShutdown(Shutdown& command) {
|
||||||
|
this->shutdown();
|
||||||
|
return std::make_unique<Response>();
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<Responses::TargetDescriptor> TargetControllerComponent::handleGetTargetDescriptor(
|
std::unique_ptr<Responses::TargetDescriptor> TargetControllerComponent::handleGetTargetDescriptor(
|
||||||
GetTargetDescriptor& command
|
GetTargetDescriptor& command
|
||||||
) {
|
) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
#include "Commands/Command.hpp"
|
#include "Commands/Command.hpp"
|
||||||
|
#include "Commands/Shutdown.hpp"
|
||||||
#include "Commands/GetTargetDescriptor.hpp"
|
#include "Commands/GetTargetDescriptor.hpp"
|
||||||
#include "Commands/GetTargetState.hpp"
|
#include "Commands/GetTargetState.hpp"
|
||||||
#include "Commands/StopTargetExecution.hpp"
|
#include "Commands/StopTargetExecution.hpp"
|
||||||
@@ -303,6 +304,7 @@ namespace Bloom::TargetController
|
|||||||
void onDebugSessionFinishedEvent(const Events::DebugSessionFinished& event);
|
void onDebugSessionFinishedEvent(const Events::DebugSessionFinished& event);
|
||||||
|
|
||||||
// Command handlers
|
// Command handlers
|
||||||
|
std::unique_ptr<Responses::Response> handleShutdown(Commands::Shutdown& command);
|
||||||
std::unique_ptr<Responses::TargetDescriptor> handleGetTargetDescriptor(Commands::GetTargetDescriptor& command);
|
std::unique_ptr<Responses::TargetDescriptor> handleGetTargetDescriptor(Commands::GetTargetDescriptor& command);
|
||||||
std::unique_ptr<Responses::TargetState> handleGetTargetState(Commands::GetTargetState& command);
|
std::unique_ptr<Responses::TargetState> handleGetTargetState(Commands::GetTargetState& command);
|
||||||
std::unique_ptr<Responses::Response> handleStopTargetExecution(Commands::StopTargetExecution& command);
|
std::unique_ptr<Responses::Response> handleStopTargetExecution(Commands::StopTargetExecution& command);
|
||||||
|
|||||||
Reference in New Issue
Block a user