Duet 3D and Raspberry Pi connection
-
DWC runs in the web browser, so in your setup using a RPi you would need to replicate whatever DWC functions you want to use on the RPi, for example in Octoprint.
Thanks for the speedy response! We might end up switching to Raspian due to somethings coming up with the GUI, just wanted to check that the process would be the same Any idea on this? Thanks in advance!
-
I am using RPi to monitor print progress as I keep print progress updated in a sql database from each of my printers – and others are updated via octoprint -- I have a process which sends commands to DWC via http requests (basically a REST api) and get back a json object with all the information I'd need to build a full fledged UI, I only take the information I need to get progress, and estimation to completion as that's all I display on a rolling ticker LCD which shows progress of all print jobs. There are a handful of supported commands which are documented in DWC, some give more information than others, you can also execute gcode commands if necessary.
-
I am using RPi to monitor print progress as I keep print progress updated in a sql database from each of my printers – and others are updated via octoprint -- I have a process which sends commands to DWC via http requests (basically a REST api) and get back a json object with all the information I'd need to build a full fledged UI, I only take the information I need to get progress, and estimation to completion as that's all I display on a rolling ticker LCD which shows progress of all print jobs. There are a handful of supported commands which are documented in DWC, some give more information than others, you can also execute gcode commands if necessary.
If I can pick you brain real quick: We have an Rpi3 running Raspbian and want to connect to Duet using ethernet and send HTTP requests to send gcode and print. Do we connect using the DWC? If so, how do we get DWC on the Rpi? Do we treat the Rpi like a computer and access it that way?
-
The very best thing to do is look at DWC on Github for examples.
There was a topic in a different forum discussion about having a "multi printer" monitor, and, by looking at DWC, I was able to have a draft in a day, and a workable product in about three. With only a couple of hours per day. And having never looked at DWC before.
This is in no way a brag on me. I'm medium skilled web person at best.
It is pointing out how much can be done, and how quickly, through the existing APIs, and how much those APIs can be understood by looking at functions in DWC.
-
If I can pick you brain real quick: We have an Rpi3 running Raspbian and want to connect to Duet using ethernet and send HTTP requests to send gcode and print. Do we connect using the DWC? If so, how do we get DWC on the Rpi? Do we treat the Rpi like a computer and access it that way?
If you are connecting to the Duet and sending http from.another application (like some software you are running in the Raspi), rather than a web browser, then you can send http request formatted in the same.way as DWC formats http requests.
Look at the DWC github readme:
https://github.com/chrishamm/DuetWebControl/blob/master/README.md
You will see commands like:
[[language]] rr_gcode?gcode=XXX
To send a gcode. It's worth reading that whole readme as it explains how to establish a session and gives some examples.of the AJAX that the Duet returns.
-
I send
rr_status?type=[1-3]depending on what I want to get from duet
so let's say your duet address is 192.168.0.100 you'd send an http request
http://192.168.0.100/rr_status?type=1and you'll get back a json payload and you then read it into your app and display it as you see fit.
treat the duet as you'd treat any REST host – you send commands to the DWC from the Pi and get back information.
You can do that inside a web app, a python script, or a Java web service as I am doing. -
DWC runs in the web browser, so in your setup using a RPi you would need to replicate whatever DWC functions you want to use on the RPi, for example in Octoprint.
Hey dc42, we are having trouble with using "rr_upload?name=XXX&time=YYY."
Using a web browser on the Rpi, we are able to use "rr_gcode?gcode=XXX" to select the gcode file and print it out, but this only works on a gcode file that is already on the SD card.
Example:
_> [IP address of Duet]/rr_gcode?gcode=M23 [filename].gcode
[IP address of Duet]/rr_gcode?gcode=M24_
But once again, this only works with gcode files that are already on the SD.
When we try to use the rr_upload, we don't know how to specify the gcode file that needs to be uploaded:
So looking at the HTTP command:
> rr_upload?name=XXX&time=YYY
According to the documentation, XXX is the folder we want to save the gcode file to, so here:
> rr_upload?name=gcodes/[filename].gcode
However, how do we SELECT the gcode we want to upload TO that folder?
So say we have a gcode file "zTest.gcode" that is on the Rpi and we want to send that gcode file to the SD card.
How do we do this?
-
You can't use a browser to upload, because a browser does a "get" request with what you type into the address bar.
The "rr_upload…" has to be a "post" request. The direct answer to your question "Which file is sent" is "the file you encode and send in the post request".
See https://github.com/chrishamm/DuetWebControl/blob/master/core/js/upload.js for details.
-
You can't use a browser to upload, because a browser does a "get" request with what you type into the address bar.
The "rr_upload…" has to be a "post" request. The direct answer to your question "Which file is sent" is "the file you encode and send in the post request".
See https://github.com/chrishamm/DuetWebControl/blob/master/core/js/upload.js for details.
EDIT: I have completely redone this post
Thank you for your help in this manner.
So the rr_upload is a POST request, but this can't really be done in the browser because the browser only does GET requests.
So we must use python to run this rr_upload command, do we need to specify it in python to be a POST?
And I would like to clarify, if you don't mind and when it's convenient for you, how do we encode the file and send in the POST request?
Thank you in advance!
-
DWC runs in the web browser, so in your setup using a RPi you would need to replicate whatever DWC functions you want to use on the RPi, for example in Octoprint.
Hey dc42, hope you're doing well.
Would this example of python and http POST requests be what we are looking for?
url = '[Duet_IP_Address]/rr_upload?name=gcodes/[filename].gcode'
files = {'file': open('[filename].gcode', 'rb')}
values = {'author': 'John Smith'}
r = requests.post(url, files=files, data=values)