Tidying
This commit is contained in:
@@ -84,7 +84,7 @@ void SetBreakpoint::handle(DebugSession& debugSession, TargetControllerService&
|
||||
Logger::debug("Handling SetBreakpoint packet");
|
||||
|
||||
try {
|
||||
targetControllerServicesetBreakpoint(TargetBreakpoint(this->address));
|
||||
targetControllerService.setBreakpoint(TargetBreakpoint(this->address));
|
||||
debugSession.connection.writePacket(OkResponsePacket());
|
||||
|
||||
} catch (const Exception& exception) {
|
||||
|
||||
@@ -73,14 +73,14 @@ namespace Bloom::Services
|
||||
using Targets::TargetPinState;
|
||||
using Targets::TargetPinStateMapping;
|
||||
|
||||
TargetControllerState TargetControllerService::getTargetControllerState() {
|
||||
TargetControllerState TargetControllerService::getTargetControllerState() const {
|
||||
return this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<GetState>(),
|
||||
this->defaultTimeout
|
||||
)->state;
|
||||
}
|
||||
|
||||
bool TargetControllerService::isTargetControllerInService() noexcept {
|
||||
bool TargetControllerService::isTargetControllerInService() const noexcept {
|
||||
try {
|
||||
return this->getTargetControllerState() == TargetControllerState::ACTIVE;
|
||||
|
||||
@@ -89,7 +89,7 @@ namespace Bloom::Services
|
||||
}
|
||||
}
|
||||
|
||||
void TargetControllerService::resumeTargetController() {
|
||||
void TargetControllerService::resumeTargetController() const {
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<Resume>(),
|
||||
this->defaultTimeout
|
||||
@@ -97,7 +97,7 @@ namespace Bloom::Services
|
||||
return;
|
||||
}
|
||||
|
||||
void TargetControllerService::suspendTargetController() {
|
||||
void TargetControllerService::suspendTargetController() const {
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<Suspend>(),
|
||||
this->defaultTimeout
|
||||
@@ -105,28 +105,28 @@ namespace Bloom::Services
|
||||
return;
|
||||
}
|
||||
|
||||
const TargetDescriptor& TargetControllerService::getTargetDescriptor() {
|
||||
const TargetDescriptor& TargetControllerService::getTargetDescriptor() const {
|
||||
return this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<GetTargetDescriptor>(),
|
||||
this->defaultTimeout
|
||||
)->targetDescriptor;
|
||||
}
|
||||
|
||||
TargetState TargetControllerService::getTargetState() {
|
||||
TargetState TargetControllerService::getTargetState() const {
|
||||
return this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<GetTargetState>(),
|
||||
this->defaultTimeout
|
||||
)->targetState;
|
||||
}
|
||||
|
||||
void TargetControllerService::stopTargetExecution() {
|
||||
void TargetControllerService::stopTargetExecution() const {
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<StopTargetExecution>(),
|
||||
this->defaultTimeout
|
||||
);
|
||||
}
|
||||
|
||||
void TargetControllerService::continueTargetExecution(std::optional<TargetProgramCounter> fromAddress) {
|
||||
void TargetControllerService::continueTargetExecution(std::optional<TargetProgramCounter> fromAddress) const {
|
||||
auto resumeExecutionCommand = std::make_unique<ResumeTargetExecution>();
|
||||
|
||||
if (fromAddress.has_value()) {
|
||||
@@ -139,7 +139,7 @@ namespace Bloom::Services
|
||||
);
|
||||
}
|
||||
|
||||
void TargetControllerService::stepTargetExecution(std::optional<TargetProgramCounter> fromAddress) {
|
||||
void TargetControllerService::stepTargetExecution(std::optional<TargetProgramCounter> fromAddress) const {
|
||||
auto stepExecutionCommand = std::make_unique<StepTargetExecution>();
|
||||
|
||||
if (fromAddress.has_value()) {
|
||||
@@ -152,14 +152,14 @@ namespace Bloom::Services
|
||||
);
|
||||
}
|
||||
|
||||
TargetRegisters TargetControllerService::readRegisters(const TargetRegisterDescriptors& descriptors) {
|
||||
TargetRegisters TargetControllerService::readRegisters(const TargetRegisterDescriptors& descriptors) const {
|
||||
return this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<ReadTargetRegisters>(descriptors),
|
||||
this->defaultTimeout
|
||||
)->registers;
|
||||
}
|
||||
|
||||
void TargetControllerService::writeRegisters(const TargetRegisters& registers) {
|
||||
void TargetControllerService::writeRegisters(const TargetRegisters& registers) const {
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<WriteTargetRegisters>(registers),
|
||||
this->defaultTimeout
|
||||
@@ -171,7 +171,7 @@ namespace Bloom::Services
|
||||
TargetMemoryAddress startAddress,
|
||||
TargetMemorySize bytes,
|
||||
const std::set<TargetMemoryAddressRange>& excludedAddressRanges
|
||||
) {
|
||||
) const {
|
||||
return this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<ReadTargetMemory>(
|
||||
memoryType,
|
||||
@@ -187,84 +187,84 @@ namespace Bloom::Services
|
||||
TargetMemoryType memoryType,
|
||||
TargetMemoryAddress startAddress,
|
||||
const TargetMemoryBuffer& buffer
|
||||
) {
|
||||
) const {
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<WriteTargetMemory>(memoryType, startAddress, buffer),
|
||||
this->defaultTimeout
|
||||
);
|
||||
}
|
||||
|
||||
void TargetControllerService::eraseMemory(Targets::TargetMemoryType memoryType) {
|
||||
void TargetControllerService::eraseMemory(Targets::TargetMemoryType memoryType) const {
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<EraseTargetMemory>(memoryType),
|
||||
this->defaultTimeout
|
||||
);
|
||||
}
|
||||
|
||||
void TargetControllerService::setBreakpoint(TargetBreakpoint breakpoint) {
|
||||
void TargetControllerService::setBreakpoint(TargetBreakpoint breakpoint) const {
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<SetBreakpoint>(breakpoint),
|
||||
this->defaultTimeout
|
||||
);
|
||||
}
|
||||
|
||||
void TargetControllerService::removeBreakpoint(TargetBreakpoint breakpoint) {
|
||||
void TargetControllerService::removeBreakpoint(TargetBreakpoint breakpoint) const {
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<RemoveBreakpoint>(breakpoint),
|
||||
this->defaultTimeout
|
||||
);
|
||||
}
|
||||
|
||||
TargetProgramCounter TargetControllerService::getProgramCounter() {
|
||||
TargetProgramCounter TargetControllerService::getProgramCounter() const {
|
||||
return this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<GetTargetProgramCounter>(),
|
||||
this->defaultTimeout
|
||||
)->programCounter;
|
||||
}
|
||||
|
||||
void TargetControllerService::setProgramCounter(TargetProgramCounter address) {
|
||||
void TargetControllerService::setProgramCounter(TargetProgramCounter address) const {
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<SetTargetProgramCounter>(address),
|
||||
this->defaultTimeout
|
||||
);
|
||||
}
|
||||
|
||||
TargetPinStateMapping TargetControllerService::getPinStates(int variantId) {
|
||||
TargetPinStateMapping TargetControllerService::getPinStates(int variantId) const {
|
||||
return this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<GetTargetPinStates>(variantId),
|
||||
this->defaultTimeout
|
||||
)->pinStatesByNumber;
|
||||
}
|
||||
|
||||
void TargetControllerService::setPinState(TargetPinDescriptor pinDescriptor, TargetPinState pinState) {
|
||||
void TargetControllerService::setPinState(TargetPinDescriptor pinDescriptor, TargetPinState pinState) const {
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<SetTargetPinState>(pinDescriptor, pinState),
|
||||
this->defaultTimeout
|
||||
);
|
||||
}
|
||||
|
||||
TargetStackPointer TargetControllerService::getStackPointer() {
|
||||
TargetStackPointer TargetControllerService::getStackPointer() const {
|
||||
return this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<GetTargetStackPointer>(),
|
||||
this->defaultTimeout
|
||||
)->stackPointer;
|
||||
}
|
||||
|
||||
void TargetControllerService::resetTarget() {
|
||||
void TargetControllerService::resetTarget() const {
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<ResetTarget>(),
|
||||
this->defaultTimeout
|
||||
);
|
||||
}
|
||||
|
||||
void TargetControllerService::enableProgrammingMode() {
|
||||
void TargetControllerService::enableProgrammingMode() const {
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<EnableProgrammingMode>(),
|
||||
this->defaultTimeout
|
||||
);
|
||||
}
|
||||
|
||||
void TargetControllerService::disableProgrammingMode() {
|
||||
void TargetControllerService::disableProgrammingMode() const {
|
||||
this->commandManager.sendCommandAndWaitForResponse(
|
||||
std::make_unique<DisableProgrammingMode>(),
|
||||
this->defaultTimeout
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Bloom::Services
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
TargetController::TargetControllerState getTargetControllerState();
|
||||
TargetController::TargetControllerState getTargetControllerState() const;
|
||||
|
||||
/**
|
||||
* Retrieves the TargetController state and checks if it's currently active.
|
||||
@@ -47,50 +47,50 @@ namespace Bloom::Services
|
||||
* @return
|
||||
* True if the TargetController is currently in an active state, otherwise false.
|
||||
*/
|
||||
bool isTargetControllerInService() noexcept;
|
||||
bool isTargetControllerInService() const noexcept;
|
||||
|
||||
/**
|
||||
* Resumes the TargetController if it's suspended. Otherwise, this function does nothing.
|
||||
*/
|
||||
void resumeTargetController();
|
||||
void resumeTargetController() const;
|
||||
|
||||
/**
|
||||
* Suspends the TargetController if it's active. Otherwise, this function does nothing.
|
||||
*/
|
||||
void suspendTargetController();
|
||||
void suspendTargetController() const;
|
||||
|
||||
/**
|
||||
* Requests the TargetDescriptor from the TargetController
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
const Targets::TargetDescriptor& getTargetDescriptor();
|
||||
const Targets::TargetDescriptor& getTargetDescriptor() const;
|
||||
|
||||
/**
|
||||
* Fetches the current target state.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Targets::TargetState getTargetState();
|
||||
Targets::TargetState getTargetState() const;
|
||||
|
||||
/**
|
||||
* Requests the TargetController to halt execution on the target.
|
||||
*/
|
||||
void stopTargetExecution();
|
||||
void stopTargetExecution() const;
|
||||
|
||||
/**
|
||||
* Requests the TargetController to continue execution on the target.
|
||||
*
|
||||
* @param fromAddress
|
||||
*/
|
||||
void continueTargetExecution(std::optional<Targets::TargetProgramCounter> fromAddress);
|
||||
void continueTargetExecution(std::optional<Targets::TargetProgramCounter> fromAddress) const;
|
||||
|
||||
/**
|
||||
* Requests the TargetController to step execution on the target.
|
||||
*
|
||||
* @param fromAddress
|
||||
*/
|
||||
void stepTargetExecution(std::optional<Targets::TargetProgramCounter> fromAddress);
|
||||
void stepTargetExecution(std::optional<Targets::TargetProgramCounter> fromAddress) const;
|
||||
|
||||
/**
|
||||
* Requests the TargetController to read register values from the target.
|
||||
@@ -100,14 +100,14 @@ namespace Bloom::Services
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Targets::TargetRegisters readRegisters(const Targets::TargetRegisterDescriptors& descriptors);
|
||||
Targets::TargetRegisters readRegisters(const Targets::TargetRegisterDescriptors& descriptors) const;
|
||||
|
||||
/**
|
||||
* Requests the TargetController to write register values to the target.
|
||||
*
|
||||
* @param registers
|
||||
*/
|
||||
void writeRegisters(const Targets::TargetRegisters& registers);
|
||||
void writeRegisters(const Targets::TargetRegisters& registers) const;
|
||||
|
||||
/**
|
||||
* Requests the TargetController to read memory from the target.
|
||||
@@ -123,7 +123,7 @@ namespace Bloom::Services
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
Targets::TargetMemorySize bytes,
|
||||
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
|
||||
);
|
||||
) const;
|
||||
|
||||
/**
|
||||
* Requests the TargetController to write memory to the target.
|
||||
@@ -136,49 +136,49 @@ namespace Bloom::Services
|
||||
Targets::TargetMemoryType memoryType,
|
||||
Targets::TargetMemoryAddress startAddress,
|
||||
const Targets::TargetMemoryBuffer& buffer
|
||||
);
|
||||
) const;
|
||||
|
||||
/**
|
||||
* Requests the TargetController to erase the given target memory type.
|
||||
*
|
||||
* @param memoryType
|
||||
*/
|
||||
void eraseMemory(Targets::TargetMemoryType memoryType);
|
||||
void eraseMemory(Targets::TargetMemoryType memoryType) const;
|
||||
|
||||
/**
|
||||
* Requests the TargetController to set a breakpoint on the target.
|
||||
*
|
||||
* @param breakpoint
|
||||
*/
|
||||
void setBreakpoint(Targets::TargetBreakpoint breakpoint);
|
||||
void setBreakpoint(Targets::TargetBreakpoint breakpoint) const;
|
||||
|
||||
/**
|
||||
* Requests the TargetController to remove a breakpoint from the target.
|
||||
*
|
||||
* @param breakpoint
|
||||
*/
|
||||
void removeBreakpoint(Targets::TargetBreakpoint breakpoint);
|
||||
void removeBreakpoint(Targets::TargetBreakpoint breakpoint) const;
|
||||
|
||||
/**
|
||||
* Retrieves the current program counter value from the target.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Targets::TargetProgramCounter getProgramCounter();
|
||||
Targets::TargetProgramCounter getProgramCounter() const;
|
||||
|
||||
/**
|
||||
* Sets the target's program counter to the given address.
|
||||
*
|
||||
* @param address
|
||||
*/
|
||||
void setProgramCounter(Targets::TargetProgramCounter address);
|
||||
void setProgramCounter(Targets::TargetProgramCounter address) const;
|
||||
|
||||
/**
|
||||
* Retrieves the pin states for a particular target variant.
|
||||
*
|
||||
* @param variantId
|
||||
*/
|
||||
Targets::TargetPinStateMapping getPinStates(int variantId);
|
||||
Targets::TargetPinStateMapping getPinStates(int variantId) const;
|
||||
|
||||
/**
|
||||
* Updates the pin state on the target, for a specific pin.
|
||||
@@ -186,19 +186,19 @@ namespace Bloom::Services
|
||||
* @param pinDescriptor
|
||||
* @param pinState
|
||||
*/
|
||||
void setPinState(Targets::TargetPinDescriptor pinDescriptor, Targets::TargetPinState pinState);
|
||||
void setPinState(Targets::TargetPinDescriptor pinDescriptor, Targets::TargetPinState pinState) const;
|
||||
|
||||
/**
|
||||
* Retrieves the current stack pointer value from the target.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Targets::TargetStackPointer getStackPointer();
|
||||
Targets::TargetStackPointer getStackPointer() const;
|
||||
|
||||
/**
|
||||
* Triggers a reset on the target. The target will be held in a stopped state.
|
||||
*/
|
||||
void resetTarget();
|
||||
void resetTarget() const;
|
||||
|
||||
/**
|
||||
* Enables programming mode on the target.
|
||||
@@ -207,12 +207,12 @@ namespace Bloom::Services
|
||||
* debug operations (such as ResumeTargetExecution, ReadTargetRegisters, etc), until programming mode has
|
||||
* been disabled.
|
||||
*/
|
||||
void enableProgrammingMode();
|
||||
void enableProgrammingMode() const;
|
||||
|
||||
/**
|
||||
* Disables programming mode on the target.
|
||||
*/
|
||||
void disableProgrammingMode();
|
||||
void disableProgrammingMode() const;
|
||||
|
||||
private:
|
||||
TargetController::CommandManager commandManager = TargetController::CommandManager();
|
||||
|
||||
@@ -25,7 +25,7 @@ namespace Bloom::TargetController
|
||||
auto sendCommandAndWaitForResponse(
|
||||
std::unique_ptr<CommandType> command,
|
||||
std::chrono::milliseconds timeout
|
||||
) {
|
||||
) const {
|
||||
using SuccessResponseType = typename CommandType::SuccessResponseType;
|
||||
|
||||
const auto commandId = command->id;
|
||||
|
||||
@@ -60,7 +60,7 @@ simplified means for other components to interact with the connected hardware. I
|
||||
memory from the target:
|
||||
|
||||
```c++
|
||||
auto tcService = Services::TargetControllerService();
|
||||
const auto tcService = Services::TargetControllerService();
|
||||
|
||||
const auto data = tcService.readMemory(
|
||||
someMemoryType, // Flash, RAM, EEPROM, etc
|
||||
|
||||
Reference in New Issue
Block a user