Introduction
Disclaimer: this might still be experimental. I have been using it long enough to think it is a good idea to try it, but please search the discord for possible problems/limitations.
These instructions assume the software will run on a Raspberry Pi computer and that you already have done the setup for klipper. It also assumes you are comfortable using SSH and modifying your printer.cfg.
Instructions copied from the readme on github.
Pros:
- loads fast
- can edit printer.cfg from web interface (if you mess it up, the web interface won't load again)
- automatically adapt to display size
Cons:
- only one instance at once (if more, you might not receive the ACK for the commands you send)
- console history only accumulate in opened instance
Resources:
-
-
After having installed klipper, ssh into the target machine to install dwc2.
-
Install necessary packages:
-
sudo apt install wget gzip tar
-
Stop klipper:
-
sudo systemctl stop klipper
-
-
-
If you went through the klipper setup, you are logged in as the user "pi" and klipper is installed in your home directory, let's insure we are in the good folder:
-
cd ~
-
It might be a good idea to backup your current klipper and start fresh with a new copy, it means you might have to update your electronics afterwards:
-
mv klipper klipper_backup
-
git clone https://github.com/KevinOConnor/klipper.git
-
-
-
We need to load the python environment used by klipper, if you went through the klipper guide:
-
PYTHONDIR="${HOME}/klippy-env"
-
virtualenv ${PYTHONDIR}
-
And while the environment is active, we need to install a new python package:
-
${PYTHONDIR}/bin/pip install tornado==5.1.1
-
-
-
Get the code from github
-
git clone https://github.com/Stephan3/dwc2-for-klipper.git
-
One of the file has to be in klipper's path, instead of just copying it, we will create a link or shortcut to it:
-
ln -s ~/dwc2-for-klipper/web_dwc2.py ~/klipper/klippy/extras/web_dwc2.py
-
-
-
Some changes are needed in klipper for dwc2 to work, considering you installed in the default folders, go to your home (cd ~) and:
-
This should work, but it might be easier to copy those 4 lines from the readme of the dwc2 for klipper in case the formatting of the wiki causes problems when copying. The expected changes can be seen in this PR.
-
gcode=$(sed 's/self.bytes_read = 0/self.bytes_read = 0\n self.respond_callbacks = []/g' klipper/klippy/gcode.py)
-
gcode=$(echo "$gcode" | sed 's/# Response handling/def register_respond_callback(self, callback):\n self.respond_callbacks.append(callback)/')
-
gcode=$(echo "$gcode" | sed 's/os.write(self.fd, msg+"\\n")/os.write(self.fd, msg+"\\n")\n for callback in self.respond_callbacks:\n callback(msg+"\\n")/')
-
echo "$gcode" > klipper/klippy/gcode.py
-
-
-
Create the necessary folders:
-
mkdir -p ~/sdcard/dwc2/web
-
mkdir -p ~/sdcard/sys
-
Download dwc2 and unzip it (newer releases than the one linked might work):
-
cd ~/sdcard/dwc2/web
-
wget https://github.com/chrishamm/DuetWebControl/releases/download/2.0.6/DuetWebControl-SBC.zip
-
You can check https://github.com/chrishamm/DuetWebCont... to see the latest releases (test at your own risk)
-
unzip *.zip && for f_ in $(find . | grep '.gz');do gunzip ${f_};done
-
-
-
Edit klipper's config (Example config: https://github.com/Stephan3/dwc2-for-kli...): nano ~/printer.cfg
-
[virtual_sdcard]
-
path: /home/pi/sdcard
-
[web_dwc2]
-
listen_port: 4750
-
Restart klipper:
-
sudo systemctl start klipper
-
-
-
If you've followed the guide up to this point, you're basically done. You have a working system. But DWC is running on port 4750. So every time you want to visit it, you have to include the port.
-
To fix this, you need to override the linux security model, and allow python access to the "privileged ports"
-
sudo setcap CAP_NET_BIND_SERVICE=+eip /home/pi/klippy-env/bin/python2
-
If you update the copy of python in your venv, you'll need to redo this step. Most people don't do that very often though, so don't worry about this too much
-
Now head back to your printer.cfg, and find the [web_dwc2] section
-
change the line "listen_port:4750" to "listen_port:80"
-
restart klipper, and you're done.
-
sudo systemctl restart klipper
-