I'm trying to re-parse the GCode recieved from my closed source ChiTu board to better interact with Octoprint.
Unfortunately I receive T: and T0: for my single extruder head, but the set temp only reports correctly for T: and octoprint likes to use T0:
Here's an example of a received line - Temp is set to 100C and is currently 100C
Recv: ok T:100 /100 B:20 /0 T0:100 /0 T1:-50 /0 @:21 B@:0
Notice T: reports set temp correctly but T0: does not (I know this is my boards fault)
Recv: ok T:100 /100 B:20 /0 T0:100 /0 T1:-50 /0 @:21 B@:0
My plan was to parse out "T0:" by re.sub to "T2:", and then re.sub "T:" to "T0:" but I haven't ever coded python and I'm looking for some help.
Here's my code so far:
# coding=utf-8
import octoprint.plugin
import re
class XinkebotTemperatureFixPlugin(octoprint.plugin.OctoPrintPlugin):
def process_gcode_received(self, comm_instance, line, *args, **kwargs):
if re.match("T:", line):
fix = re.sub("T0:", "T2:", line)
fix2 = re.sub("T:", "T0:", fix)
return fix2
return line
__plugin_name__ = "Xinkebot Temperature Fix"
def __plugin_load__():
global __plugin_implementation__
__plugin_implementation__ = XinkebotTemperatureFixPlugin()
global __plugin_hooks__
__plugin_hooks__ = {
"octoprint.comm.protocol.gcode.received": __plugin_implementation__.process_gcode_received
}
I can see that my plugin is loaded, but as far as I can tell, nothing is happening at all.
Please!?!?! and thank you for anyone that can shed some light on this