Access virtual endstops within extras module?

I am working on a Klipper extras module to add crash detection. I am a bit stuck, however, on how to access the virtual endstops. I want to be able to read the state of the virtual endstop in code (True or False). I’ve tried dissecting the homing and TMC code, but I’m still confused. Any help would be appreciated.

Does this help?

Virtual Endstops are assigned to the stepper as if it were a normal endstop, namely as an MCU_endstop.

The has the most usage of the endstop objects to see the usage.

Since you’re asking about virtual endstops I assume this is on a probe? if so, the probe has the mcu_endstop defined within it.


vendstop = self.printer.lookup_object('probe').mcu_probe.mcu_endstop

I’m by no means an expert in the Klipper source, but I’ve been getting kinda handy with it while working on my own projects. Let me know if you need some additional help.

Thank you for the quick reply. I will look into those and post my results back here.