Connect Repetier Server to Klipper firmware
Is it possible to connect the Repetier Server to a Klipper firmware?
Short description:
"Klipper is a new experimental firmware! It is designed to run on both a micro-controller and a low cost host computer such as a Raspberry Pi. The host does all the work of determining how and when to move each stepper motor, it compresses that information, and sends it to the micro-controller. The micro-controller then uncompresses the given schedule and executes it at the specified times. The same host computer can be used to run both Klipper and OctoPrint."
https://github.com/KevinOConnor/klipper
I succesfully run it with OctoPrint but Repetier Server has much much better Touch UI and many other nice features.
In OctoPrint I added specific serial port in "Additional serial ports" section - named /tmp/printer. And OctoPrint "talks" to the firmware through it.
I asked the developer of Klipper to integrate it with Repetier and he answered me next:
"In order to replace OctoPrint, you'll need to convince the Repetier Server software to connect to /tmp/printer. (Only the Klipper host software talks directly with the micro-controller - Repetier Server needs to talk directly with the Klipper host software via /tmp/printer.)"
I tried manually change the Device / Port in connection tab to /tmp/printer but the Repetier Server didn't connect it.
May you suggest me what can I do to fix it.
I would like to combine two great products
Kind regards,
Alex
Short description:
"Klipper is a new experimental firmware! It is designed to run on both a micro-controller and a low cost host computer such as a Raspberry Pi. The host does all the work of determining how and when to move each stepper motor, it compresses that information, and sends it to the micro-controller. The micro-controller then uncompresses the given schedule and executes it at the specified times. The same host computer can be used to run both Klipper and OctoPrint."
https://github.com/KevinOConnor/klipper
I succesfully run it with OctoPrint but Repetier Server has much much better Touch UI and many other nice features.
In OctoPrint I added specific serial port in "Additional serial ports" section - named /tmp/printer. And OctoPrint "talks" to the firmware through it.
I asked the developer of Klipper to integrate it with Repetier and he answered me next:
"In order to replace OctoPrint, you'll need to convince the Repetier Server software to connect to /tmp/printer. (Only the Klipper host software talks directly with the micro-controller - Repetier Server needs to talk directly with the Klipper host software via /tmp/printer.)"
I tried manually change the Device / Port in connection tab to /tmp/printer but the Repetier Server didn't connect it.
May you suggest me what can I do to fix it.
I would like to combine two great products
Kind regards,
Alex
Comments
Second thing is selecting the right firmware. I think Marlin would be the correct start to get it going. Also you can copy the firmware description /usr/local/Repetier-Servers/firmwares to adjust to special answer format. But most important is to get a general communication running and repetier-firmware uses a binary format that klipper surely does not speak.
Looking into klippy sources I found that this creates the port:# Support for creating a pseudo-tty for emulating a serial port:
now is python a language I do not really speak or use, so I can not say if this is really a virtual serial port. I see for example no baud rate, not that it matters on virtual devices.
From https://docs.python.org/3.2/library/pty.html I would think it is more a input/output socket. Once the communication is established that makes no big difference, but I guess that the used library will fail when trying to set rts/DTR signals or baud rate with some error. So please report what you see.
Also does klippy work without a board so I can test it some time?
1. I checked the server.log and found just this:
and /var/lib/Repetier-Server/printer/DBot/logs/connected.log file is empty
2. Klipper (RPi Host part) start as service and fine works without printer board. Octoprint succesfully connecting to the virtual /tmp/printer port
For my case, at first I installed the Octopi 0.14 RPi image, then Klipper and after that the Repetier Server armel 0.86.2 version. Of course before connect the Repetier Server to Klipper I closed connection from Octopi.
I will be willing to test anything.
BTW: It requires a ramps or so connected to work and not just show an error message.
Just as I thought it has no serial port - it is a pseudo terminal. You can use it simply if you have 2 terminals. In one you send
cat /tmp/printer
here you will see all output. To send some commands enter in second terminal
echo "status" > /tmp/printer
I think pyserial just detects the difference and therefore it works with octoprint while repetier really wants a serial port and fails here on connect. For the further communication this makes no difference, so all I have to do is somehow make it detect this somehow and use it a simple 2 files for reading and writing and it should work. Hope I can make it work for next release but for now there is nothing you can do.
echo /tmp/printer > /dev/tnt0 & echo /dev/tnt0 > /tmp/printer
Then type in Repetier host serial port: /dev/tnt1
Done! Works perfectly fine! Gotta test high segmented line 12 inch circle on 80mm/steps at 100mm/s now will report back.
I sent RESTART from the console tab like in the pic below, but it seems repetier only sends gcode, either way I used the built in reset command field . (sh script that echo "RESTART" > /tmp/printer") , its much neater that way (couldn't do it in Octoprint without plugins killing my ram, and having to type or click a button, useful for diagnosis)
After restart: https://imgur.com/a/U070C
I'm gonna dry print a 10 hour print of a protien complex model as a stress test and stability before using it as my daily driver and will report back.
Also, repetier smooth printing a large circle test succeeded with large amount of segmented lines (since arcs are not supported by most slicers) this is important for large prints, not for small prints due to molten plastic physics. There is no more 8bit blockyness on 10 inch diameter surface. You can simply test it by exporting a circle shaped model from fusion 360 with "high" profile. This is all tested on Rpi Zero wireless version for anyone wondering. This comes first after my clone Duet 0.6 with fried stepper driver for extruder, not sure if it has to do with it being clone, but duet was louadly vibrating on the curves making ripples on the surface, running the latest firmware and printing from sdcard.
see http://man7.org/linux/man-pages/man3/termios.3.html
looks like there is a way to set baud rate and other stuff
You can force server to send commands 1:1 by pretending a # like
#status
that way you can use the special commands as well. Das added this for smoothieware but should work here as well. Next release will also detect non standard gcode and send it also 1:1 but maybe with line number and checksum. Not sure what I did there, but # should work and is I think already included in latest version.
installing raspberrypi-kernel-headers works for tty0tty, but doing quick search, it seems new rpi debian images (w/ kernel 4.4+) repos no longer offer that so back to crosscompiling.
You can however still test it without any MCU connected in a VM or Linux desktop host (used lubuntu 17.10), thats how I discovered that it works first. You will see "klippy is not ready" messages on each m105 request in the console log with 0c temp reporting. And most desktop distros offer the header package.
Now I've other trouble. Few times printing failed because Klipper doesn't support g-code line numbering and Repetier-Server shuffle the lines. For example:
source g-code:
G1 X110.407 Y79.808 E0.0180
G1 X110.323 Y80.316 E0.0180
G1 X110.296 Y80.805 E0.0171
G1 X110.298 Y113.909 E1.1561
G1 X110.322 Y114.350 E0.0154
G1 X110.401 Y114.835 E0.0171
received g-code by Klipper:
Read 55661.970401: 'N155729 G1 X110.407 Y79.808 E0.0180*91\n'
Read 55661.970698: 'N155730 G1 X110.323 Y80.316 E0.0180*80\n'
Read 55661.970973: 'N155731 G1 X110.296 Y80.805 E0.0171*89\n'
Read 55661.971765: 'N155733 G1 X110.322 Y114.350 E0.0154*101\nN155732 G1 X110.298 Y113.909 E1.1561*103\n'
Read 55661.975812: 'N155734 G1 X110.401 Y114.835 E0.0171*107\n'
Read 55663.483560: 'N155735 M105*23\nN155736 M105*20\n'
Read 55664.530720: 'N155737 M105*21\nN155738 G1 X110.530 Y115.307 E0.0171*111\n'
Read 55665.534970: 'N155739 M105*27\n'
Read 55666.537640: 'N155740 M105*21\n'
Is it possible to fix it on the Repetier Server?
Link to the Klipper issue ticket - https://github.com/KevinOConnor/klipper/issues/146#issuecomment-361033682
Only way to be 100% sure is when I have next release running with pipe support.
Line numbers are not ancient btw, they are a very good method for firmwares to communicate errors. How else could a firmware tell which line had a defect. During internal communcation there is of course no chance for com errors so line numbers and resends can be skipped.
i dont want to sound needy, but especially this feature is quite interesting to me aswell since i just switched from repetier-firmware to klipper, is there already some kind of closed beta going on where tech savyy linux engineers can test and give some feedback?
https://github.com/KevinOConnor/klipper/issues/348
Might be a bit of a beginner question but, I have klipper installed and started with sudo service klipper start. Now if I go to Repetier-server do I have to choose Serial connection or Pipe/UNIX Socket for Connection Method? just wondering because I have tried both with /tmp/printer and /dev/pts/1 but havent been able to connect. If possible, would someone be able to write down the setting for Repetier side to connect to Klipper service, because Ive used it with OctoPrint before and loved it, but Ive come to like Repetier more than Octo and would love to use it here.
Cheers
It is important to use latest github version of klipper. Klipper in 0.6 does not set the permissions for the device correctly, but if you use latest github version of klipper the fix will do that.