Send "end process" command to detach from target, upon deactivaition of WCH-Link debug tools

This commit is contained in:
Nav
2023-11-26 00:41:45 +00:00
parent ddcb122137
commit d6b216d51e
2 changed files with 26 additions and 1 deletions

View File

@@ -0,0 +1,20 @@
#pragma once
#include <cstdint>
#include "src/DebugToolDrivers/WCH/Protocols/WchLink/Commands/Command.hpp"
namespace DebugToolDrivers::Wch::Protocols::WchLink::Commands::Control
{
class DetachTarget: public Command<std::array<unsigned char, 1>>
{
public:
DetachTarget()
: Command(0x0d)
{
this->payload = {
0xff
};
}
};
}

View File

@@ -4,6 +4,7 @@
#include "Commands/Control/GetDeviceInfo.hpp"
#include "Commands/Control/AttachTarget.hpp"
#include "Commands/Control/DetachTarget.hpp"
#include "Commands/SetClockSpeed.hpp"
#include "Commands/DebugModuleInterfaceOperation.hpp"
@@ -63,7 +64,11 @@ namespace DebugToolDrivers::Wch::Protocols::WchLink
}
void WchLinkInterface::deactivate() {
// TODO: implement this
const auto response = this->sendCommandAndWaitForResponse(Commands::Control::DetachTarget());
if (response.payload.size() != 1) {
throw Exceptions::DeviceCommunicationFailure("Unexpected response payload size for DetachTarget command");
}
}
std::string WchLinkInterface::getDeviceId() {