From 693abced8e9467806f89cf3d45e967e7f6bf538d Mon Sep 17 00:00:00 2001 From: Nav Date: Fri, 20 Jan 2023 22:53:04 +0000 Subject: [PATCH] Replaced overloaded casting of CMSIS-DAP Command with `rawCommand` member function --- .../Protocols/CMSIS-DAP/CmsisDapInterface.cpp | 2 +- src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.cpp | 3 ++- src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp | 5 ++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.cpp index 5ef79492..7eb420f3 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/CmsisDapInterface.cpp @@ -25,6 +25,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap this->lastCommandSentTimeStamp = now; } - this->getUsbHidInterface().write(static_cast>(cmsisDapCommand)); + this->getUsbHidInterface().write(cmsisDapCommand.rawCommand()); } } diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.cpp index e1c11087..e22dd131 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.cpp @@ -6,8 +6,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap : id(commandId) {} - Command::operator std::vector() const { + std::vector Command::rawCommand() const { auto rawCommand = std::vector(1, this->id); + rawCommand.reserve(this->data.size() + 1); rawCommand.insert(rawCommand.end(), this->data.begin(), this->data.end()); return rawCommand; diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp index dcb0583b..fa3c5b73 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/Command.hpp @@ -72,11 +72,10 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap } /** - * Converts instance of a CMSIS Command to a vector of unsigned char (buffer), for sending - * to the debug tool. + * Generates the raw CMSIS-DAP command, for sending to the CMSIS-DAP-enabled device. * * @return */ - explicit virtual operator std::vector() const; + std::vector rawCommand() const; }; }