printipi icon indicating copy to clipboard operation
printipi copied to clipboard

Implement M119: Get Endstop Status

Open Wallacoloo opened this issue 10 years ago • 1 comments

J.S. sent me the following code for his M119 implementation (in state.h):

} else if (cmd.isM119()) { //output endstop status
        LOGW("Warning (state.h): OP_M119 (output endstop status) not implemented\n");
        std::string msgTRIGGERED = "TRIGGERED";
        std::string msgOPEN = "open";
        return gparse::Response(gparse::ResponseOk,
            "Reporting endstop status x_min:" + ((driver.endstopHit(0) == true ) ? msgTRIGGERED : msgOPEN ) +
            " y_min:" + ((driver.endstopHit(1) == true ) ? msgTRIGGERED : msgOPEN ) +
            " z_min:" + ((driver.endstopHit(2) == true ) ? msgTRIGGERED : msgOPEN )  );

It shouldn't be too difficult to get this to compile with the current devel version / machines.

Wallacoloo avatar Jan 09 '15 06:01 Wallacoloo

Implemented, but the endstops have no labels. So it returns, e.g., Ok triggered open triggered (I lowercased TRIGGERED for compatibility with Teacup).

There are a few ways to fix this:

  1. Add a std::string field to the Endstop object to create a label for it upon instantiation.
  2. Require that endstops are only owned by the CoordMap & query the CoordMap for both the endstop objects and names.

(1) has the downside of being less inline-able. (2) makes implementation slightly easier.

I'll probably go with (1) because putting the Endstops in the ioDrivers tuple is more consistent with the rest of Printipi, although that paradigm might eventually change.

Wallacoloo avatar Jan 11 '15 04:01 Wallacoloo