I need a simple gcode re-write plugin to add index info to M106 commands

Hi all.

I need help with a simple plugin to simply change M106 Sxxx commands to M106 P1 Sxxx commands because the slicer we use simply can't be made to put that in.

We upload directly to OctoPrint and post-processing scripts don't seem to execute against "send to" gcode with PrusaSlicer.

I'm experienced with Python, I just don't have the cycles to understand how to leverage the plugin interfaces.

I can pay a small fee to anyone who can whip this up for me, just send me paypal info with the working plugin and I'll take care of you.

Thanks in advance!

There's an example that you could tweak, and then just upload the single file to OctoPrint via Plugin Manager > Get More....

so something like this...

# coding=utf-8

import octoprint.plugin

class RewriteM106Plugin(octoprint.plugin.OctoPrintPlugin):
    def rewrite_m106(self, comm_instance, phase, cmd, cmd_type, gcode, *args, **kwargs):
        if gcode and gcode == "M106":
            cmd = cmd.replace('M106 S','M106 P1 S')
        return cmd,

__plugin_name__ = "Rewrite M106"
__plugin_pythoncompat__ = ">=2.7,<4"
def __plugin_load__():
    global __plugin_implementation__
    __plugin_implementation__ = RewriteM106Plugin()

    global __plugin_hooks__
    __plugin_hooks__ = {
        "octoprint.comm.protocol.gcode.queuing": __plugin_implementation__.rewrite_m106
1 Like

Alright, link me to your paypal.me page. :rofl:

https://www.paypal.com/paypalme/jneilliii :wink: Jim makes some awesome plugins.



Money sent Jim, thanks for the quick response and getting me exactly what I needed.