Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PFW-1294: Don't attempt to find SD file when recovering USB print #4437

Merged
merged 6 commits into from
Nov 11, 2023

Conversation

gudnimg
Copy link
Collaborator

@gudnimg gudnimg commented Oct 9, 2023

Summary of changes:

  • Remote host prints (serial and USB): there is no filename on the printer side (in RAM or EEPROM). Power panic recovery for remote prints should not attempt to recover a filename from the printer and interact with the SD card (which may not even be connected)
  • SD print: The filename recovery is split into a separate function. This will be useful later to optimise code size in "Reprint" LCD menu. (PFW-1536)
  • SD print: Support any valid DOS 8.3 filename. Previously .gco extension was hardcoded, but now .g will work as well. A new EEPROM entry is added EEPROM_FILENAME_EXTENSION
  • SD print: Generally refactor reading and writing the filename & directory.
    • Write/read EEPROM blocks instead of one byte at a time.
    • Don't convert the SFN to lower case. The code that searches for the matching filename is not case sensitive.

TODO:

  • Test very short filename e.g. "test.gcode" (Starting a print, Power panic, and Power panic recovery)
  • Do some more testing and try to break things :)

@github-actions
Copy link

github-actions bot commented Oct 9, 2023

All values in bytes. Δ Delta to base

Target ΔFlash ΔSRAM Used Flash Used SRAM Free Flash Free SRAM
MK3S_MULTILANG -70 -4 245962 5634 7990 2558
MK3_MULTILANG -68 -4 245250 5643 8702 2549

@gudnimg gudnimg force-pushed the filename-powerpanic branch from 4195a39 to a858bda Compare October 14, 2023 09:36
@gudnimg
Copy link
Collaborator Author

gudnimg commented Oct 14, 2023

Notes on testing changes to short filename (card.filename) on Windows. Use this command in Powershell to see the short filenames on the SD card cmd /c dir /x

https://devblogs.microsoft.com/scripting/use-powershell-to-display-short-file-and-folder-names/

This is my SD card setup (tree d:\ /f):

D:\
│   Shape-Box_0.4n_0.2mm_PETG_MK3SMMU2S_39m.gcode
│   findarunout.gcode
│   3dbenchy_0.6n_0.2mm_PLA_MK3SMMU2S_1h10m.gcode
│   Shape-Box_0.6n_0.2mm_PLA_MK3SMMU3_1h50m.gcode
│   t.gcode
│   te.gcode
│   test.gcode
│   tes.gcode
│   testt.gcode
│   testte.gcode
│   testtes.gcode
│   testtest.gcode
│
├───te
│       t.gcode
│       te.gcode
│       tes.gcode
│       test.gcode
│       testt.gcode
│       testte.gcode
│       testtes.gcode
│       testtest.gcode
│
└───testfolder
        t.gcode
        te.gcode
        tes.gcode
        test.gcode
        testt.gcode
        testte.gcode
        testtes.gcode
        testtest.gcode

image

@3d-gussner 3d-gussner added this to the FW 3.14.0 milestone Oct 14, 2023
@gudnimg gudnimg changed the title 🚧 Power Panic: Don't attempt to find SD file when recovering USB print Power Panic: Don't attempt to find SD file when recovering USB print Oct 15, 2023
@gudnimg gudnimg force-pushed the filename-powerpanic branch from ef34b06 to d7d7ce1 Compare October 22, 2023 16:41
@gudnimg gudnimg requested review from 3d-gussner and DRracer November 5, 2023 12:59
@gudnimg gudnimg added the Prusa-Link_Connect Prusa Link and Prusa Connect related label Nov 5, 2023
If the saved printing type was USB, then EEPROM_FILENAME
does not contain anything. The firmware should also
not be trying to open a file on a SD card which is maybe
not even mounted.

Change in memory:
Flash: +12 bytes
SRAM: 0 bytes
We can just read the whole EEPROM block since short filenames
are always null terminated. strcat_P will then apply the file extension
at the correct position.

Change in memory:
Flash: -24 bytes
SRAM: 0 bytes
There is no need to read one byte at a time. We can simply
read the whole block in one go. This saves some flash memory.

Change in memory:
Flash: -18 bytes
SRAM: 0 bytes
When a SD file is selected to print
save the DOS 8.3 extension into EEPROM.

After a power outage, the correct file extension is then
selected instead of always assuming it's ".gco"

This allows users to recover ".g" files.

Change in memory:
Flash: +104 bytes
SRAM: 0 bytes
@gudnimg gudnimg force-pushed the filename-powerpanic branch from f61a121 to dc280b0 Compare November 5, 2023 16:47
@gudnimg gudnimg changed the title Power Panic: Don't attempt to find SD file when recovering USB print PFW-1294: Don't attempt to find SD file when recovering USB print Nov 5, 2023
Copy link
Collaborator

@3d-gussner 3d-gussner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested on MK404

  • SD print works as known.

@3d-gussner 3d-gussner merged commit a76e129 into prusa3d:MK3 Nov 11, 2023
@gudnimg gudnimg deleted the filename-powerpanic branch September 1, 2024 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
powerpanic Prusa-Link_Connect Prusa Link and Prusa Connect related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants