Duet Web control for rr_"commands"
-
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
-
@kaoshihchuan if you're in SBC mode, it's /machine/status
See here https://github.com/Duet3D/DuetSoftwareFrameworkIf it's standalone, /rr_status etc should still work.
See here https://github.com/Duet3D/RepRapFirmware/wiki/HTTP-requests -
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 ?
-
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
-
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!
-
@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.
-
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
-
Thanks for helping!
Indeed, my Duet3 system is in SBC mode....So I will have to look how to use the REST API. -
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 reportbut 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 !
-
@kaoshihchuan said in Duet Web control for rr_"commands":
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