Skip to content
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

Turn off when an unrecoverable firmware or communication error occurs does not work on serial exception #260

Open
shadow578 opened this issue Feb 5, 2023 · 1 comment

Comments

@shadow578
Copy link

What were you doing?

  1. configure PSU Control normally (using system command switching, but shouldn't matter for this issue)
  2. enable Turn off when an unrecoverable firmware or communication error occurs option
  3. turn on the psu and connect the printer
  4. cause a serial communication error (e.g. unplug the printer usb cable)

What did you expect to happen?

I'd expect the psu to shut down when a communication error occurs.

What happened instead?

Printer is disconnected (with error), but psu stays on.

Version of OctoPrint-PSUControl

1.0.6

Operating System running OctoPrint

OctoPrint 1.8.6, Python 3.9.2, Linux

Printer model & used firmware incl. version

Link to octoprint.log with octoprnt.plugins.psucontrol set to DEBUG

https://gist.github.com/shadow578/b7cb8de193a29c4435b81cf0c9be9529

@shadow578 shadow578 changed the title Turn off when an unrecoverable firmware or communication error occurs does not work on serial disconnect Turn off when an unrecoverable firmware or communication error occurs does not work on serial exception Feb 5, 2023
@shadow578
Copy link
Author

Ok, so i did some digging and it seems like OctoPrint does not raise a ERROR event when the serial connection fails (at all).
Since the plugin only checks for the ERROR event, it cannot do anything when the serial connection does fail.

However, OctoPrint does raise a DISCONNECTED event.
when handling this event*, the printer does turn of as expected:

def on_event(self, event, payload):
    if event == Events.CLIENT_OPENED:
        self._plugin_manager.send_plugin_message(self._identifier, dict(isPSUOn=self.isPSUOn))
        return
    elif event == Events.ERROR and self.config['turnOffWhenError']:
        self._logger.info("Firmware or communication error detected. Turning PSU Off")
        self.turn_psu_off()
        return
    elif event == Events.DISCONNECTED and self.isPSUOn: # <- added branch
        self._logger.info("Printer disconnect detected. Turning PSU Off")
        self.turn_psu_off()
        return

* event handling was botched directly into the installed plugin, in init.py. Will break on next update, but good enough for testing i guess.


is this expected behaviour (by the plugin and OctoPrint)?
if yes, this should be clearly mentioned in the docs.

additionally, would it make sense to add an config option like 'Turn off on printer disconnect' that turns off the psu on DISCONNECTED event?

additionally, i saw that OctoPrint has the following events too (see https://docs.octoprint.org/en/master/events/index.html#printer-communication):

  • PRINT_FAILED: seems to be raised on a print failure (idk what qualifies as such tho)
  • SHUTDOWN: seems to be raised when octoprint shuts down

Maybe adding (configurable) options to turn off the psu on those events could be helpful too?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant