diff --git a/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.cpp b/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.cpp index 4f1d8413..809f382e 100644 --- a/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.cpp +++ b/src/DebugToolDrivers/Microchip/AtmelICE/AtmelIce.cpp @@ -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) diff --git a/src/DebugToolDrivers/Microchip/CuriosityNano/CuriosityNano.cpp b/src/DebugToolDrivers/Microchip/CuriosityNano/CuriosityNano.cpp index 7d7f363a..04394029 100644 --- a/src/DebugToolDrivers/Microchip/CuriosityNano/CuriosityNano.cpp +++ b/src/DebugToolDrivers/Microchip/CuriosityNano/CuriosityNano.cpp @@ -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) diff --git a/src/DebugToolDrivers/Microchip/MplabPickit4/MplabPickit4.cpp b/src/DebugToolDrivers/Microchip/MplabPickit4/MplabPickit4.cpp index 542b3b96..cb0de062 100644 --- a/src/DebugToolDrivers/Microchip/MplabPickit4/MplabPickit4.cpp +++ b/src/DebugToolDrivers/Microchip/MplabPickit4/MplabPickit4.cpp @@ -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) diff --git a/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.cpp b/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.cpp index 60783f76..508cc4bf 100644 --- a/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.cpp +++ b/src/DebugToolDrivers/Microchip/MplabSnap/MplabSnap.cpp @@ -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) diff --git a/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.cpp b/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.cpp index b370f142..99f275ef 100644 --- a/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.cpp +++ b/src/DebugToolDrivers/Microchip/PowerDebugger/PowerDebugger.cpp @@ -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) diff --git a/src/DebugToolDrivers/Microchip/XplainedMini/XplainedMini.cpp b/src/DebugToolDrivers/Microchip/XplainedMini/XplainedMini.cpp index 140d39b7..4223024f 100644 --- a/src/DebugToolDrivers/Microchip/XplainedMini/XplainedMini.cpp +++ b/src/DebugToolDrivers/Microchip/XplainedMini/XplainedMini.cpp @@ -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) diff --git a/src/DebugToolDrivers/Microchip/XplainedNano/XplainedNano.cpp b/src/DebugToolDrivers/Microchip/XplainedNano/XplainedNano.cpp index d9ef241d..797f07c3 100644 --- a/src/DebugToolDrivers/Microchip/XplainedNano/XplainedNano.cpp +++ b/src/DebugToolDrivers/Microchip/XplainedNano/XplainedNano.cpp @@ -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) diff --git a/src/DebugToolDrivers/Microchip/XplainedPro/XplainedPro.cpp b/src/DebugToolDrivers/Microchip/XplainedPro/XplainedPro.cpp index ad2965e0..90056e0a 100644 --- a/src/DebugToolDrivers/Microchip/XplainedPro/XplainedPro.cpp +++ b/src/DebugToolDrivers/Microchip/XplainedPro/XplainedPro.cpp @@ -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) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp index 5c6c0196..7e4a8cd1 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/Discovery/DiscoveryCommandFrame.hpp @@ -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(id) == rawId; - } - - inline bool operator == (ResponseId id, unsigned char rawId) { - return static_cast(id) == rawId; - } - - inline bool operator != (unsigned char rawId, ResponseId id) { - return static_cast(id) != rawId; - } - - inline bool operator != (ResponseId id, unsigned char rawId) { - return static_cast(id) != rawId; - } - template class DiscoveryCommandFrame: public AvrCommandFrame { public: - using ExpectedResponseFrameType = ResponseFrames::DiscoveryResponseFrame; + using ExpectedResponseFrameType = ResponseFrames::Discovery::DiscoveryResponseFrame; DiscoveryCommandFrame(): AvrCommandFrame(ProtocolHandlerId::DISCOVERY) {} }; diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.cpp index e64bb376..d1e1297d 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.cpp @@ -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(payload[0]); } std::vector DiscoveryResponseFrame::getPayloadData() { diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.hpp index 527ed607..95bedd4b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/ResponseFrames/Discovery/DiscoveryResponseFrame.hpp @@ -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& avrResponses): AvrResponseFrame(avrResponses) {} - unsigned char getResponseId(); + ResponseId getResponseId(); /** * See parent method.