General tidying, addressing issues found by static analysis tool.
This commit is contained in:
@@ -23,7 +23,7 @@ namespace Bloom
|
||||
}
|
||||
|
||||
public:
|
||||
bool isInitialised() const {
|
||||
[[nodiscard]] bool isInitialised() const {
|
||||
return this->initialised;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap;
|
||||
|
||||
Command::operator std::vector<unsigned char> () const
|
||||
{
|
||||
Command::operator std::vector<unsigned char> () const {
|
||||
auto rawCommand = std::vector<unsigned char>(1, this->getCommandId());
|
||||
auto commandData = this->getData();
|
||||
rawCommand.insert(rawCommand.end(), commandData.begin(), commandData.end());
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
|
||||
std::vector<unsigned char> data;
|
||||
|
||||
public:
|
||||
unsigned char getCommandId() const {
|
||||
[[nodiscard]] unsigned char getCommandId() const {
|
||||
return this->commandId;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
|
||||
this->commandId = commandId;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getData() const {
|
||||
[[nodiscard]] virtual std::vector<unsigned char> getData() const {
|
||||
return this->data;
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
|
||||
return (int) (1 + this->getData().size());
|
||||
}
|
||||
|
||||
std::uint16_t getDataSize() const {
|
||||
[[nodiscard]] std::uint16_t getDataSize() const {
|
||||
return (std::uint16_t) this->getData().size();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,5 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
|
||||
explicit virtual operator std::vector<unsigned char>() const;
|
||||
|
||||
virtual ~Command() = default;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -3,13 +3,11 @@
|
||||
|
||||
using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap;
|
||||
|
||||
void Response::init(const std::vector<unsigned char>& rawResponse)
|
||||
{
|
||||
if (rawResponse.size() < 1) {
|
||||
void Response::init(const std::vector<unsigned char>& rawResponse) {
|
||||
if (rawResponse.empty()) {
|
||||
throw Exceptions::Exception("Failed to process CMSIS-DAP response - invalid response");
|
||||
}
|
||||
|
||||
this->setResponseId(rawResponse[0]);
|
||||
this->setData(std::vector<unsigned char>(rawResponse.begin() + 1, rawResponse.end()));
|
||||
}
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap
|
||||
Response() = default;
|
||||
virtual void init(const std::vector<unsigned char>& rawResponse);
|
||||
|
||||
unsigned char getResponseId() const {
|
||||
[[nodiscard]] unsigned char getResponseId() const {
|
||||
return this->responseId;
|
||||
}
|
||||
|
||||
virtual const std::vector<unsigned char>& getData() const {
|
||||
[[nodiscard]] virtual const std::vector<unsigned char>& getData() const {
|
||||
return this->data;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
|
||||
using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr;
|
||||
|
||||
std::vector<unsigned char> AvrCommand::getData() const
|
||||
{
|
||||
std::vector<unsigned char> AvrCommand::getData() const {
|
||||
std::vector<unsigned char> data;
|
||||
auto commandPacket = this->getCommandPacket();
|
||||
std::size_t commandPacketSize = commandPacket.size();
|
||||
@@ -21,4 +20,3 @@ std::vector<unsigned char> AvrCommand::getData() const
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
std::vector<unsigned char> getData() const override;
|
||||
[[nodiscard]] std::vector<unsigned char> getData() const override;
|
||||
|
||||
size_t getFragmentNumber() const {
|
||||
[[nodiscard]] size_t getFragmentNumber() const {
|
||||
return this->fragmentNumber;
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
this->fragmentNumber = fragmentNumber;
|
||||
}
|
||||
|
||||
size_t getFragmentCount() const {
|
||||
[[nodiscard]] size_t getFragmentCount() const {
|
||||
return this->fragmentCount;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
this->fragmentCount = fragmentCount;
|
||||
}
|
||||
|
||||
const std::vector<unsigned char>& getCommandPacket() const {
|
||||
[[nodiscard]] const std::vector<unsigned char>& getCommandPacket() const {
|
||||
return this->commandPacket;
|
||||
}
|
||||
|
||||
@@ -50,5 +50,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
this->commandPacket = commandPacket;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ void AvrEvent::init(const std::vector<unsigned char>& rawResponse) {
|
||||
}
|
||||
|
||||
// Response size is two bytes, MSB
|
||||
size_t responsePacketSize = static_cast<size_t>((responseData[0] << 8) | responseData[1]);
|
||||
auto responsePacketSize = static_cast<size_t>((responseData[0] << 8) | responseData[1]);
|
||||
|
||||
if (responseData.size() < 2) {
|
||||
// All AVR_EVT responses should consist of at least two bytes (excluding the AVR_EVT ID)
|
||||
@@ -42,8 +42,7 @@ void AvrEvent::init(const std::vector<unsigned char>& rawResponse) {
|
||||
|
||||
this->setEventData(eventData);
|
||||
|
||||
if (eventData.size() >= 1) {
|
||||
if (!eventData.empty()) {
|
||||
this->eventId = eventData[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
class AvrEvent: public Response
|
||||
{
|
||||
private:
|
||||
unsigned char eventId;
|
||||
unsigned char eventId = 0;
|
||||
|
||||
std::vector<unsigned char> eventData;
|
||||
|
||||
@@ -48,15 +48,15 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
|
||||
void init(const std::vector<unsigned char>& rawResponse) override;
|
||||
|
||||
const std::vector<unsigned char>& getEventData() const {
|
||||
[[nodiscard]] const std::vector<unsigned char>& getEventData() const {
|
||||
return this->eventData;
|
||||
}
|
||||
|
||||
size_t getEventDataSize() const {
|
||||
[[nodiscard]] size_t getEventDataSize() const {
|
||||
return this->eventData.size();
|
||||
}
|
||||
|
||||
AvrEventId getEventId() {
|
||||
[[nodiscard]] AvrEventId getEventId() const {
|
||||
return static_cast<AvrEventId>(this->eventId);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -44,15 +44,15 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
|
||||
void init(const std::vector<unsigned char>& rawResponse) override;
|
||||
|
||||
std::uint8_t getFragmentNumber() const {
|
||||
[[nodiscard]] std::uint8_t getFragmentNumber() const {
|
||||
return this->fragmentNumber;
|
||||
}
|
||||
|
||||
std::uint8_t getFragmentCount() const {
|
||||
[[nodiscard]] std::uint8_t getFragmentCount() const {
|
||||
return this->fragmentCount;
|
||||
}
|
||||
|
||||
const std::vector<unsigned char>& getResponsePacket() const {
|
||||
[[nodiscard]] const std::vector<unsigned char>& getResponsePacket() const {
|
||||
return this->responsePacket;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
|
||||
public:
|
||||
ActivatePhysical() = default;
|
||||
ActivatePhysical(bool reset): reset(reset) {};
|
||||
explicit ActivatePhysical(bool reset): reset(reset) {};
|
||||
|
||||
void setReset(bool reset) {
|
||||
this->reset = reset;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The activate physical command consists of 3 bytes:
|
||||
* 1. Command ID (0x10)
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
|
||||
public:
|
||||
Attach() = default;
|
||||
Attach(bool breakAfterAttach): breakAfterAttach(breakAfterAttach) {};
|
||||
explicit Attach(bool breakAfterAttach): breakAfterAttach(breakAfterAttach) {};
|
||||
|
||||
void setBreadAfterAttach(bool breakAfterAttach) {
|
||||
this->breakAfterAttach = breakAfterAttach;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The attach command consists of 3 bytes:
|
||||
* 1. Command ID (0x13)
|
||||
|
||||
@@ -13,8 +13,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
using ResponseFrameType = ResponseFrames::Avr8Generic::Avr8GenericResponseFrame;
|
||||
|
||||
Avr8GenericCommandFrame() {
|
||||
this->setProtocolHandlerId(ProtocolHandlerId::Avr8Generic);
|
||||
this->setProtocolHandlerId(ProtocolHandlerId::AVR8_GENERIC);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
init();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
|
||||
#include "Avr8GenericCommandFrame.hpp"
|
||||
|
||||
@@ -14,13 +15,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
public:
|
||||
ClearSoftwareBreakpoints() = default;
|
||||
|
||||
ClearSoftwareBreakpoints(const std::vector<std::uint32_t>& addresses): addresses(addresses) {}
|
||||
explicit ClearSoftwareBreakpoints(std::vector<std::uint32_t> addresses): addresses(std::move(addresses)) {}
|
||||
|
||||
void setAddresses(const std::vector<std::uint32_t>& addresses) {
|
||||
this->addresses = addresses;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The clear software breakpoints command consists of 2 bytes + 4*n bytes, where n is the number
|
||||
* of breakpoints to clear:
|
||||
@@ -43,5 +44,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
init();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
init();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
init();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -27,5 +27,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
init();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -10,12 +10,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
{
|
||||
private:
|
||||
Avr8EdbgParameter parameter;
|
||||
std::uint8_t size;
|
||||
std::uint8_t size = 0;
|
||||
|
||||
public:
|
||||
GetParameter() = default;
|
||||
|
||||
GetParameter(const Avr8EdbgParameter& parameter) {
|
||||
explicit GetParameter(const Avr8EdbgParameter& parameter) {
|
||||
this->setParameter(parameter);
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
this->size = size;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The get param command consists of 5 bytes:
|
||||
* 1. Command ID (0x02)
|
||||
@@ -50,5 +50,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -27,5 +27,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
init();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
class ReadMemory: public Avr8GenericCommandFrame
|
||||
{
|
||||
private:
|
||||
Avr8MemoryType type;
|
||||
Avr8MemoryType type = Avr8MemoryType::SRAM;
|
||||
std::uint32_t address = 0;
|
||||
std::uint32_t bytes = 0;
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
this->bytes = bytes;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The read memory command consists of 11 bytes:
|
||||
* 1. Command ID (0x21)
|
||||
@@ -56,5 +56,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
|
||||
public:
|
||||
Reset() = default;
|
||||
Reset(bool stopAtMainAddress): stopAtMainAddress(stopAtMainAddress) {};
|
||||
explicit Reset(bool stopAtMainAddress): stopAtMainAddress(stopAtMainAddress) {};
|
||||
|
||||
void setStopAtMainAddress(bool stopAtMainAddress) {
|
||||
this->stopAtMainAddress = stopAtMainAddress;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The reset command consists of 3 bytes:
|
||||
* 1. Command ID (0x30)
|
||||
@@ -32,5 +32,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
init();
|
||||
};
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -9,18 +9,18 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
class RunTo: public Avr8GenericCommandFrame
|
||||
{
|
||||
private:
|
||||
std::uint32_t address;
|
||||
std::uint32_t address = 0;
|
||||
|
||||
public:
|
||||
RunTo() = default;
|
||||
|
||||
RunTo(const std::uint32_t& address): address(address) {}
|
||||
explicit RunTo(const std::uint32_t& address): address(address) {}
|
||||
|
||||
void setAddress(const std::uint32_t& address) {
|
||||
this->address = address;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The run-to command consists of 6 bytes:
|
||||
*
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
public:
|
||||
SetParameter() = default;
|
||||
|
||||
SetParameter(const Avr8EdbgParameter& parameter) {
|
||||
explicit SetParameter(const Avr8EdbgParameter& parameter) {
|
||||
this->setParameter(parameter);
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
this->value.resize(1, value);
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The set param command consists of this->value.size() + 5 bytes. The first five bytes consist of:
|
||||
* 1. Command ID (0x01)
|
||||
@@ -58,5 +58,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
std::uint32_t programCounter = 0;
|
||||
|
||||
public:
|
||||
SetProgramCounter(std::uint32_t programCounter): programCounter(programCounter) {}
|
||||
explicit SetProgramCounter(std::uint32_t programCounter): programCounter(programCounter) {}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The PC write command consists of 6 bytes:
|
||||
* 1. Command ID (0x01)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <utility>
|
||||
|
||||
#include "Avr8GenericCommandFrame.hpp"
|
||||
|
||||
@@ -14,13 +15,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
public:
|
||||
SetSoftwareBreakpoints() = default;
|
||||
|
||||
SetSoftwareBreakpoints(const std::vector<std::uint32_t>& addresses): addresses(addresses) {}
|
||||
explicit SetSoftwareBreakpoints(std::vector<std::uint32_t> addresses): addresses(std::move(addresses)) {}
|
||||
|
||||
void setAddresses(const std::vector<std::uint32_t>& addresses) {
|
||||
this->addresses = addresses;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The set software breakpoint command consists of 2 bytes + 4*n bytes, where n is the number
|
||||
* of breakpoints to set:
|
||||
@@ -43,5 +44,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -9,18 +9,18 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
class SetXmegaSoftwareBreakpoint: public Avr8GenericCommandFrame
|
||||
{
|
||||
private:
|
||||
std::uint32_t address;
|
||||
std::uint32_t address = 0;
|
||||
|
||||
public:
|
||||
SetXmegaSoftwareBreakpoint() = default;
|
||||
|
||||
SetXmegaSoftwareBreakpoint(std::uint32_t address): address(address) {}
|
||||
explicit SetXmegaSoftwareBreakpoint(std::uint32_t address): address(address) {}
|
||||
|
||||
void setAddress(std::uint32_t address) {
|
||||
this->address = address;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The set software breakpoint command consists of 6 bytes bytes
|
||||
*
|
||||
@@ -41,5 +41,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
public:
|
||||
Step() = default;
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The step command consists of 4 bytes:
|
||||
* 1. Command ID (0x34)
|
||||
@@ -26,5 +26,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -11,13 +11,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
|
||||
public:
|
||||
Stop() = default;
|
||||
Stop(bool stopImmediately): stopImmediately(stopImmediately) {};
|
||||
explicit Stop(bool stopImmediately): stopImmediately(stopImmediately) {};
|
||||
|
||||
void setStopImmediately(bool stopImmediately) {
|
||||
this->stopImmediately = stopImmediately;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The stop command consists of 3 bytes:
|
||||
* 1. Command ID (0x31)
|
||||
@@ -32,5 +32,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
class WriteMemory: public Avr8GenericCommandFrame
|
||||
{
|
||||
private:
|
||||
Avr8MemoryType type;
|
||||
Avr8MemoryType type = Avr8MemoryType::SRAM;
|
||||
std::uint32_t address = 0;
|
||||
Targets::TargetMemoryBuffer buffer;
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
this->buffer = buffer;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The write memory command consists of 12 bytes + the buffer size:
|
||||
* 1. Command ID (0x23)
|
||||
@@ -63,5 +63,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
return output;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,9 @@ using namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr;
|
||||
std::vector<AvrCommand> AvrCommandFrame::generateAvrCommands(std::size_t maximumCommandPacketSize) const {
|
||||
auto rawCommandFrame = static_cast<std::vector<unsigned char>>(*this);
|
||||
std::size_t commandFrameSize = rawCommandFrame.size();
|
||||
std::size_t commandsRequired = static_cast<std::size_t>(ceil(static_cast<float>(commandFrameSize) / static_cast<float>(maximumCommandPacketSize)));
|
||||
auto commandsRequired = static_cast<std::size_t>(
|
||||
ceil(static_cast<float>(commandFrameSize) / static_cast<float>(maximumCommandPacketSize))
|
||||
);
|
||||
|
||||
std::vector<AvrCommand> avrCommands;
|
||||
std::size_t copiedPacketSize = 0;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
/**
|
||||
* Destination sub-protocol handler ID
|
||||
*/
|
||||
ProtocolHandlerId protocolHandlerID;
|
||||
ProtocolHandlerId protocolHandlerID = ProtocolHandlerId::DISCOVERY;
|
||||
|
||||
std::vector<unsigned char> payload;
|
||||
|
||||
@@ -36,16 +36,16 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
using ResponseFrameType = AvrResponseFrame;
|
||||
|
||||
AvrCommandFrame() {
|
||||
if (this->lastSequenceId < std::numeric_limits<decltype(this->lastSequenceId)>::max()) {
|
||||
this->sequenceId = ++(this->lastSequenceId);
|
||||
if (AvrCommandFrame::lastSequenceId < std::numeric_limits<decltype(AvrCommandFrame::lastSequenceId)>::max()) {
|
||||
this->sequenceId = ++(AvrCommandFrame::lastSequenceId);
|
||||
|
||||
} else {
|
||||
this->sequenceId = 0;
|
||||
this->lastSequenceId = 0;
|
||||
AvrCommandFrame::lastSequenceId = 0;
|
||||
}
|
||||
};
|
||||
|
||||
unsigned char getProtocolVersion() const {
|
||||
[[nodiscard]] unsigned char getProtocolVersion() const {
|
||||
return this->protocolVersion;
|
||||
}
|
||||
|
||||
@@ -53,11 +53,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
this->protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
std::uint16_t getSequenceId() const {
|
||||
[[nodiscard]] std::uint16_t getSequenceId() const {
|
||||
return this->sequenceId;
|
||||
}
|
||||
|
||||
ProtocolHandlerId getProtocolHandlerId() const {
|
||||
[[nodiscard]] ProtocolHandlerId getProtocolHandlerId() const {
|
||||
return this->protocolHandlerID;
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
this->protocolHandlerID = static_cast<ProtocolHandlerId>(protocolHandlerId);
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const {
|
||||
[[nodiscard]] virtual std::vector<unsigned char> getPayload() const {
|
||||
return this->payload;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @return
|
||||
* A vector of sequenced AVRCommands, each containing a segment of the AvrCommandFrame.
|
||||
*/
|
||||
std::vector<AvrCommand> generateAvrCommands(std::size_t maximumCommandPacketSize) const;
|
||||
[[nodiscard]] std::vector<AvrCommand> generateAvrCommands(std::size_t maximumCommandPacketSize) const;
|
||||
|
||||
/**
|
||||
* Converts instance of a CMSIS Command to an unsigned char, for sending to the Atmel ICE device.
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
using ResponseFrameType = ResponseFrames::DiscoveryResponseFrame;
|
||||
|
||||
DiscoveryCommandFrame() {
|
||||
this->setProtocolHandlerId(ProtocolHandlerId::Discovery);
|
||||
this->setProtocolHandlerId(ProtocolHandlerId::DISCOVERY);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -22,12 +22,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
class Query: public DiscoveryCommandFrame
|
||||
{
|
||||
private:
|
||||
QueryContext context;
|
||||
QueryContext context = QueryContext::COMMAND_HANDLERS;
|
||||
|
||||
public:
|
||||
Query(): DiscoveryCommandFrame() {}
|
||||
|
||||
Query(QueryContext context): DiscoveryCommandFrame() {
|
||||
explicit Query(QueryContext context): DiscoveryCommandFrame() {
|
||||
this->setContext(context);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
this->context = context;
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayload() const override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayload() const override {
|
||||
/*
|
||||
* The payload for the Query command consists of three bytes. A command ID (0x00), version (0x00) and a
|
||||
* query context.
|
||||
|
||||
@@ -27,5 +27,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
this->init();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -25,8 +25,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
{
|
||||
public:
|
||||
HouseKeepingCommandFrame() {
|
||||
this->setProtocolHandlerId(ProtocolHandlerId::HouseKeeping);
|
||||
this->setProtocolHandlerId(ProtocolHandlerId::HOUSE_KEEPING);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -26,5 +26,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
|
||||
this->init();
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ using Bloom::Targets::TargetState;
|
||||
using Bloom::Targets::TargetMemoryType;
|
||||
using Bloom::Targets::TargetMemoryBuffer;
|
||||
using Bloom::Targets::TargetRegister;
|
||||
using Bloom::Targets::TargetRegisterDescriptor;
|
||||
using Bloom::Targets::TargetRegisterType;
|
||||
using Bloom::Targets::TargetRegisters;
|
||||
|
||||
@@ -554,7 +555,7 @@ std::uint32_t EdbgAvr8Interface::getProgramCounter() {
|
||||
}
|
||||
|
||||
TargetRegister EdbgAvr8Interface::getStackPointerRegister() {
|
||||
return TargetRegister(TargetRegisterType::STACK_POINTER, this->readMemory(
|
||||
return TargetRegister(TargetRegisterDescriptor(TargetRegisterType::STACK_POINTER), this->readMemory(
|
||||
Avr8MemoryType::SRAM,
|
||||
this->targetParameters.stackPointerRegisterStartAddress.value(),
|
||||
this->targetParameters.stackPointerRegisterSize.value()
|
||||
@@ -562,7 +563,7 @@ TargetRegister EdbgAvr8Interface::getStackPointerRegister() {
|
||||
}
|
||||
|
||||
TargetRegister EdbgAvr8Interface::getStatusRegister() {
|
||||
return TargetRegister(TargetRegisterType::STATUS_REGISTER, this->readMemory(
|
||||
return TargetRegister(TargetRegisterDescriptor(TargetRegisterType::STATUS_REGISTER), this->readMemory(
|
||||
Avr8MemoryType::SRAM,
|
||||
this->targetParameters.statusRegisterStartAddress.value(),
|
||||
this->targetParameters.statusRegisterSize.value()
|
||||
@@ -840,7 +841,7 @@ TargetMemoryBuffer EdbgAvr8Interface::readMemory(Avr8MemoryType type, std::uint3
|
||||
return response.getMemoryBuffer();
|
||||
}
|
||||
|
||||
void EdbgAvr8Interface::writeMemory(Avr8MemoryType type, std::uint32_t address, TargetMemoryBuffer buffer) {
|
||||
void EdbgAvr8Interface::writeMemory(Avr8MemoryType type, std::uint32_t address, const TargetMemoryBuffer& buffer) {
|
||||
if (type == Avr8MemoryType::FLASH_PAGE) {
|
||||
// TODO: Implement support for writing to flash
|
||||
throw Exception("Cannot write to flash");
|
||||
@@ -855,8 +856,6 @@ void EdbgAvr8Interface::writeMemory(Avr8MemoryType type, std::uint32_t address,
|
||||
if (response.getResponseId() == Avr8ResponseId::FAILED) {
|
||||
throw Avr8CommandFailure("Write memory AVR8 from target command failed", response);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
TargetRegisters EdbgAvr8Interface::readGeneralPurposeRegisters(std::set<std::size_t> registerIds) {
|
||||
|
||||
@@ -350,7 +350,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param address
|
||||
* @param buffer
|
||||
*/
|
||||
void writeMemory(Avr8MemoryType type, std::uint32_t address, Targets::TargetMemoryBuffer buffer);
|
||||
void writeMemory(Avr8MemoryType type, std::uint32_t address, const Targets::TargetMemoryBuffer& buffer);
|
||||
|
||||
/**
|
||||
* Fetches the current target state.
|
||||
@@ -413,7 +413,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
void waitForStoppedEvent();
|
||||
|
||||
public:
|
||||
EdbgAvr8Interface(EdbgInterface& edbgInterface)
|
||||
explicit EdbgAvr8Interface(EdbgInterface& edbgInterface)
|
||||
: edbgInterface(edbgInterface) {};
|
||||
|
||||
/*
|
||||
@@ -427,7 +427,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*
|
||||
* @param targetConfig
|
||||
*/
|
||||
virtual void configure(const TargetConfig& targetConfig) override;
|
||||
void configure(const TargetConfig& targetConfig) override;
|
||||
|
||||
/**
|
||||
* Configures the target family. For some physical interfaces, the target family is required in order
|
||||
@@ -445,22 +445,22 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*
|
||||
* @param config
|
||||
*/
|
||||
virtual void setTargetParameters(const Targets::Microchip::Avr::Avr8Bit::TargetParameters& config) override;
|
||||
void setTargetParameters(const Targets::Microchip::Avr::Avr8Bit::TargetParameters& config) override;
|
||||
|
||||
/**
|
||||
* Initialises the AVR8 Generic protocol interface by setting the appropriate parameters on the debug tool.
|
||||
*/
|
||||
virtual void init() override;
|
||||
void init() override;
|
||||
|
||||
/**
|
||||
* Issues the "stop" command to the debug tool, halting target execution.
|
||||
*/
|
||||
virtual void stop() override;
|
||||
void stop() override;
|
||||
|
||||
/**
|
||||
* Issues the "run" command to the debug tool, resuming execution on the target.
|
||||
*/
|
||||
virtual void run() override;
|
||||
void run() override;
|
||||
|
||||
/**
|
||||
* Issues the "run to" command to the debug tool, resuming execution on the target, up to a specific byte
|
||||
@@ -469,65 +469,65 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param address
|
||||
* The (byte) address to run to.
|
||||
*/
|
||||
virtual void runTo(std::uint32_t address) override;
|
||||
void runTo(std::uint32_t address) override;
|
||||
|
||||
/**
|
||||
* Issues the "step" command to the debug tool, stepping the execution on the target. The stepping can be
|
||||
* configured to step in, out or over. But currently we only support stepping in. The target will dispatch
|
||||
* an AVR BREAK event once it reaches the next instruction.
|
||||
*/
|
||||
virtual void step() override;
|
||||
void step() override;
|
||||
|
||||
/**
|
||||
* Issues the "reset" command to the debug tool, resetting target execution.
|
||||
*/
|
||||
virtual void reset() override;
|
||||
void reset() override;
|
||||
|
||||
/**
|
||||
* Activates the physical interface and starts a debug session on the target (via attach()).
|
||||
*/
|
||||
virtual void activate() override;
|
||||
void activate() override;
|
||||
|
||||
/**
|
||||
* Terminates any active debug session on the target and severs the connection between the debug tool and
|
||||
* the target (by deactivating the physical interface).
|
||||
*/
|
||||
virtual void deactivate() override;
|
||||
void deactivate() override;
|
||||
|
||||
/**
|
||||
* Issues the "PC Read" command to the debug tool, to extract the current program counter.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
virtual std::uint32_t getProgramCounter() override;
|
||||
std::uint32_t getProgramCounter() override;
|
||||
|
||||
/**
|
||||
* Reads the stack pointer register from the target.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
virtual Targets::TargetRegister getStackPointerRegister() override;
|
||||
Targets::TargetRegister getStackPointerRegister() override;
|
||||
|
||||
/**
|
||||
* Reads the status register from the target.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
virtual Targets::TargetRegister getStatusRegister() override;
|
||||
Targets::TargetRegister getStatusRegister() override;
|
||||
|
||||
/**
|
||||
* Updates the stack pointer register on ther target.
|
||||
*
|
||||
* @param stackPointerRegister
|
||||
*/
|
||||
virtual void setStackPointerRegister(const Targets::TargetRegister& stackPointerRegister) override;
|
||||
void setStackPointerRegister(const Targets::TargetRegister& stackPointerRegister) override;
|
||||
|
||||
/**
|
||||
* Updates the status register on the target.
|
||||
*
|
||||
* @param statusRegister
|
||||
*/
|
||||
virtual void setStatusRegister(const Targets::TargetRegister& statusRegister) override;
|
||||
void setStatusRegister(const Targets::TargetRegister& statusRegister) override;
|
||||
|
||||
/**
|
||||
* Issues the "PC Write" command to the debug tool, setting the program counter on the target.
|
||||
@@ -535,14 +535,14 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param programCounter
|
||||
* The byte address to set as the program counter.
|
||||
*/
|
||||
virtual void setProgramCounter(std::uint32_t programCounter) override;
|
||||
void setProgramCounter(std::uint32_t programCounter) override;
|
||||
|
||||
/**
|
||||
* Issues the "Get ID" command to the debug tool, to extract the signature from the target.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
virtual Targets::Microchip::Avr::TargetSignature getDeviceId() override;
|
||||
Targets::Microchip::Avr::TargetSignature getDeviceId() override;
|
||||
|
||||
/**
|
||||
* Issues the "Software Breakpoint Set" command to the debug tool, setting a software breakpoint at the given
|
||||
@@ -551,7 +551,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param address
|
||||
* The byte address to position the breakpoint.
|
||||
*/
|
||||
virtual void setBreakpoint(std::uint32_t address) override;
|
||||
void setBreakpoint(std::uint32_t address) override;
|
||||
|
||||
/**
|
||||
* Issues the "Software Breakpoint Clear" command to the debug tool, clearing any breakpoint at the given
|
||||
@@ -560,7 +560,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param address
|
||||
* The byte address of the breakpoint to clear.
|
||||
*/
|
||||
virtual void clearBreakpoint(std::uint32_t address) override;
|
||||
void clearBreakpoint(std::uint32_t address) override;
|
||||
|
||||
/**
|
||||
* Issues the "Software Breakpoint Clear All" command to the debug tool, clearing all software breakpoints
|
||||
@@ -568,7 +568,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*
|
||||
* If the debug session ended before any of the set breakpoints were cleared, this will *not* clear them.
|
||||
*/
|
||||
virtual void clearAllBreakpoints() override;
|
||||
void clearAllBreakpoints() override;
|
||||
|
||||
/**
|
||||
* Reads gernal purpose registers from the target.
|
||||
@@ -576,14 +576,14 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param registerIds
|
||||
* @return
|
||||
*/
|
||||
virtual Targets::TargetRegisters readGeneralPurposeRegisters(std::set<std::size_t> registerIds) override;
|
||||
Targets::TargetRegisters readGeneralPurposeRegisters(std::set<std::size_t> registerIds) override;
|
||||
|
||||
/**
|
||||
* Writes general purpose registers to target.
|
||||
*
|
||||
* @param registers
|
||||
*/
|
||||
virtual void writeGeneralPurposeRegisters(const Targets::TargetRegisters& registers) override;
|
||||
void writeGeneralPurposeRegisters(const Targets::TargetRegisters& registers) override;
|
||||
|
||||
/**
|
||||
* This is an overloaded method.
|
||||
@@ -595,7 +595,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param bytes
|
||||
* @return
|
||||
*/
|
||||
virtual Targets::TargetMemoryBuffer readMemory(
|
||||
Targets::TargetMemoryBuffer readMemory(
|
||||
Targets::TargetMemoryType memoryType,
|
||||
std::uint32_t startAddress,
|
||||
std::uint32_t bytes
|
||||
@@ -610,7 +610,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* @param startAddress
|
||||
* @param buffer
|
||||
*/
|
||||
virtual void writeMemory(
|
||||
void writeMemory(
|
||||
Targets::TargetMemoryType memoryType,
|
||||
std::uint32_t startAddress,
|
||||
const Targets::TargetMemoryBuffer& buffer
|
||||
@@ -621,6 +621,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
virtual Targets::TargetState getTargetState() override;
|
||||
Targets::TargetState getTargetState() override;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -10,21 +10,21 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
class BreakEvent: public AvrEvent
|
||||
{
|
||||
private:
|
||||
std::uint32_t programCounter;
|
||||
Targets::TargetBreakCause breakCause;
|
||||
std::uint32_t programCounter = 0;
|
||||
Targets::TargetBreakCause breakCause = Targets::TargetBreakCause::UNKNOWN;
|
||||
|
||||
void init(const AvrEvent& event);
|
||||
|
||||
public:
|
||||
BreakEvent(const AvrEvent& event) {
|
||||
explicit BreakEvent(const AvrEvent& event) {
|
||||
this->init(event);
|
||||
}
|
||||
|
||||
std::uint32_t getProgramCounter() {
|
||||
[[nodiscard]] std::uint32_t getProgramCounter() const {
|
||||
return this->programCounter;
|
||||
}
|
||||
|
||||
Targets::TargetBreakCause getBreakCause() {
|
||||
[[nodiscard]] Targets::TargetBreakCause getBreakCause() const {
|
||||
return this->breakCause;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -7,13 +7,14 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
class Avr8GenericResponseFrame: public AvrResponseFrame
|
||||
{
|
||||
public:
|
||||
Avr8GenericResponseFrame(const std::vector<AvrResponse>& AVRResponses): AvrResponseFrame(AVRResponses) {}
|
||||
Avr8GenericResponseFrame() {}
|
||||
Avr8GenericResponseFrame() = default;
|
||||
explicit Avr8GenericResponseFrame(const std::vector<AvrResponse>& AVRResponses)
|
||||
: AvrResponseFrame(AVRResponses) {}
|
||||
|
||||
/**
|
||||
* See parent method.
|
||||
*/
|
||||
std::vector<unsigned char> getPayloadData() override {
|
||||
[[nodiscard]] std::vector<unsigned char> getPayloadData() override {
|
||||
/*
|
||||
* AVR8 data payloads are in little endian form and include two bytes before the data (response ID and
|
||||
* version byte) as well as an additional byte after the data, known as the 'status code'.
|
||||
@@ -27,5 +28,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
class GetDeviceId: public Avr8GenericResponseFrame
|
||||
{
|
||||
public:
|
||||
GetDeviceId(const std::vector<AvrResponse>& AvrResponses): Avr8GenericResponseFrame(AvrResponses) {}
|
||||
GetDeviceId() {}
|
||||
GetDeviceId() = default;
|
||||
explicit GetDeviceId(const std::vector<AvrResponse>& AvrResponses): Avr8GenericResponseFrame(AvrResponses) {}
|
||||
|
||||
Targets::Microchip::Avr::TargetSignature extractSignature(Avr8PhysicalInterface physicalInterface) {
|
||||
auto payloadData = this->getPayloadData();
|
||||
|
||||
@@ -10,8 +10,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
class GetProgramCounter: public Avr8GenericResponseFrame
|
||||
{
|
||||
public:
|
||||
GetProgramCounter(const std::vector<AvrResponse>& AVRResponses): Avr8GenericResponseFrame(AVRResponses) {}
|
||||
GetProgramCounter() {}
|
||||
GetProgramCounter() = default;
|
||||
explicit GetProgramCounter(const std::vector<AvrResponse>& AVRResponses): Avr8GenericResponseFrame(AVRResponses) {}
|
||||
|
||||
std::uint32_t extractProgramCounter() {
|
||||
/*
|
||||
|
||||
@@ -8,8 +8,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
class ReadMemory: public Avr8GenericResponseFrame
|
||||
{
|
||||
public:
|
||||
ReadMemory(const std::vector<AvrResponse>& AVRResponses): Avr8GenericResponseFrame(AVRResponses) {}
|
||||
ReadMemory() {}
|
||||
ReadMemory() = default;
|
||||
explicit ReadMemory(const std::vector<AvrResponse>& AVRResponses): Avr8GenericResponseFrame(AVRResponses) {}
|
||||
|
||||
Targets::TargetMemoryBuffer getMemoryBuffer() {
|
||||
/*
|
||||
@@ -24,5 +24,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -35,4 +35,4 @@ void AvrResponseFrame::initFromRawFrame(const std::vector<unsigned char>& rawFra
|
||||
|
||||
auto& payload = this->getPayload();
|
||||
payload.insert(payload.begin(), rawFrame.begin() + 4, rawFrame.end());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
/**
|
||||
* Destination sub-protocol handler ID
|
||||
*/
|
||||
ProtocolHandlerId protocolHandlerID;
|
||||
ProtocolHandlerId protocolHandlerID = ProtocolHandlerId::AVR8_GENERIC;
|
||||
|
||||
std::vector<unsigned char> payload;
|
||||
|
||||
@@ -48,12 +48,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
}
|
||||
|
||||
public:
|
||||
explicit AvrResponseFrame() = default;
|
||||
|
||||
explicit AvrResponseFrame(const std::vector<AvrResponse>& AVRResponses) {
|
||||
this->initFromAvrResponses(AVRResponses);
|
||||
}
|
||||
|
||||
explicit AvrResponseFrame() {}
|
||||
|
||||
/**
|
||||
* An AVRResponse contains a single fragment of an AvrResponseFrame.
|
||||
*
|
||||
@@ -63,11 +63,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*/
|
||||
void initFromAvrResponses(const std::vector<AvrResponse>& avrResponses);
|
||||
|
||||
std::uint16_t getSequenceId() const {
|
||||
[[nodiscard]] std::uint16_t getSequenceId() const {
|
||||
return this->sequenceID;
|
||||
}
|
||||
|
||||
ProtocolHandlerId getProtocolHandlerId() const {
|
||||
[[nodiscard]] ProtocolHandlerId getProtocolHandlerId() const {
|
||||
return this->protocolHandlerID;
|
||||
}
|
||||
|
||||
@@ -79,8 +79,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
return this->payload[0];
|
||||
}
|
||||
|
||||
virtual std::vector<unsigned char> getPayloadData() {
|
||||
return this->getPayload();
|
||||
[[nodiscard]] virtual std::vector<unsigned char> getPayloadData() {
|
||||
return this->payload;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -7,8 +7,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
class DiscoveryResponseFrame: public AvrResponseFrame
|
||||
{
|
||||
public:
|
||||
DiscoveryResponseFrame(const std::vector<AvrResponse>& AVRResponses): AvrResponseFrame(AVRResponses) {}
|
||||
DiscoveryResponseFrame() {}
|
||||
DiscoveryResponseFrame() = default;
|
||||
explicit DiscoveryResponseFrame(const std::vector<AvrResponse>& AVRResponses): AvrResponseFrame(AVRResponses) {}
|
||||
|
||||
/**
|
||||
* See parent method.
|
||||
@@ -25,5 +25,4 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg
|
||||
{
|
||||
enum class ProtocolHandlerId: unsigned char
|
||||
{
|
||||
Discovery = 0x00,
|
||||
HouseKeeping = 0x01,
|
||||
Avr8Generic = 0x12,
|
||||
Avr32Generic = 0x13,
|
||||
DISCOVERY = 0x00,
|
||||
HOUSE_KEEPING = 0x01,
|
||||
AVR8_GENERIC = 0x12,
|
||||
AVR32_GENERIC = 0x13,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,4 +89,4 @@ std::vector<Protocols::CmsisDap::Edbg::Avr::AvrResponse> EdbgInterface::requestA
|
||||
}
|
||||
|
||||
return responses;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Bloom::Usb
|
||||
}
|
||||
|
||||
public:
|
||||
std::size_t getInputReportSize() {
|
||||
std::size_t getInputReportSize() const {
|
||||
return this->inputReportSize;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
*
|
||||
* https://github.com/signal11/hidapi
|
||||
*/
|
||||
struct hid_device_ {
|
||||
struct hid_device_
|
||||
{
|
||||
// Handle to the actual device.
|
||||
libusb_device_handle* device_handle;
|
||||
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#include <libusb-1.0/libusb.h>
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
#include "Interface.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
#include "src/Exceptions/Exception.hpp"
|
||||
|
||||
using namespace Bloom::Usb;
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Bloom::Usb
|
||||
std::uint16_t productId = 0;
|
||||
|
||||
std::uint8_t number = 0;
|
||||
std::string name = "";
|
||||
std::string name;
|
||||
|
||||
bool initialised = false;
|
||||
bool claimed = false;
|
||||
@@ -52,11 +52,11 @@ namespace Bloom::Usb
|
||||
this->name = name;
|
||||
}
|
||||
|
||||
bool isClaimed() {
|
||||
bool isClaimed() const {
|
||||
return this->claimed;
|
||||
}
|
||||
|
||||
bool isInitialised() {
|
||||
bool isInitialised() const {
|
||||
return this->initialised;
|
||||
}
|
||||
|
||||
|
||||
@@ -26,8 +26,6 @@ namespace Bloom::Usb
|
||||
void close();
|
||||
|
||||
public:
|
||||
void init();
|
||||
|
||||
UsbDevice(std::uint16_t vendorId, std::uint16_t productId) {
|
||||
this->vendorId = vendorId;
|
||||
this->productId = productId;
|
||||
@@ -35,6 +33,8 @@ namespace Bloom::Usb
|
||||
|
||||
~UsbDevice() = default;
|
||||
|
||||
void init();
|
||||
|
||||
[[nodiscard]] libusb_device* getLibUsbDevice() const {
|
||||
return this->libUsbDevice;
|
||||
}
|
||||
@@ -43,11 +43,11 @@ namespace Bloom::Usb
|
||||
this->libUsbDevice = libUsbDevice;
|
||||
}
|
||||
|
||||
std::uint16_t getVendorId() const {
|
||||
[[nodiscard]] std::uint16_t getVendorId() const {
|
||||
return this->vendorId;
|
||||
}
|
||||
|
||||
std::uint16_t getProductId() const {
|
||||
[[nodiscard]] std::uint16_t getProductId() const {
|
||||
return this->productId;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user