Added ResponsePacket constructor with string param

This commit is contained in:
Nav
2022-04-06 17:10:57 +01:00
parent 203b6ff86f
commit 7fdfa389da
4 changed files with 8 additions and 6 deletions

View File

@@ -64,9 +64,8 @@ namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
this->bytes this->bytes
); );
auto hexMemoryBuffer = Packet::toHex(memoryBuffer);
debugSession.connection.writePacket( debugSession.connection.writePacket(
ResponsePacket(std::vector<unsigned char>(hexMemoryBuffer.begin(), hexMemoryBuffer.end())) ResponsePacket(Packet::toHex(memoryBuffer))
); );
} catch (const Exception& exception) { } catch (const Exception& exception) {

View File

@@ -42,13 +42,13 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
if (packetString.find("qAttached") == 0) { if (packetString.find("qAttached") == 0) {
Logger::debug("Handling qAttached"); Logger::debug("Handling qAttached");
debugSession.connection.writePacket(ResponsePacket({1})); debugSession.connection.writePacket(ResponsePacket(std::vector<unsigned char>({1})));
return; return;
} }
Logger::debug("Unknown GDB RSP packet: " + packetString + " - returning empty response"); Logger::debug("Unknown GDB RSP packet: " + packetString + " - returning empty response");
// Respond with an empty packet // Respond with an empty packet
debugSession.connection.writePacket(ResponsePacket({0})); debugSession.connection.writePacket(ResponsePacket(std::vector<unsigned char>({0})));
} }
} }

View File

@@ -84,9 +84,8 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
registers.insert(registers.end(), reg.value.begin(), reg.value.end()); registers.insert(registers.end(), reg.value.begin(), reg.value.end());
} }
auto responseRegisters = Packet::toHex(registers);
debugSession.connection.writePacket( debugSession.connection.writePacket(
ResponsePacket(std::vector<unsigned char>(responseRegisters.begin(), responseRegisters.end())) ResponsePacket(Packet::toHex(registers))
); );
} catch (const Exception& exception) { } catch (const Exception& exception) {

View File

@@ -18,5 +18,9 @@ namespace Bloom::DebugServer::Gdb::ResponsePackets
explicit ResponsePacket(const std::vector<unsigned char>& data) { explicit ResponsePacket(const std::vector<unsigned char>& data) {
this->data = data; this->data = data;
} }
explicit ResponsePacket(const std::string& data) {
this->data = std::vector<unsigned char>(data.begin(), data.end());
}
}; };
} }