Moving ResponseId enum for the DISCOVERY EDBG protocol out of the command frame class header.
This commit is contained in:
@@ -53,6 +53,7 @@ namespace Bloom::DebugToolDrivers
|
||||
|
||||
std::string AtmelIce::getSerialNumber() {
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace Bloom::DebugToolDrivers
|
||||
|
||||
std::string CuriosityNano::getSerialNumber() {
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace Bloom::DebugToolDrivers
|
||||
|
||||
std::string MplabPickit4::getSerialNumber() {
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace Bloom::DebugToolDrivers
|
||||
|
||||
std::string MplabSnap::getSerialNumber() {
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace Bloom::DebugToolDrivers
|
||||
|
||||
std::string PowerDebugger::getSerialNumber() {
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace Bloom::DebugToolDrivers
|
||||
|
||||
std::string XplainedMini::getSerialNumber() {
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
|
||||
@@ -45,6 +45,7 @@ namespace Bloom::DebugToolDrivers
|
||||
|
||||
std::string XplainedNano::getSerialNumber() {
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace Bloom::DebugToolDrivers
|
||||
|
||||
std::string XplainedPro::getSerialNumber() {
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
|
||||
@@ -5,40 +5,11 @@
|
||||
|
||||
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Discovery
|
||||
{
|
||||
/**
|
||||
* Discovery commands can only return two responses; A LIST response and a failure.
|
||||
*/
|
||||
enum class ResponseId : unsigned char
|
||||
{
|
||||
/*
|
||||
* According to the protocol docs, response ID 0x81 is for a LIST response, but this doesn't seem to be
|
||||
* well defined. So just going to use a generic name.
|
||||
*/
|
||||
OK = 0x81,
|
||||
FAILED = 0xA0,
|
||||
};
|
||||
|
||||
inline bool operator == (unsigned char rawId, ResponseId id) {
|
||||
return static_cast<unsigned char>(id) == rawId;
|
||||
}
|
||||
|
||||
inline bool operator == (ResponseId id, unsigned char rawId) {
|
||||
return static_cast<unsigned char>(id) == rawId;
|
||||
}
|
||||
|
||||
inline bool operator != (unsigned char rawId, ResponseId id) {
|
||||
return static_cast<unsigned char>(id) != rawId;
|
||||
}
|
||||
|
||||
inline bool operator != (ResponseId id, unsigned char rawId) {
|
||||
return static_cast<unsigned char>(id) != rawId;
|
||||
}
|
||||
|
||||
template<class PayloadContainerType>
|
||||
class DiscoveryCommandFrame: public AvrCommandFrame<PayloadContainerType>
|
||||
{
|
||||
public:
|
||||
using ExpectedResponseFrameType = ResponseFrames::DiscoveryResponseFrame;
|
||||
using ExpectedResponseFrameType = ResponseFrames::Discovery::DiscoveryResponseFrame;
|
||||
|
||||
DiscoveryCommandFrame(): AvrCommandFrame<PayloadContainerType>(ProtocolHandlerId::DISCOVERY) {}
|
||||
};
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
|
||||
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames
|
||||
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Discovery
|
||||
{
|
||||
using namespace Bloom::Exceptions;
|
||||
|
||||
unsigned char DiscoveryResponseFrame::getResponseId() {
|
||||
ResponseId DiscoveryResponseFrame::getResponseId() {
|
||||
const auto& payload = this->getPayload();
|
||||
|
||||
if (payload.empty()) {
|
||||
throw Exception("Response ID missing from DISCOVERY response frame payload.");
|
||||
}
|
||||
|
||||
return payload[0];
|
||||
return static_cast<ResponseId>(payload[0]);
|
||||
}
|
||||
|
||||
std::vector<unsigned char> DiscoveryResponseFrame::getPayloadData() {
|
||||
|
||||
@@ -2,15 +2,28 @@
|
||||
|
||||
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp"
|
||||
|
||||
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames
|
||||
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Discovery
|
||||
{
|
||||
/**
|
||||
* Discovery commands can only return two responses; A LIST response and a failure.
|
||||
*/
|
||||
enum class ResponseId : unsigned char
|
||||
{
|
||||
/*
|
||||
* According to the protocol docs, response ID 0x81 is for a LIST response, but this doesn't seem to be
|
||||
* well defined. So just going to use a generic name.
|
||||
*/
|
||||
OK = 0x81,
|
||||
FAILED = 0xA0,
|
||||
};
|
||||
|
||||
class DiscoveryResponseFrame: public AvrResponseFrame
|
||||
{
|
||||
public:
|
||||
DiscoveryResponseFrame() = default;
|
||||
explicit DiscoveryResponseFrame(const std::vector<AvrResponse>& avrResponses): AvrResponseFrame(avrResponses) {}
|
||||
|
||||
unsigned char getResponseId();
|
||||
ResponseId getResponseId();
|
||||
|
||||
/**
|
||||
* See parent method.
|
||||
|
||||
Reference in New Issue
Block a user