+ } else if(gcode->has_g && gcode->g == 38 ) { // G38.2 Straight Probe with error, G38.3 straight probe without error
+ // linuxcnc/grbl style probe http://www.linuxcnc.org/docs/2.5/html/gcode/gcode.html#sec:G38-probe
+ if(gcode->subcode < 2 || gcode->subcode > 5) {
+ gcode->stream->printf("error:Only G38.2, G38.3, G38.4, and G38.5 are supported\n");
+ return;
+ }
+
+ // make sure the probe is defined and not already triggered before moving motors
+ if(!this->pin.connected()) {
+ gcode->stream->printf("error:ZProbe not connected.\n");
+ return;
+ }
+
+ if(gcode->subcode == 4 || gcode->subcode == 5) {
+ if(!this->pin.get()) {
+ gcode->stream->printf("error:ZProbe triggered before move, aborting command.\n");
+ return;
+ }
+ } else {
+ if(this->pin.get()) {
+ gcode->stream->printf("error:ZProbe triggered before move, aborting command.\n");
+ return;
+ }
+ }
+
+ // first wait for all moves to finish
+ THEKERNEL->conveyor->wait_for_idle();
+
+ float x= NAN, y=NAN, z=NAN;
+ if(gcode->has_letter('X')) {
+ x= gcode->get_value('X');
+ }
+
+ if(gcode->has_letter('Y')) {
+ y= gcode->get_value('Y');
+ }
+
+ if(gcode->has_letter('Z')) {
+ z= gcode->get_value('Z');
+ }
+
+ if(isnan(x) && isnan(y) && isnan(z)) {
+ gcode->stream->printf("error:at least one of X Y or Z must be specified\n");
+ return;
+ }
+
+ if(gcode->subcode == 4 || gcode->subcode == 5) {
+ pin.set_inverting(pin.is_inverting() != 1);
+ }
+
+ probe_XYZ(gcode, x, y, z);
+
+ if(gcode->subcode == 4 || gcode->subcode == 5) {
+ pin.set_inverting(pin.is_inverting() != 1);
+ }
+
+ return;
+