Duet 3D and Raspberry Pi connection
-
In fact, I'm a little curious what the real role of the Pi will be in your proposed design.
When you say "building a custom GUI on the Pi", building in what? Will it run on the Pi and display on the Pi's physical console, the HDMI connection? If so, in what languages or "tech stack"?
Or does it work some other way? Does the Pi talk to a browser?
What is the "overall flow" intended?
-
Oh, and you can certainly have your Gcode file on the Pi, and feed it one command at a time over the network to the Duet. With
rr_gcode?gcode=XXX
However, since the Duet has a file upload facility, and can print from that uploaded file residing on its own SD card, sending the file in pieces from the Pi certainly seems like "re inventing the wheel" and a serious step backwards in reliability.
1.) We are using the Rpi to allow a HD touchscreen and further expansion of the project (paneldue is too low resolution and not many options for customization).
2.) We are building the GUI with Python. It will be running on the Rpi and the touchscreen will be connected via HDMI.
3.) The Rpi will be talking to the Duet via ethernet (potentially octoprint). We might also use HTTP protocol client to send and request info to the Duet USING the GUI.
So just to summarize our plan: The Duet is connected to the Rpi using ethernet and the Rpi is connected to our touchscreen. The touchscreen will display the GUI and also have the accessible SD card slot.
To clarify, the HTTP command "rr_gcode?gcode=XXX" only passes 1 gcode command at a time? So say we have the gcode on a SD card on the Rpi's touchscreen, can we use the HTTP command "rr_upload?name=XXX&time=YYY" to pass the whole gcode file to the Duet?
So… say we have this line of pseudocode HTTP commands sent from the Rpi to the Duet:
host = 192.xxx.xxx.xx // address for the the duet
sendfile = "rr_upload?name=XXX&time=YYY" // specify the gcode file to send
send(host, sendfile) // send the entire gcode file to the duetIf this is the case, where exactly on the Duet does this gcode file go? The onboard SD card?
Thank you in advance!
-
Yes it would upload to the SD card. You would then need to send a GCode command to print the file you just uploaded.
-
Yes it would upload to the SD card. You would then need to send a GCode command to print the file you just uploaded.
Thank you very much! We are done with the first draft of the GUI and how it will send the gcode file to the Duet's SD card.
Here's another challenge: So the Rpi and the Duet are connected via Ethernet. How does the DWC factor in? Do we need to do some installing/setting up or will the Duet and Rpi automatically connect via the DWC?
Thanks!
-
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.
-
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)