Replaced overloaded casting of CMSIS-DAP Command with rawCommand member function

This commit is contained in:
Nav
2023-01-20 22:53:04 +00:00
parent c35fdbd4ed
commit 693abced8e
3 changed files with 5 additions and 5 deletions

View File

@@ -25,6 +25,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
this->lastCommandSentTimeStamp = now;
}
this->getUsbHidInterface().write(static_cast<std::vector<unsigned char>>(cmsisDapCommand));
this->getUsbHidInterface().write(cmsisDapCommand.rawCommand());
}
}

View File

@@ -6,8 +6,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
: id(commandId)
{}
Command::operator std::vector<unsigned char>() const {
std::vector<unsigned char> Command::rawCommand() const {
auto rawCommand = std::vector<unsigned char>(1, this->id);
rawCommand.reserve(this->data.size() + 1);
rawCommand.insert(rawCommand.end(), this->data.begin(), this->data.end());
return rawCommand;

View File

@@ -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<unsigned char>() const;
std::vector<unsigned char> rawCommand() const;
};
}