@@ -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
0 commit comments