• Tags
  • Documentation
  • Order
  • Register
  • Login
Duet3D Logo Duet3D
  • Tags
  • Documentation
  • Order
  • Register
  • Login

keeping variables (global) after reset

Scheduled Pinned Locked Moved
Gcode meta commands
3
7
514
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • undefined
    benecito
    last edited by 17 Jul 2021, 15:25

    Is there a way to keep variables even after reseting or turning off the board?
    I don't want to re-set them in config.g or alike as I'd need them to be editable via G-Code.
    I had something in mind like storing them in config override with M500 or alike.

    Using a Duet 3 mini with RRF 3.3

    undefined undefined 3 Replies Last reply 17 Jul 2021, 17:04 Reply Quote 0
    • undefined
      fcwilt @benecito
      last edited by 17 Jul 2021, 17:04

      @benecito

      You might be able to use M28, M29 and M32.

      M28 and M29 allow writing commands to a file on the SD card.

      M32 allows executing that file.

      It would be easy to test.

      Frederick

      Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

      1 Reply Last reply Reply Quote 0
      • undefined
        fcwilt @benecito
        last edited by 17 Jul 2021, 17:05

        @benecito

        But it might be nice to have some news commands to save/load variables.

        Would being able to do all of them at once work for you?

        Frederick

        Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

        undefined 1 Reply Last reply 17 Jul 2021, 17:09 Reply Quote 0
        • undefined
          benecito @fcwilt
          last edited by 17 Jul 2021, 17:09

          @fcwilt I'll try tomorrow!

          And I suppose yes, if I don't need the variables they don't need to be in there.

          1 Reply Last reply Reply Quote 0
          • undefined
            benecito
            last edited by 17 Jul 2021, 20:19

            Just tried 😉

            It works, but I suppose it does not make much sense as I (the user) would need to write them all sequentially. This is very likely to cause mistakes.

            I guess it would make sense to have a M*** command that writes all currently set globals to a file variables.g (or alike) in sys, which could then be called while startup. This way you could simply change the value of one variable, and write them all back to the variables file if needed.

            While writing I might try creating a file for every variable, but it's still a lot more complicated.

            undefined 1 Reply Last reply 17 Jul 2021, 20:25 Reply Quote 0
            • undefined
              fcwilt @benecito
              last edited by 17 Jul 2021, 20:25

              @benecito said in keeping variables (global) after reset:

              Just tried 😉

              It works, but I suppose it does not make much sense as I (the user) would need to write them all sequentially. This is very likely to cause mistakes.

              I guess it would make sense to have a M*** command that writes all currently set globals to a file variables.g (or alike) in sys, which could then be called while startup. This way you could simply change the value of one variable, and write them all back to the variables file if needed.

              While writing I might try creating a file for every variable, but it's still a lot more complicated.

              Glad to hear it works.

              Why don't you post to the firmware wish list a suggestion to have the needed commands to save/load all global variables to file.

              Frederick

              Printers: a small Utilmaker style, a small CoreXY and a E3D MS/TC setup. Various hotends. Using Duet 3 hardware running 3.4.6

              1 Reply Last reply Reply Quote 0
              • undefined
                DonStauffer @benecito
                last edited by DonStauffer 21 Jul 2021, 01:12

                @benecito Put your code setting the globals in a macro and call it from config.g. Then you can edit the file using GCode without messing with config.g itself. In config.g:

                M98 P"/macros/setglobals"

                Then, to change the globals, you'd have to rewrite the entire setglobals file, unless you had it, in turn, do calls to other files:

                M28 "/macros/setglobals"
                global var1=1
                global var2=2
                ...
                M29

                1 Reply Last reply Reply Quote 0
                7 out of 7
                • First post
                  7/7
                  Last post
                Unless otherwise noted, all forum content is licensed under CC-BY-SA