Renamed TargetControllerConsole to TargetControllerService

This commit is contained in:
Nav
2022-12-26 21:27:19 +00:00
parent de97e8d4e0
commit d353b55f9b
85 changed files with 261 additions and 257 deletions

View File

@@ -4,6 +4,9 @@ target_sources(
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Application.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Application.cpp
# Services
${CMAKE_CURRENT_SOURCE_DIR}/Services/TargetControllerService.cpp
# Helpers & other # Helpers & other
${CMAKE_CURRENT_SOURCE_DIR}/Logger/Logger.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Logger/Logger.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Helpers/Paths.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Helpers/Paths.cpp

View File

@@ -27,7 +27,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb
DebugServer::Gdb::GdbRspDebugServer::init(); DebugServer::Gdb::GdbRspDebugServer::init();
this->gdbTargetDescriptor = TargetDescriptor( this->gdbTargetDescriptor = TargetDescriptor(
this->targetControllerConsole.getTargetDescriptor() this->targetControllerService.getTargetDescriptor()
); );
} }

View File

@@ -8,7 +8,7 @@
namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
using ResponsePackets::OkResponsePacket; using ResponsePackets::OkResponsePacket;
@@ -19,7 +19,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
: CommandPacket(rawPacket) : CommandPacket(rawPacket)
{} {}
void FlashDone::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void FlashDone::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling FlashDone packet"); Logger::debug("Handling FlashDone packet");
try { try {
@@ -29,9 +29,9 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
"Flushing " + std::to_string(programmingSession.buffer.size()) + " bytes to target's program memory" "Flushing " + std::to_string(programmingSession.buffer.size()) + " bytes to target's program memory"
); );
targetControllerConsole.enableProgrammingMode(); targetControllerService.enableProgrammingMode();
targetControllerConsole.writeMemory( targetControllerService.writeMemory(
Targets::TargetMemoryType::FLASH, Targets::TargetMemoryType::FLASH,
programmingSession.startAddress, programmingSession.startAddress,
std::move(programmingSession.buffer) std::move(programmingSession.buffer)
@@ -41,10 +41,10 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
} }
Logger::warning("Program memory updated"); Logger::warning("Program memory updated");
targetControllerConsole.disableProgrammingMode(); targetControllerService.disableProgrammingMode();
Logger::warning("Resetting target"); Logger::warning("Resetting target");
targetControllerConsole.resetTarget(); targetControllerService.resetTarget();
Logger::info("Target reset complete"); Logger::info("Target reset complete");
debugSession.connection.writePacket(OkResponsePacket()); debugSession.connection.writePacket(OkResponsePacket());
@@ -54,7 +54,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
debugSession.programmingSession.reset(); debugSession.programmingSession.reset();
try { try {
targetControllerConsole.disableProgrammingMode(); targetControllerService.disableProgrammingMode();
} catch (const Exception& exception) { } catch (const Exception& exception) {
Logger::error("Failed to disable programming mode - " + exception.getMessage()); Logger::error("Failed to disable programming mode - " + exception.getMessage());

View File

@@ -20,7 +20,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -8,7 +8,7 @@
namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
using ResponsePackets::OkResponsePacket; using ResponsePackets::OkResponsePacket;
@@ -48,16 +48,16 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
} }
} }
void FlashErase::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void FlashErase::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling FlashErase packet"); Logger::debug("Handling FlashErase packet");
try { try {
targetControllerConsole.enableProgrammingMode(); targetControllerService.enableProgrammingMode();
Logger::warning("Erasing entire chip, in preparation for programming"); Logger::warning("Erasing entire chip, in preparation for programming");
// We don't erase a specific address range - we just erase the entire program memory. // We don't erase a specific address range - we just erase the entire program memory.
targetControllerConsole.eraseMemory(Targets::TargetMemoryType::FLASH); targetControllerService.eraseMemory(Targets::TargetMemoryType::FLASH);
debugSession.connection.writePacket(OkResponsePacket()); debugSession.connection.writePacket(OkResponsePacket());
@@ -66,7 +66,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
debugSession.programmingSession.reset(); debugSession.programmingSession.reset();
try { try {
targetControllerConsole.disableProgrammingMode(); targetControllerService.disableProgrammingMode();
} catch (const Exception& exception) { } catch (const Exception& exception) {
Logger::error("Failed to disable programming mode - " + exception.getMessage()); Logger::error("Failed to disable programming mode - " + exception.getMessage());

View File

@@ -24,7 +24,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -10,7 +10,7 @@
namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
using ResponsePackets::OkResponsePacket; using ResponsePackets::OkResponsePacket;
@@ -48,7 +48,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
this->buffer = Targets::TargetMemoryBuffer(colonIt + 1, this->data.end()); this->buffer = Targets::TargetMemoryBuffer(colonIt + 1, this->data.end());
} }
void FlashWrite::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void FlashWrite::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling FlashWrite packet"); Logger::debug("Handling FlashWrite packet");
try { try {
@@ -91,7 +91,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
debugSession.programmingSession.reset(); debugSession.programmingSession.reset();
try { try {
targetControllerConsole.disableProgrammingMode(); targetControllerService.disableProgrammingMode();
} catch (const Exception& exception) { } catch (const Exception& exception) {
Logger::error("Failed to disable programming mode - " + exception.getMessage()); Logger::error("Failed to disable programming mode - " + exception.getMessage());

View File

@@ -24,7 +24,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -10,7 +10,7 @@
namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
using ResponsePackets::ResponsePacket; using ResponsePackets::ResponsePacket;
@@ -62,7 +62,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
} }
} }
void ReadMemory::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void ReadMemory::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling ReadMemory packet"); Logger::debug("Handling ReadMemory packet");
try { try {
@@ -136,7 +136,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
auto memoryBuffer = Targets::TargetMemoryBuffer(); auto memoryBuffer = Targets::TargetMemoryBuffer();
if (bytesToRead > 0) { if (bytesToRead > 0) {
memoryBuffer = targetControllerConsole.readMemory( memoryBuffer = targetControllerService.readMemory(
this->memoryType, this->memoryType,
this->startAddress, this->startAddress,
bytesToRead bytesToRead

View File

@@ -36,7 +36,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -6,7 +6,7 @@
namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ResponsePacket; using ResponsePackets::ResponsePacket;
@@ -50,7 +50,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
} }
} }
void ReadMemoryMap::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void ReadMemoryMap::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling ReadMemoryMap packet"); Logger::debug("Handling ReadMemoryMap packet");
using Targets::TargetMemoryType; using Targets::TargetMemoryType;

View File

@@ -27,7 +27,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -8,7 +8,7 @@
namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
using ResponsePackets::OkResponsePacket; using ResponsePackets::OkResponsePacket;
@@ -68,7 +68,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
} }
} }
void WriteMemory::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void WriteMemory::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling WriteMemory packet"); Logger::debug("Handling WriteMemory packet");
try { try {
@@ -123,7 +123,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
); );
} }
targetControllerConsole.writeMemory( targetControllerService.writeMemory(
this->memoryType, this->memoryType,
this->startAddress, this->startAddress,
this->buffer this->buffer

View File

@@ -36,7 +36,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -15,7 +15,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
using ResponsePackets::ResponsePacket; using ResponsePackets::ResponsePacket;
@@ -26,7 +26,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
: Monitor(std::move(monitorPacket)) : Monitor(std::move(monitorPacket))
{} {}
void BloomVersion::handle(DebugSession& debugSession, TargetControllerConsole&) { void BloomVersion::handle(DebugSession& debugSession, TargetControllerService&) {
Logger::debug("Handling BloomVersion packet"); Logger::debug("Handling BloomVersion packet");
debugSession.connection.writePacket(ResponsePacket(String::toHex( debugSession.connection.writePacket(ResponsePacket(String::toHex(

View File

@@ -18,7 +18,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -15,7 +15,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ResponsePacket; using ResponsePackets::ResponsePacket;
@@ -25,7 +25,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
: Monitor(std::move(monitorPacket)) : Monitor(std::move(monitorPacket))
{} {}
void BloomVersionMachine::handle(DebugSession& debugSession, TargetControllerConsole&) { void BloomVersionMachine::handle(DebugSession& debugSession, TargetControllerService&) {
Logger::debug("Handling BloomVersionMachine packet"); Logger::debug("Handling BloomVersionMachine packet");
debugSession.connection.writePacket(ResponsePacket(String::toHex( debugSession.connection.writePacket(ResponsePacket(String::toHex(

View File

@@ -18,7 +18,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -13,7 +13,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ResponsePacket; using ResponsePackets::ResponsePacket;
using ResponsePackets::OkResponsePacket; using ResponsePackets::OkResponsePacket;
@@ -23,7 +23,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
using Exceptions::Exception; using Exceptions::Exception;
void CommandPacket::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void CommandPacket::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
const auto packetString = std::string(this->data.begin(), this->data.end()); const auto packetString = std::string(this->data.begin(), this->data.end());
if (packetString.empty()) { if (packetString.empty()) {

View File

@@ -6,7 +6,7 @@
#include "src/DebugServer/Gdb/Packet.hpp" #include "src/DebugServer/Gdb/Packet.hpp"
#include "src/DebugServer/Gdb/DebugSession.hpp" #include "src/DebugServer/Gdb/DebugSession.hpp"
#include "src/TargetController/TargetControllerConsole.hpp" #include "src/Services/TargetControllerService.hpp"
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
@@ -44,11 +44,11 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
* @param debugSession * @param debugSession
* The current active debug session. * The current active debug session.
* *
* @param targetControllerConsole * @param TargetControllerService
*/ */
virtual void handle( virtual void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
); );
}; };
} }

View File

@@ -7,7 +7,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
using Exceptions::Exception; using Exceptions::Exception;
@@ -22,11 +22,11 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
} }
} }
void ContinueExecution::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void ContinueExecution::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling ContinueExecution packet"); Logger::debug("Handling ContinueExecution packet");
try { try {
targetControllerConsole.continueTargetExecution(this->fromProgramCounter); targetControllerService.continueTargetExecution(this->fromProgramCounter);
debugSession.waitingForBreak = true; debugSession.waitingForBreak = true;
} catch (const Exception& exception) { } catch (const Exception& exception) {

View File

@@ -30,7 +30,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -9,7 +9,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::OkResponsePacket; using ResponsePackets::OkResponsePacket;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
@@ -20,12 +20,12 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
: CommandPacket(rawPacket) : CommandPacket(rawPacket)
{} {}
void Detach::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void Detach::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling Detach packet"); Logger::debug("Handling Detach packet");
try { try {
if (Process::isManagedByClion()) { if (Process::isManagedByClion()) {
targetControllerConsole.suspendTargetController(); targetControllerService.suspendTargetController();
} }
debugSession.connection.writePacket(OkResponsePacket()); debugSession.connection.writePacket(OkResponsePacket());

View File

@@ -11,7 +11,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -14,7 +14,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ResponsePacket; using ResponsePackets::ResponsePacket;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
@@ -34,7 +34,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
this->fillValue = Targets::TargetMemoryBuffer(fillValueByteArray.begin(), fillValueByteArray.end()); this->fillValue = Targets::TargetMemoryBuffer(fillValueByteArray.begin(), fillValueByteArray.end());
} }
void EepromFill::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void EepromFill::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling EepromFill packet"); Logger::debug("Handling EepromFill packet");
try { try {
@@ -90,7 +90,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
const auto hexValues = String::toHex(data); const auto hexValues = String::toHex(data);
Logger::debug("Filling EEPROM with values: " + hexValues); Logger::debug("Filling EEPROM with values: " + hexValues);
targetControllerConsole.writeMemory( targetControllerService.writeMemory(
Targets::TargetMemoryType::EEPROM, Targets::TargetMemoryType::EEPROM,
eepromDescriptor.addressRange.startAddress, eepromDescriptor.addressRange.startAddress,
std::move(data) std::move(data)

View File

@@ -20,7 +20,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
private: private:

View File

@@ -17,7 +17,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ResponsePacket; using ResponsePackets::ResponsePacket;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
@@ -28,7 +28,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
, sendOutput(this->commandOptions.contains("out")) , sendOutput(this->commandOptions.contains("out"))
{} {}
void GenerateSvd::handle(DebugSession& debugSession, TargetControllerConsole&) { void GenerateSvd::handle(DebugSession& debugSession, TargetControllerService&) {
Logger::debug("Handling GenerateSvd packet"); Logger::debug("Handling GenerateSvd packet");
try { try {

View File

@@ -21,7 +21,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
private: private:

View File

@@ -14,7 +14,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
using ResponsePackets::ResponsePacket; using ResponsePackets::ResponsePacket;
@@ -25,7 +25,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
: Monitor(std::move(monitorPacket)) : Monitor(std::move(monitorPacket))
{} {}
void HelpMonitorInfo::handle(DebugSession& debugSession, TargetControllerConsole&) { void HelpMonitorInfo::handle(DebugSession& debugSession, TargetControllerService&) {
Logger::debug("Handling HelpMonitorInfo packet"); Logger::debug("Handling HelpMonitorInfo packet");
try { try {

View File

@@ -18,7 +18,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -9,17 +9,17 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::TargetStopped; using ResponsePackets::TargetStopped;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
using Exceptions::Exception; using Exceptions::Exception;
void InterruptExecution::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void InterruptExecution::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling InterruptExecution packet"); Logger::debug("Handling InterruptExecution packet");
try { try {
targetControllerConsole.stopTargetExecution(); targetControllerService.stopTargetExecution();
debugSession.connection.writePacket(TargetStopped(Signal::INTERRUPTED)); debugSession.connection.writePacket(TargetStopped(Signal::INTERRUPTED));
} catch (const Exception& exception) { } catch (const Exception& exception) {

View File

@@ -19,7 +19,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -6,7 +6,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::EmptyResponsePacket; using ResponsePackets::EmptyResponsePacket;
@@ -27,7 +27,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
this->commandOptions = this->extractCommandOptions(this->command); this->commandOptions = this->extractCommandOptions(this->command);
} }
void Monitor::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void Monitor::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::error("Unknown custom GDB command (\"" + this->command + "\") received."); Logger::error("Unknown custom GDB command (\"" + this->command + "\") received.");
debugSession.connection.writePacket(EmptyResponsePacket()); debugSession.connection.writePacket(EmptyResponsePacket());
} }

View File

@@ -33,7 +33,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
private: private:

View File

@@ -11,7 +11,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using Targets::TargetRegister; using Targets::TargetRegister;
using Targets::TargetRegisterDescriptors; using Targets::TargetRegisterDescriptors;
@@ -32,7 +32,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
} }
} }
void ReadRegisters::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void ReadRegisters::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling ReadRegisters packet"); Logger::debug("Handling ReadRegisters packet");
try { try {
@@ -52,7 +52,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
} }
} }
auto registerSet = targetControllerConsole.readRegisters(descriptors); auto registerSet = targetControllerService.readRegisters(descriptors);
/* /*
* Sort each register by their respective GDB register number - this will leave us with a collection of * Sort each register by their respective GDB register number - this will leave us with a collection of

View File

@@ -29,7 +29,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -12,7 +12,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using Targets::TargetBreakpoint; using Targets::TargetBreakpoint;
@@ -50,11 +50,11 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
} }
} }
void RemoveBreakpoint::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void RemoveBreakpoint::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Removing breakpoint at address " + std::to_string(this->address)); Logger::debug("Removing breakpoint at address " + std::to_string(this->address));
try { try {
targetControllerConsole.removeBreakpoint(TargetBreakpoint(this->address)); targetControllerService.removeBreakpoint(TargetBreakpoint(this->address));
debugSession.connection.writePacket(OkResponsePacket()); debugSession.connection.writePacket(OkResponsePacket());
} catch (const Exception& exception) { } catch (const Exception& exception) {

View File

@@ -32,7 +32,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -10,7 +10,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
using ResponsePackets::ResponsePacket; using ResponsePackets::ResponsePacket;
@@ -21,12 +21,12 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
: Monitor(std::move(monitorPacket)) : Monitor(std::move(monitorPacket))
{} {}
void ResetTarget::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void ResetTarget::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling ResetTarget packet"); Logger::debug("Handling ResetTarget packet");
try { try {
Logger::warning("Resetting target"); Logger::warning("Resetting target");
targetControllerConsole.resetTarget(); targetControllerService.resetTarget();
Logger::info("Target reset complete"); Logger::info("Target reset complete");
debugSession.connection.writePacket(ResponsePacket(String::toHex( debugSession.connection.writePacket(ResponsePacket(String::toHex(

View File

@@ -19,7 +19,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -12,7 +12,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using Targets::TargetBreakpoint; using Targets::TargetBreakpoint;
@@ -50,11 +50,11 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
} }
} }
void SetBreakpoint::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void SetBreakpoint::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling SetBreakpoint packet"); Logger::debug("Handling SetBreakpoint packet");
try { try {
targetControllerConsole.setBreakpoint(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

@@ -32,7 +32,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -7,7 +7,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
@@ -23,11 +23,11 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
} }
} }
void StepExecution::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void StepExecution::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling StepExecution packet"); Logger::debug("Handling StepExecution packet");
try { try {
targetControllerConsole.stepTargetExecution(this->fromProgramCounter); targetControllerService.stepTargetExecution(this->fromProgramCounter);
debugSession.waitingForBreak = true; debugSession.waitingForBreak = true;
} catch (const Exception& exception) { } catch (const Exception& exception) {

View File

@@ -25,7 +25,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -13,7 +13,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using ResponsePackets::SupportedFeaturesResponse; using ResponsePackets::SupportedFeaturesResponse;
using ResponsePackets::ErrorResponsePacket; using ResponsePackets::ErrorResponsePacket;
@@ -53,7 +53,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
} }
} }
void SupportedFeaturesQuery::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void SupportedFeaturesQuery::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling QuerySupport packet"); Logger::debug("Handling QuerySupport packet");
if (!this->isFeatureSupported(Feature::HARDWARE_BREAKPOINTS) if (!this->isFeatureSupported(Feature::HARDWARE_BREAKPOINTS)

View File

@@ -34,7 +34,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
private: private:

View File

@@ -11,7 +11,7 @@
namespace Bloom::DebugServer::Gdb::CommandPackets namespace Bloom::DebugServer::Gdb::CommandPackets
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
using Targets::TargetRegister; using Targets::TargetRegister;
using Targets::TargetRegisterDescriptors; using Targets::TargetRegisterDescriptors;
@@ -42,7 +42,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
std::reverse(this->registerValue.begin(), this->registerValue.end()); std::reverse(this->registerValue.begin(), this->registerValue.end());
} }
void WriteRegister::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void WriteRegister::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
Logger::debug("Handling WriteRegister packet"); Logger::debug("Handling WriteRegister packet");
try { try {
@@ -72,7 +72,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
} }
} }
targetControllerConsole.writeRegisters({ targetControllerService.writeRegisters({
TargetRegister(targetRegisterDescriptor, this->registerValue) TargetRegister(targetRegisterDescriptor, this->registerValue)
}); });

View File

@@ -21,7 +21,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
void handle( void handle(
DebugSession& debugSession, DebugSession& debugSession,
TargetController::TargetControllerConsole& targetControllerConsole Services::TargetControllerService& targetControllerService
) override; ) override;
}; };
} }

View File

@@ -160,29 +160,29 @@ namespace Bloom::DebugServer::Gdb
* Before proceeding with a new debug session, we must ensure that the TargetController is able to * Before proceeding with a new debug session, we must ensure that the TargetController is able to
* service it. * service it.
*/ */
if (!this->targetControllerConsole.isTargetControllerInService()) { if (!this->targetControllerService.isTargetControllerInService()) {
// The TargetController is suspended - attempt to wake it up // The TargetController is suspended - attempt to wake it up
try { try {
this->targetControllerConsole.resumeTargetController(); this->targetControllerService.resumeTargetController();
} catch (Bloom::Exceptions::Exception& exception) { } catch (Bloom::Exceptions::Exception& exception) {
Logger::error("Failed to wake up TargetController - " + exception.getMessage()); Logger::error("Failed to wake up TargetController - " + exception.getMessage());
} }
if (!this->targetControllerConsole.isTargetControllerInService()) { if (!this->targetControllerService.isTargetControllerInService()) {
this->activeDebugSession.reset(); this->activeDebugSession.reset();
throw DebugSessionInitialisationFailure("TargetController not in service"); throw DebugSessionInitialisationFailure("TargetController not in service");
} }
} }
this->targetControllerConsole.stopTargetExecution(); this->targetControllerService.stopTargetExecution();
this->targetControllerConsole.resetTarget(); this->targetControllerService.resetTarget();
} }
const auto commandPacket = this->waitForCommandPacket(); const auto commandPacket = this->waitForCommandPacket();
if (commandPacket) { if (commandPacket) {
commandPacket->handle(this->activeDebugSession.value(), this->targetControllerConsole); commandPacket->handle(this->activeDebugSession.value(), this->targetControllerService);
} }
} catch (const ClientDisconnected&) { } catch (const ClientDisconnected&) {

View File

@@ -13,7 +13,7 @@
#include "src/EventManager/EventListener.hpp" #include "src/EventManager/EventListener.hpp"
#include "src/Helpers/EpollInstance.hpp" #include "src/Helpers/EpollInstance.hpp"
#include "src/Helpers/EventFdNotifier.hpp" #include "src/Helpers/EventFdNotifier.hpp"
#include "src/TargetController/TargetControllerConsole.hpp" #include "src/Services/TargetControllerService.hpp"
#include "Connection.hpp" #include "Connection.hpp"
#include "TargetDescriptor.hpp" #include "TargetDescriptor.hpp"
@@ -114,7 +114,7 @@ namespace Bloom::DebugServer::Gdb
* *
* See documentation in src/DebugServer/Gdb/README.md for more on how GDB commands are processed. * See documentation in src/DebugServer/Gdb/README.md for more on how GDB commands are processed.
*/ */
TargetController::TargetControllerConsole targetControllerConsole = TargetController::TargetControllerConsole(); Services::TargetControllerService targetControllerService = Services::TargetControllerService();
/** /**
* Listening socket address * Listening socket address

View File

@@ -53,7 +53,7 @@ public:
explicit SetBreakpoint(const RawPacket& rawPacket); explicit SetBreakpoint(const RawPacket& rawPacket);
void handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) override; void handle(DebugSession& debugSession, TargetControllerService& targetControllerService) override;
}; };
``` ```
@@ -67,15 +67,15 @@ Upon receiving a command packet from the GDB client, the command must be handled
Each command packet class implements a `handle()` member function. This function is called upon receipt of the command Each command packet class implements a `handle()` member function. This function is called upon receipt of the command
and is expected to handle the command and deliver any necessary response to the client. Two parameters are passed to the and is expected to handle the command and deliver any necessary response to the client. Two parameters are passed to the
`handle()` member function - a reference to the active `DebugSession` object, and a reference to a `handle()` member function - a reference to the active `DebugSession` object, and a reference to a
`TargetControllerConsole` object. The `DebugSession` object provides access to the current connection with the GDB `TargetControllerService` object. The `DebugSession` object provides access to the current connection with the GDB
client, as well as other debug session specific information. The `TargetControllerConsole` object provides an interface client, as well as other debug session specific information. The `TargetControllerService` object provides an interface
to the `TargetController`, for any GDB commands that need to interface with the connected target (see the to the `TargetController`, for any GDB commands that need to interface with the connected target (see the
[TargetController documentation](../../TargetController/README.md) for more on this). [TargetController documentation](../../TargetController/README.md) for more on this).
Handling the `SetBreakpoint` command packet: Handling the `SetBreakpoint` command packet:
```c++ ```c++
void SetBreakpoint::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) { void SetBreakpoint::handle(DebugSession& debugSession, TargetControllerService& targetControllerService) {
/* /*
* I know the breakpoint type (this->type) isn't used in here - this is because the current implementation only * I know the breakpoint type (this->type) isn't used in here - this is because the current implementation only
* supports software breakpoints, so we don't do anything with this->type, for now. * supports software breakpoints, so we don't do anything with this->type, for now.
@@ -84,7 +84,7 @@ void SetBreakpoint::handle(DebugSession& debugSession, TargetControllerConsole&
Logger::debug("Handling SetBreakpoint packet"); Logger::debug("Handling SetBreakpoint packet");
try { try {
targetControllerConsole.setBreakpoint(TargetBreakpoint(this->address)); targetControllerServicesetBreakpoint(TargetBreakpoint(this->address));
debugSession.connection.writePacket(OkResponsePacket()); debugSession.connection.writePacket(OkResponsePacket());
} catch (const Exception& exception) { } catch (const Exception& exception) {

View File

@@ -206,7 +206,7 @@ namespace Bloom
this->checkBloomVersion(); this->checkBloomVersion();
this->mainWindow->init(this->targetControllerConsole.getTargetDescriptor()); this->mainWindow->init(this->targetControllerService.getTargetDescriptor());
this->mainWindow->show(); this->mainWindow->show();
} }
@@ -322,7 +322,7 @@ namespace Bloom
void Insight::onTargetResetEvent(const Events::TargetReset& event) { void Insight::onTargetResetEvent(const Events::TargetReset& event) {
try { try {
if (this->targetControllerConsole.getTargetState() != TargetState::STOPPED) { if (this->targetControllerService.getTargetState() != TargetState::STOPPED) {
return; return;
} }

View File

@@ -17,7 +17,7 @@
#include "src/EventManager/EventListener.hpp" #include "src/EventManager/EventListener.hpp"
#include "src/EventManager/Events/Events.hpp" #include "src/EventManager/Events/Events.hpp"
#include "src/TargetController/TargetControllerConsole.hpp" #include "src/Services/TargetControllerService.hpp"
#include "src/Targets/TargetState.hpp" #include "src/Targets/TargetState.hpp"
#include "InsightSignals.hpp" #include "InsightSignals.hpp"
@@ -90,7 +90,7 @@ namespace Bloom
this->insightProjectSettings this->insightProjectSettings
); );
TargetController::TargetControllerConsole targetControllerConsole = TargetController::TargetControllerConsole(); Services::TargetControllerService targetControllerService = Services::TargetControllerService();
Targets::TargetState lastTargetState = Targets::TargetState::UNKNOWN; Targets::TargetState lastTargetState = Targets::TargetState::UNKNOWN;
bool targetStepping = false; bool targetStepping = false;

View File

@@ -83,7 +83,7 @@ namespace Bloom
auto* task = queuedTask.value(); auto* task = queuedTask.value();
task->moveToThread(this->thread()); task->moveToThread(this->thread());
task->setParent(this); task->setParent(this);
task->execute(this->targetControllerConsole); task->execute(this->targetControllerService);
{ {
const auto taskGroupsLock = InsightWorker::taskGroupsInExecution.acquireLock(); const auto taskGroupsLock = InsightWorker::taskGroupsInExecution.acquireLock();

View File

@@ -9,7 +9,7 @@
#include "Tasks/InsightWorkerTask.hpp" #include "Tasks/InsightWorkerTask.hpp"
#include "src/Helpers/SyncSafe.hpp" #include "src/Helpers/SyncSafe.hpp"
#include "src/TargetController/TargetControllerConsole.hpp" #include "src/Services/TargetControllerService.hpp"
namespace Bloom namespace Bloom
{ {
@@ -41,7 +41,7 @@ namespace Bloom
static inline SyncSafe<std::map<QueuedTaskId, InsightWorkerTask*>> queuedTasksById = {}; static inline SyncSafe<std::map<QueuedTaskId, InsightWorkerTask*>> queuedTasksById = {};
static inline SyncSafe<TaskGroups> taskGroupsInExecution = {}; static inline SyncSafe<TaskGroups> taskGroupsInExecution = {};
TargetController::TargetControllerConsole targetControllerConsole = TargetController::TargetControllerConsole(); Services::TargetControllerService targetControllerService = Services::TargetControllerService();
void executeTasks(); void executeTasks();
}; };

View File

@@ -10,7 +10,7 @@
namespace Bloom namespace Bloom
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
CaptureMemorySnapshot::CaptureMemorySnapshot( CaptureMemorySnapshot::CaptureMemorySnapshot(
const QString& name, const QString& name,
@@ -28,12 +28,12 @@ namespace Bloom
, data(data) , data(data)
{} {}
void CaptureMemorySnapshot::run(TargetControllerConsole& targetControllerConsole) { void CaptureMemorySnapshot::run(TargetControllerService& targetControllerService) {
using Targets::TargetMemorySize; using Targets::TargetMemorySize;
Logger::info("Capturing snapshot"); Logger::info("Capturing snapshot");
const auto& targetDescriptor = targetControllerConsole.getTargetDescriptor(); const auto& targetDescriptor = targetControllerService.getTargetDescriptor();
const auto memoryDescriptorIt = targetDescriptor.memoryDescriptorsByType.find(this->memoryType); const auto memoryDescriptorIt = targetDescriptor.memoryDescriptorsByType.find(this->memoryType);
if (memoryDescriptorIt == targetDescriptor.memoryDescriptorsByType.end()) { if (memoryDescriptorIt == targetDescriptor.memoryDescriptorsByType.end()) {
@@ -58,7 +58,7 @@ namespace Bloom
); );
for (std::uint32_t i = 0; i < readsRequired; i++) { for (std::uint32_t i = 0; i < readsRequired; i++) {
auto dataSegment = targetControllerConsole.readMemory( auto dataSegment = targetControllerService.readMemory(
this->memoryType, this->memoryType,
memoryDescriptor.addressRange.startAddress + static_cast<Targets::TargetMemoryAddress>(readSize * i), memoryDescriptor.addressRange.startAddress + static_cast<Targets::TargetMemoryAddress>(readSize * i),
(memorySize - this->data->size()) >= readSize (memorySize - this->data->size()) >= readSize
@@ -78,7 +78,7 @@ namespace Bloom
std::move(this->description), std::move(this->description),
this->memoryType, this->memoryType,
std::move(*this->data), std::move(*this->data),
targetControllerConsole.getProgramCounter(), targetControllerService.getProgramCounter(),
std::move(this->focusedRegions), std::move(this->focusedRegions),
std::move(this->excludedRegions) std::move(this->excludedRegions)
); );

View File

@@ -28,7 +28,7 @@ namespace Bloom
void memorySnapshotCaptured(MemorySnapshot snapshot); void memorySnapshotCaptured(MemorySnapshot snapshot);
protected: protected:
void run(TargetController::TargetControllerConsole& targetControllerConsole) override; void run(Services::TargetControllerService& targetControllerService) override;
private: private:
QString name; QString name;

View File

@@ -20,7 +20,7 @@ namespace Bloom
qRegisterMetaType<std::map<Targets::TargetMemoryAddress, Widgets::ByteItem*>>(); qRegisterMetaType<std::map<Targets::TargetMemoryAddress, Widgets::ByteItem*>>();
} }
void ConstructHexViewerByteItems::run(TargetController::TargetControllerConsole&) { void ConstructHexViewerByteItems::run(Services::TargetControllerService&) {
const auto memorySize = this->memoryDescriptor.size(); const auto memorySize = this->memoryDescriptor.size();
const auto startAddress = this->memoryDescriptor.addressRange.startAddress; const auto startAddress = this->memoryDescriptor.addressRange.startAddress;

View File

@@ -37,7 +37,7 @@ namespace Bloom
void byteItems(std::map<Targets::TargetMemoryAddress, Widgets::ByteItem*> byteItemsByAddress); void byteItems(std::map<Targets::TargetMemoryAddress, Widgets::ByteItem*> byteItemsByAddress);
protected: protected:
void run(TargetController::TargetControllerConsole&) override; void run(Services::TargetControllerService&) override;
private: private:
std::map<Targets::TargetMemoryAddress, Widgets::ByteItem*> byteItemsByAddress; std::map<Targets::TargetMemoryAddress, Widgets::ByteItem*> byteItemsByAddress;

View File

@@ -2,9 +2,9 @@
namespace Bloom namespace Bloom
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
void GetTargetDescriptor::run(TargetControllerConsole& targetControllerConsole) { void GetTargetDescriptor::run(TargetControllerService& targetControllerService) {
emit this->targetDescriptor(targetControllerConsole.getTargetDescriptor()); emit this->targetDescriptor(targetControllerService.getTargetDescriptor());
} }
} }

View File

@@ -23,6 +23,6 @@ namespace Bloom
void targetDescriptor(Targets::TargetDescriptor targetDescriptor); void targetDescriptor(Targets::TargetDescriptor targetDescriptor);
protected: protected:
void run(TargetController::TargetControllerConsole& targetControllerConsole) override; void run(Services::TargetControllerService& targetControllerService) override;
}; };
} }

View File

@@ -2,9 +2,9 @@
namespace Bloom namespace Bloom
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
void GetTargetState::run(TargetControllerConsole& targetControllerConsole) { void GetTargetState::run(TargetControllerService& targetControllerService) {
emit this->targetState(targetControllerConsole.getTargetState()); emit this->targetState(targetControllerService.getTargetState());
} }
} }

View File

@@ -23,6 +23,6 @@ namespace Bloom
void targetState(Targets::TargetState state); void targetState(Targets::TargetState state);
protected: protected:
void run(TargetController::TargetControllerConsole& targetControllerConsole) override; void run(Services::TargetControllerService& targetControllerService) override;
}; };
} }

View File

@@ -4,13 +4,13 @@
namespace Bloom namespace Bloom
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
void InsightWorkerTask::execute(TargetControllerConsole& targetControllerConsole) { void InsightWorkerTask::execute(TargetControllerService& targetControllerService) {
try { try {
this->state = InsightWorkerTaskState::STARTED; this->state = InsightWorkerTaskState::STARTED;
emit this->started(); emit this->started();
this->run(targetControllerConsole); this->run(targetControllerService);
this->state = InsightWorkerTaskState::COMPLETED; this->state = InsightWorkerTaskState::COMPLETED;
emit this->completed(); emit this->completed();

View File

@@ -4,7 +4,7 @@
#include <QString> #include <QString>
#include "TaskGroup.hpp" #include "TaskGroup.hpp"
#include "src/TargetController/TargetControllerConsole.hpp" #include "src/Services/TargetControllerService.hpp"
namespace Bloom namespace Bloom
{ {
@@ -29,7 +29,7 @@ namespace Bloom
return TaskGroups(); return TaskGroups();
}; };
void execute(TargetController::TargetControllerConsole& targetControllerConsole); void execute(Services::TargetControllerService& targetControllerService);
signals: signals:
/** /**
@@ -56,6 +56,6 @@ namespace Bloom
void finished(); void finished();
protected: protected:
virtual void run(TargetController::TargetControllerConsole& targetControllerConsole) = 0; virtual void run(Services::TargetControllerService& targetControllerService) = 0;
}; };
} }

View File

@@ -2,9 +2,9 @@
namespace Bloom namespace Bloom
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
void ReadProgramCounter::run(TargetControllerConsole& targetControllerConsole) { void ReadProgramCounter::run(TargetControllerService& targetControllerService) {
emit this->programCounterRead(targetControllerConsole.getProgramCounter()); emit this->programCounterRead(targetControllerService.getProgramCounter());
} }
} }

View File

@@ -23,6 +23,6 @@ namespace Bloom
void programCounterRead(Targets::TargetProgramCounter programCounter); void programCounterRead(Targets::TargetProgramCounter programCounter);
protected: protected:
void run(TargetController::TargetControllerConsole& targetControllerConsole) override; void run(Services::TargetControllerService& targetControllerService) override;
}; };
} }

View File

@@ -2,9 +2,9 @@
namespace Bloom namespace Bloom
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
void ReadStackPointer::run(TargetControllerConsole& targetControllerConsole) { void ReadStackPointer::run(TargetControllerService& targetControllerService) {
emit this->stackPointerRead(targetControllerConsole.getStackPointer()); emit this->stackPointerRead(targetControllerService.getStackPointer());
} }
} }

View File

@@ -23,6 +23,6 @@ namespace Bloom
void stackPointerRead(Targets::TargetStackPointer stackPointer); void stackPointerRead(Targets::TargetStackPointer stackPointer);
protected: protected:
void run(TargetController::TargetControllerConsole& targetControllerConsole) override; void run(Services::TargetControllerService& targetControllerService) override;
}; };
} }

View File

@@ -8,12 +8,12 @@
namespace Bloom namespace Bloom
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
void ReadTargetMemory::run(TargetControllerConsole& targetControllerConsole) { void ReadTargetMemory::run(TargetControllerService& targetControllerService) {
using Targets::TargetMemorySize; using Targets::TargetMemorySize;
const auto& targetDescriptor = targetControllerConsole.getTargetDescriptor(); const auto& targetDescriptor = targetControllerService.getTargetDescriptor();
const auto memoryDescriptorIt = targetDescriptor.memoryDescriptorsByType.find(this->memoryType); const auto memoryDescriptorIt = targetDescriptor.memoryDescriptorsByType.find(this->memoryType);
if (memoryDescriptorIt == targetDescriptor.memoryDescriptorsByType.end()) { if (memoryDescriptorIt == targetDescriptor.memoryDescriptorsByType.end()) {
@@ -39,7 +39,7 @@ namespace Bloom
Targets::TargetMemoryBuffer data; Targets::TargetMemoryBuffer data;
for (std::uint32_t i = 0; i < readsRequired; i++) { for (std::uint32_t i = 0; i < readsRequired; i++) {
auto dataSegment = targetControllerConsole.readMemory( auto dataSegment = targetControllerService.readMemory(
this->memoryType, this->memoryType,
this->startAddress + static_cast<Targets::TargetMemoryAddress>(readSize * i), this->startAddress + static_cast<Targets::TargetMemoryAddress>(readSize * i),
(this->size - data.size()) >= readSize (this->size - data.size()) >= readSize

View File

@@ -35,7 +35,7 @@ namespace Bloom
void targetMemoryRead(Targets::TargetMemoryBuffer buffer); void targetMemoryRead(Targets::TargetMemoryBuffer buffer);
protected: protected:
void run(TargetController::TargetControllerConsole& targetControllerConsole) override; void run(Services::TargetControllerService& targetControllerService) override;
private: private:
Targets::TargetMemoryType memoryType; Targets::TargetMemoryType memoryType;

View File

@@ -2,9 +2,9 @@
namespace Bloom namespace Bloom
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
void ReadTargetRegisters::run(TargetControllerConsole& targetControllerConsole) { void ReadTargetRegisters::run(TargetControllerService& targetControllerService) {
emit this->targetRegistersRead(targetControllerConsole.readRegisters(this->descriptors)); emit this->targetRegistersRead(targetControllerService.readRegisters(this->descriptors));
} }
} }

View File

@@ -24,7 +24,7 @@ namespace Bloom
void targetRegistersRead(Targets::TargetRegisters registers); void targetRegistersRead(Targets::TargetRegisters registers);
protected: protected:
void run(TargetController::TargetControllerConsole& targetControllerConsole) override; void run(Services::TargetControllerService& targetControllerService) override;
private: private:
Targets::TargetRegisterDescriptors descriptors; Targets::TargetRegisterDescriptors descriptors;

View File

@@ -2,9 +2,9 @@
namespace Bloom namespace Bloom
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
void RefreshTargetPinStates::run(TargetControllerConsole& targetControllerConsole) { void RefreshTargetPinStates::run(TargetControllerService& targetControllerService) {
emit this->targetPinStatesRetrieved(targetControllerConsole.getPinStates(this->variantId)); emit this->targetPinStatesRetrieved(targetControllerService.getPinStates(this->variantId));
} }
} }

View File

@@ -25,7 +25,7 @@ namespace Bloom
void targetPinStatesRetrieved(Bloom::Targets::TargetPinStateMapping pinStatesByNumber); void targetPinStatesRetrieved(Bloom::Targets::TargetPinStateMapping pinStatesByNumber);
protected: protected:
void run(TargetController::TargetControllerConsole& targetControllerConsole) override; void run(Services::TargetControllerService& targetControllerService) override;
private: private:
int variantId; int variantId;

View File

@@ -12,13 +12,13 @@
namespace Bloom namespace Bloom
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
RetrieveMemorySnapshots::RetrieveMemorySnapshots(Targets::TargetMemoryType memoryType) RetrieveMemorySnapshots::RetrieveMemorySnapshots(Targets::TargetMemoryType memoryType)
: memoryType(memoryType) : memoryType(memoryType)
{} {}
void RetrieveMemorySnapshots::run(TargetControllerConsole& targetControllerConsole) { void RetrieveMemorySnapshots::run(TargetControllerService& targetControllerService) {
emit this->memorySnapshotsRetrieved(this->getSnapshots(this->memoryType)); emit this->memorySnapshotsRetrieved(this->getSnapshots(this->memoryType));
} }

View File

@@ -20,7 +20,7 @@ namespace Bloom
void memorySnapshotsRetrieved(std::vector<MemorySnapshot> snapshots); void memorySnapshotsRetrieved(std::vector<MemorySnapshot> snapshots);
protected: protected:
void run(TargetController::TargetControllerConsole& targetControllerConsole) override; void run(Services::TargetControllerService& targetControllerService) override;
private: private:
Targets::TargetMemoryType memoryType; Targets::TargetMemoryType memoryType;

View File

@@ -2,9 +2,9 @@
namespace Bloom namespace Bloom
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
void SetTargetPinState::run(TargetControllerConsole& targetControllerConsole) { void SetTargetPinState::run(TargetControllerService& targetControllerService) {
targetControllerConsole.setPinState(this->pinDescriptor, this->pinState); targetControllerService.setPinState(this->pinDescriptor, this->pinState);
} }
} }

View File

@@ -22,7 +22,7 @@ namespace Bloom
}; };
protected: protected:
void run(TargetController::TargetControllerConsole& targetControllerConsole) override; void run(Services::TargetControllerService& targetControllerService) override;
private: private:
Targets::TargetPinDescriptor pinDescriptor; Targets::TargetPinDescriptor pinDescriptor;

View File

@@ -2,9 +2,9 @@
namespace Bloom namespace Bloom
{ {
using TargetController::TargetControllerConsole; using Services::TargetControllerService;
void WriteTargetRegister::run(TargetControllerConsole& targetControllerConsole) { void WriteTargetRegister::run(TargetControllerService& targetControllerService) {
targetControllerConsole.writeRegisters({this->targetRegister}); targetControllerService.writeRegisters({this->targetRegister});
} }
} }

View File

@@ -21,7 +21,7 @@ namespace Bloom
}; };
protected: protected:
void run(TargetController::TargetControllerConsole& targetControllerConsole) override; void run(Services::TargetControllerService& targetControllerService) override;
private: private:
Targets::TargetRegister targetRegister; Targets::TargetRegister targetRegister;

View File

@@ -1,55 +1,57 @@
#include "TargetControllerConsole.hpp" #include "TargetControllerService.hpp"
// Commands // Commands
#include "Commands/GetState.hpp" #include "src/TargetController/Commands/GetState.hpp"
#include "Commands/Suspend.hpp" #include "src/TargetController/Commands/Suspend.hpp"
#include "Commands/Resume.hpp" #include "src/TargetController/Commands/Resume.hpp"
#include "Commands/GetTargetDescriptor.hpp" #include "src/TargetController/Commands/GetTargetDescriptor.hpp"
#include "Commands/GetTargetState.hpp" #include "src/TargetController/Commands/GetTargetState.hpp"
#include "Commands/StopTargetExecution.hpp" #include "src/TargetController/Commands/StopTargetExecution.hpp"
#include "Commands/ResumeTargetExecution.hpp" #include "src/TargetController/Commands/ResumeTargetExecution.hpp"
#include "Commands/ResetTarget.hpp" #include "src/TargetController/Commands/ResetTarget.hpp"
#include "Commands/ReadTargetRegisters.hpp" #include "src/TargetController/Commands/ReadTargetRegisters.hpp"
#include "Commands/WriteTargetRegisters.hpp" #include "src/TargetController/Commands/WriteTargetRegisters.hpp"
#include "Commands/ReadTargetMemory.hpp" #include "src/TargetController/Commands/ReadTargetMemory.hpp"
#include "Commands/WriteTargetMemory.hpp" #include "src/TargetController/Commands/WriteTargetMemory.hpp"
#include "Commands/EraseTargetMemory.hpp" #include "src/TargetController/Commands/EraseTargetMemory.hpp"
#include "Commands/StepTargetExecution.hpp" #include "src/TargetController/Commands/StepTargetExecution.hpp"
#include "Commands/SetBreakpoint.hpp" #include "src/TargetController/Commands/SetBreakpoint.hpp"
#include "Commands/RemoveBreakpoint.hpp" #include "src/TargetController/Commands/RemoveBreakpoint.hpp"
#include "Commands/SetTargetProgramCounter.hpp" #include "src/TargetController/Commands/SetTargetProgramCounter.hpp"
#include "Commands/GetTargetPinStates.hpp" #include "src/TargetController/Commands/GetTargetPinStates.hpp"
#include "Commands/SetTargetPinState.hpp" #include "src/TargetController/Commands/SetTargetPinState.hpp"
#include "Commands/GetTargetStackPointer.hpp" #include "src/TargetController/Commands/GetTargetStackPointer.hpp"
#include "Commands/GetTargetProgramCounter.hpp" #include "src/TargetController/Commands/GetTargetProgramCounter.hpp"
#include "Commands/EnableProgrammingMode.hpp" #include "src/TargetController/Commands/EnableProgrammingMode.hpp"
#include "Commands/DisableProgrammingMode.hpp" #include "src/TargetController/Commands/DisableProgrammingMode.hpp"
namespace Bloom::TargetController namespace Bloom::Services
{ {
using Commands::GetState; using TargetController::Commands::GetState;
using Commands::Suspend; using TargetController::Commands::Suspend;
using Commands::Resume; using TargetController::Commands::Resume;
using Commands::GetTargetDescriptor; using TargetController::Commands::GetTargetDescriptor;
using Commands::GetTargetState; using TargetController::Commands::GetTargetState;
using Commands::StopTargetExecution; using TargetController::Commands::StopTargetExecution;
using Commands::ResumeTargetExecution; using TargetController::Commands::ResumeTargetExecution;
using Commands::ResetTarget; using TargetController::Commands::ResetTarget;
using Commands::ReadTargetRegisters; using TargetController::Commands::ReadTargetRegisters;
using Commands::WriteTargetRegisters; using TargetController::Commands::WriteTargetRegisters;
using Commands::ReadTargetMemory; using TargetController::Commands::ReadTargetMemory;
using Commands::WriteTargetMemory; using TargetController::Commands::WriteTargetMemory;
using Commands::EraseTargetMemory; using TargetController::Commands::EraseTargetMemory;
using Commands::StepTargetExecution; using TargetController::Commands::StepTargetExecution;
using Commands::SetBreakpoint; using TargetController::Commands::SetBreakpoint;
using Commands::RemoveBreakpoint; using TargetController::Commands::RemoveBreakpoint;
using Commands::SetTargetProgramCounter; using TargetController::Commands::SetTargetProgramCounter;
using Commands::GetTargetPinStates; using TargetController::Commands::GetTargetPinStates;
using Commands::SetTargetPinState; using TargetController::Commands::SetTargetPinState;
using Commands::GetTargetStackPointer; using TargetController::Commands::GetTargetStackPointer;
using Commands::GetTargetProgramCounter; using TargetController::Commands::GetTargetProgramCounter;
using Commands::EnableProgrammingMode; using TargetController::Commands::EnableProgrammingMode;
using Commands::DisableProgrammingMode; using TargetController::Commands::DisableProgrammingMode;
using TargetController::TargetControllerState;
using Targets::TargetDescriptor; using Targets::TargetDescriptor;
using Targets::TargetState; using Targets::TargetState;
@@ -71,14 +73,14 @@ namespace Bloom::TargetController
using Targets::TargetPinState; using Targets::TargetPinState;
using Targets::TargetPinStateMapping; using Targets::TargetPinStateMapping;
TargetControllerState TargetControllerConsole::getTargetControllerState() { TargetControllerState TargetControllerService::getTargetControllerState() {
return this->commandManager.sendCommandAndWaitForResponse( return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<GetState>(), std::make_unique<GetState>(),
this->defaultTimeout this->defaultTimeout
)->state; )->state;
} }
bool TargetControllerConsole::isTargetControllerInService() noexcept { bool TargetControllerService::isTargetControllerInService() noexcept {
try { try {
return this->getTargetControllerState() == TargetControllerState::ACTIVE; return this->getTargetControllerState() == TargetControllerState::ACTIVE;
@@ -87,7 +89,7 @@ namespace Bloom::TargetController
} }
} }
void TargetControllerConsole::resumeTargetController() { void TargetControllerService::resumeTargetController() {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<Resume>(), std::make_unique<Resume>(),
this->defaultTimeout this->defaultTimeout
@@ -95,7 +97,7 @@ namespace Bloom::TargetController
return; return;
} }
void TargetControllerConsole::suspendTargetController() { void TargetControllerService::suspendTargetController() {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<Suspend>(), std::make_unique<Suspend>(),
this->defaultTimeout this->defaultTimeout
@@ -103,28 +105,28 @@ namespace Bloom::TargetController
return; return;
} }
const TargetDescriptor& TargetControllerConsole::getTargetDescriptor() { const TargetDescriptor& TargetControllerService::getTargetDescriptor() {
return this->commandManager.sendCommandAndWaitForResponse( return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<GetTargetDescriptor>(), std::make_unique<GetTargetDescriptor>(),
this->defaultTimeout this->defaultTimeout
)->targetDescriptor; )->targetDescriptor;
} }
TargetState TargetControllerConsole::getTargetState() { TargetState TargetControllerService::getTargetState() {
return this->commandManager.sendCommandAndWaitForResponse( return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<GetTargetState>(), std::make_unique<GetTargetState>(),
this->defaultTimeout this->defaultTimeout
)->targetState; )->targetState;
} }
void TargetControllerConsole::stopTargetExecution() { void TargetControllerService::stopTargetExecution() {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<StopTargetExecution>(), std::make_unique<StopTargetExecution>(),
this->defaultTimeout this->defaultTimeout
); );
} }
void TargetControllerConsole::continueTargetExecution(std::optional<TargetProgramCounter> fromAddress) { void TargetControllerService::continueTargetExecution(std::optional<TargetProgramCounter> fromAddress) {
auto resumeExecutionCommand = std::make_unique<ResumeTargetExecution>(); auto resumeExecutionCommand = std::make_unique<ResumeTargetExecution>();
if (fromAddress.has_value()) { if (fromAddress.has_value()) {
@@ -137,7 +139,7 @@ namespace Bloom::TargetController
); );
} }
void TargetControllerConsole::stepTargetExecution(std::optional<TargetProgramCounter> fromAddress) { void TargetControllerService::stepTargetExecution(std::optional<TargetProgramCounter> fromAddress) {
auto stepExecutionCommand = std::make_unique<StepTargetExecution>(); auto stepExecutionCommand = std::make_unique<StepTargetExecution>();
if (fromAddress.has_value()) { if (fromAddress.has_value()) {
@@ -150,21 +152,21 @@ namespace Bloom::TargetController
); );
} }
TargetRegisters TargetControllerConsole::readRegisters(const TargetRegisterDescriptors& descriptors) { TargetRegisters TargetControllerService::readRegisters(const TargetRegisterDescriptors& descriptors) {
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 TargetControllerConsole::writeRegisters(const TargetRegisters& registers) { void TargetControllerService::writeRegisters(const TargetRegisters& registers) {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<WriteTargetRegisters>(registers), std::make_unique<WriteTargetRegisters>(registers),
this->defaultTimeout this->defaultTimeout
); );
} }
TargetMemoryBuffer TargetControllerConsole::readMemory( TargetMemoryBuffer TargetControllerService::readMemory(
TargetMemoryType memoryType, TargetMemoryType memoryType,
TargetMemoryAddress startAddress, TargetMemoryAddress startAddress,
TargetMemorySize bytes, TargetMemorySize bytes,
@@ -181,7 +183,7 @@ namespace Bloom::TargetController
)->data; )->data;
} }
void TargetControllerConsole::writeMemory( void TargetControllerService::writeMemory(
TargetMemoryType memoryType, TargetMemoryType memoryType,
TargetMemoryAddress startAddress, TargetMemoryAddress startAddress,
const TargetMemoryBuffer& buffer const TargetMemoryBuffer& buffer
@@ -192,77 +194,77 @@ namespace Bloom::TargetController
); );
} }
void TargetControllerConsole::eraseMemory(Targets::TargetMemoryType memoryType) { void TargetControllerService::eraseMemory(Targets::TargetMemoryType memoryType) {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<EraseTargetMemory>(memoryType), std::make_unique<EraseTargetMemory>(memoryType),
this->defaultTimeout this->defaultTimeout
); );
} }
void TargetControllerConsole::setBreakpoint(TargetBreakpoint breakpoint) { void TargetControllerService::setBreakpoint(TargetBreakpoint breakpoint) {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<SetBreakpoint>(breakpoint), std::make_unique<SetBreakpoint>(breakpoint),
this->defaultTimeout this->defaultTimeout
); );
} }
void TargetControllerConsole::removeBreakpoint(TargetBreakpoint breakpoint) { void TargetControllerService::removeBreakpoint(TargetBreakpoint breakpoint) {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<RemoveBreakpoint>(breakpoint), std::make_unique<RemoveBreakpoint>(breakpoint),
this->defaultTimeout this->defaultTimeout
); );
} }
TargetProgramCounter TargetControllerConsole::getProgramCounter() { TargetProgramCounter TargetControllerService::getProgramCounter() {
return this->commandManager.sendCommandAndWaitForResponse( return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<GetTargetProgramCounter>(), std::make_unique<GetTargetProgramCounter>(),
this->defaultTimeout this->defaultTimeout
)->programCounter; )->programCounter;
} }
void TargetControllerConsole::setProgramCounter(TargetProgramCounter address) { void TargetControllerService::setProgramCounter(TargetProgramCounter address) {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<SetTargetProgramCounter>(address), std::make_unique<SetTargetProgramCounter>(address),
this->defaultTimeout this->defaultTimeout
); );
} }
TargetPinStateMapping TargetControllerConsole::getPinStates(int variantId) { TargetPinStateMapping TargetControllerService::getPinStates(int variantId) {
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 TargetControllerConsole::setPinState(TargetPinDescriptor pinDescriptor, TargetPinState pinState) { void TargetControllerService::setPinState(TargetPinDescriptor pinDescriptor, TargetPinState pinState) {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<SetTargetPinState>(pinDescriptor, pinState), std::make_unique<SetTargetPinState>(pinDescriptor, pinState),
this->defaultTimeout this->defaultTimeout
); );
} }
TargetStackPointer TargetControllerConsole::getStackPointer() { TargetStackPointer TargetControllerService::getStackPointer() {
return this->commandManager.sendCommandAndWaitForResponse( return this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<GetTargetStackPointer>(), std::make_unique<GetTargetStackPointer>(),
this->defaultTimeout this->defaultTimeout
)->stackPointer; )->stackPointer;
} }
void TargetControllerConsole::resetTarget() { void TargetControllerService::resetTarget() {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<ResetTarget>(), std::make_unique<ResetTarget>(),
this->defaultTimeout this->defaultTimeout
); );
} }
void TargetControllerConsole::enableProgrammingMode() { void TargetControllerService::enableProgrammingMode() {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<EnableProgrammingMode>(), std::make_unique<EnableProgrammingMode>(),
this->defaultTimeout this->defaultTimeout
); );
} }
void TargetControllerConsole::disableProgrammingMode() { void TargetControllerService::disableProgrammingMode() {
this->commandManager.sendCommandAndWaitForResponse( this->commandManager.sendCommandAndWaitForResponse(
std::make_unique<DisableProgrammingMode>(), std::make_unique<DisableProgrammingMode>(),
this->defaultTimeout this->defaultTimeout

View File

@@ -4,8 +4,8 @@
#include <chrono> #include <chrono>
#include <optional> #include <optional>
#include "CommandManager.hpp" #include "src/TargetController/CommandManager.hpp"
#include "TargetControllerState.hpp" #include "src/TargetController/TargetControllerState.hpp"
#include "src/Targets/TargetState.hpp" #include "src/Targets/TargetState.hpp"
#include "src/Targets/TargetRegister.hpp" #include "src/Targets/TargetRegister.hpp"
@@ -16,15 +16,15 @@
#include "src/Exceptions/Exception.hpp" #include "src/Exceptions/Exception.hpp"
namespace Bloom::TargetController namespace Bloom::Services
{ {
/** /**
* The TargetControllerConsole provides an interface to the TargetController. * The TargetControllerService provides an interface to the TargetController.
*/ */
class TargetControllerConsole class TargetControllerService
{ {
public: public:
TargetControllerConsole() = default; TargetControllerService() = default;
void setDefaultTimeout(std::chrono::milliseconds timeout) { void setDefaultTimeout(std::chrono::milliseconds timeout) {
this->defaultTimeout = timeout; this->defaultTimeout = timeout;
@@ -39,7 +39,7 @@ namespace Bloom::TargetController
* *
* @return * @return
*/ */
TargetControllerState getTargetControllerState(); TargetController::TargetControllerState getTargetControllerState();
/** /**
* Retrieves the TargetController state and checks if it's currently active. * Retrieves the TargetController state and checks if it's currently active.
@@ -215,7 +215,7 @@ namespace Bloom::TargetController
void disableProgrammingMode(); void disableProgrammingMode();
private: private:
CommandManager commandManager = CommandManager(); TargetController::CommandManager commandManager = TargetController::CommandManager();
std::chrono::milliseconds defaultTimeout = std::chrono::milliseconds(60000); std::chrono::milliseconds defaultTimeout = std::chrono::milliseconds(60000);
}; };

View File

@@ -2,5 +2,4 @@ target_sources(
Bloom Bloom
PRIVATE PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/TargetControllerComponent.cpp ${CMAKE_CURRENT_SOURCE_DIR}/TargetControllerComponent.cpp
${CMAKE_CURRENT_SOURCE_DIR}/TargetControllerConsole.cpp
) )

View File

@@ -18,9 +18,9 @@ All TargetController commands can be found in [src/TargetController/Commands](./
[`Bloom::TargetController::Responses::Response`](./Responses/Response.hpp) base class. [`Bloom::TargetController::Responses::Response`](./Responses/Response.hpp) base class.
**NOTE:** Components within Bloom do not typically concern themselves with the TargetController command-response **NOTE:** Components within Bloom do not typically concern themselves with the TargetController command-response
mechanism. Instead, they use the `TargetControllerConsole` class, which encapsulates the command-response mechanism and mechanism. Instead, they use the `TargetControllerService` class, which encapsulates the command-response mechanism and
provides a simplified means for interaction with the connected hardware. For more, see provides a simplified means for interaction with the connected hardware. For more, see
[The TargetControllerConsole class](#the-targetcontrollerconsole-class) section below. [The TargetControllerService class](#the-TargetControllerService-class) section below.
Commands can be sent to the TargetController via the [`Bloom::TargetController::CommandManager`](./CommandManager.hpp) Commands can be sent to the TargetController via the [`Bloom::TargetController::CommandManager`](./CommandManager.hpp)
class. class.
@@ -53,26 +53,26 @@ until a timeout has been reached. Because it is a template function, it is able
type at compile-time (see the `SuccessResponseType` alias in some command classes). If the TargetController responds type at compile-time (see the `SuccessResponseType` alias in some command classes). If the TargetController responds
with an error, or the timeout is reached, `CommandManager::sendCommandAndWaitForResponse()` will throw an exception. with an error, or the timeout is reached, `CommandManager::sendCommandAndWaitForResponse()` will throw an exception.
#### The TargetControllerConsole class #### The TargetControllerService class
The `TargetControllerConsole` class encapsulates the TargetController's command-response mechanism and provides a The `TargetControllerService` class encapsulates the TargetController's command-response mechanism and provides a
simplified means for other components to interact with the connected hardware. Iterating on the example above, to read simplified means for other components to interact with the connected hardware. Iterating on the example above, to read
memory from the target: memory from the target:
```c++ ```c++
auto tcConsole = TargetController::TargetControllerConsole(); auto tcService = Services::TargetControllerService();
const auto data = tcConsole.readMemory( const auto data = tcService.readMemory(
someMemoryType, // Flash, RAM, EEPROM, etc someMemoryType, // Flash, RAM, EEPROM, etc
someStartAddress, someStartAddress,
someNumberOfBytes someNumberOfBytes
); );
``` ```
The `TargetControllerConsole` class does not require any dependencies at construction. It can be constructed in The `TargetControllerService` class does not require any dependencies at construction. It can be constructed in
different threads and used freely to gain access to the connected hardware, from any component within Bloom. different threads and used freely to gain access to the connected hardware, from any component within Bloom.
All components within Bloom should use the `TargetControllerConsole` class to interact with the connected hardware. They All components within Bloom should use the `TargetControllerService` class to interact with the connected hardware. They
**should not** directly issue commands via the `Bloom::TargetController::CommandManager`, unless there is a very good **should not** directly issue commands via the `Bloom::TargetController::CommandManager`, unless there is a very good
reason to do so. reason to do so.
@@ -114,7 +114,7 @@ For more on TargetController suspension, see `TargetControllerComponent::suspend
When a component needs to write to the target's program memory, it must enable programming mode on the target. This can When a component needs to write to the target's program memory, it must enable programming mode on the target. This can
be done by issuing the `EnableProgrammingMode` command to the TargetController (see be done by issuing the `EnableProgrammingMode` command to the TargetController (see
`TargetControllerConsole::enableProgrammingMode()`). Once programming mode has been enabled, the TargetController will `TargetControllerService::enableProgrammingMode()`). Once programming mode has been enabled, the TargetController will
reject any subsequent commands that involve debug operations (such as `ResumeTargetExecution`, `ReadTargetRegisters`, reject any subsequent commands that involve debug operations (such as `ResumeTargetExecution`, `ReadTargetRegisters`,
etc), until programming mode has been disabled. etc), until programming mode has been disabled.