Skip to content

Commit c334ae7

Browse files
committed
Make it easy to debug print the command response
1 parent 07e3994 commit c334ae7

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

src/SparkFun_u-blox_SARA-R5_Arduino_Library.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5630,7 +5630,8 @@ SARA_R5_error_t SARA_R5::sendCommandWithResponse(
56305630
int responseLen = 0;
56315631
int errorLen = 0;
56325632
const char* expectedError= nullptr;
5633-
//bool printedSomething = false;
5633+
bool printResponse = false; // Change to true to print the full response
5634+
bool printedSomething = false;
56345635

56355636
if (_printDebug == true)
56365637
{
@@ -5654,15 +5655,15 @@ SARA_R5_error_t SARA_R5::sendCommandWithResponse(
56545655
if (hwAvailable() > 0) //hwAvailable can return -1 if the serial port is nullptr
56555656
{
56565657
char c = readChar();
5657-
// if (_printDebug == true)
5658-
// {
5659-
// if (printedSomething == false)
5660-
// {
5661-
// _debugPort->print(F("sendCommandWithResponse: Response: "));
5662-
// printedSomething = true;
5663-
// }
5664-
// _debugPort->write(c);
5665-
// }
5658+
if ((printResponse = true) && (_printDebug == true))
5659+
{
5660+
if (printedSomething == false)
5661+
{
5662+
_debugPort->print(F("sendCommandWithResponse: Response: "));
5663+
printedSomething = true;
5664+
}
5665+
_debugPort->write(c);
5666+
}
56665667
if (responseDest != nullptr)
56675668
{
56685669
if (destIndex < destSize) // Only add this char to response if there is room for it
@@ -5672,11 +5673,11 @@ SARA_R5_error_t SARA_R5::sendCommandWithResponse(
56725673
{
56735674
if (_printDebug == true)
56745675
{
5675-
// if (printedSomething)
5676-
// _debugPort->println();
5676+
if ((printResponse = true) && (printedSomething))
5677+
_debugPort->println();
56775678
_debugPort->print(F("sendCommandWithResponse: Panic! responseDest is full!"));
5678-
// if (printedSomething)
5679-
// _debugPort->print(F("sendCommandWithResponse: Ignored response: "));
5679+
if ((printResponse = true) && (printedSomething))
5680+
_debugPort->print(F("sendCommandWithResponse: Ignored response: "));
56805681
}
56815682
}
56825683
}
@@ -5722,9 +5723,9 @@ SARA_R5_error_t SARA_R5::sendCommandWithResponse(
57225723
}
57235724
}
57245725

5725-
// if (_printDebug == true)
5726-
// if (printedSomething)
5727-
// _debugPort->println();
5726+
if (_printDebug == true)
5727+
if ((printResponse = true) && (printedSomething))
5728+
_debugPort->println();
57285729

57295730
pruneBacklog(); // Prune any incoming non-actionable URC's and responses/errors from the backlog
57305731

0 commit comments

Comments
 (0)