This commit is contained in:
Nav
2022-12-26 22:25:35 +00:00
parent 0a15ce8a84
commit b8ca1fbc41
5 changed files with 51 additions and 51 deletions

View File

@@ -84,7 +84,7 @@ void SetBreakpoint::handle(DebugSession& debugSession, TargetControllerService&
Logger::debug("Handling SetBreakpoint packet"); Logger::debug("Handling SetBreakpoint packet");
try { try {
targetControllerServicesetBreakpoint(TargetBreakpoint(this->address)); targetControllerService.setBreakpoint(TargetBreakpoint(this->address));
debugSession.connection.writePacket(OkResponsePacket()); debugSession.connection.writePacket(OkResponsePacket());
} catch (const Exception& exception) { } catch (const Exception& exception) {

View File

@@ -73,14 +73,14 @@ namespace Bloom::Services
using Targets::TargetPinState; using Targets::TargetPinState;
using Targets::TargetPinStateMapping; using Targets::TargetPinStateMapping;
TargetControllerState TargetControllerService::getTargetControllerState() { TargetControllerState TargetControllerService::getTargetControllerState() const {
return this->commandManager.sendCommandAndWaitForResponse( return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<GetState>(), std::make_unique<GetState>(),
this->defaultTimeout this->defaultTimeout
)->state; )->state;
} }
bool TargetControllerService::isTargetControllerInService() noexcept { bool TargetControllerService::isTargetControllerInService() const noexcept {
try { try {
return this->getTargetControllerState() == TargetControllerState::ACTIVE; return this->getTargetControllerState() == TargetControllerState::ACTIVE;
@@ -89,7 +89,7 @@ namespace Bloom::Services
} }
} }
void TargetControllerService::resumeTargetController() { void TargetControllerService::resumeTargetController() const {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<Resume>(), std::make_unique<Resume>(),
this->defaultTimeout this->defaultTimeout
@@ -97,7 +97,7 @@ namespace Bloom::Services
return; return;
} }
void TargetControllerService::suspendTargetController() { void TargetControllerService::suspendTargetController() const {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<Suspend>(), std::make_unique<Suspend>(),
this->defaultTimeout this->defaultTimeout
@@ -105,28 +105,28 @@ namespace Bloom::Services
return; return;
} }
const TargetDescriptor& TargetControllerService::getTargetDescriptor() { const TargetDescriptor& TargetControllerService::getTargetDescriptor() const {
return this->commandManager.sendCommandAndWaitForResponse( return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<GetTargetDescriptor>(), std::make_unique<GetTargetDescriptor>(),
this->defaultTimeout this->defaultTimeout
)->targetDescriptor; )->targetDescriptor;
} }
TargetState TargetControllerService::getTargetState() { TargetState TargetControllerService::getTargetState() const {
return this->commandManager.sendCommandAndWaitForResponse( return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<GetTargetState>(), std::make_unique<GetTargetState>(),
this->defaultTimeout this->defaultTimeout
)->targetState; )->targetState;
} }
void TargetControllerService::stopTargetExecution() { void TargetControllerService::stopTargetExecution() const {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<StopTargetExecution>(), std::make_unique<StopTargetExecution>(),
this->defaultTimeout this->defaultTimeout
); );
} }
void TargetControllerService::continueTargetExecution(std::optional<TargetProgramCounter> fromAddress) { void TargetControllerService::continueTargetExecution(std::optional<TargetProgramCounter> fromAddress) const {
auto resumeExecutionCommand = std::make_unique<ResumeTargetExecution>(); auto resumeExecutionCommand = std::make_unique<ResumeTargetExecution>();
if (fromAddress.has_value()) { 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>(); auto stepExecutionCommand = std::make_unique<StepTargetExecution>();
if (fromAddress.has_value()) { 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( return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<ReadTargetRegisters>(descriptors), std::make_unique<ReadTargetRegisters>(descriptors),
this->defaultTimeout this->defaultTimeout
)->registers; )->registers;
} }
void TargetControllerService::writeRegisters(const TargetRegisters& registers) { void TargetControllerService::writeRegisters(const TargetRegisters& registers) const {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<WriteTargetRegisters>(registers), std::make_unique<WriteTargetRegisters>(registers),
this->defaultTimeout this->defaultTimeout
@@ -171,7 +171,7 @@ namespace Bloom::Services
TargetMemoryAddress startAddress, TargetMemoryAddress startAddress,
TargetMemorySize bytes, TargetMemorySize bytes,
const std::set<TargetMemoryAddressRange>& excludedAddressRanges const std::set<TargetMemoryAddressRange>& excludedAddressRanges
) { ) const {
return this->commandManager.sendCommandAndWaitForResponse( return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<ReadTargetMemory>( std::make_unique<ReadTargetMemory>(
memoryType, memoryType,
@@ -187,84 +187,84 @@ namespace Bloom::Services
TargetMemoryType memoryType, TargetMemoryType memoryType,
TargetMemoryAddress startAddress, TargetMemoryAddress startAddress,
const TargetMemoryBuffer& buffer const TargetMemoryBuffer& buffer
) { ) const {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<WriteTargetMemory>(memoryType, startAddress, buffer), std::make_unique<WriteTargetMemory>(memoryType, startAddress, buffer),
this->defaultTimeout this->defaultTimeout
); );
} }
void TargetControllerService::eraseMemory(Targets::TargetMemoryType memoryType) { void TargetControllerService::eraseMemory(Targets::TargetMemoryType memoryType) const {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<EraseTargetMemory>(memoryType), std::make_unique<EraseTargetMemory>(memoryType),
this->defaultTimeout this->defaultTimeout
); );
} }
void TargetControllerService::setBreakpoint(TargetBreakpoint breakpoint) { void TargetControllerService::setBreakpoint(TargetBreakpoint breakpoint) const {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<SetBreakpoint>(breakpoint), std::make_unique<SetBreakpoint>(breakpoint),
this->defaultTimeout this->defaultTimeout
); );
} }
void TargetControllerService::removeBreakpoint(TargetBreakpoint breakpoint) { void TargetControllerService::removeBreakpoint(TargetBreakpoint breakpoint) const {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<RemoveBreakpoint>(breakpoint), std::make_unique<RemoveBreakpoint>(breakpoint),
this->defaultTimeout this->defaultTimeout
); );
} }
TargetProgramCounter TargetControllerService::getProgramCounter() { TargetProgramCounter TargetControllerService::getProgramCounter() const {
return this->commandManager.sendCommandAndWaitForResponse( return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<GetTargetProgramCounter>(), std::make_unique<GetTargetProgramCounter>(),
this->defaultTimeout this->defaultTimeout
)->programCounter; )->programCounter;
} }
void TargetControllerService::setProgramCounter(TargetProgramCounter address) { void TargetControllerService::setProgramCounter(TargetProgramCounter address) const {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<SetTargetProgramCounter>(address), std::make_unique<SetTargetProgramCounter>(address),
this->defaultTimeout this->defaultTimeout
); );
} }
TargetPinStateMapping TargetControllerService::getPinStates(int variantId) { TargetPinStateMapping TargetControllerService::getPinStates(int variantId) const {
return this->commandManager.sendCommandAndWaitForResponse( return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<GetTargetPinStates>(variantId), std::make_unique<GetTargetPinStates>(variantId),
this->defaultTimeout this->defaultTimeout
)->pinStatesByNumber; )->pinStatesByNumber;
} }
void TargetControllerService::setPinState(TargetPinDescriptor pinDescriptor, TargetPinState pinState) { void TargetControllerService::setPinState(TargetPinDescriptor pinDescriptor, TargetPinState pinState) const {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<SetTargetPinState>(pinDescriptor, pinState), std::make_unique<SetTargetPinState>(pinDescriptor, pinState),
this->defaultTimeout this->defaultTimeout
); );
} }
TargetStackPointer TargetControllerService::getStackPointer() { TargetStackPointer TargetControllerService::getStackPointer() const {
return this->commandManager.sendCommandAndWaitForResponse( return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<GetTargetStackPointer>(), std::make_unique<GetTargetStackPointer>(),
this->defaultTimeout this->defaultTimeout
)->stackPointer; )->stackPointer;
} }
void TargetControllerService::resetTarget() { void TargetControllerService::resetTarget() const {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<ResetTarget>(), std::make_unique<ResetTarget>(),
this->defaultTimeout this->defaultTimeout
); );
} }
void TargetControllerService::enableProgrammingMode() { void TargetControllerService::enableProgrammingMode() const {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<EnableProgrammingMode>(), std::make_unique<EnableProgrammingMode>(),
this->defaultTimeout this->defaultTimeout
); );
} }
void TargetControllerService::disableProgrammingMode() { void TargetControllerService::disableProgrammingMode() const {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<DisableProgrammingMode>(), std::make_unique<DisableProgrammingMode>(),
this->defaultTimeout this->defaultTimeout

View File

@@ -39,7 +39,7 @@ namespace Bloom::Services
* *
* @return * @return
*/ */
TargetController::TargetControllerState getTargetControllerState(); TargetController::TargetControllerState getTargetControllerState() const;
/** /**
* Retrieves the TargetController state and checks if it's currently active. * Retrieves the TargetController state and checks if it's currently active.
@@ -47,50 +47,50 @@ namespace Bloom::Services
* @return * @return
* True if the TargetController is currently in an active state, otherwise false. * 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. * 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. * Suspends the TargetController if it's active. Otherwise, this function does nothing.
*/ */
void suspendTargetController(); void suspendTargetController() const;
/** /**
* Requests the TargetDescriptor from the TargetController * Requests the TargetDescriptor from the TargetController
* *
* @return * @return
*/ */
const Targets::TargetDescriptor& getTargetDescriptor(); const Targets::TargetDescriptor& getTargetDescriptor() const;
/** /**
* Fetches the current target state. * Fetches the current target state.
* *
* @return * @return
*/ */
Targets::TargetState getTargetState(); Targets::TargetState getTargetState() const;
/** /**
* Requests the TargetController to halt execution on the target. * Requests the TargetController to halt execution on the target.
*/ */
void stopTargetExecution(); void stopTargetExecution() const;
/** /**
* Requests the TargetController to continue execution on the target. * Requests the TargetController to continue execution on the target.
* *
* @param fromAddress * @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. * Requests the TargetController to step execution on the target.
* *
* @param fromAddress * @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. * Requests the TargetController to read register values from the target.
@@ -100,14 +100,14 @@ namespace Bloom::Services
* *
* @return * @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. * Requests the TargetController to write register values to the target.
* *
* @param registers * @param registers
*/ */
void writeRegisters(const Targets::TargetRegisters& registers); void writeRegisters(const Targets::TargetRegisters& registers) const;
/** /**
* Requests the TargetController to read memory from the target. * Requests the TargetController to read memory from the target.
@@ -123,7 +123,7 @@ namespace Bloom::Services
Targets::TargetMemoryAddress startAddress, Targets::TargetMemoryAddress startAddress,
Targets::TargetMemorySize bytes, Targets::TargetMemorySize bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {} const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges = {}
); ) const;
/** /**
* Requests the TargetController to write memory to the target. * Requests the TargetController to write memory to the target.
@@ -136,49 +136,49 @@ namespace Bloom::Services
Targets::TargetMemoryType memoryType, Targets::TargetMemoryType memoryType,
Targets::TargetMemoryAddress startAddress, Targets::TargetMemoryAddress startAddress,
const Targets::TargetMemoryBuffer& buffer const Targets::TargetMemoryBuffer& buffer
); ) const;
/** /**
* Requests the TargetController to erase the given target memory type. * Requests the TargetController to erase the given target memory type.
* *
* @param memoryType * @param memoryType
*/ */
void eraseMemory(Targets::TargetMemoryType memoryType); void eraseMemory(Targets::TargetMemoryType memoryType) const;
/** /**
* Requests the TargetController to set a breakpoint on the target. * Requests the TargetController to set a breakpoint on the target.
* *
* @param breakpoint * @param breakpoint
*/ */
void setBreakpoint(Targets::TargetBreakpoint breakpoint); void setBreakpoint(Targets::TargetBreakpoint breakpoint) const;
/** /**
* Requests the TargetController to remove a breakpoint from the target. * Requests the TargetController to remove a breakpoint from the target.
* *
* @param breakpoint * @param breakpoint
*/ */
void removeBreakpoint(Targets::TargetBreakpoint breakpoint); void removeBreakpoint(Targets::TargetBreakpoint breakpoint) const;
/** /**
* Retrieves the current program counter value from the target. * Retrieves the current program counter value from the target.
* *
* @return * @return
*/ */
Targets::TargetProgramCounter getProgramCounter(); Targets::TargetProgramCounter getProgramCounter() const;
/** /**
* Sets the target's program counter to the given address. * Sets the target's program counter to the given address.
* *
* @param address * @param address
*/ */
void setProgramCounter(Targets::TargetProgramCounter address); void setProgramCounter(Targets::TargetProgramCounter address) const;
/** /**
* Retrieves the pin states for a particular target variant. * Retrieves the pin states for a particular target variant.
* *
* @param variantId * @param variantId
*/ */
Targets::TargetPinStateMapping getPinStates(int variantId); Targets::TargetPinStateMapping getPinStates(int variantId) const;
/** /**
* Updates the pin state on the target, for a specific pin. * Updates the pin state on the target, for a specific pin.
@@ -186,19 +186,19 @@ namespace Bloom::Services
* @param pinDescriptor * @param pinDescriptor
* @param pinState * @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. * Retrieves the current stack pointer value from the target.
* *
* @return * @return
*/ */
Targets::TargetStackPointer getStackPointer(); Targets::TargetStackPointer getStackPointer() const;
/** /**
* Triggers a reset on the target. The target will be held in a stopped state. * 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. * Enables programming mode on the target.
@@ -207,12 +207,12 @@ namespace Bloom::Services
* debug operations (such as ResumeTargetExecution, ReadTargetRegisters, etc), until programming mode has * debug operations (such as ResumeTargetExecution, ReadTargetRegisters, etc), until programming mode has
* been disabled. * been disabled.
*/ */
void enableProgrammingMode(); void enableProgrammingMode() const;
/** /**
* Disables programming mode on the target. * Disables programming mode on the target.
*/ */
void disableProgrammingMode(); void disableProgrammingMode() const;
private: private:
TargetController::CommandManager commandManager = TargetController::CommandManager(); TargetController::CommandManager commandManager = TargetController::CommandManager();

View File

@@ -25,7 +25,7 @@ namespace Bloom::TargetController
auto sendCommandAndWaitForResponse( auto sendCommandAndWaitForResponse(
std::unique_ptr<CommandType> command, std::unique_ptr<CommandType> command,
std::chrono::milliseconds timeout std::chrono::milliseconds timeout
) { ) const {
using SuccessResponseType = typename CommandType::SuccessResponseType; using SuccessResponseType = typename CommandType::SuccessResponseType;
const auto commandId = command->id; const auto commandId = command->id;

View File

@@ -60,7 +60,7 @@ simplified means for other components to interact with the connected hardware. I
memory from the target: memory from the target:
```c++ ```c++
auto tcService = Services::TargetControllerService(); const auto tcService = Services::TargetControllerService();
const auto data = tcService.readMemory( const auto data = tcService.readMemory(
someMemoryType, // Flash, RAM, EEPROM, etc someMemoryType, // Flash, RAM, EEPROM, etc