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() {
|
std::string AtmelIce::getSerialNumber() {
|
||||||
using namespace CommandFrames::Discovery;
|
using namespace CommandFrames::Discovery;
|
||||||
|
using ResponseFrames::Discovery::ResponseId;
|
||||||
|
|
||||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||||
Query(QueryContext::SERIAL_NUMBER)
|
Query(QueryContext::SERIAL_NUMBER)
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ namespace Bloom::DebugToolDrivers
|
|||||||
|
|
||||||
std::string CuriosityNano::getSerialNumber() {
|
std::string CuriosityNano::getSerialNumber() {
|
||||||
using namespace CommandFrames::Discovery;
|
using namespace CommandFrames::Discovery;
|
||||||
|
using ResponseFrames::Discovery::ResponseId;
|
||||||
|
|
||||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||||
Query(QueryContext::SERIAL_NUMBER)
|
Query(QueryContext::SERIAL_NUMBER)
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ namespace Bloom::DebugToolDrivers
|
|||||||
|
|
||||||
std::string MplabPickit4::getSerialNumber() {
|
std::string MplabPickit4::getSerialNumber() {
|
||||||
using namespace CommandFrames::Discovery;
|
using namespace CommandFrames::Discovery;
|
||||||
|
using ResponseFrames::Discovery::ResponseId;
|
||||||
|
|
||||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||||
Query(QueryContext::SERIAL_NUMBER)
|
Query(QueryContext::SERIAL_NUMBER)
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ namespace Bloom::DebugToolDrivers
|
|||||||
|
|
||||||
std::string MplabSnap::getSerialNumber() {
|
std::string MplabSnap::getSerialNumber() {
|
||||||
using namespace CommandFrames::Discovery;
|
using namespace CommandFrames::Discovery;
|
||||||
|
using ResponseFrames::Discovery::ResponseId;
|
||||||
|
|
||||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||||
Query(QueryContext::SERIAL_NUMBER)
|
Query(QueryContext::SERIAL_NUMBER)
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ namespace Bloom::DebugToolDrivers
|
|||||||
|
|
||||||
std::string PowerDebugger::getSerialNumber() {
|
std::string PowerDebugger::getSerialNumber() {
|
||||||
using namespace CommandFrames::Discovery;
|
using namespace CommandFrames::Discovery;
|
||||||
|
using ResponseFrames::Discovery::ResponseId;
|
||||||
|
|
||||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||||
Query(QueryContext::SERIAL_NUMBER)
|
Query(QueryContext::SERIAL_NUMBER)
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ namespace Bloom::DebugToolDrivers
|
|||||||
|
|
||||||
std::string XplainedMini::getSerialNumber() {
|
std::string XplainedMini::getSerialNumber() {
|
||||||
using namespace CommandFrames::Discovery;
|
using namespace CommandFrames::Discovery;
|
||||||
|
using ResponseFrames::Discovery::ResponseId;
|
||||||
|
|
||||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||||
Query(QueryContext::SERIAL_NUMBER)
|
Query(QueryContext::SERIAL_NUMBER)
|
||||||
|
|||||||
@@ -45,6 +45,7 @@ namespace Bloom::DebugToolDrivers
|
|||||||
|
|
||||||
std::string XplainedNano::getSerialNumber() {
|
std::string XplainedNano::getSerialNumber() {
|
||||||
using namespace CommandFrames::Discovery;
|
using namespace CommandFrames::Discovery;
|
||||||
|
using ResponseFrames::Discovery::ResponseId;
|
||||||
|
|
||||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||||
Query(QueryContext::SERIAL_NUMBER)
|
Query(QueryContext::SERIAL_NUMBER)
|
||||||
|
|||||||
@@ -54,6 +54,7 @@ namespace Bloom::DebugToolDrivers
|
|||||||
|
|
||||||
std::string XplainedPro::getSerialNumber() {
|
std::string XplainedPro::getSerialNumber() {
|
||||||
using namespace CommandFrames::Discovery;
|
using namespace CommandFrames::Discovery;
|
||||||
|
using ResponseFrames::Discovery::ResponseId;
|
||||||
|
|
||||||
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
auto response = this->getEdbgInterface().sendAvrCommandFrameAndWaitForResponseFrame(
|
||||||
Query(QueryContext::SERIAL_NUMBER)
|
Query(QueryContext::SERIAL_NUMBER)
|
||||||
|
|||||||
@@ -5,40 +5,11 @@
|
|||||||
|
|
||||||
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames::Discovery
|
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>
|
template<class PayloadContainerType>
|
||||||
class DiscoveryCommandFrame: public AvrCommandFrame<PayloadContainerType>
|
class DiscoveryCommandFrame: public AvrCommandFrame<PayloadContainerType>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using ExpectedResponseFrameType = ResponseFrames::DiscoveryResponseFrame;
|
using ExpectedResponseFrameType = ResponseFrames::Discovery::DiscoveryResponseFrame;
|
||||||
|
|
||||||
DiscoveryCommandFrame(): AvrCommandFrame<PayloadContainerType>(ProtocolHandlerId::DISCOVERY) {}
|
DiscoveryCommandFrame(): AvrCommandFrame<PayloadContainerType>(ProtocolHandlerId::DISCOVERY) {}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,18 +2,18 @@
|
|||||||
|
|
||||||
#include "src/Exceptions/Exception.hpp"
|
#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;
|
using namespace Bloom::Exceptions;
|
||||||
|
|
||||||
unsigned char DiscoveryResponseFrame::getResponseId() {
|
ResponseId DiscoveryResponseFrame::getResponseId() {
|
||||||
const auto& payload = this->getPayload();
|
const auto& payload = this->getPayload();
|
||||||
|
|
||||||
if (payload.empty()) {
|
if (payload.empty()) {
|
||||||
throw Exception("Response ID missing from DISCOVERY response frame payload.");
|
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() {
|
std::vector<unsigned char> DiscoveryResponseFrame::getPayloadData() {
|
||||||
|
|||||||
@@ -2,15 +2,28 @@
|
|||||||
|
|
||||||
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/AvrResponseFrame.hpp"
|
#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
|
class DiscoveryResponseFrame: public AvrResponseFrame
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DiscoveryResponseFrame() = default;
|
DiscoveryResponseFrame() = default;
|
||||||
explicit DiscoveryResponseFrame(const std::vector<AvrResponse>& avrResponses): AvrResponseFrame(avrResponses) {}
|
explicit DiscoveryResponseFrame(const std::vector<AvrResponse>& avrResponses): AvrResponseFrame(avrResponses) {}
|
||||||
|
|
||||||
unsigned char getResponseId();
|
ResponseId getResponseId();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See parent method.
|
* See parent method.
|
||||||
|
|||||||
Reference in New Issue
Block a user