2021-04-04 21:04:12 +01:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
|
|
|
|
|
{
|
|
|
|
|
class Command
|
|
|
|
|
{
|
|
|
|
|
private:
|
|
|
|
|
unsigned char commandId = 0x00;
|
|
|
|
|
std::vector<unsigned char> data;
|
|
|
|
|
|
|
|
|
|
public:
|
2021-06-22 23:52:31 +01:00
|
|
|
[[nodiscard]] unsigned char getCommandId() const {
|
2021-04-04 21:04:12 +01:00
|
|
|
return this->commandId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setCommandId(unsigned char commandId) {
|
|
|
|
|
this->commandId = commandId;
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-22 23:52:31 +01:00
|
|
|
[[nodiscard]] virtual std::vector<unsigned char> getData() const {
|
2021-04-04 21:04:12 +01:00
|
|
|
return this->data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void setData(const std::vector<unsigned char>& data) {
|
|
|
|
|
this->data = data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[[nodiscard]] int getCommandSize() const {
|
|
|
|
|
// +1 for the command ID
|
|
|
|
|
return (int) (1 + this->getData().size());
|
|
|
|
|
}
|
|
|
|
|
|
2021-06-22 23:52:31 +01:00
|
|
|
[[nodiscard]] std::uint16_t getDataSize() const {
|
2021-04-04 21:04:12 +01:00
|
|
|
return (std::uint16_t) this->getData().size();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Converts instance of a CMSIS Command to a vector of unsigned char (buffer), for sending
|
|
|
|
|
* to the debug tool.
|
|
|
|
|
*
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
explicit virtual operator std::vector<unsigned char>() const;
|
|
|
|
|
|
|
|
|
|
virtual ~Command() = default;
|
|
|
|
|
};
|
|
|
|
|
}
|