-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Auto-reconnect #835
Comments
did you try 'RESTART' and 'FIRMWARE_RESTART' in your host software on your laptop? |
Restart works, but that's whan I want to avoid |
I don't mean restarting the service (which I assume you mean the |
Yes. Sorry, I was not clear. Those are the commands I normally use. |
The issue I see with that is that klipper cannot know whether the mcu was shutdown on purpose or just crashed. In case of a faulty MCU your suggestion would send klipper into a constant bootloop. Octoprint also doesn't automatically reconnect to a serial port that comes back online so I think this is how it is supposed to be. |
If nothing wrong with service com port stays connected even if mcu is off. |
Just for information / background: |
Why can't it raise the flag that something is wrong? |
Auto reconnect has been raised a few times (eg, #729 , #478 ). The fundamental issue is that the outage could have been the result of a severe error and reconnecting in that situation could make the problem worse. I feel the user should acknowledge the error (via a RESTART or similar command) prior to the software resuming normal operation. -Kevin |
@Avalonnw I'm also one of the few people that actually switch off their printer, but keep Klipper running. I solved the "manual Klippy restart" problem by adding a udev rule to the linux environment which runs klippy. I created a new udev rule
And now klippy gets a RESTART command sent whenever I connect or power on my printer. This only happens when the USB device is added to the system and not when Klippy automatically disconnects due to an error situation. Therefore the risk which Kevin mentioned above should be avoided. |
Oh WOW! Thanks, I'll try that!
…On Fri, 23 Nov. 2018, 19:08 sidddy ***@***.*** wrote:
@Avalonnw <https://github.com/Avalonnw> I'm also one of the few people
that actually switch off their printer, but keep Klipper running. I solved
the "manual Klippy restart" problem by adding a udev rule to the linux
environment which runs klippy. I created a new udev rule
/etc/udev/rules.d/98-klipper.rules with the content:
## rule to restart klipper when the printer is connected via usb
SUBSYSTEM=="usb", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", ACTION=="add", RUN+="/bin/sh -c '/bin/echo RESTART > /tmp/printer'"
And now klippy gets a RESTART command sent whenever I connect or power on
my printer. This only happens when the USB device is added to the system
and not when Klippy automatically disconnects due to an error situation.
Therefore the risk which Kevin mentioned above should be avoided.
Note that you'd have to change the product-id and vendor-id in above rule
according to your setup (can be figured out via lsusb)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#835 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AG6h0Xu8QtPSgNzAm-x2BfVaE5kNH0FNks5ux7r7gaJpZM4YA5SY>
.
|
@sidddy That's awesome, it works flawlessly, I test it for more than one week now, I have tried powering printer off, quickly unplugging and plugging printer during test print, and it was always giving error (it was first time I was happy when getting error :D) |
@Siddly Perfect solution. I was googling how to get Klipper to restart automatically when I either turn my printer off and on or after manually pressing reset and this worked perfectly. Now reset button on my printer actually works as expected with this udev rule. Manually sending RESTART command or restarting the host in addition to my printer is too inconvenient and is not necessary especially if all I did is turned my printer off and on. I think turning my printer off and on (or manually pressing reset button) should not count as an error - this is normal thing to do with any printer. Thank you very much for sharing your solution. |
I couldn't get the udev rule to work, because on my Linux system (armbian) /tmp had the 't' flag - and /tmp/printer couldn't be accessed by root - it would give me the error 'failed with exit code 2' Fixed this by changing the command that the udev rule runs, using sudo to run as the Klipper user :
where |
The udev rule mentioned by @sidddy doesn't work for me. I don't have a clue WHY this is working only this way, since Btw both |
Good call. For me /tmp/printer is a symlink to /dev/pts/1 instead, that works for me. |
Hey. Im connected via /dev/serial0 to board. Im use relay module and octoprint PSU plugin for power control. After power on im need use firmware_restart from terminal. Use firmware restart "before connect to printer" in "gcode scripts" no work. Any ideas?) |
@whoim2 did you even try the solutions given in this thread? |
It does not work for me either. I created the file 98-klipper.rules in /etc/udev/rules.d/
lsusb shows the following Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Do I need to change any file permissions to 98-klipper.rules? I also tried to replace /tmp/printer with /dev/pts/0 From the terminal "/bin/echo RESTART > /tmp/printer" works just fine. |
@EagleeyeKai what does the output of 'ls -al /tmp/' show? Specifically the /tmp/printer symlink. Am curious about this too. |
@teikjoon Thanks for helping me out!
|
@EagleeyeKai These are the permissions for my udev rule -
Since you can restart klipper using terminal, I can only think of two things, the rule not triggering, or the root user not having permission to /tmp/printer (which was my problem - due to /tmp having sticky bit set - thus needing the sudo command prefixed) Try changing the udev command to this -
Then you will need to reload udev rules using After udev is reloaded, try power cycling the printer, if the rule triggers, your /var/log/syslog should have this following lines (specifically the last line, which shows the the rule is actually run) -
|
@teikjoon Is just checked the permissions. I got the same permissions like you have I changed the rule according to your proposal, cycled power of the printer. Syslog shows: ` May 13 18:43:49 octopi kernel: [101332.052771] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3 May 13 18:43:49 octopi kernel: [101332.052784] usb 1-1.3: Product: lpc1769 May 13 18:43:49 octopi mtp-probe: bus: 1, device: 7 was not an MTP device May 13 18:43:49 octopi mtp-probe: bus: 1, device: 7 was not an MTP device |
@EagleeyeKai okay cool, from syslog, the udev rule is triggered...now we gotta figure out why the command doesn't restart Klipper... Do the following -
|
@EagleeyeKai I had similar issues with trying to get this rule setup on my octopi. In this reply it looks like you may have switched idVendor and idProduct, idVendor should be 2341. My issue was that the I was unable to execute the following command: |
@teikjoon Ok, I changed to the root user using sudo su root..
Just to make sure, my 98-klipper.rules file looks like this right now:
After making changes to the file, I rebooted the system every time. I also tried |
The error message means that the command 'echo' isn't in the /bin/ directory. Try running |
Try adding a
My inadequate understanding is that when calling on |
Thank you @siddy for this brilliant idea! I ended up putting this into my rule: |
I ended up with this: |
I couldn't get any of the previous rules to work; I got permission denied (even as root!!) when trying to echo to either I've worked around this by using udev to restart the
This works for Arch Linux and its klipper package; I'm unsure about OctoPi or Rasbian. |
Correct file /etc/udev/rules.d/98-klipper.rules
|
I believe the issue here is the attempt of trying to run as a different user 'su pi -c' system-udevd doesn't like user switching, apparently. ( see https://forum-raspberrypi.de/forum/thread/22708-systemd-service-als-anderer-benutzer-programm-starten/ ) |
Thanks for this! I recently replaced my hardware with a Raspberry Pi Zero W, and it works on Raspbian too |
Can this be the same problem? |
Hey! So I've been trying to get this to work, but like some others, I have so far failed. I think I have tried all of the suggestions in this thread, but none have worked. When running I tried @teikjoon's suggestions to see if the rule triggers at all, but there is no output in the syslog saying that the rule is running when power cycling the main board, so it seems that my issue is that the rule isn't running at all. I always reload the rules when making changes with Any ideas what to try next? Regards, |
@chrstrvs have you confirmed vendor and productid? what is the output of |
@teikjoon No, I have not. Can you guide me on how to do that? Now that I think about it, I'm not connecting the Pi and the main board using USB, I'm using the gpio pins on the Pi. That's probably why it won't trigger the rule. |
@chrstrvs I don't really have much experience using the GPIO pins, but you should be able to do : ls -l /dev/serial/by-path/ What's your printer.cfg look like? Do you connect using /dev/ttyAMA0 ? |
Yes, I connect using /dev/ttyAMA0. |
Hello, tell me what to spell out in the 98-klipper.rules file if rasberry pi is connected to two printer control boards through two usb ports? |
I might be the only one, but I sometimes turn my printer off.
(Sorry, could not resist putting a full stop there).
As I run OP and Klipper on a laptop, I don't turn THAT part off, so it's only the printer itself. What would be nice, if Klipper host could ping MCU every once in a while and auto-reconnect when the printer is back on. Currently I have to restart service to get connection.
The text was updated successfully, but these errors were encountered: