diff --git a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp index 0b1e1bcd..d4025a11 100644 --- a/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp +++ b/src/DebugServer/Gdb/AvrGdb/CommandPackets/ReadMemory.cpp @@ -3,7 +3,7 @@ #include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp" #include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp" -#include "src/Helpers/String.hpp" +#include "src/Services/StringService.hpp" #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" @@ -148,7 +148,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets memoryBuffer.insert(memoryBuffer.end(), (this->bytes - bytesToRead), 0x00); } - debugSession.connection.writePacket(ResponsePacket(String::toHex(memoryBuffer))); + debugSession.connection.writePacket(ResponsePacket(Services::StringService::toHex(memoryBuffer))); } catch (const Exception& exception) { Logger::error("Failed to read memory from target - " + exception.getMessage()); diff --git a/src/DebugServer/Gdb/CommandPackets/BloomVersion.cpp b/src/DebugServer/Gdb/CommandPackets/BloomVersion.cpp index 9325bcc2..e9e0a0b4 100644 --- a/src/DebugServer/Gdb/CommandPackets/BloomVersion.cpp +++ b/src/DebugServer/Gdb/CommandPackets/BloomVersion.cpp @@ -8,7 +8,7 @@ #include "src/Application.hpp" #include "src/Services/PathService.hpp" -#include "src/Helpers/String.hpp" +#include "src/Services/StringService.hpp" #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" @@ -29,7 +29,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets void BloomVersion::handle(DebugSession& debugSession, TargetControllerService&) { Logger::debug("Handling BloomVersion packet"); - debugSession.connection.writePacket(ResponsePacket(String::toHex( + debugSession.connection.writePacket(ResponsePacket(Services::StringService::toHex( std::string( "Bloom v" + Application::VERSION.toString() + "\n" + Services::PathService::homeDomainName() + "\n" diff --git a/src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.cpp b/src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.cpp index b3655b29..5e79f5e4 100644 --- a/src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.cpp +++ b/src/DebugServer/Gdb/CommandPackets/BloomVersionMachine.cpp @@ -8,7 +8,7 @@ #include "src/Application.hpp" -#include "src/Helpers/String.hpp" +#include "src/Services/StringService.hpp" #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" @@ -28,7 +28,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets void BloomVersionMachine::handle(DebugSession& debugSession, TargetControllerService&) { Logger::debug("Handling BloomVersionMachine packet"); - debugSession.connection.writePacket(ResponsePacket(String::toHex( + debugSession.connection.writePacket(ResponsePacket(Services::StringService::toHex( QJsonDocument(QJsonObject({ {"version", QString::fromStdString(Application::VERSION.toString())}, {"components", QJsonObject({ diff --git a/src/DebugServer/Gdb/CommandPackets/EepromFill.cpp b/src/DebugServer/Gdb/CommandPackets/EepromFill.cpp index c2a6f909..0043fcae 100644 --- a/src/DebugServer/Gdb/CommandPackets/EepromFill.cpp +++ b/src/DebugServer/Gdb/CommandPackets/EepromFill.cpp @@ -6,7 +6,7 @@ #include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp" #include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp" -#include "src/Helpers/String.hpp" +#include "src/Services/StringService.hpp" #include "src/Logger/Logger.hpp" #include "src/DebugServer/Gdb/Exceptions/InvalidCommandOption.hpp" @@ -87,7 +87,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets ); } - const auto hexValues = String::toHex(data); + const auto hexValues = Services::StringService::toHex(data); Logger::debug("Filling EEPROM with values: " + hexValues); targetControllerService.writeMemory( @@ -96,13 +96,15 @@ namespace Bloom::DebugServer::Gdb::CommandPackets std::move(data) ); - debugSession.connection.writePacket(ResponsePacket(String::toHex( + debugSession.connection.writePacket(ResponsePacket(Services::StringService::toHex( "Filled " + std::to_string(eepromSize) + " bytes of EEPROM, with values: " + hexValues + "\n" ))); } catch (const InvalidCommandOption& exception) { Logger::error(exception.getMessage()); - debugSession.connection.writePacket(ResponsePacket(String::toHex(exception.getMessage() + "\n"))); + debugSession.connection.writePacket( + ResponsePacket(Services::StringService::toHex(exception.getMessage() + "\n")) + ); } catch (const Exception& exception) { Logger::error("Failed to fill EEPROM - " + exception.getMessage()); diff --git a/src/DebugServer/Gdb/CommandPackets/GenerateSvd.cpp b/src/DebugServer/Gdb/CommandPackets/GenerateSvd.cpp index 034b0041..cadfbc74 100644 --- a/src/DebugServer/Gdb/CommandPackets/GenerateSvd.cpp +++ b/src/DebugServer/Gdb/CommandPackets/GenerateSvd.cpp @@ -10,7 +10,7 @@ #include "src/Application.hpp" #include "src/Services/PathService.hpp" -#include "src/Helpers/String.hpp" +#include "src/Services/StringService.hpp" #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" @@ -42,7 +42,9 @@ namespace Bloom::DebugServer::Gdb::CommandPackets ); if (this->sendOutput) { - debugSession.connection.writePacket(ResponsePacket(String::toHex(svdXml.toString().toStdString()))); + debugSession.connection.writePacket( + ResponsePacket(Services::StringService::toHex(svdXml.toString().toStdString())) + ); return; } @@ -58,7 +60,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets outputFile.write(svdXml.toByteArray()); outputFile.close(); - debugSession.connection.writePacket(ResponsePacket(String::toHex( + debugSession.connection.writePacket(ResponsePacket(Services::StringService::toHex( "SVD output saved to " + svdOutputFilePath + "\n" ))); diff --git a/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.cpp b/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.cpp index a65c437f..916bb257 100644 --- a/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.cpp +++ b/src/DebugServer/Gdb/CommandPackets/HelpMonitorInfo.cpp @@ -7,7 +7,7 @@ #include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp" #include "src/Services/PathService.hpp" -#include "src/Helpers/String.hpp" +#include "src/Services/StringService.hpp" #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" @@ -41,13 +41,15 @@ namespace Bloom::DebugServer::Gdb::CommandPackets if (!helpFile.open(QIODevice::ReadOnly)) { throw Exception( - "Failed to open GDB monitor info help file - please report this issue at " + Services::PathService::homeDomainName() - + "/report-issue" + "Failed to open GDB monitor info help file - please report this issue at " + + Services::PathService::homeDomainName() + "/report-issue" ); } debugSession.connection.writePacket( - ResponsePacket(String::toHex("\n" + QTextStream(&helpFile).readAll().toUtf8().toStdString() + "\n")) + ResponsePacket(Services::StringService::toHex( + "\n" + QTextStream(&helpFile).readAll().toUtf8().toStdString() + "\n" + )) ); } catch (const Exception& exception) { diff --git a/src/DebugServer/Gdb/CommandPackets/ReadRegisters.cpp b/src/DebugServer/Gdb/CommandPackets/ReadRegisters.cpp index 6e8213e0..245bcca6 100644 --- a/src/DebugServer/Gdb/CommandPackets/ReadRegisters.cpp +++ b/src/DebugServer/Gdb/CommandPackets/ReadRegisters.cpp @@ -4,7 +4,7 @@ #include "src/Targets/TargetRegister.hpp" -#include "src/Helpers/String.hpp" +#include "src/Services/StringService.hpp" #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" @@ -89,7 +89,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets } debugSession.connection.writePacket( - ResponsePacket(String::toHex(registers)) + ResponsePacket(Services::StringService::toHex(registers)) ); } catch (const Exception& exception) { diff --git a/src/DebugServer/Gdb/CommandPackets/ResetTarget.cpp b/src/DebugServer/Gdb/CommandPackets/ResetTarget.cpp index ef45ed3a..c7137c7e 100644 --- a/src/DebugServer/Gdb/CommandPackets/ResetTarget.cpp +++ b/src/DebugServer/Gdb/CommandPackets/ResetTarget.cpp @@ -3,7 +3,7 @@ #include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp" #include "src/DebugServer/Gdb/ResponsePackets/ResponsePacket.hpp" -#include "src/Helpers/String.hpp" +#include "src/Services/StringService.hpp" #include "src/Logger/Logger.hpp" #include "src/Exceptions/Exception.hpp" @@ -29,7 +29,7 @@ namespace Bloom::DebugServer::Gdb::CommandPackets targetControllerService.resetTarget(); Logger::info("Target reset complete"); - debugSession.connection.writePacket(ResponsePacket(String::toHex( + debugSession.connection.writePacket(ResponsePacket(Services::StringService::toHex( "Target reset complete - use the 'continue' command to begin execution.\n" ))); diff --git a/src/DebugServer/Gdb/ResponsePackets/TargetStopped.hpp b/src/DebugServer/Gdb/ResponsePackets/TargetStopped.hpp index d665c82e..4d12f9e4 100644 --- a/src/DebugServer/Gdb/ResponsePackets/TargetStopped.hpp +++ b/src/DebugServer/Gdb/ResponsePackets/TargetStopped.hpp @@ -7,7 +7,7 @@ #include "src/DebugServer/Gdb/Signal.hpp" #include "src/DebugServer/Gdb/StopReason.hpp" -#include "src/Helpers/String.hpp" +#include "src/Services/StringService.hpp" namespace Bloom::DebugServer::Gdb::ResponsePackets { @@ -25,7 +25,7 @@ namespace Bloom::DebugServer::Gdb::ResponsePackets : signal(signal) , stopReason(stopReason) { - std::string packetData = "T" + String::toHex(std::vector({static_cast(this->signal)})); + std::string packetData = "T" + Services::StringService::toHex(static_cast(this->signal)); if (this->stopReason.has_value()) { static const auto stopReasonMapping = getStopReasonToNameMapping(); diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp index dee968ea..7cada4b3 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp @@ -4,7 +4,7 @@ #include #include "src/Services/PathService.hpp" -#include "src/Helpers/String.hpp" +#include "src/Services/StringService.hpp" #include "src/Logger/Logger.hpp" #include "src/Exceptions/InvalidConfig.hpp" @@ -984,13 +984,15 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr } void EdbgAvr8Interface::setParameter(const Avr8EdbgParameter& parameter, const std::vector& value) { + using Services::StringService; + const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame( SetParameter(parameter, value) ); Logger::debug( - "Setting AVR8 EDBG parameter (context: 0x" + String::toHex(parameter.context) + ", id: 0x" - + String::toHex(parameter.id) + ", value: 0x" + String::toHex(value) + ")" + "Setting AVR8 EDBG parameter (context: 0x" + StringService::toHex(parameter.context) + ", id: 0x" + + StringService::toHex(parameter.id) + ", value: 0x" + StringService::toHex(value) + ")" ); if (responseFrame.id == Avr8ResponseId::FAILED) { diff --git a/src/Insight/Insight.cpp b/src/Insight/Insight.cpp index 49b5c664..a01c4306 100644 --- a/src/Insight/Insight.cpp +++ b/src/Insight/Insight.cpp @@ -39,11 +39,7 @@ namespace Bloom ( QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts, true), #ifndef BLOOM_DEBUG_BUILD -<<<<<<< HEAD - QCoreApplication::addLibraryPath(QString::fromStdString(Paths::applicationDirPath() + "/../plugins")), -======= QCoreApplication::addLibraryPath(QString::fromStdString(Services::PathService::applicationDirPath() + "/plugins")), ->>>>>>> 0fea8bc1 (Moved Paths helper functions to service class) #endif QApplication(this->qtApplicationArgc, this->qtApplicationArgv.data()) ) diff --git a/src/Services/StringService.cpp b/src/Services/StringService.cpp index f2ed3f2f..242c925b 100644 --- a/src/Services/StringService.cpp +++ b/src/Services/StringService.cpp @@ -29,13 +29,13 @@ namespace Bloom::Services }); } - std::string String::toHex(unsigned char value) { + std::string StringService::toHex(unsigned char value) { auto stream = std::stringstream(); stream << std::hex << std::setfill('0') << std::setw(2) << static_cast(value); return stream.str(); } - std::string String::toHex(const std::vector& data) { + std::string StringService::toHex(const std::vector& data) { auto stream = std::stringstream(); stream << std::hex << std::setfill('0'); @@ -46,7 +46,7 @@ namespace Bloom::Services return stream.str(); } - std::string String::toHex(const std::string& data) { + std::string StringService::toHex(const std::string& data) { std::stringstream stream; stream << std::hex << std::setfill('0'); diff --git a/src/TargetController/TargetControllerComponent.cpp b/src/TargetController/TargetControllerComponent.cpp index 7fd7efb4..961b768f 100644 --- a/src/TargetController/TargetControllerComponent.cpp +++ b/src/TargetController/TargetControllerComponent.cpp @@ -439,40 +439,6 @@ namespace Bloom::TargetController TargetControllerComponent::responsesByCommandIdCv.notify_all(); } -<<<<<<< HEAD -======= - void TargetControllerComponent::checkUdevRules() { - auto bloomRulesPath = std::string("/etc/udev/rules.d/99-bloom.rules"); - auto latestBloomRulesPath = Services::PathService::resourcesDirPath() + "/UDevRules/99-bloom.rules"; - - if (!std::filesystem::exists(bloomRulesPath)) { - Logger::warning("Bloom udev rules missing - attempting installation"); - - // We can only install them if we're running as root - if (!Services::ProcessService::isRunningAsRoot()) { - Logger::error("Bloom udev rules missing - cannot install udev rules without root privileges.\n" - "Running Bloom once with root privileges will allow it to automatically install the udev rules. " - "Alternatively, instructions on manually installing the udev rules can be found " - "here: " + Services::PathService::homeDomainName() + "/docs/getting-started\nBloom may fail to connect to some " - "debug tools until this is resolved."); - return; - } - - if (!std::filesystem::exists(latestBloomRulesPath)) { - // This shouldn't happen, but it can if someone has been messing with the installation files - Logger::error( - "Unable to install Bloom udev rules - \"" + latestBloomRulesPath + "\" does not exist." - ); - return; - } - - std::filesystem::copy(latestBloomRulesPath, bloomRulesPath); - Logger::warning("Bloom udev rules installed - a reconnect of the debug tool may be required " - "before the new udev rules come into effect."); - } - } - ->>>>>>> b5402709 (Moved Process helper functions to service class) void TargetControllerComponent::shutdown() { if (this->getThreadState() == ThreadState::STOPPED) { return;