Replaced RetrieveTargetPinStates event with TC command
This commit is contained in:
@@ -32,7 +32,6 @@ namespace Bloom::Events
|
||||
EXTRACT_TARGET_DESCRIPTOR,
|
||||
TARGET_DESCRIPTOR_EXTRACTED,
|
||||
INSIGHT_THREAD_STATE_CHANGED,
|
||||
RETRIEVE_TARGET_PIN_STATES,
|
||||
TARGET_PIN_STATES_RETRIEVED,
|
||||
SET_TARGET_PIN_STATE,
|
||||
RETRIEVE_STACK_POINTER_FROM_TARGET,
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
#include "ExtractTargetDescriptor.hpp"
|
||||
#include "TargetDescriptorExtracted.hpp"
|
||||
#include "InsightThreadStateChanged.hpp"
|
||||
#include "RetrieveTargetPinStates.hpp"
|
||||
#include "TargetPinStatesRetrieved.hpp"
|
||||
#include "SetTargetPinState.hpp"
|
||||
#include "RetrieveStackPointerFromTarget.hpp"
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Event.hpp"
|
||||
#include "TargetPinStatesRetrieved.hpp"
|
||||
|
||||
namespace Bloom::Events
|
||||
{
|
||||
class RetrieveTargetPinStates: public Event
|
||||
{
|
||||
public:
|
||||
using TargetControllerResponseType = TargetPinStatesRetrieved;
|
||||
|
||||
static constexpr EventType type = EventType::RETRIEVE_TARGET_PIN_STATES;
|
||||
static inline const std::string name = "RetrieveTargetPinStates";
|
||||
int variantId = 0;
|
||||
|
||||
[[nodiscard]] EventType getType() const override {
|
||||
return RetrieveTargetPinStates::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string getName() const override {
|
||||
return RetrieveTargetPinStates::name;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -20,5 +20,6 @@ namespace Bloom::TargetController::Commands
|
||||
SET_BREAKPOINT,
|
||||
REMOVE_BREAKPOINT,
|
||||
SET_PROGRAM_COUNTER,
|
||||
GET_TARGET_PIN_STATES,
|
||||
};
|
||||
}
|
||||
|
||||
31
src/TargetController/Commands/GetTargetPinStates.hpp
Normal file
31
src/TargetController/Commands/GetTargetPinStates.hpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#pragma once
|
||||
|
||||
#include "Command.hpp"
|
||||
|
||||
#include "src/TargetController/Responses/TargetPinStates.hpp"
|
||||
|
||||
namespace Bloom::TargetController::Commands
|
||||
{
|
||||
class GetTargetPinStates: public Command
|
||||
{
|
||||
public:
|
||||
using SuccessResponseType = Responses::TargetPinStates;
|
||||
|
||||
static constexpr CommandType type = CommandType::GET_TARGET_PIN_STATES;
|
||||
static inline const std::string name = "GetTargetPinStates";
|
||||
|
||||
int variantId = 0;
|
||||
|
||||
explicit GetTargetPinStates(int variantId)
|
||||
: variantId(variantId)
|
||||
{};
|
||||
|
||||
[[nodiscard]] CommandType getType() const override {
|
||||
return GetTargetPinStates::type;
|
||||
}
|
||||
|
||||
[[nodiscard]] bool requiresStoppedTargetState() const override {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -11,5 +11,6 @@ namespace Bloom::TargetController::Responses
|
||||
TARGET_REGISTERS_READ,
|
||||
TARGET_MEMORY_READ,
|
||||
TARGET_STATE,
|
||||
TARGET_PIN_STATES,
|
||||
};
|
||||
}
|
||||
|
||||
24
src/TargetController/Responses/TargetPinStates.hpp
Normal file
24
src/TargetController/Responses/TargetPinStates.hpp
Normal file
@@ -0,0 +1,24 @@
|
||||
#pragma once
|
||||
|
||||
#include "Response.hpp"
|
||||
|
||||
#include "src/Targets/TargetPinDescriptor.hpp"
|
||||
|
||||
namespace Bloom::TargetController::Responses
|
||||
{
|
||||
class TargetPinStates: public Response
|
||||
{
|
||||
public:
|
||||
static constexpr ResponseType type = ResponseType::TARGET_PIN_STATES;
|
||||
|
||||
Targets::TargetPinStateMappingType pinStatesByNumber;
|
||||
|
||||
explicit TargetPinStates(const Targets::TargetPinStateMappingType& pinStatesByNumber)
|
||||
: pinStatesByNumber(pinStatesByNumber)
|
||||
{}
|
||||
|
||||
[[nodiscard]] ResponseType getType() const override {
|
||||
return TargetPinStates::type;
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -34,10 +34,12 @@ namespace Bloom::TargetController
|
||||
using Commands::SetBreakpoint;
|
||||
using Commands::RemoveBreakpoint;
|
||||
using Commands::SetProgramCounter;
|
||||
using Commands::GetTargetPinStates;
|
||||
|
||||
using Responses::Response;
|
||||
using Responses::TargetRegistersRead;
|
||||
using Responses::TargetMemoryRead;
|
||||
using Responses::TargetPinStates;
|
||||
|
||||
TargetControllerComponent::TargetControllerComponent(
|
||||
const ProjectConfig& projectConfig,
|
||||
@@ -399,11 +401,11 @@ namespace Bloom::TargetController
|
||||
this->deregisterCommandHandler(SetBreakpoint::type);
|
||||
this->deregisterCommandHandler(RemoveBreakpoint::type);
|
||||
this->deregisterCommandHandler(SetProgramCounter::type);
|
||||
this->deregisterCommandHandler(GetTargetPinStates::type);
|
||||
|
||||
this->eventListener->deregisterCallbacksForEventType<Events::DebugSessionFinished>();
|
||||
this->eventListener->deregisterCallbacksForEventType<Events::ExtractTargetDescriptor>();
|
||||
this->eventListener->deregisterCallbacksForEventType<Events::InsightThreadStateChanged>();
|
||||
this->eventListener->deregisterCallbacksForEventType<Events::RetrieveTargetPinStates>();
|
||||
this->eventListener->deregisterCallbacksForEventType<Events::SetTargetPinState>();
|
||||
this->eventListener->deregisterCallbacksForEventType<Events::RetrieveStackPointerFromTarget>();
|
||||
|
||||
@@ -470,6 +472,10 @@ namespace Bloom::TargetController
|
||||
std::bind(&TargetControllerComponent::handleSetProgramCounter, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
this->registerCommandHandler<GetTargetPinStates>(
|
||||
std::bind(&TargetControllerComponent::handleGetTargetPinStates, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
this->eventListener->registerCallbackForEventType<Events::DebugSessionFinished>(
|
||||
std::bind(&TargetControllerComponent::onDebugSessionFinishedEvent, this, std::placeholders::_1)
|
||||
);
|
||||
@@ -478,10 +484,6 @@ namespace Bloom::TargetController
|
||||
std::bind(&TargetControllerComponent::onExtractTargetDescriptor, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
this->eventListener->registerCallbackForEventType<Events::RetrieveTargetPinStates>(
|
||||
std::bind(&TargetControllerComponent::onRetrieveTargetPinStatesEvent, this, std::placeholders::_1)
|
||||
);
|
||||
|
||||
this->eventListener->registerCallbackForEventType<Events::SetTargetPinState>(
|
||||
std::bind(&TargetControllerComponent::onSetPinStateEvent, this, std::placeholders::_1)
|
||||
);
|
||||
@@ -877,25 +879,8 @@ namespace Bloom::TargetController
|
||||
return std::make_unique<Response>();
|
||||
}
|
||||
|
||||
void TargetControllerComponent::onRetrieveTargetPinStatesEvent(const Events::RetrieveTargetPinStates& event) {
|
||||
try {
|
||||
if (this->target->getState() != TargetState::STOPPED) {
|
||||
throw TargetOperationFailure(
|
||||
"Invalid target state - target must be stopped before pin states can be retrieved"
|
||||
);
|
||||
}
|
||||
|
||||
auto pinStatesRetrieved = std::make_shared<Events::TargetPinStatesRetrieved>();
|
||||
pinStatesRetrieved->correlationId = event.id;
|
||||
pinStatesRetrieved->variantId = event.variantId;
|
||||
pinStatesRetrieved->pinSatesByNumber = this->target->getPinStates(event.variantId);
|
||||
|
||||
EventManager::triggerEvent(pinStatesRetrieved);
|
||||
|
||||
} catch (const TargetOperationFailure& exception) {
|
||||
Logger::error("Failed to retrieve target pin states - " + exception.getMessage());
|
||||
this->emitErrorEvent(event.id, exception.getMessage());
|
||||
}
|
||||
std::unique_ptr<TargetPinStates> TargetControllerComponent::handleGetTargetPinStates(GetTargetPinStates& command) {
|
||||
return std::make_unique<TargetPinStates>(this->target->getPinStates(command.variantId));
|
||||
}
|
||||
|
||||
void TargetControllerComponent::onSetPinStateEvent(const Events::SetTargetPinState& event) {
|
||||
|
||||
@@ -30,12 +30,14 @@
|
||||
#include "Commands/SetBreakpoint.hpp"
|
||||
#include "Commands/RemoveBreakpoint.hpp"
|
||||
#include "Commands/SetProgramCounter.hpp"
|
||||
#include "Commands/GetTargetPinStates.hpp"
|
||||
|
||||
// Responses
|
||||
#include "Responses/Response.hpp"
|
||||
#include "Responses/TargetState.hpp"
|
||||
#include "Responses/TargetRegistersRead.hpp"
|
||||
#include "Responses/TargetMemoryRead.hpp"
|
||||
#include "Responses/TargetPinStates.hpp"
|
||||
|
||||
#include "TargetControllerState.hpp"
|
||||
|
||||
@@ -312,13 +314,7 @@ namespace Bloom::TargetController
|
||||
std::unique_ptr<Responses::Response> handleSetBreakpoint(Commands::SetBreakpoint& command);
|
||||
std::unique_ptr<Responses::Response> handleRemoveBreakpoint(Commands::RemoveBreakpoint& command);
|
||||
std::unique_ptr<Responses::Response> handleSetProgramCounter(Commands::SetProgramCounter& command);
|
||||
|
||||
/**
|
||||
* Will attempt to obtain the pin states from the target. Will emit a TargetPinStatesRetrieved event on success.
|
||||
*
|
||||
* @param event
|
||||
*/
|
||||
void onRetrieveTargetPinStatesEvent(const Events::RetrieveTargetPinStates& event);
|
||||
std::unique_ptr<Responses::TargetPinStates> handleGetTargetPinStates(Commands::GetTargetPinStates& command);
|
||||
|
||||
/**
|
||||
* Will update a pin state for a particular pin. Will emit a TargetPinStatesRetrieved with the new pin
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "Commands/SetBreakpoint.hpp"
|
||||
#include "Commands/RemoveBreakpoint.hpp"
|
||||
#include "Commands/SetProgramCounter.hpp"
|
||||
#include "Commands/GetTargetPinStates.hpp"
|
||||
|
||||
#include "src/Logger/Logger.hpp"
|
||||
|
||||
@@ -38,6 +39,7 @@ namespace Bloom::TargetController
|
||||
using Commands::SetBreakpoint;
|
||||
using Commands::RemoveBreakpoint;
|
||||
using Commands::SetProgramCounter;
|
||||
using Commands::GetTargetPinStates;
|
||||
|
||||
TargetControllerConsole::TargetControllerConsole(EventListener& eventListener)
|
||||
: eventListener(eventListener)
|
||||
@@ -166,10 +168,10 @@ namespace Bloom::TargetController
|
||||
}
|
||||
|
||||
Targets::TargetPinStateMappingType TargetControllerConsole::getPinStates(int variantId) {
|
||||
auto requestEvent = std::make_shared<RetrieveTargetPinStates>();
|
||||
requestEvent->variantId = variantId;
|
||||
|
||||
return this->triggerTargetControllerEventAndWaitForResponse(requestEvent)->pinSatesByNumber;
|
||||
return this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<GetTargetPinStates>(variantId),
|
||||
this->defaultTimeout
|
||||
)->pinStatesByNumber;
|
||||
}
|
||||
|
||||
void TargetControllerConsole::setPinState(TargetPinDescriptor pinDescriptor, TargetPinState pinState) {
|
||||
|
||||
Reference in New Issue
Block a user