Skip to content

Commit

Permalink
Fix get filesize and cancle print for RepRapFirmware (bigtreetech#1533)
Browse files Browse the repository at this point in the history
  • Loading branch information
Thro42 authored Jan 21, 2021
1 parent 4d8cd89 commit fc2057b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
14 changes: 13 additions & 1 deletion TFT/src/User/API/Gcode/gcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ char *request_M33(char *filename)
long request_M23_M36(char *filename)
{
uint8_t offset = 5;
const char *sizeTag;
if (infoMachineSettings.firmwareType != FW_REPRAPFW) // all other firmwares except reprap firmware
{
resetRequestCommandInfo("File opened", // The magic to identify the start
Expand All @@ -145,6 +146,7 @@ long request_M23_M36(char *filename)
NULL); // The third error magic

mustStoreCmd("M23 %s\n", filename);
sizeTag = "Size:";
}
else // reprap firmware
{
Expand All @@ -156,6 +158,7 @@ long request_M23_M36(char *filename)

mustStoreCmd("M36 %s\n", filename);
offset = 6;
sizeTag = "size\":"; // reprap firmware reports size JSON
}

// Wait for response
Expand All @@ -169,7 +172,7 @@ long request_M23_M36(char *filename)
mustStoreCmd("M23 %s\n", filename); //send M23 for reprap firmware
// Find file size and report its.
char *ptr;
long size = strtol(strstr(requestCommandInfo.cmd_rev_buf, "Size:") + offset, &ptr, 10);
long size = strtol(strstr(requestCommandInfo.cmd_rev_buf, sizeTag) + offset, &ptr, 10);
clearRequestCommandInfo();
return size;
}
Expand Down Expand Up @@ -213,3 +216,12 @@ bool request_M27(int seconds)
mustStoreCmd("M27 S%d\n", seconds);
return true;
}

/**
* Stop or Unconditional stop in reprap firmware
**/
bool request_M0(void)
{
mustStoreCmd("M0 \n");
return true;
}
6 changes: 5 additions & 1 deletion TFT/src/User/API/Printing.c
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,11 @@ void abortPrinting(void)
breakAndContinue();
breakAndContinue();
breakAndContinue();
request_M524();
if (infoMachineSettings.firmwareType == FW_REPRAPFW)
request_M0(); // M524 is not supportet in reprap firmware
else
request_M524();

break;

case TFT_UDISK:
Expand Down

0 comments on commit fc2057b

Please sign in to comment.