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

    RRF3 / Duet3 with Pi: execute bash through M code

    Scheduled Pinned Locked Moved
    Firmware wishlist
    4
    13
    729
    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.
    • dc42undefined
      dc42 administrators
      last edited by

      This is on the list to be added, once we have decided how to manage the security implications.

      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

      1 Reply Last reply Reply Quote 0
      • wilrikerundefined
        wilriker @too
        last edited by wilriker

        @too You could write a client to the DuetAPI that listens on a user-defined M-Code and then executes whatever system command you like. There are implementations for .NET and Go available so far (the latter by mean unfortunately missing documentation but it's simply a port of the .NET).

        EDIT: I already have one that listens for M7722 and then executes poweroff.

        EDIT2: I will push this to GitHub tomorrow latest and it can be used as a template.

        EDIT3: Here you go: https://forum.duet3d.com/topic/13194/dsf-extension-shutdown-sbc

        And sending GCode commands from Pi's terminal can be done with CodeConsole that you will find in /opt/dsf/bin/CodeConsole. You need to run it as root though.

        Manuel
        Duet 3 6HC (v0.6) with RPi 4B on a custom Cartesian
        with probably always latest firmware/DWC (incl. betas or self-compiled)
        My Tool Collection

        tooundefined 1 Reply Last reply Reply Quote 1
        • Danalundefined
          Danal
          last edited by Danal

          You can also send gcode to a telnet session on any Duet. Of course, it must be enabled.

          Therefore, I'd imagine you can send G-Code to a telnet 127.0.0.1 on the Pi in a Duet3 configuration (I have not tested this). And many scripting languages will let you open a telnet equivalent and send to it.

          Delta / Kossel printer fanatic

          wilrikerundefined 1 Reply Last reply Reply Quote 0
          • wilrikerundefined
            wilriker @Danal
            last edited by

            @Danal said in RRF3 / Duet3 with Pi: execute bash through M code:

            Therefore, I'd imagine you can send G-Code to a telnet 127.0.0.1 on the Pi in a Duet3 configuration (I have not tested this).

            Unfortunately, this won't work.

            Manuel
            Duet 3 6HC (v0.6) with RPi 4B on a custom Cartesian
            with probably always latest firmware/DWC (incl. betas or self-compiled)
            My Tool Collection

            1 Reply Last reply Reply Quote 0
            • tooundefined
              too @wilriker
              last edited by

              @wilriker thanks, I will look into that!
              I guess I will start learning go then 👍

              Cartesian Duet3+Raspberry pi 4 with 5x 1XD using servo drives printing mortars and concrete

              wilrikerundefined 1 Reply Last reply Reply Quote 0
              • Danalundefined
                Danal
                last edited by

                Is 127.0.0.1 not working because telnet does not yet work from anywhere in D3?

                42bff36b-9667-481f-b14b-cf07e4afd3ce-image.png

                Or is that a long-term thing?

                Delta / Kossel printer fanatic

                wilrikerundefined 1 Reply Last reply Reply Quote 0
                • wilrikerundefined
                  wilriker @too
                  last edited by

                  @too said in RRF3 / Duet3 with Pi: execute bash through M code:

                  I guess I will start learning go then 👍

                  Go is a great language! My preferred one by now. 👍

                  Manuel
                  Duet 3 6HC (v0.6) with RPi 4B on a custom Cartesian
                  with probably always latest firmware/DWC (incl. betas or self-compiled)
                  My Tool Collection

                  1 Reply Last reply Reply Quote 0
                  • wilrikerundefined
                    wilriker @Danal
                    last edited by

                    @Danal OK, maybe we have to distinguish here a bit. Duet 3 running in standalone-mode, i.e. without a SBC attached does have HTTP, FTP and Telnet (optionally) available and will respond to it when enabled. That's just like Duet 2 does. But once you use Duet 3 with a SBC all network traffic will be handled by the SBC - which is simply Linux. DuetSoftwareFramework does not (and IMHO should not) implement Telnet or FTP protocols. It only provides HTTP support via DuetWebServer (based on .NET Kestrel server). So if you are trying to connect to the SBC via FTP or Telnet there has to be a service to accept these connections - but then you will communicate with the SBC like if you would open such a connection to any other Linux machine.

                    Manuel
                    Duet 3 6HC (v0.6) with RPi 4B on a custom Cartesian
                    with probably always latest firmware/DWC (incl. betas or self-compiled)
                    My Tool Collection

                    Danalundefined 1 Reply Last reply Reply Quote 0
                    • Danalundefined
                      Danal @wilriker
                      last edited by Danal

                      @wilriker said in RRF3 / Duet3 with Pi: execute bash through M code:

                      @Danal OK, maybe we have to distinguish here a bit. Duet 3 running in standalone-mode, i.e. without a SBC attached does have HTTP, FTP and Telnet (optionally) available and will respond to it when enabled. That's just like Duet 2 does. But once you use Duet 3 with a SBC all network traffic will be handled by the SBC - which is simply Linux. DuetSoftwareFramework does not (and IMHO should not) implement Telnet or FTP protocols. It only provides HTTP support via DuetWebServer (based on .NET Kestrel server). So if you are trying to connect to the SBC via FTP or Telnet there has to be a service to accept these connections - but then you will communicate with the SBC like if you would open such a connection to any other Linux machine.

                      If I read this correctly, an SBC equipped D3 has no Telnet support equivalent to D2 telnet support. Ever.

                      Interesting design choice. I do understand the logic/reasoning behind it, just as you've explained it. Nonetheless, setting all that reasoning aside, i.e. from "outside", an existing capability goes away. Specifically IP-of-printer:23 is a telnet that accepts G-Code.

                      Hmmm... Normal Linux FTP server could be easily configured to 'appear' to be just like the D2 FTP, by way of simply pointing the default directory to the virtual SD... or set it to default to other places on the Pi. End-user choice, easy via configuration on the Pi.

                      Is there any Linux standard way to do the same with Telnet? Somehow configure the Pi so that it 'appears' that telnet to port 23 reaches the Duet just like it always did?

                      Of course, there are other configurations where telnet would reach the Pi, which we'd likely keep turned off in favor of ssh for reaching the Pi itself.

                      Delta / Kossel printer fanatic

                      1 Reply Last reply Reply Quote 0
                      • dc42undefined
                        dc42 administrators
                        last edited by

                        It would be perfectly possible (and probably straightforward) to take a Telnet client and have it talk to the API provided by DSF. But Telnet is horribly insecure, so it would be much better to implement SSH or another secure alternative.

                        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

                        Danalundefined 1 Reply Last reply Reply Quote 0
                        • Danalundefined
                          Danal @dc42
                          last edited by

                          @dc42 said in RRF3 / Duet3 with Pi: execute bash through M code:

                          It would be perfectly possible (and probably straightforward) to take a Telnet client and have it talk to the API provided by DSF. But Telnet is horribly insecure, so it would be much better to implement SSH or another secure alternative.

                          Completely agreed. But there it is on D2. Hmm....

                          Delta / Kossel printer fanatic

                          dc42undefined 1 Reply Last reply Reply Quote 0
                          • dc42undefined
                            dc42 administrators @Danal
                            last edited by dc42

                            @Danal said in RRF3 / Duet3 with Pi: execute bash through M code:

                            @dc42 said in RRF3 / Duet3 with Pi: execute bash through M code:

                            It would be perfectly possible (and probably straightforward) to take a Telnet client and have it talk to the API provided by DSF. But Telnet is horribly insecure, so it would be much better to implement SSH or another secure alternative.

                            Completely agreed. But there it is on D2. Hmm....

                            And it's disabled by default. And we tell users not to make a Duet accessible to the Internet without using a VPN.

                            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

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