Tidying EDBG driver code:
- Binned a lot of pointless code - Simplified many EDBG data structure implementations - Const-correctness - Many other bits of tidying
This commit is contained in:
@@ -58,17 +58,17 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
);
|
||||
|
||||
if (response.getResponseId() != ResponseId::OK) {
|
||||
if (responseFrame.id != ResponseId::OK) {
|
||||
throw DeviceInitializationFailure(
|
||||
"Failed to fetch serial number from device - invalid Discovery Protocol response ID."
|
||||
);
|
||||
}
|
||||
|
||||
const auto data = response.getPayloadData();
|
||||
const auto data = responseFrame.getPayloadData();
|
||||
return std::string(data.begin(), data.end());
|
||||
}
|
||||
|
||||
@@ -76,11 +76,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
StartSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceInitializationFailure("Failed to start session with Atmel-ICE!");
|
||||
}
|
||||
@@ -92,11 +92,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
EndSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceFailure("Failed to end session with Atmel-ICE!");
|
||||
}
|
||||
|
||||
@@ -55,17 +55,17 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
);
|
||||
|
||||
if (response.getResponseId() != ResponseId::OK) {
|
||||
if (responseFrame.id != ResponseId::OK) {
|
||||
throw DeviceInitializationFailure(
|
||||
"Failed to fetch serial number from device - invalid Discovery Protocol response ID."
|
||||
);
|
||||
}
|
||||
|
||||
const auto data = response.getPayloadData();
|
||||
const auto data = responseFrame.getPayloadData();
|
||||
return std::string(data.begin(), data.end());
|
||||
}
|
||||
|
||||
@@ -73,11 +73,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
StartSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceInitializationFailure("Failed to start session with Curiosity Nano!");
|
||||
}
|
||||
@@ -89,11 +89,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
EndSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceFailure("Failed to end session with Curiosity Nano!");
|
||||
}
|
||||
|
||||
@@ -52,17 +52,17 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
);
|
||||
|
||||
if (response.getResponseId() != ResponseId::OK) {
|
||||
if (responseFrame.id != ResponseId::OK) {
|
||||
throw DeviceInitializationFailure(
|
||||
"Failed to fetch serial number from device - invalid Discovery Protocol response ID."
|
||||
);
|
||||
}
|
||||
|
||||
const auto data = response.getPayloadData();
|
||||
const auto data = responseFrame.getPayloadData();
|
||||
return std::string(data.begin(), data.end());
|
||||
}
|
||||
|
||||
@@ -70,11 +70,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
StartSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceInitializationFailure("Failed to start session with the JTAGICE3!");
|
||||
}
|
||||
@@ -86,11 +86,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
EndSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceFailure("Failed to end session with the JTAGICE3!");
|
||||
}
|
||||
|
||||
@@ -51,17 +51,17 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
);
|
||||
|
||||
if (response.getResponseId() != ResponseId::OK) {
|
||||
if (responseFrame.id != ResponseId::OK) {
|
||||
throw DeviceInitializationFailure(
|
||||
"Failed to fetch serial number from device - invalid Discovery Protocol response ID."
|
||||
);
|
||||
}
|
||||
|
||||
const auto data = response.getPayloadData();
|
||||
const auto data = responseFrame.getPayloadData();
|
||||
return std::string(data.begin(), data.end());
|
||||
}
|
||||
|
||||
@@ -69,11 +69,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
StartSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceInitializationFailure("Failed to start session with MPLAB PICkit 4!");
|
||||
}
|
||||
@@ -85,11 +85,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
EndSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceFailure("Failed to end session with MPLAB PICkit 4!");
|
||||
}
|
||||
|
||||
@@ -51,17 +51,17 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
);
|
||||
|
||||
if (response.getResponseId() != ResponseId::OK) {
|
||||
if (responseFrame.id != ResponseId::OK) {
|
||||
throw DeviceInitializationFailure(
|
||||
"Failed to fetch serial number from device - invalid Discovery Protocol response ID."
|
||||
);
|
||||
}
|
||||
|
||||
const auto data = response.getPayloadData();
|
||||
const auto data = responseFrame.getPayloadData();
|
||||
return std::string(data.begin(), data.end());
|
||||
}
|
||||
|
||||
@@ -69,11 +69,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
StartSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceInitializationFailure("Failed to start session with MPLAB Snap!");
|
||||
}
|
||||
@@ -85,11 +85,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
EndSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceFailure("Failed to end session with MPLAB Snap!");
|
||||
}
|
||||
|
||||
@@ -51,17 +51,17 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
);
|
||||
|
||||
if (response.getResponseId() != ResponseId::OK) {
|
||||
if (responseFrame.id != ResponseId::OK) {
|
||||
throw DeviceInitializationFailure(
|
||||
"Failed to fetch serial number from device - invalid Discovery Protocol response ID."
|
||||
);
|
||||
}
|
||||
|
||||
const auto data = response.getPayloadData();
|
||||
const auto data = responseFrame.getPayloadData();
|
||||
return std::string(data.begin(), data.end());
|
||||
}
|
||||
|
||||
@@ -69,11 +69,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
StartSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceInitializationFailure(
|
||||
"Failed to start session with the Power Debugger - device returned failed response ID"
|
||||
@@ -87,11 +87,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
EndSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceFailure(
|
||||
"Failed to end session with the Power Debugger - device returned failed response ID"
|
||||
|
||||
@@ -55,17 +55,17 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
);
|
||||
|
||||
if (response.getResponseId() != ResponseId::OK) {
|
||||
if (responseFrame.id != ResponseId::OK) {
|
||||
throw DeviceInitializationFailure(
|
||||
"Failed to fetch serial number from device - invalid Discovery Protocol response ID."
|
||||
);
|
||||
}
|
||||
|
||||
auto data = response.getPayloadData();
|
||||
auto data = responseFrame.getPayloadData();
|
||||
return std::string(data.begin(), data.end());
|
||||
}
|
||||
|
||||
@@ -73,11 +73,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
StartSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceInitializationFailure("Failed to start session with Xplained Mini!");
|
||||
}
|
||||
@@ -89,11 +89,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
EndSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceFailure("Failed to end session with Xplained Mini!");
|
||||
}
|
||||
|
||||
@@ -53,17 +53,17 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
);
|
||||
|
||||
if (response.getResponseId() != ResponseId::OK) {
|
||||
if (responseFrame.id != ResponseId::OK) {
|
||||
throw DeviceInitializationFailure(
|
||||
"Failed to fetch serial number from device - invalid Discovery Protocol response ID."
|
||||
);
|
||||
}
|
||||
|
||||
const auto data = response.getPayloadData();
|
||||
const auto data = responseFrame.getPayloadData();
|
||||
return std::string(data.begin(), data.end());
|
||||
}
|
||||
|
||||
@@ -71,11 +71,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
StartSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceInitializationFailure("Failed to start session with Xplained Nano!");
|
||||
}
|
||||
@@ -87,11 +87,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
EndSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceFailure("Failed to end session with Xplained Nano!");
|
||||
}
|
||||
|
||||
@@ -62,17 +62,17 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::Discovery;
|
||||
using ResponseFrames::Discovery::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
Query(QueryContext::SERIAL_NUMBER)
|
||||
);
|
||||
|
||||
if (response.getResponseId() != ResponseId::OK) {
|
||||
if (responseFrame.id != ResponseId::OK) {
|
||||
throw DeviceInitializationFailure(
|
||||
"Failed to fetch serial number from device - invalid Discovery Protocol response ID."
|
||||
);
|
||||
}
|
||||
|
||||
auto data = response.getPayloadData();
|
||||
auto data = responseFrame.getPayloadData();
|
||||
return std::string(data.begin(), data.end());
|
||||
}
|
||||
|
||||
@@ -80,11 +80,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
StartSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceInitializationFailure("Failed to start session with Xplained Pro!");
|
||||
}
|
||||
@@ -96,11 +96,11 @@ namespace Bloom::DebugToolDrivers
|
||||
using namespace CommandFrames::HouseKeeping;
|
||||
using ResponseFrames::HouseKeeping::ResponseId;
|
||||
|
||||
auto response = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
const auto responseFrame = this->edbgInterface->sendAvrCommandFrameAndWaitForResponseFrame(
|
||||
EndSession()
|
||||
);
|
||||
|
||||
if (response.getResponseId() == ResponseId::FAILED) {
|
||||
if (responseFrame.id == ResponseId::FAILED) {
|
||||
// Failed response returned!
|
||||
throw DeviceFailure("Failed to end session with Xplained Pro!");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user