Debug question: How to write contents to klippy.log from gcode macro?

I’ve used klipper for a while now. I have a single setup for triggering the M112 (emergency stop) command (using my Voron Tap as a trigger) and it works great to avoid smashing the nozzle.

I have had this setup for a while and it works great but with a new print, I’m running into a problem where my printer will run for several hours and then throw a M112 command (emergency stop). I wanted to verify that it was coming from the Voron Tap trigger, so I did this:

[gcode_button kill_switch]
pin: ^!sb2209:PB6
press_gcode: KILL_ME_NOW

[gcode_macro KILL_ME_NOW]
gcode:
	M117 SB TAP Kill Switch Activated!
	M118 SB TAP Kill Switch Activated!
	M112

Then to verify that I could see those messages, I manually triggered the emergency stop by lifting the Tap. In the console and on the LED screen I see the message, BUT IT DIDN’T WRITE IT TO THE klippy.log FILE!? I can see that the M112 was issued but there is no mention in klippy.log of the “SB TAP Kill Switch Activated!” message. :frowning:

How is someone supposed to debug this system without being able to get a debug statement to show up in the klippy.log file record??

Try adding a RESPOND statement like:

     RESPOND TYPE=error MSG="M112 Error Thrown"

before the M112 gcode instruction.

This should give you a console message as well as writing to klippy.log.

1 Like

thanks for the suggestion. I just tried it and no dice…

I changed the macro to this:

[gcode_macro KILL_ME_NOW]
gcode:
	M117 SB TAP Kill Switch Activated!
	M118 SB TAP Kill Switch Activated!
	RESPOND TYPE=error MSG="SB TAP Kill Switch Activated!"
	M112

and my log file looks like this after triggering it:

Stats 2512288.0: gcodein=0   mcu: mcu_awake=0.004 mcu_task_avg=0.000005 mcu_task_stddev=0.000002 bytes_write=3937 b>
Stats 2512289.1: gcodein=0   mcu: mcu_awake=0.004 mcu_task_avg=0.000005 mcu_task_stddev=0.000002 bytes_write=3943 b>
Stats 2512290.1: gcodein=0   mcu: mcu_awake=0.004 mcu_task_avg=0.000005 mcu_task_stddev=0.000002 bytes_write=3949 b>
Stats 2512291.1: gcodein=0   mcu: mcu_awake=0.004 mcu_task_avg=0.000005 mcu_task_stddev=0.000002 bytes_write=3955 b>
Stats 2512292.1: gcodein=0   mcu: mcu_awake=0.004 mcu_task_avg=0.000005 mcu_task_stddev=0.000002 bytes_write=3961 b>
Stats 2512293.1: gcodein=0   mcu: mcu_awake=0.004 mcu_task_avg=0.000005 mcu_task_stddev=0.000002 bytes_write=3967 b>
Stats 2512294.1: gcodein=0   mcu: mcu_awake=0.004 mcu_task_avg=0.000005 mcu_task_stddev=0.000002 bytes_write=3973 b>
Stats 2512295.1: gcodein=0   mcu: mcu_awake=0.004 mcu_task_avg=0.000005 mcu_task_stddev=0.000002 bytes_write=3979 b>
Stats 2512296.1: gcodein=0   mcu: mcu_awake=0.004 mcu_task_avg=0.000005 mcu_task_stddev=0.000002 bytes_write=3985 b>
Transition to shutdown state: Shutdown due to M112 command
Dumping gcode input 0 blocks
Dumping 20 requests for client 3911352656
Received 2512255.824696: b'{"id": 4034800240, "method": "objects/query", "params": {"objects": {"heaters": null}}}'
Received 2512255.824825: b'{"id": 4065687248, "method": "gcode/script", "params": {"script": "_SET_TIMELAPSE_SETUP >
Received 2512255.824825: b'{"id": 4034799696, "method": "gcode/script", "params": {"script": "HYPERLAPSE ACTION=STO>
Received 2512256.055717: b'{"id": 4065990480, "method": "objects/subscribe", "params": {"objects": {"webhooks": nul>
Received 2512256.306401: b'{"id": 4047218032, "method": "objects/subscribe", "params": {"objects": {"webhooks": nul>
Received 2512256.671915: b'{"id": 4047453648, "method": "info", "params": {}}'

I saw that RESPOND command and tried it out manually but I couldn’t get it to write the klippy.log file. :frowning:

Sorry - I thought that would update the klippy.log.

Hopefully somebody else can point you in the right direction.

1 Like

Thank you @Sineos, this was just what the doctor ordered! :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.