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

M98 directory

Scheduled Pinned Locked Moved
Firmware wishlist
5
12
654
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
    DonStauffer
    last edited by 12 Jun 2024, 15:54

    Would it be difficult to add a feature to M98 where beginning a macro filespec with "./":

    M98 P"./foo" ...
    

    would run macro foo in the same directory as the macro containing the M98 (if it's being done in a macro)? I know there's no such thing as the "current directory", but does a macro "know where it came from"?

    This would really clean up some of my macros and make them readable.

    In a perfect world, one could extend that path as in:

    M98 P"./bar/foo" ...
    

    but even just allowing "./filename" would be wonderful for groups of macros to call one another without something like

    M98 P"0:/macros/In/Deeply/Nested/Folders/Make/Long/Lines/To/DoSomething"
    

    Obviously that leaves open the question of what beginning a filespec with "./" would mean when not running a macro from a macro, but that could be stripped out, just be meaningless or illegal, or some logical thing I haven't thought of. Whatever it does now would probably be fine.

    undefined 1 Reply Last reply 12 Jun 2024, 17:08 Reply Quote 0
    • undefined T3P3Tony moved this topic from Tuning and tweaking 12 Jun 2024, 17:07
    • undefined
      T3P3Tony administrators @DonStauffer
      last edited by 12 Jun 2024, 17:08

      @DonStauffer I have moved this to the firmware wishlist for further discussion.

      I can see how it would be useful but not sure how much more memory ti would use to keep track of where the macros were from, especially in a set of nested macros.

      www.duet3d.com

      undefined 2 Replies Last reply 12 Jun 2024, 17:37 Reply Quote 0
      • undefined
        DonStauffer @T3P3Tony
        last edited by 12 Jun 2024, 17:37

        @T3P3Tony I can understand if the path of the currently running macro isn't already stored it would take a byte for every character plus a little overhead to save it. That could be substantial on a Duet2 especially. But if it's already there, I think very little memory would be needed.

        Presumably, a pointer to the string containing the filespec for a nested macro call gets passed to a function to begin reading the file. I'm imagining in the calling scope that string wouldn't get freed until the nested call returns, though it's certainly possible it's freed sooner. But if it's not freed until after return, and there's a pointer to it, storing that pointer would only take a few bytes.

        1 Reply Last reply Reply Quote 0
        • undefined
          oliof
          last edited by 12 Jun 2024, 17:56

          it would be a couple bytes per nested call, and since this feature would most likely be used by people doing more complex macros, it would be more memory than just a few bytes sooner rather than later...

          <>RatRig V-Minion Fly Super5Pro RRF<> V-Core 3.1 IDEX k*****r <> RatRig V-Minion SKR 2 Marlin<>

          undefined 1 Reply Last reply 12 Jun 2024, 18:54 Reply Quote -1
          • undefined
            DonStauffer @T3P3Tony
            last edited by DonStauffer 6 Dec 2024, 19:00 12 Jun 2024, 18:44

            @T3P3Tony For the heck of it, I looked at the code on GitHub. Hard to get a handle on it looking at it briefly, so I may be way off base, but a question:

            Does the GCodeBuffer object for the M98 continue to live until the macro is fully done executing? It seems like it would, and it's the GetString method that returns the filename (which seems to actually be a filespec), so that makes me hopeful.

            I'm curious if I'm anywhere in the right vicinity.

            PS: I love C++!

            undefined 1 Reply Last reply 12 Jun 2024, 20:39 Reply Quote 0
            • undefined
              DonStauffer @oliof
              last edited by DonStauffer 12 Jun 2024, 18:54

              @oliof Yes, that's true. Still, I wonder if a pointer may already be stored indirectly, in the form of a pointer to an object which can return the pointer. Maybe. IDK, I could be way off base, but if a pointer is already sitting there ...

              undefined 1 Reply Last reply 16 Jun 2024, 16:46 Reply Quote 0
              • undefined
                T3P3Tony administrators @DonStauffer
                last edited by 12 Jun 2024, 20:39

                @DonStauffer that's a question for @dc42 or @chrishamm .

                www.duet3d.com

                1 Reply Last reply Reply Quote 0
                • undefined
                  dc42 administrators @DonStauffer
                  last edited by 16 Jun 2024, 16:46

                  @DonStauffer RRF has no concept of a current directory. For every command that takes a filename argument there is a default directory that is used if the specified filename does not include an a absolute path.

                  Currently, RRF does not remember the names of macro files currently executing. I am planning to add this (except on Duet 2 because of memory constraints) in order that error messages can include the filename. So in principle we could have M98 accept a relative path when M98 is invoked from another macro file. However, there is another issue with using "./" as a prefix for this, which is that using that prefix is the same as not using it. That is the convention for path names and I am fairly sure is how the FatFs filesystem used by RRF behaves. I would not want to deviate from that behaviour.

                  Duet WiFi hardware designer and firmware engineer
                  Please do not ask me for Duet support via PM or email, use the forum
                  http://www.escher3d.com, https://miscsolutions.wordpress.com

                  undefined 1 Reply Last reply 16 Jun 2024, 23:45 Reply Quote 0
                  • undefined
                    DonStauffer @dc42
                    last edited by DonStauffer 16 Jun 2024, 23:45

                    @dc42 The ability to change that default directory might be just as good.

                    Unfortunately my Railcore has a Duet2 (with Duex & PanelDue). I've thought about replacing it with a Duet3 but I don't have time to evaluate form factor and connections to be sure I could just drop it in my Railcore.

                    undefined 1 Reply Last reply 18 Jun 2024, 15:42 Reply Quote 0
                    • undefined
                      oliof @DonStauffer
                      last edited by 18 Jun 2024, 15:42

                      @DonStauffer two Duet 3 mini would be drop in replacements for Duet2 and Duex foot print wise, running one of the minis as CAN expansion board. Whether that has all the IO you need depends on your machine specifics.

                      <>RatRig V-Minion Fly Super5Pro RRF<> V-Core 3.1 IDEX k*****r <> RatRig V-Minion SKR 2 Marlin<>

                      undefined 1 Reply Last reply 20 Jun 2024, 00:14 Reply Quote 0
                      • undefined
                        DonStauffer @oliof
                        last edited by DonStauffer 20 Jun 2024, 00:14

                        @oliof This is up to date for my dual-extruder Railcore, except that since then I've been playing with the LED output and the I2C output, and I have in mind adding a thermistor to measure ambient temperature:

                        Ports are listed in order from left to right and top to bottom.
                        Duet 2 WiFi

                        Power (Middle Right)
                        USB (Middle Left)

                        Stepper Motors (Top Right)
                        Drive 4 E1 MOTOR Secondary extruder
                        Drive 3 E0 MOTOR Primary extruder
                        Drive 0 X MOTOR Back XY stepper
                        Drive 1 Y MOTOR Front XY stepper
                        Drive 2 Z MOTOR (unused)
                        End Stops (Middle)
                        E1 STOP e1stop filament sensor
                        E0 STOP e0stop filament sensor
                        X STOP xstop Build area Left Rear
                        Y STOP ystop On carriage
                        Z STOP (unused)
                        Heaters (Top Left, Bottom Right)
                        E1 HEATER e1heat Secondary hot end
                        E0 HEATER e0heat Primary hot end
                        HEATED BED bedheat Bed heater MOSFET control

                        Thermistors (Middle Left, Bottom Right)
                        THERMISTOR2 E1 e1temp Secondary Hot End
                        THERMISTOR1 E0 e0temp Primary Hot End
                        THERMISTOR0 BED bedtemp Bed
                        Fans (Middle Right)
                        PWM:
                        FAN2 (unused)
                        FAN1 fan1 Secondary Part Fan
                        FAN0 fan0 Primary Part Fan
                        Always On:
                        Secondary Heat Sink Fan
                        Primary Heat Sink Fan
                        Z Probe (Bottom Left)
                        Z PROBE zprobe.in BLTouch

                        Duex

                        Power (Middle Right)
                        Stepper Motors (Bottom)
                        Drive 9 E6 MOTOR (unused)
                        Drive 8 E5 MOTOR (unused)
                        Drive 7 E4 MOTOR Right Z stepper
                        Drive 6 E3 MOTOR Back Left Z stepper
                        Drive 5 E2 MOTOR Front Left Z stepper
                        Servos (Lower Left)
                        PWM5 E6_PWM (unused)
                        PWM4 E5_PWM (unused)
                        PWM3 E4_PWM (unused)
                        PWM2 E3_PWM duex.pwm2 LED lights (white, not NeoPixels)
                        PWM1 E2_PWM duex.pwm1 BLTouch
                        End Stops (Upper Center)
                        E6 STOP E1 STOP (unused)
                        E5 STOP E0 STOP (unused)
                        E4 STOP X STOP (unused)
                        E3 STOP Y STOP (unused)
                        E2 STOP Z STOP (unused)
                        Heaters (Upper Right)
                        E2 HEATER (unused)
                        E3 HEATER LED lights wiring
                        E4 HEATER (unused)
                        E5 HEATER (unused)
                        E6 HEATER (unused)
                        Thermistors (Middle)
                        E4 THERMISTOR5 (unused)
                        E3 THERMISTOR4 (unused)
                        E2 THERMISTOR3 (unused)
                        E6 THERMISTOR7 (unused)
                        E5 THERMISTOR6 (unused)
                        Fans (Upper Left)
                        FAN8 (unused)
                        FAN7 (unused)
                        FAN6 (unused)
                        FAN5 (unused)
                        FAN4 duex.fan4 (unused)
                        FAN3 duex.fan3 Case fan

                        droftartsundefined 1 Reply Last reply 20 Jun 2024, 12:18 Reply Quote 0
                        • droftartsundefined
                          droftarts administrators @DonStauffer
                          last edited by 20 Jun 2024, 12:18

                          @DonStauffer I think there's enough drivers and I/O on a Duet 3 Mini 5+ with Duet 3 expansion Mini 2+ (to give 7 motor drivers) to drive your setup.

                          Ian

                          Bed-slinger - Mini5+ WiFi/1LC | RRP Fisher v1 - D2 WiFi | Polargraph - D2 WiFi | TronXY X5S - 6HC/Roto | CNC router - 6HC | Tractus3D T1250 - D2 Eth

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