Duet3D Logo

    Duet3D

    • Register
    • Login
    • Search
    • Categories
    • Tags
    • Documentation
    • Order

    Duet Web control for rr_"commands"

    Duet Web Control
    4
    10
    278
    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.
    • kaoshihchuan
      kaoshihchuan last edited by

      Hi Experts

      I have some codes to controls Duet2/Wifi based on those rr_commands ( rr_gcode, rr_status ... ).
      Since I have some new hardware (Duet3), these codes would not work for it. What is the new method to inquire status report or send gcode command via this new web control system?

      Thanks a lot !

      Kevin

      jay_s_uk 1 Reply Last reply Reply Quote 0
      • jay_s_uk
        jay_s_uk @kaoshihchuan last edited by

        @kaoshihchuan if you're in SBC mode, it's /machine/status
        See here https://github.com/Duet3D/DuetSoftwareFramework

        If it's standalone, /rr_status etc should still work.
        See here https://github.com/Duet3D/RepRapFirmware/wiki/HTTP-requests

        Owns various duet boards and is the main wiki maintainer for the Teamgloomy LPC/STM32 port of RRF. Assume I'm running whatever the latest beta/stable build is

        kaoshihchuan 1 Reply Last reply Reply Quote 1
        • kaoshihchuan
          kaoshihchuan @jay_s_uk last edited by

          @jay_s_uk

          Thanks!

          I use python requests to send the http commands like this

          r = requests.get('http://192.168.168.144/rr_model?type=1/')
          or any other similar rr_commands ...

          but the response is always 404 .... Do I mistake anything ?

          stuartofmt 1 Reply Last reply Reply Quote 0
          • stuartofmt
            stuartofmt @kaoshihchuan last edited by stuartofmt

            @kaoshihchuan

            The error code 404 is saying that it could not find that url and / or query string.

            Have a look at the available url / query combinations that @jay_s_uk pointed to in his post above.

            Try something simple like

            r = requests.get('http://192.168.168.144/rr_model?key=state') where here state is one of the available objects in the object model.

            Edit: Many of these will work directly from a browser

            kaoshihchuan 1 Reply Last reply Reply Quote 0
            • kaoshihchuan
              kaoshihchuan @stuartofmt last edited by

              @stuartofmt , @jay_s_uk

              Thanks for helping me.

              The url is certainly working. (I can see the web page and control the printer using the web interface)
              but url/query_command (like rr_status, rr_model, rr_reply, rr_gcode ...) won't work (even in browser) .

              I wonder whether any setup for Deut web control need to be configured. From my Duet WiFi system, I can see many transactions/responses (F12 on the web page) like rr_reply , but I did not see any from Duet 3.

              Thanks!

              chrishamm 1 Reply Last reply Reply Quote 0
              • chrishamm
                chrishamm administrators @kaoshihchuan last edited by

                @kaoshihchuan If the rr_ requests return error code 404, you are not operating your Duet in standalone mode. rr_ requests are (at present) only supported in standalone mode but not in SBC mode. See here for a full list of supported HTTP requests in SBC mode.

                Duet software engineer

                1 Reply Last reply Reply Quote 0
                • stuartofmt
                  stuartofmt last edited by stuartofmt

                  @kaoshihchuan

                  Here is the python function I use to determine what APIs to use:

                  def getDuetVersion():
                      # Used to get the API version from  Duet
                      try:
                          URL = ('http://' + duet + '/rr_model?key=boards')
                          r = urlCall(URL, 5)
                          j = json.loads(r.text)
                          version = j['result'][0]['firmwareVersion']
                          return 'STANDALONE', version
                      except:
                          try:
                              URL = ('http://' + duet + '/machine/status')
                              r = urlCall(URL, 5)
                              j = json.loads(r.text)
                              version = j['boards'][0]['firmwareVersion']
                              return 'SBC', version
                          except:
                              return 'none', '0'
                  

                  P.S. I am a python "hacker" - so excuse any poor coding

                  kaoshihchuan 2 Replies Last reply Reply Quote 0
                  • kaoshihchuan
                    kaoshihchuan @stuartofmt last edited by

                    @stuartofmt , @chrishamm ,

                    Thanks for helping!
                    Indeed, my Duet3 system is in SBC mode....So I will have to look how to use the REST API.

                    1 Reply Last reply Reply Quote 0
                    • kaoshihchuan
                      kaoshihchuan @stuartofmt last edited by

                      @stuartofmt

                      Sorry ... I have a question again .

                      The machine/status does response properly ..
                      r = requests.get('http://192.168.168.144/machine/status/')
                      I did get all the status report

                      but when I sent the gcode command
                      r = requests.post('http://192.168.168.144/machine/code?gcode=G0 X300 Y300')

                      return code of r is 200 but the print is not moving as it was instructed.
                      I have tried "-" or just space to replace %20 space string but it doesn't work either.

                      Do I have the right format for the code I sent?

                      Thanks !

                      stuartofmt 1 Reply Last reply Reply Quote 0
                      • stuartofmt
                        stuartofmt @kaoshihchuan last edited by stuartofmt

                        @kaoshihchuan said in Duet Web control for rr_"commands":

                        @stuartofmt

                        Do I have the right format for the code I sent?

                        I'm not the best to ask on this as my projects so far have been "blind" as it relates to sending gcode to an SBC. I have relied on others to report back any issues.

                        Ultimately - when GET is used , all parameters end up being encoded into the URL as query string parameters. With POST, the data is in the message body.

                        My GUESS would be that the correct form is something like this:

                        command = 'G0 X300 Y300'
                        r = requests.post('http://192.168.168.144/machine/code', data=command)
                        
                        or maybe with
                        command = {'gcode':'G0 X300 Y300'}
                        
                        

                        Edit: Please let me know what works as I have a bit of POST code in one of my Duet related projects and I'm not sure if it works or not 🙂

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