New GetTargetState TargetController command
This commit is contained in:
@@ -14,5 +14,6 @@ namespace Bloom::TargetController::Commands
|
|||||||
READ_TARGET_REGISTERS,
|
READ_TARGET_REGISTERS,
|
||||||
WRITE_TARGET_REGISTERS,
|
WRITE_TARGET_REGISTERS,
|
||||||
READ_TARGET_MEMORY,
|
READ_TARGET_MEMORY,
|
||||||
|
GET_TARGET_STATE,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
20
src/TargetController/Commands/GetTargetState.hpp
Normal file
20
src/TargetController/Commands/GetTargetState.hpp
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Command.hpp"
|
||||||
|
#include "src/TargetController/Responses/TargetState.hpp"
|
||||||
|
|
||||||
|
namespace Bloom::TargetController::Commands
|
||||||
|
{
|
||||||
|
class GetTargetState: public Command
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using SuccessResponseType = Responses::TargetState;
|
||||||
|
|
||||||
|
static constexpr CommandType type = CommandType::GET_TARGET_STATE;
|
||||||
|
static inline const std::string name = "GetTargetState";
|
||||||
|
|
||||||
|
[[nodiscard]] CommandType getType() const override {
|
||||||
|
return GetTargetState::type;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -10,5 +10,6 @@ namespace Bloom::TargetController::Responses
|
|||||||
ERROR,
|
ERROR,
|
||||||
TARGET_REGISTERS_READ,
|
TARGET_REGISTERS_READ,
|
||||||
TARGET_MEMORY_READ,
|
TARGET_MEMORY_READ,
|
||||||
|
TARGET_STATE,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
24
src/TargetController/Responses/TargetState.hpp
Normal file
24
src/TargetController/Responses/TargetState.hpp
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "Response.hpp"
|
||||||
|
|
||||||
|
#include "src/Targets/TargetState.hpp"
|
||||||
|
|
||||||
|
namespace Bloom::TargetController::Responses
|
||||||
|
{
|
||||||
|
class TargetState: public Response
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
static constexpr ResponseType type = ResponseType::TARGET_STATE;
|
||||||
|
|
||||||
|
Targets::TargetState targetState;
|
||||||
|
|
||||||
|
TargetState(Targets::TargetState targetState)
|
||||||
|
: targetState(targetState)
|
||||||
|
{}
|
||||||
|
|
||||||
|
[[nodiscard]] ResponseType getType() const override {
|
||||||
|
return TargetState::type;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ namespace Bloom::TargetController
|
|||||||
|
|
||||||
using Commands::Command;
|
using Commands::Command;
|
||||||
using Commands::CommandIdType;
|
using Commands::CommandIdType;
|
||||||
|
using Commands::GetTargetState;
|
||||||
using Commands::StopTargetExecution;
|
using Commands::StopTargetExecution;
|
||||||
using Commands::ResumeTargetExecution;
|
using Commands::ResumeTargetExecution;
|
||||||
using Commands::ResetTarget;
|
using Commands::ResetTarget;
|
||||||
@@ -376,6 +377,7 @@ namespace Bloom::TargetController
|
|||||||
+ std::string(exception.what()));
|
+ std::string(exception.what()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this->deregisterCommandHandler(GetTargetState::type);
|
||||||
this->deregisterCommandHandler(StopTargetExecution::type);
|
this->deregisterCommandHandler(StopTargetExecution::type);
|
||||||
this->deregisterCommandHandler(ResumeTargetExecution::type);
|
this->deregisterCommandHandler(ResumeTargetExecution::type);
|
||||||
this->deregisterCommandHandler(ResetTarget::type);
|
this->deregisterCommandHandler(ResetTarget::type);
|
||||||
@@ -410,6 +412,10 @@ namespace Bloom::TargetController
|
|||||||
this->acquireHardware();
|
this->acquireHardware();
|
||||||
this->loadRegisterDescriptors();
|
this->loadRegisterDescriptors();
|
||||||
|
|
||||||
|
this->registerCommandHandler<GetTargetState>(
|
||||||
|
std::bind(&TargetControllerComponent::handleGetTargetState, this, std::placeholders::_1)
|
||||||
|
);
|
||||||
|
|
||||||
this->registerCommandHandler<StopTargetExecution>(
|
this->registerCommandHandler<StopTargetExecution>(
|
||||||
std::bind(&TargetControllerComponent::handleStopTargetExecution, this, std::placeholders::_1)
|
std::bind(&TargetControllerComponent::handleStopTargetExecution, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
@@ -462,10 +468,6 @@ namespace Bloom::TargetController
|
|||||||
std::bind(&TargetControllerComponent::onSetProgramCounterEvent, this, std::placeholders::_1)
|
std::bind(&TargetControllerComponent::onSetProgramCounterEvent, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
|
|
||||||
this->eventListener->registerCallbackForEventType<Events::InsightThreadStateChanged>(
|
|
||||||
std::bind(&TargetControllerComponent::onInsightStateChangedEvent, this, std::placeholders::_1)
|
|
||||||
);
|
|
||||||
|
|
||||||
this->eventListener->registerCallbackForEventType<Events::RetrieveTargetPinStates>(
|
this->eventListener->registerCallbackForEventType<Events::RetrieveTargetPinStates>(
|
||||||
std::bind(&TargetControllerComponent::onRetrieveTargetPinStatesEvent, this, std::placeholders::_1)
|
std::bind(&TargetControllerComponent::onRetrieveTargetPinStatesEvent, this, std::placeholders::_1)
|
||||||
);
|
);
|
||||||
@@ -726,6 +728,10 @@ namespace Bloom::TargetController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<Responses::TargetState> TargetControllerComponent::handleGetTargetState(GetTargetState& command) {
|
||||||
|
return std::make_unique<Responses::TargetState>(this->target->getState());
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<Response> TargetControllerComponent::handleStopTargetExecution(StopTargetExecution& command) {
|
std::unique_ptr<Response> TargetControllerComponent::handleStopTargetExecution(StopTargetExecution& command) {
|
||||||
if (this->target->getState() != TargetState::STOPPED) {
|
if (this->target->getState() != TargetState::STOPPED) {
|
||||||
this->target->stop();
|
this->target->stop();
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
#include "Commands/Command.hpp"
|
#include "Commands/Command.hpp"
|
||||||
|
#include "Commands/GetTargetState.hpp"
|
||||||
#include "Commands/StopTargetExecution.hpp"
|
#include "Commands/StopTargetExecution.hpp"
|
||||||
#include "Commands/ResumeTargetExecution.hpp"
|
#include "Commands/ResumeTargetExecution.hpp"
|
||||||
#include "Commands/ResetTarget.hpp"
|
#include "Commands/ResetTarget.hpp"
|
||||||
@@ -27,6 +28,7 @@
|
|||||||
|
|
||||||
// Responses
|
// Responses
|
||||||
#include "Responses/Response.hpp"
|
#include "Responses/Response.hpp"
|
||||||
|
#include "Responses/TargetState.hpp"
|
||||||
#include "Responses/TargetRegistersRead.hpp"
|
#include "Responses/TargetRegistersRead.hpp"
|
||||||
#include "Responses/TargetMemoryRead.hpp"
|
#include "Responses/TargetMemoryRead.hpp"
|
||||||
|
|
||||||
@@ -291,6 +293,7 @@ namespace Bloom::TargetController
|
|||||||
*/
|
*/
|
||||||
void onDebugSessionFinishedEvent(const Events::DebugSessionFinished& event);
|
void onDebugSessionFinishedEvent(const Events::DebugSessionFinished& event);
|
||||||
|
|
||||||
|
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);
|
||||||
std::unique_ptr<Responses::Response> handleResumeTargetExecution(Commands::ResumeTargetExecution& command);
|
std::unique_ptr<Responses::Response> handleResumeTargetExecution(Commands::ResumeTargetExecution& command);
|
||||||
std::unique_ptr<Responses::Response> handleResetTarget(Commands::ResetTarget& command);
|
std::unique_ptr<Responses::Response> handleResetTarget(Commands::ResetTarget& command);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "TargetControllerComponent.hpp"
|
#include "TargetControllerComponent.hpp"
|
||||||
|
|
||||||
// Commands
|
// Commands
|
||||||
|
#include "Commands/GetTargetState.hpp"
|
||||||
#include "Commands/StopTargetExecution.hpp"
|
#include "Commands/StopTargetExecution.hpp"
|
||||||
#include "Commands/ResumeTargetExecution.hpp"
|
#include "Commands/ResumeTargetExecution.hpp"
|
||||||
#include "Commands/ResetTarget.hpp"
|
#include "Commands/ResetTarget.hpp"
|
||||||
@@ -20,6 +21,7 @@ namespace Bloom::TargetController
|
|||||||
using namespace Bloom::Events;
|
using namespace Bloom::Events;
|
||||||
using namespace Bloom::Exceptions;
|
using namespace Bloom::Exceptions;
|
||||||
|
|
||||||
|
using Commands::GetTargetState;
|
||||||
using Commands::StopTargetExecution;
|
using Commands::StopTargetExecution;
|
||||||
using Commands::ResumeTargetExecution;
|
using Commands::ResumeTargetExecution;
|
||||||
using Commands::ResetTarget;
|
using Commands::ResetTarget;
|
||||||
@@ -50,6 +52,13 @@ namespace Bloom::TargetController
|
|||||||
)->targetDescriptor;
|
)->targetDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Targets::TargetState TargetControllerConsole::getTargetState() {
|
||||||
|
return this->commandManager.sendCommandAndWaitForResponse(
|
||||||
|
std::make_unique<GetTargetState>(),
|
||||||
|
this->defaultTimeout
|
||||||
|
)->targetState;
|
||||||
|
}
|
||||||
|
|
||||||
void TargetControllerConsole::stopTargetExecution() {
|
void TargetControllerConsole::stopTargetExecution() {
|
||||||
this->commandManager.sendCommandAndWaitForResponse(
|
this->commandManager.sendCommandAndWaitForResponse(
|
||||||
std::make_unique<StopTargetExecution>(),
|
std::make_unique<StopTargetExecution>(),
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
#include "src/EventManager/EventListener.hpp"
|
#include "src/EventManager/EventListener.hpp"
|
||||||
#include "src/EventManager/EventManager.hpp"
|
#include "src/EventManager/EventManager.hpp"
|
||||||
|
|
||||||
|
#include "src/Targets/TargetState.hpp"
|
||||||
#include "src/Targets/TargetRegister.hpp"
|
#include "src/Targets/TargetRegister.hpp"
|
||||||
#include "src/Targets/TargetMemory.hpp"
|
#include "src/Targets/TargetMemory.hpp"
|
||||||
#include "src/Targets/TargetBreakpoint.hpp"
|
#include "src/Targets/TargetBreakpoint.hpp"
|
||||||
#include "src/Targets/TargetVariant.hpp"
|
#include "src/Targets/TargetVariant.hpp"
|
||||||
#include "src/Targets/TargetState.hpp"
|
|
||||||
#include "src/Targets/TargetPinDescriptor.hpp"
|
#include "src/Targets/TargetPinDescriptor.hpp"
|
||||||
|
|
||||||
#include "src/Exceptions/Exception.hpp"
|
#include "src/Exceptions/Exception.hpp"
|
||||||
@@ -58,6 +58,13 @@ namespace Bloom::TargetController
|
|||||||
*/
|
*/
|
||||||
Targets::TargetDescriptor getTargetDescriptor();
|
Targets::TargetDescriptor getTargetDescriptor();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetches the current target state.
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
Targets::TargetState getTargetState();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests the TargetController to halt execution on the target.
|
* Requests the TargetController to halt execution on the target.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user