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

Export M503 setting to file - serial redirect #26904

Open
wants to merge 5 commits into
base: bugfix-2.1.x
Choose a base branch
from

Conversation

vovodroid
Copy link
Contributor

@vovodroid vovodroid commented Mar 25, 2024

Description

This PR adds menu item for redirection of M503 serial output to M503.gc file in the SD card root.

Requirements

SD media and LCD screed. Build and tested with TFT35 display.

Benefits

It allows to save and next load current memory settings. It could serve as backup, and especially useful when flash new Marlin build with changed settings structure, demanding initialization of EEPROM. After such initialization M503.gc file could be "printed" and previous settings is being loaded into the memory.

Serial redirect could also be used in future for saving logs to file.

Example of export file:

  G21 ; (mm)
  M149 C ; Units in Celsius
  M200 S0 D1.7500
  M92 X80.0000 Y80.0000 Z400.0000 E399.5100
  M203 X200.0000 Y200.0000 Z12.0000 E100.0000
  M201 X2000.0000 Y2000.0000 Z100.0000 E2500.0000
  M204 P4000.0000 R1200.0000 T4000.0000
  M205 B20000.0000 S0.0000 T0.0000 X12.0000 Y12.0000 Z0.4000 E10.0000
  M206 X0.0000 Y0.0000 Z0.0000
  M420 S0 Z30.0000 ; Leveling OFF
  M145 S0 H180.0000 B70.0000 F0
  M145 S1 H240.0000 B110.0000 F0
  M304 P82.5000 I8.0600 D563.1000
  M710 S255 I0 A1 D60 ; (100% 0%)
  M413 S0 B0 ; OFF
  M207 S3.0000 W13.0000 F1500.0000 Z0.0000
  M208 S0.0000 W0.0000 F1500.0000
  M851 X-19.9900 Y12.0100 Z-1.0500 ; (mm)
  M906 X800 Y800 Z600
  M906 T0 E500
  M569 S1 X Y Z
  M569 S1 T0 E
  M592 A0.0000 B0.0002 C1.0000
  M593 X F60.0000 D0.1500
  M593 Y F30.0000 D0.1500
  M86 B120 E0 S240 T180
  M900 K0.0000
  M603 L105.0000 U115.0000 ; (mm)
  M412 S0 D100.0000 ; Sensor OFF
  M306 E0 P40.00 C16.94 R0.2483 A0.0942 F0.1067 H0.0056


Related Issues

@ellensp
Copy link
Contributor

ellensp commented Mar 25, 2024

Why are people so adverse to using a control program?..
M503, cut and paste results, done...

Dont have to fight with a sdcard or any such silliness...

@vovodroid
Copy link
Contributor Author

M503, cut and paste results, done...

You should use serial - or computer, or phone/tablet with USB OTG adapter.

@ThomasToka
Copy link
Contributor

People are too lazy. Otherwise: when you have a possibility to Export settings to a file and Import it you use it.

So i have written something similar and People like and use it.

https://github.com/ThomasToka/Marlin/blob/75ce38ef4bc678db0dec4aa7eb68f119f29a184e/Marlin/src/lcd/rts/e3s1pro/lcd_rts.cpp#L3864

@bmourit
Copy link

bmourit commented Mar 25, 2024

This is simply a user experience upgrade. It does seem useful to me. Why do anything to make things simpler? Well, cause it makes life easier for some people. My only qualm is that this would require 2 SDCards, since the one used to flash has to contain only the firmware file.

@thisiskeithb
Copy link
Member

My only qualm is that this would require 2 SDCards, since the one used to flash has to contain only the firmware file.

I’m not aware of any board that requires this. You can store / print G-code from the same SD that’s used for flashing firmware.

@thisiskeithb
Copy link
Member

@vovodroid: It would be extremely helpful if you completed this PR to add a proper configuration option as well as ensure all CI tests pass.

@bmourit
Copy link

bmourit commented Mar 26, 2024

My only qualm is that this would require 2 SDCards, since the one used to flash has to contain only the firmware file.

I’m not aware of any board that requires this. You can store / print G-code from the same SD that’s used for flashing firmware.

On Ender-3 the firmware.bin file must be the only file on the SDCard to properly flash the firmware. While you could use one card, it would involve backing up on a computer and kinda defeat the whole purpose of this. But that is just 1 machine, and maybe not even all of those machines, since mine seems to have some weird quirks with flashing.

Still a useful feature to add this IMHO.

@vovodroid
Copy link
Contributor Author

vovodroid commented Mar 29, 2024

@thisiskeithb

as well as ensure all CI tests pass.

Can I run all these tests in my local environment?

@thisiskeithb
Copy link
Member

thisiskeithb commented Mar 29, 2024

Can I run all these tests in my local environment?

Yes, with make like:

make tests-all-local

Note

  • If you get a get_test_targets.py: Permission denied error, get_test_targets.py will need to be made executable with chmod +x /path/to/buildroot/share/scripts/get_test_targets.py.
  • If you get a ModuleNotFoundError: No module named 'yaml' error, install pyyaml with pip install pyyaml.
  • Last but not least, the linux_native test will fail if you're not on Linux, but the tests should continue.

(h/t to @The-EG for walking me through these errors!)

Or run a single test like:

make tests-single-local TEST_TARGET=FYSETC_F6

@vovodroid
Copy link
Contributor Author

I tried to run make tests-all-local from Visual Studio Code Terminal window on Windows10, for clean bugfix-2.1.x branch.
All tests fail with error avr-g++: error: CreateProcess: No such file or directory like

Running tests for mega2560
Running mega2560 Tests

[Test mega2560 --target clean] Setup Build Environment...
Passed
which: no gsed in (/c/DISK_D/3D/Marlin/buildroot/bin:/c/DISK_D/3D/Marlin/buildroot/bin/../tests:./buildroot/bin/:./buildroot/tests/:/c/Users/Vovodroid/.platformio/penv/Scripts:/c/Users/Vovodroid/.platformio/penv:/c/Users/Vovodroid/.platformio/python3:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/Program Files/dotnet:/c/Program Files/Git/cmd:/c/Python310/Scripts:/c/Python310:/c/Users/Vovodroid/AppData/Local/Programs/Python/Launcher:/c/Users/Vovodroid/AppData/Local/Microsoft/WindowsApps:/c/ffmpeg/bin:/c/Users/Vovodroid/.dotnet/tools:/mingw64/bin:/ucrt64/bin:/usr/bin:/c/Program Files/CMake/bin:/c/Windows/system32:/c/Windows:/c/Windows/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0:/c/Windows/System32/OpenSSH:/c/Program Files/dotnet:/c/Program Files/Git/cmd:/c/Python310/Scripts:/c/Python310:/c/Users/Vovodroid/AppData/Local/Programs/Python/Launcher:/c/Users/Vovodroid/AppData/Local/Microsoft/WindowsApps:/c/ffmpeg/bin:/c/Users/Vovodroid/.dotnet/tools:/mingw64/bin:/ucrt64/bin:/usr/bin:/c/Program Files/CMake/bin)      

[Test mega2560] Default Configuration | no source filtering...
Marlin\src\inc\Warnings.cpp:103:4: warning: #warning "Your Configuration provides no method to acquire user feedback!" [-Wcpp]
   #warning "Your Configuration provides no method to acquire user feedback!"
    ^~~~~~~
avr-g++: error: CreateProcess: No such file or directory
*** [.pio\build\mega2560\firmware.elf] Error 1
=========================================================================== [FAILED] Took 96.45 seconds ===========================================================================
Environment    Status    Duration
-------------  --------  ------------
mega2560       FAILED    00:01:36.449
====================================================================== 1 failed, 0 succeeded in 00:01:36.449 ======================================================================

@The-EG
Copy link
Contributor

The-EG commented Apr 5, 2024

I tried to run make tests-all-local from Visual Studio Code Terminal window on Windows10, for clean bugfix-2.1.x branch.

I see you have a MingW64 environment setup, whether you intended to use it for this or not. The makefile is intended to be used in a linux/unix environment, so you'll need to arrange for the standard utilities to be there. In this case it's complaining about not finding gsed. sed should also work.

Note that you need that *nix environment and PlatformIO both available, and PIO generally doesn't play nicely with MingW/MSYS. I've gotten these running on Windows before with some finagling but setting up WSL would probably be a better solution for this (and you can even use VSCode with it still too).

@sjasonsmith
Copy link
Contributor

I've gotten these running on Windows before with some finagling but setting up WSL would probably be a better solution for this (and you can even use VSCode with it still too).

I will second this. Actually cloning the git repo into a WSL session and opening it remotely from VSCode works very well. As long as you are using WSL2 and using a native-Linux path for the git repo it will also build much faster than doing it on Windows through MinGW.

Just be sure you are not using WSL2 inside a Windows folder...that is horrendously slow.

(WSL1 was exactly the opposite, but I imagine nobody is using WSL1 anymore?)

@vovodroid
Copy link
Contributor Author

vovodroid commented Apr 7, 2024

I didn't succeed in getting platformio working in WSL, so eventually I run all (including Visual Studio Code) inside VMware Ubuntu guest.

But when I run make tests-all-local it seems not all tests for each environment are performed, for example

dev@dev:/mnt/hgfs/MarlinU$ make tests-all-local
export PATH="./buildroot/bin/:./buildroot/tests/:/home/dev/.platformio/penv/bin:/home/dev/.platformio/penv:/home/dev/.platformio/python3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin" \
  && export VERBOSE_PLATFORMIO= \
  && for TEST_TARGET in $(buildroot/share/scripts/get_test_targets.py) ; do echo "Running tests for $TEST_TARGET" ; run_tests . $TEST_TARGET ; done
Running tests for linux_native
Running linux_native Tests

[Test linux_native --target clean] Setup Build Environment...
Passed
Running tests for mega2560
Running mega2560 Tests

while on Guthub after --target clean goes [Test linux_native] Linux with EEPROM..., that fails.

@vovodroid vovodroid force-pushed the m503-export-pr branch 2 times, most recently from 3a04b53 to 1e88ac8 Compare April 13, 2024 09:29
@vovodroid
Copy link
Contributor Author

I updated PR to pass all tests. But when new feature is disabled by default no actual build is performed. Also when Sanity.h detects conflicting option for some config test also fails.

So just for tests I enabled setting export and and add check to Configuration_adv.h to prevent test fail. For actual build two latest commit should be discarded.

@sl1pkn07
Copy link
Contributor

sl1pkn07 commented May 20, 2024

finally #15052

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FR] Allow save the printer settings into a gcode file
9 participants