This commit is contained in:
Nav
2021-04-06 02:10:14 +01:00
parent 2fd045e056
commit 7a28f93ee9
85 changed files with 319 additions and 1177 deletions

View File

@@ -1,24 +1,15 @@
#include <cstdint>
#include "src/Exceptions/Exception.hpp"
#include "Response.hpp"
using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap;
void Response::init(unsigned char* response, std::size_t length)
void Response::init(const std::vector<unsigned char>& rawResponse)
{
if (length == 0) {
if (rawResponse.size() < 1) {
throw Exceptions::Exception("Failed to process CMSIS-DAP response - invalid response");
}
this->setResponseId(response[0]);
std::vector<unsigned char> data = this->getData();
// TODO: use insert with iterators here
for (std::size_t i = 1; i < length; i++) {
data.push_back(response[i]);
}
this->setData(data);
this->setResponseId(rawResponse[0]);
this->setData(std::vector<unsigned char>(rawResponse.begin() + 1, rawResponse.end()));
}