Updated application to code to accomodate changes to TDF format (new pad elements and changes to variant elements)

This commit is contained in:
Nav
2024-08-16 22:50:06 +01:00
parent 129e54dd2d
commit c662e946ca
35 changed files with 534 additions and 311 deletions

View File

@@ -25,8 +25,8 @@ namespace TargetController::Commands
REMOVE_BREAKPOINT,
SET_TARGET_PROGRAM_COUNTER,
SET_TARGET_STACK_POINTER,
GET_TARGET_GPIO_PIN_STATES,
SET_TARGET_GPIO_PIN_STATE,
GET_TARGET_GPIO_PAD_STATES,
SET_TARGET_GPIO_PAD_STATE,
GET_TARGET_STACK_POINTER,
GET_TARGET_PROGRAM_COUNTER,
ENABLE_PROGRAMMING_MODE,

View File

@@ -0,0 +1,32 @@
#pragma once
#include "Command.hpp"
#include "src/TargetController/Responses/TargetGpioPadStates.hpp"
#include "src/Targets/TargetPadDescriptor.hpp"
namespace TargetController::Commands
{
class GetTargetGpioPadStates: public Command
{
public:
using SuccessResponseType = Responses::TargetGpioPadStates;
static constexpr CommandType type = CommandType::GET_TARGET_GPIO_PAD_STATES;
static const inline std::string name = "GetTargetGpioPadStates";
const Targets::TargetPadDescriptors padDescriptors;
explicit GetTargetGpioPadStates(const Targets::TargetPadDescriptors& padDescriptors)
: padDescriptors(padDescriptors)
{};
[[nodiscard]] CommandType getType() const override {
return GetTargetGpioPadStates::type;
}
[[nodiscard]] bool requiresStoppedTargetState() const override {
return true;
}
};
}

View File

@@ -1,31 +0,0 @@
#pragma once
#include "Command.hpp"
#include "src/TargetController/Responses/TargetGpioPinStates.hpp"
namespace TargetController::Commands
{
class GetTargetGpioPinStates: public Command
{
public:
using SuccessResponseType = Responses::TargetGpioPinStates;
static constexpr CommandType type = CommandType::GET_TARGET_GPIO_PIN_STATES;
static const inline std::string name = "GetTargetGpioPinStates";
const Targets::TargetPinoutDescriptor& pinoutDescriptor;
explicit GetTargetGpioPinStates(const Targets::TargetPinoutDescriptor& pinoutDescriptor)
: pinoutDescriptor(pinoutDescriptor)
{};
[[nodiscard]] CommandType getType() const override {
return GetTargetGpioPinStates::type;
}
[[nodiscard]] bool requiresStoppedTargetState() const override {
return true;
}
};
}

View File

@@ -0,0 +1,35 @@
#pragma once
#include "Command.hpp"
#include "src/Targets/TargetPadDescriptor.hpp"
#include "src/Targets/TargetGpioPadState.hpp"
namespace TargetController::Commands
{
class SetTargetGpioPadState: public Command
{
public:
static constexpr CommandType type = CommandType::SET_TARGET_GPIO_PAD_STATE;
static const inline std::string name = "SetTargetGpioPadState";
const Targets::TargetPadDescriptor& padDescriptor;
Targets::TargetGpioPadState state;
SetTargetGpioPadState(
const Targets::TargetPadDescriptor& padDescriptor,
const Targets::TargetGpioPadState& state
)
: padDescriptor(padDescriptor)
, state(state)
{};
[[nodiscard]] CommandType getType() const override {
return SetTargetGpioPadState::type;
}
[[nodiscard]] bool requiresStoppedTargetState() const override {
return true;
}
};
}

View File

@@ -1,35 +0,0 @@
#pragma once
#include "Command.hpp"
#include "src/Targets/TargetPinDescriptor.hpp"
#include "src/Targets/TargetGpioPinState.hpp"
namespace TargetController::Commands
{
class SetTargetGpioPinState: public Command
{
public:
static constexpr CommandType type = CommandType::SET_TARGET_GPIO_PIN_STATE;
static const inline std::string name = "SetTargetGpioPinState";
const Targets::TargetPinDescriptor& pinDescriptor;
Targets::TargetGpioPinState state;
SetTargetGpioPinState(
const Targets::TargetPinDescriptor& pinDescriptor,
const Targets::TargetGpioPinState& state
)
: pinDescriptor(pinDescriptor)
, state(state)
{};
[[nodiscard]] CommandType getType() const override {
return SetTargetGpioPinState::type;
}
[[nodiscard]] bool requiresStoppedTargetState() const override {
return true;
}
};
}

View File

@@ -13,7 +13,7 @@ namespace TargetController::Responses
TARGET_REGISTERS_READ,
TARGET_MEMORY_READ,
TARGET_STATE,
TARGET_GPIO_PIN_STATES,
TARGET_GPIO_PAD_STATES,
TARGET_STACK_POINTER,
TARGET_PROGRAM_COUNTER,
BREAKPOINT,

View File

@@ -0,0 +1,29 @@
#pragma once
#include <vector>
#include "Response.hpp"
#include "src/Targets/TargetPinDescriptor.hpp"
#include "src/Targets/TargetGpioPadState.hpp"
#include "src/Helpers/Pair.hpp"
namespace TargetController::Responses
{
class TargetGpioPadStates: public Response
{
public:
static constexpr ResponseType type = ResponseType::TARGET_GPIO_PAD_STATES;
Targets::TargetGpioPadDescriptorAndStatePairs gpioPadStates;
explicit TargetGpioPadStates(const Targets::TargetGpioPadDescriptorAndStatePairs& gpioPadStates)
: gpioPadStates(gpioPadStates)
{}
[[nodiscard]] ResponseType getType() const override {
return TargetGpioPadStates::type;
}
};
}

View File

@@ -1,29 +0,0 @@
#pragma once
#include <vector>
#include "Response.hpp"
#include "src/Targets/TargetPinDescriptor.hpp"
#include "src/Targets/TargetGpioPinState.hpp"
#include "src/Helpers/Pair.hpp"
namespace TargetController::Responses
{
class TargetGpioPinStates: public Response
{
public:
static constexpr ResponseType type = ResponseType::TARGET_GPIO_PIN_STATES;
Targets::TargetGpioPinDescriptorAndStatePairs gpioPinStates;
explicit TargetGpioPinStates(const Targets::TargetGpioPinDescriptorAndStatePairs& gpioPinStates)
: gpioPinStates(gpioPinStates)
{}
[[nodiscard]] ResponseType getType() const override {
return TargetGpioPinStates::type;
}
};
}

View File

@@ -44,8 +44,8 @@ namespace TargetController
using Commands::RemoveBreakpoint;
using Commands::SetTargetProgramCounter;
using Commands::SetTargetStackPointer;
using Commands::GetTargetGpioPinStates;
using Commands::SetTargetGpioPinState;
using Commands::GetTargetGpioPadStates;
using Commands::SetTargetGpioPadState;
using Commands::GetTargetStackPointer;
using Commands::GetTargetProgramCounter;
using Commands::EnableProgrammingMode;
@@ -55,7 +55,7 @@ namespace TargetController
using Responses::AtomicSessionId;
using Responses::TargetRegistersRead;
using Responses::TargetMemoryRead;
using Responses::TargetGpioPinStates;
using Responses::TargetGpioPadStates;
using Responses::TargetStackPointer;
using Responses::TargetProgramCounter;
using Responses::Breakpoint;
@@ -233,12 +233,12 @@ namespace TargetController
std::bind(&TargetControllerComponent::handleSetProgramCounter, this, std::placeholders::_1)
);
this->registerCommandHandler<GetTargetGpioPinStates>(
std::bind(&TargetControllerComponent::handleGetTargetGpioPinStates, this, std::placeholders::_1)
this->registerCommandHandler<GetTargetGpioPadStates>(
std::bind(&TargetControllerComponent::handleGetTargetGpioPadStates, this, std::placeholders::_1)
);
this->registerCommandHandler<SetTargetGpioPinState>(
std::bind(&TargetControllerComponent::handleSetTargetGpioPinState, this, std::placeholders::_1)
this->registerCommandHandler<SetTargetGpioPadState>(
std::bind(&TargetControllerComponent::handleSetTargetGpioPadState, this, std::placeholders::_1)
);
this->registerCommandHandler<GetTargetStackPointer>(
@@ -1007,7 +1007,7 @@ namespace TargetController
return std::make_unique<Response>();
}
std::unique_ptr<Response> TargetControllerComponent::handleStepTargetExecution(StepTargetExecution& command) {
std::unique_ptr<Response> TargetControllerComponent::handleStepTargetExecution(StepTargetExecution&) {
this->stepTarget();
return std::make_unique<Response>();
}
@@ -1053,14 +1053,14 @@ namespace TargetController
return std::make_unique<Response>();
}
std::unique_ptr<TargetGpioPinStates> TargetControllerComponent::handleGetTargetGpioPinStates(
GetTargetGpioPinStates& command
std::unique_ptr<TargetGpioPadStates> TargetControllerComponent::handleGetTargetGpioPadStates(
GetTargetGpioPadStates& command
) {
return std::make_unique<TargetGpioPinStates>(this->target->getGpioPinStates(command.pinoutDescriptor));
return std::make_unique<TargetGpioPadStates>(this->target->getGpioPadStates(command.padDescriptors));
}
std::unique_ptr<Response> TargetControllerComponent::handleSetTargetGpioPinState(SetTargetGpioPinState& command) {
this->target->setGpioPinState(command.pinDescriptor, command.state);
std::unique_ptr<Response> TargetControllerComponent::handleSetTargetGpioPadState(SetTargetGpioPadState& command) {
this->target->setGpioPadState(command.padDescriptor, command.state);
return std::make_unique<Response>();
}
@@ -1076,7 +1076,7 @@ namespace TargetController
return std::make_unique<TargetProgramCounter>(this->target->getProgramCounter());
}
std::unique_ptr<Response> TargetControllerComponent::handleEnableProgrammingMode(EnableProgrammingMode& command) {
std::unique_ptr<Response> TargetControllerComponent::handleEnableProgrammingMode(EnableProgrammingMode&) {
if (!this->target->programmingModeEnabled()) {
this->enableProgrammingMode();
}
@@ -1084,7 +1084,7 @@ namespace TargetController
return std::make_unique<Response>();
}
std::unique_ptr<Response> TargetControllerComponent::handleDisableProgrammingMode(DisableProgrammingMode& command) {
std::unique_ptr<Response> TargetControllerComponent::handleDisableProgrammingMode(DisableProgrammingMode&) {
if (this->target->programmingModeEnabled()) {
this->disableProgrammingMode();
}

View File

@@ -39,8 +39,8 @@
#include "Commands/RemoveBreakpoint.hpp"
#include "Commands/SetTargetProgramCounter.hpp"
#include "Commands/SetTargetStackPointer.hpp"
#include "Commands/GetTargetGpioPinStates.hpp"
#include "Commands/SetTargetGpioPinState.hpp"
#include "Commands/GetTargetGpioPadStates.hpp"
#include "Commands/SetTargetGpioPadState.hpp"
#include "Commands/GetTargetStackPointer.hpp"
#include "Commands/GetTargetProgramCounter.hpp"
#include "Commands/EnableProgrammingMode.hpp"
@@ -53,7 +53,7 @@
#include "Responses/TargetState.hpp"
#include "Responses/TargetRegistersRead.hpp"
#include "Responses/TargetMemoryRead.hpp"
#include "Responses/TargetGpioPinStates.hpp"
#include "Responses/TargetGpioPadStates.hpp"
#include "Responses/TargetStackPointer.hpp"
#include "Responses/TargetProgramCounter.hpp"
#include "Responses/Breakpoint.hpp"
@@ -369,10 +369,10 @@ namespace TargetController
std::unique_ptr<Responses::Response> handleRemoveBreakpoint(Commands::RemoveBreakpoint& command);
std::unique_ptr<Responses::Response> handleSetProgramCounter(Commands::SetTargetProgramCounter& command);
std::unique_ptr<Responses::Response> handleSetStackPointer(Commands::SetTargetStackPointer& command);
std::unique_ptr<Responses::TargetGpioPinStates> handleGetTargetGpioPinStates(
Commands::GetTargetGpioPinStates& command
std::unique_ptr<Responses::TargetGpioPadStates> handleGetTargetGpioPadStates(
Commands::GetTargetGpioPadStates& command
);
std::unique_ptr<Responses::Response> handleSetTargetGpioPinState(Commands::SetTargetGpioPinState& command);
std::unique_ptr<Responses::Response> handleSetTargetGpioPadState(Commands::SetTargetGpioPadState& command);
std::unique_ptr<Responses::TargetStackPointer> handleGetTargetStackPointer(
Commands::GetTargetStackPointer& command
);