Skip to content

Commit 9781cf0

Browse files
committed
Add more debugSerial output
1 parent a94ce9f commit 9781cf0

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

Firmware/LoRaSerial/Commands.ino

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -780,6 +780,12 @@ bool sendRemoteCommand(const char * commandString)
780780
commandTXBuffer[commandTXHead++] = commandString[x];
781781
commandTXHead %= sizeof(commandTXBuffer);
782782
}
783+
if (settings.debugSerial)
784+
{
785+
systemPrint("sendRemoteCommand moved ");
786+
systemPrint(commandLength);
787+
systemPrintln(" from commandBuffer into commandTXBuffer");
788+
}
783789
remoteCommandResponse = false;
784790
return true;
785791
}
@@ -812,8 +818,20 @@ void checkCommand()
812818
char * commandString;
813819
int index;
814820
int prefixLength;
821+
PrinterEndpoints responseDestination;
822+
uint16_t responseLength;
815823
bool success;
816824

825+
//Save previous index
826+
if (settings.debugSerial)
827+
{
828+
responseDestination = printerEndpoint;
829+
if (responseDestination == PRINT_TO_SERIAL)
830+
responseLength = txHead;
831+
else
832+
responseLength = commandTXHead;
833+
}
834+
817835
//Zero terminate the string
818836
success = false;
819837
commandBuffer[commandLength] = 0;
@@ -860,7 +878,28 @@ void checkCommand()
860878
systemPrintln("ERROR");
861879
commandComplete(false);
862880
}
881+
882+
//Display the response
863883
printerEndpoint = PRINT_TO_SERIAL;
884+
if (settings.debugSerial)
885+
{
886+
uint16_t tail;
887+
tail = responseLength;
888+
if (responseDestination == PRINT_TO_SERIAL)
889+
{
890+
responseLength = (txHead + sizeof(serialTransmitBuffer) - responseLength) % sizeof(serialTransmitBuffer);
891+
systemPrint("checkCommand placed ");
892+
systemPrint(responseLength);
893+
systemPrintln(" command response bytes into serialTransmitBuffer");
894+
}
895+
else
896+
{
897+
responseLength = (commandTXHead + sizeof(commandTXBuffer) - responseLength) % sizeof(commandTXBuffer);
898+
systemPrint("checkCommand placed ");
899+
systemPrint(responseLength);
900+
systemPrintln(" command response bytes into commandTXBuffer");
901+
}
902+
}
864903
outputSerialData(true);
865904
petWDT();
866905

Firmware/LoRaSerial/Serial.ino

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,12 @@ void processSerialInput()
417417
{
418418
printerEndpoint = PRINT_TO_SERIAL;
419419
systemPrintln();
420+
if (settings.debugSerial)
421+
{
422+
systemPrint("processSerialInput moved ");
423+
systemPrint(commandLength);
424+
systemPrintln(" from serialReceiveBuffer into commandBuffer");
425+
}
420426
checkCommand(); //Process command buffer
421427
}
422428
else if (incoming == '\n')

0 commit comments

Comments
 (0)