Moved vFlashDone GDB command packet handelr to separate class
This commit is contained in:
@@ -33,4 +33,5 @@ target_sources(
|
|||||||
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/ReadMemoryMap.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/ReadMemoryMap.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/FlashErase.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/FlashErase.cpp
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/FlashWrite.cpp
|
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/FlashWrite.cpp
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/Gdb/AvrGdb/CommandPackets/FlashDone.cpp
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
#include "CommandPackets/ReadMemoryMap.hpp"
|
#include "CommandPackets/ReadMemoryMap.hpp"
|
||||||
#include "CommandPackets/FlashErase.hpp"
|
#include "CommandPackets/FlashErase.hpp"
|
||||||
#include "CommandPackets/FlashWrite.hpp"
|
#include "CommandPackets/FlashWrite.hpp"
|
||||||
|
#include "CommandPackets/FlashDone.hpp"
|
||||||
|
|
||||||
namespace Bloom::DebugServer::Gdb::AvrGdb
|
namespace Bloom::DebugServer::Gdb::AvrGdb
|
||||||
{
|
{
|
||||||
@@ -38,6 +39,7 @@ namespace Bloom::DebugServer::Gdb::AvrGdb
|
|||||||
using AvrGdb::CommandPackets::ReadMemoryMap;
|
using AvrGdb::CommandPackets::ReadMemoryMap;
|
||||||
using AvrGdb::CommandPackets::FlashErase;
|
using AvrGdb::CommandPackets::FlashErase;
|
||||||
using AvrGdb::CommandPackets::FlashWrite;
|
using AvrGdb::CommandPackets::FlashWrite;
|
||||||
|
using AvrGdb::CommandPackets::FlashDone;
|
||||||
|
|
||||||
if (rawPacket.size() >= 2) {
|
if (rawPacket.size() >= 2) {
|
||||||
if (rawPacket[1] == 'm') {
|
if (rawPacket[1] == 'm') {
|
||||||
@@ -61,6 +63,10 @@ namespace Bloom::DebugServer::Gdb::AvrGdb
|
|||||||
if (rawPacketString.find("vFlashWrite") == 0) {
|
if (rawPacketString.find("vFlashWrite") == 0) {
|
||||||
return std::make_unique<FlashWrite>(rawPacket);
|
return std::make_unique<FlashWrite>(rawPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (rawPacketString.find("vFlashDone") == 0) {
|
||||||
|
return std::make_unique<FlashDone>(rawPacket);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return GdbRspDebugServer::resolveCommandPacket(rawPacket);
|
return GdbRspDebugServer::resolveCommandPacket(rawPacket);
|
||||||
|
|||||||
35
src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashDone.cpp
Normal file
35
src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashDone.cpp
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#include "FlashDone.hpp"
|
||||||
|
|
||||||
|
#include "src/DebugServer/Gdb/ResponsePackets/ErrorResponsePacket.hpp"
|
||||||
|
#include "src/DebugServer/Gdb/ResponsePackets/OkResponsePacket.hpp"
|
||||||
|
|
||||||
|
#include "src/Logger/Logger.hpp"
|
||||||
|
#include "src/Exceptions/Exception.hpp"
|
||||||
|
|
||||||
|
namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
|
||||||
|
{
|
||||||
|
using TargetController::TargetControllerConsole;
|
||||||
|
|
||||||
|
using ResponsePackets::ErrorResponsePacket;
|
||||||
|
using ResponsePackets::OkResponsePacket;
|
||||||
|
|
||||||
|
using namespace Bloom::Exceptions;
|
||||||
|
|
||||||
|
FlashDone::FlashDone(const RawPacketType& rawPacket)
|
||||||
|
: MemoryAccessCommandPacket(rawPacket)
|
||||||
|
{}
|
||||||
|
|
||||||
|
void FlashDone::handle(DebugSession& debugSession, TargetControllerConsole& targetControllerConsole) {
|
||||||
|
Logger::debug("Handling FlashDone packet");
|
||||||
|
|
||||||
|
try {
|
||||||
|
targetControllerConsole.disableProgrammingMode();
|
||||||
|
|
||||||
|
debugSession.connection.writePacket(OkResponsePacket());
|
||||||
|
|
||||||
|
} catch (const Exception& exception) {
|
||||||
|
Logger::error("Failed to disabling programming mode - " + exception.getMessage());
|
||||||
|
debugSession.connection.writePacket(ErrorResponsePacket());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
23
src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashDone.hpp
Normal file
23
src/DebugServer/Gdb/AvrGdb/CommandPackets/FlashDone.hpp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
|
#include "MemoryAccessCommandPacket.hpp"
|
||||||
|
|
||||||
|
namespace Bloom::DebugServer::Gdb::AvrGdb::CommandPackets
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The FlashDone class implements the structure for the "vFlashDone" packet.
|
||||||
|
*/
|
||||||
|
class FlashDone: public MemoryAccessCommandPacket
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
explicit FlashDone(const RawPacketType& rawPacket);
|
||||||
|
|
||||||
|
void handle(
|
||||||
|
DebugSession& debugSession,
|
||||||
|
TargetController::TargetControllerConsole& targetControllerConsole
|
||||||
|
) override;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -56,12 +56,6 @@ namespace Bloom::DebugServer::Gdb::CommandPackets
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (packetString.find("vFlashDone") == 0) {
|
|
||||||
Logger::debug("Handling vFlashDone");
|
|
||||||
debugSession.connection.writePacket(OkResponsePacket());
|
|
||||||
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
|
||||||
|
|||||||
Reference in New Issue
Block a user