This commit is contained in:
Nav
2022-03-27 18:34:08 +01:00
parent f848fdfc40
commit 28ea24c614
4 changed files with 14 additions and 7 deletions

View File

@@ -108,7 +108,7 @@ namespace Bloom::DebugServers::Gdb
auto output = std::vector<unsigned char>();
constexpr size_t bufferSize = 1024;
std::array<unsigned char, bufferSize> buffer = {};
ssize_t bytesRead;
ssize_t bytesRead = 0;
if (interruptible) {
if (this->readInterruptEnabled != interruptible) {
@@ -145,8 +145,10 @@ namespace Bloom::DebugServers::Gdb
}
size_t bytesToRead = (bytes > bufferSize || bytes == 0) ? bufferSize : bytes;
while (bytesToRead > 0
&& (bytesRead = ::read(this->socketFileDescriptor, buffer.data(), bytesToRead)) > 0) {
while (
bytesToRead > 0
&& (bytesRead = ::read(this->socketFileDescriptor, buffer.data(), bytesToRead)) > 0
) {
output.insert(output.end(), buffer.begin(), buffer.begin() + bytesRead);
if (bytesRead < bytesToRead) {

View File

@@ -23,6 +23,7 @@ namespace Bloom::DebugServers::Gdb
class Connection
{
public:
Connection() = delete;
explicit Connection(EventNotifier& interruptEventNotifier)
: interruptEventNotifier(interruptEventNotifier)
@@ -103,7 +104,11 @@ namespace Bloom::DebugServers::Gdb
*
* @return
*/
std::vector<unsigned char> read(std::size_t bytes = 0, bool interruptible = true, std::optional<int> msTimeout = std::nullopt);
std::vector<unsigned char> read(
std::size_t bytes = 0,
bool interruptible = true,
std::optional<int> msTimeout = std::nullopt
);
/**
* Does the same as Connection::read(), but only reads a single byte.

View File

@@ -2,8 +2,8 @@
#include <cstdint>
#include "Connection.hpp"
#include "TargetDescriptor.hpp"
#include "Connection.hpp"
namespace Bloom::DebugServers::Gdb
{

View File

@@ -11,12 +11,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::CommandFrames
public:
explicit GetParameter(const EdbgParameter& parameter) {
/*
* The EDBG Get Parameter command consists of 6 bytes:
* The EDBG Get Parameter command consists of 5 bytes:
*
* 1. Command ID (0x02)
* 2. Version (0x00)
* 3. Parameter context
* 4. Parameter
* 4. Parameter ID
* 5. Parameter size
*/
this->payload = {