implement parsing of A B C parameters for multi axis, NOTE mutually exclusive with...
[clinton/Smoothieware.git] / src / modules / utils / simpleshell / SimpleShell.cpp
index 36af94a..4f325df 100644 (file)
 #include "PublicData.h"
 #include "Gcode.h"
 #include "Robot.h"
-
-#include "modules/tools/temperaturecontrol/TemperatureControlPublicAccess.h"
+#include "ToolManagerPublicAccess.h"
+#include "GcodeDispatch.h"
+#include "BaseSolution.h"
+#include "StepperMotor.h"
+#include "Configurator.h"
+#include "Block.h"
+
+#include "TemperatureControlPublicAccess.h"
+#include "EndstopsPublicAccess.h"
 #include "NetworkPublicAccess.h"
 #include "platform_memory.h"
 #include "SwitchPublicAccess.h"
 #include "SDFAT.h"
 #include "Thermistor.h"
 #include "md5.h"
+#include "utils.h"
 
 #include "system_LPC17xx.h"
 #include "LPC17xx.h"
@@ -43,6 +51,7 @@ extern unsigned int g_maximumHeapAddress;
 #include <mri.h>
 #include <stdio.h>
 #include <stdint.h>
+#include <functional>
 
 extern "C" uint32_t  __end__;
 extern "C" uint32_t  __malloc_free_list;
@@ -74,6 +83,7 @@ const SimpleShell::ptentry_t SimpleShell::commands_table[] = {
     {"calc_thermistor", SimpleShell::calc_thermistor_command},
     {"thermistors", SimpleShell::print_thermistors_command},
     {"md5sum",   SimpleShell::md5sum_command},
+    {"test",     SimpleShell::test_command},
 
     // unknown command
     {NULL, NULL}
@@ -168,21 +178,8 @@ void SimpleShell::on_gcode_received(void *argument)
             gcode->stream->printf("End file list\r\n");
 
         } else if (gcode->m == 30) { // remove file
-            rm_command("/sd/" + args, gcode->stream);
-
-        } else if(gcode->m == 501) { // load config override
-            if(args.empty()) {
-                load_command("/sd/config-override", gcode->stream);
-            } else {
-                load_command("/sd/config-override." + args, gcode->stream);
-            }
-
-        } else if(gcode->m == 504) { // save to specific config override file
-            if(args.empty()) {
-                save_command("/sd/config-override", gcode->stream);
-            } else {
-                save_command("/sd/config-override." + args, gcode->stream);
-            }
+            if(!args.empty() && !THEKERNEL->is_grbl_mode())
+                rm_command("/sd/" + args, gcode->stream);
         }
     }
 }
@@ -203,18 +200,77 @@ bool SimpleShell::parse_command(const char *cmd, string args, StreamOutput *stre
 void SimpleShell::on_console_line_received( void *argument )
 {
     SerialMessage new_message = *static_cast<SerialMessage *>(argument);
+    string possible_command = new_message.message;
 
-    // ignore comments and blank lines and if this is a G code then also ignore it
-    char first_char = new_message.message[0];
-    if(strchr(";( \n\rGMTN", first_char) != NULL) return;
+    // ignore anything that is not lowercase or a $ as it is not a command
+    if(possible_command.size() == 0 || (!islower(possible_command[0]) && possible_command[0] != '$')) {
+        return;
+    }
 
-    string possible_command = new_message.message;
+    // it is a grbl compatible command
+    if(possible_command[0] == '$' && possible_command.size() >= 2) {
+        switch(possible_command[1]) {
+            case 'G':
+                // issue get state
+                get_command("state", new_message.stream);
+                new_message.stream->printf("ok\n");
+                break;
+
+            case 'X':
+                if(THEKERNEL->is_halted()) {
+                    THEKERNEL->call_event(ON_HALT, (void *)1); // clears on_halt
+                    new_message.stream->printf("[Caution: Unlocked]\nok\n");
+                }
+                break;
+
+            case '#':
+                grblDP_command("", new_message.stream);
+                new_message.stream->printf("ok\n");
+                break;
+
+            case 'H':
+                THEKERNEL->call_event(ON_HALT, (void *)1); // clears on_halt
+                if(THEKERNEL->is_grbl_mode()) {
+                    // issue G28.2 which is force homing cycle
+                    Gcode gcode("G28.2", new_message.stream);
+                    THEKERNEL->call_event(ON_GCODE_RECEIVED, &gcode);
+                }else{
+                    Gcode gcode("G28", new_message.stream);
+                    THEKERNEL->call_event(ON_GCODE_RECEIVED, &gcode);
+                }
+                break;
 
-    //new_message.stream->printf("Received %s\r\n", possible_command.c_str());
-    string cmd = shift_parameter(possible_command);
+            default:
+                new_message.stream->printf("error:Invalid statement\n");
+                break;
+        }
+
+    }else{
+
+        //new_message.stream->printf("Received %s\r\n", possible_command.c_str());
+        string cmd = shift_parameter(possible_command);
+
+        // Configurator commands
+        if (cmd == "config-get"){
+            THEKERNEL->configurator->config_get_command(  possible_command, new_message.stream );
+
+        } else if (cmd == "config-set"){
+            THEKERNEL->configurator->config_set_command(  possible_command, new_message.stream );
 
-    // find command and execute it
-    parse_command(cmd.c_str(), possible_command, new_message.stream);
+        } else if (cmd == "config-load"){
+            THEKERNEL->configurator->config_load_command(  possible_command, new_message.stream );
+
+        } else if (cmd == "play" || cmd == "progress" || cmd == "abort" || cmd == "suspend" || cmd == "resume") {
+            // these are handled by Player module
+
+        } else if (cmd == "ok") {
+            // probably an echo so reply ok
+            new_message.stream->printf("ok\n");
+
+        }else if(!parse_command(cmd.c_str(), possible_command, new_message.stream)) {
+            new_message.stream->printf("error:Unsupported command - %s\n", cmd.c_str());
+        }
+    }
 }
 
 // Act upon an ls command
@@ -309,15 +365,33 @@ void SimpleShell::cat_command( string parameters, StreamOutput *stream )
 {
     // Get parameters ( filename and line limit )
     string filename          = absolute_from_relative(shift_parameter( parameters ));
-    string limit_paramater   = shift_parameter( parameters );
+    string limit_parameter   = shift_parameter( parameters );
     int limit = -1;
-    if ( limit_paramater != "" ) {
+    int delay= 0;
+    bool send_eof= false;
+    if ( limit_parameter == "-d" ) {
+        string d= shift_parameter( parameters );
         char *e = NULL;
-        limit = strtol(limit_paramater.c_str(), &e, 10);
-        if (e <= limit_paramater.c_str())
+        delay = strtol(d.c_str(), &e, 10);
+        if (e <= d.c_str()) {
+            delay = 0;
+
+        } else {
+            send_eof= true; // we need to terminate file send with an eof
+        }
+
+    }else if ( limit_parameter != "" ) {
+        char *e = NULL;
+        limit = strtol(limit_parameter.c_str(), &e, 10);
+        if (e <= limit_parameter.c_str())
             limit = -1;
     }
 
+    // we have been asked to delay before cat, probably to allow time to issue upload command
+    if(delay > 0) {
+        safe_delay_ms(delay*1000);
+    }
+
     // Open file
     FILE *lp = fopen(filename.c_str(), "r");
     if (lp == NULL) {
@@ -331,8 +405,8 @@ void SimpleShell::cat_command( string parameters, StreamOutput *stream )
     // Print each line of the file
     while ((c = fgetc (lp)) != EOF) {
         buffer.append((char *)&c, 1);
-        if ( char(c) == '\n' || ++linecnt > 80) {
-            newlines++;
+        if ( c == '\n' || ++linecnt > 80) {
+            if(c == '\n') newlines++;
             stream->puts(buffer.c_str());
             buffer.clear();
             if(linecnt > 80) linecnt = 0;
@@ -344,13 +418,17 @@ void SimpleShell::cat_command( string parameters, StreamOutput *stream )
         }
     };
     fclose(lp);
+
+    if(send_eof) {
+        stream->puts("\032"); // ^Z terminates the upload
+    }
 }
 
 void SimpleShell::upload_command( string parameters, StreamOutput *stream )
 {
     // this needs to be a hack. it needs to read direct from serial and not allow on_main_loop run until done
     // NOTE this will block all operation until the upload is complete, so do not do while printing
-    if(!THEKERNEL->conveyor->is_queue_empty()) {
+    if(!THECONVEYOR->is_idle()) {
         stream->printf("upload not allowed while printing or busy\n");
         return;
     }
@@ -431,8 +509,11 @@ void SimpleShell::load_command( string parameters, StreamOutput *stream )
         while(fgets(buf, sizeof buf, fp) != NULL) {
             stream->printf("  %s", buf);
             if(buf[0] == ';') continue; // skip the comments
-            struct SerialMessage message = {&(StreamOutput::NullStream), buf};
-            THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message);
+            // NOTE only Gcodes and Mcodes can be in the config-override
+            Gcode *gcode = new Gcode(buf, &StreamOutput::NullStream);
+            THEKERNEL->call_event(ON_GCODE_RECEIVED, gcode);
+            delete gcode;
+            THEKERNEL->call_event(ON_IDLE);
         }
         stream->printf("config override file executed\n");
         fclose(fp);
@@ -451,7 +532,7 @@ void SimpleShell::save_command( string parameters, StreamOutput *stream )
         filename = THEKERNEL->config_override_filename();
     }
 
-    THEKERNEL->conveyor->wait_for_empty_queue(); //just to be safe as it can take a while to run
+    THECONVEYOR->wait_for_idle(); //just to be safe as it can take a while to run
 
     //remove(filename.c_str()); // seems to cause a hang every now and then
     {
@@ -481,7 +562,7 @@ void SimpleShell::save_command( string parameters, StreamOutput *stream )
 // show free memory
 void SimpleShell::mem_command( string parameters, StreamOutput *stream)
 {
-    bool verbose = shift_parameter( parameters ).find_first_of("Vv") != string::npos ;
+    bool verbose = shift_parameter( parameters ).find_first_of("Vv") != string::npos;
     unsigned long heap = (unsigned long)_sbrk(0);
     unsigned long m = g_maximumHeapAddress - heap;
     stream->printf("Unused Heap: %lu bytes\r\n", m);
@@ -494,6 +575,8 @@ void SimpleShell::mem_command( string parameters, StreamOutput *stream)
         AHB0.debug(stream);
         AHB1.debug(stream);
     }
+
+    stream->printf("Block size: %u bytes\n", sizeof(Block));
 }
 
 static uint32_t getDeviceType()
@@ -536,6 +619,11 @@ void SimpleShell::version_command( string parameters, StreamOutput *stream)
     uint32_t dev = getDeviceType();
     const char *mcu = (dev & 0x00100000) ? "LPC1769" : "LPC1768";
     stream->printf("Build version: %s, Build date: %s, MCU: %s, System Clock: %ldMHz\r\n", vers.get_build(), vers.get_build_date(), mcu, SystemCoreClock / 1000000);
+    #ifdef CNC
+    stream->printf("  CNC Build ");
+    #endif
+
+    stream->printf("%d axis\n", MAX_ROBOT_ACTUATORS);
 }
 
 // Reset the system
@@ -559,7 +647,80 @@ void SimpleShell::break_command( string parameters, StreamOutput *stream)
     __debugbreak();
 }
 
-// used to test out the get public data events
+static int get_active_tool()
+{
+    void *returned_data;
+    bool ok = PublicData::get_value(tool_manager_checksum, get_active_tool_checksum, &returned_data);
+    if (ok) {
+         int active_tool=  *static_cast<int *>(returned_data);
+        return active_tool;
+    } else {
+        return 0;
+    }
+}
+
+void SimpleShell::grblDP_command( string parameters, StreamOutput *stream)
+{
+    /*
+    [G54:95.000,40.000,-23.600]
+    [G55:0.000,0.000,0.000]
+    [G56:0.000,0.000,0.000]
+    [G57:0.000,0.000,0.000]
+    [G58:0.000,0.000,0.000]
+    [G59:0.000,0.000,0.000]
+    [G28:0.000,0.000,0.000]
+    [G30:0.000,0.000,0.000]
+    [G92:0.000,0.000,0.000]
+    [TLO:0.000]
+    [PRB:0.000,0.000,0.000:0]
+    */
+
+    bool verbose = shift_parameter( parameters ).find_first_of("Vv") != string::npos;
+
+    std::vector<Robot::wcs_t> v= THEROBOT->get_wcs_state();
+    if(verbose) {
+        char current_wcs= std::get<0>(v[0]);
+        stream->printf("[current WCS: %s]\n", wcs2gcode(current_wcs).c_str());
+    }
+
+    int n= std::get<1>(v[0]);
+    for (int i = 1; i <= n; ++i) {
+        stream->printf("[%s:%1.4f,%1.4f,%1.4f]\n", wcs2gcode(i-1).c_str(),
+            THEROBOT->from_millimeters(std::get<0>(v[i])),
+            THEROBOT->from_millimeters(std::get<1>(v[i])),
+            THEROBOT->from_millimeters(std::get<2>(v[i])));
+    }
+
+    float *rd;
+    PublicData::get_value( endstops_checksum, saved_position_checksum, &rd );
+    stream->printf("[G28:%1.4f,%1.4f,%1.4f]\n",
+        THEROBOT->from_millimeters(rd[0]),
+        THEROBOT->from_millimeters(rd[1]),
+        THEROBOT->from_millimeters(rd[2]));
+
+    stream->printf("[G30:%1.4f,%1.4f,%1.4f]\n",  0.0F, 0.0F, 0.0F); // not implemented
+
+    stream->printf("[G92:%1.4f,%1.4f,%1.4f]\n",
+        THEROBOT->from_millimeters(std::get<0>(v[n+1])),
+        THEROBOT->from_millimeters(std::get<1>(v[n+1])),
+        THEROBOT->from_millimeters(std::get<2>(v[n+1])));
+
+    if(verbose) {
+        stream->printf("[Tool Offset:%1.4f,%1.4f,%1.4f]\n",
+            THEROBOT->from_millimeters(std::get<0>(v[n+2])),
+            THEROBOT->from_millimeters(std::get<1>(v[n+2])),
+            THEROBOT->from_millimeters(std::get<2>(v[n+2])));
+    }else{
+        stream->printf("[TL0:%1.4f]\n", THEROBOT->from_millimeters(std::get<2>(v[n+2])));
+    }
+
+    // this is the last probe position, updated when a probe completes, also stores the number of steps moved after a homing cycle
+    float px, py, pz;
+    uint8_t ps;
+    std::tie(px, py, pz, ps) = THEROBOT->get_last_probe_position();
+    stream->printf("[PRB:%1.4f,%1.4f,%1.4f:%d]\n", THEROBOT->from_millimeters(px), THEROBOT->from_millimeters(py), THEROBOT->from_millimeters(pz), ps);
+}
+
 void SimpleShell::get_command( string parameters, StreamOutput *stream)
 {
     string what = shift_parameter( parameters );
@@ -590,15 +751,87 @@ void SimpleShell::get_command( string parameters, StreamOutput *stream)
             }
         }
 
-    } else if (what == "pos") {
+    } else if (what == "fk" || what == "ik") {
+        string p= shift_parameter( parameters );
+        bool move= false;
+        if(p == "-m") {
+            move= true;
+            p= shift_parameter( parameters );
+        }
+
+        std::vector<float> v= parse_number_list(p.c_str());
+        if(p.empty() || v.size() < 1) {
+            stream->printf("error:usage: get [fk|ik] [-m] x[,y,z]\n");
+            return;
+        }
+
+        float x= v[0];
+        float y= (v.size() > 1) ? v[1] : x;
+        float z= (v.size() > 2) ? v[2] : y;
+
+        if(what == "fk") {
+            // do forward kinematics on the given actuator position and display the cartesian coordinates
+            ActuatorCoordinates apos{x, y, z};
+            float pos[3];
+            THEROBOT->arm_solution->actuator_to_cartesian(apos, pos);
+            stream->printf("cartesian= X %f, Y %f, Z %f\n", pos[0], pos[1], pos[2]);
+            x= pos[0];
+            y= pos[1];
+            z= pos[2];
+
+        }else{
+            // do inverse kinematics on the given cartesian position and display the actuator coordinates
+            float pos[3]{x, y, z};
+            ActuatorCoordinates apos;
+            THEROBOT->arm_solution->cartesian_to_actuator(pos, apos);
+            stream->printf("actuator= X %f, Y %f, Z %f\n", apos[0], apos[1], apos[2]);
+        }
+
+        if(move) {
+            // move to the calculated, or given, XYZ
+            char cmd[64];
+            snprintf(cmd, sizeof(cmd), "G53 G0 X%f Y%f Z%f", x, y, z);
+            struct SerialMessage message;
+            message.message = cmd;
+            message.stream = &(StreamOutput::NullStream);
+            THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message );
+            THECONVEYOR->wait_for_idle();
+        }
+
+   } else if (what == "pos") {
         // convenience to call all the various M114 variants
         char buf[64];
-        THEKERNEL->robot->print_position(0, buf, sizeof buf); stream->printf("last %s\n", buf);
-        THEKERNEL->robot->print_position(1, buf, sizeof buf); stream->printf("realtime %s\n", buf);
-        THEKERNEL->robot->print_position(2, buf, sizeof buf); stream->printf("%s\n", buf);
-        THEKERNEL->robot->print_position(3, buf, sizeof buf); stream->printf("%s\n", buf);
-        THEKERNEL->robot->print_position(4, buf, sizeof buf); stream->printf("%s\n", buf);
-        THEKERNEL->robot->print_position(5, buf, sizeof buf); stream->printf("%s\n", buf);
+        THEROBOT->print_position(0, buf, sizeof buf); stream->printf("last %s\n", buf);
+        THEROBOT->print_position(1, buf, sizeof buf); stream->printf("realtime %s\n", buf);
+        THEROBOT->print_position(2, buf, sizeof buf); stream->printf("%s\n", buf);
+        THEROBOT->print_position(3, buf, sizeof buf); stream->printf("%s\n", buf);
+        THEROBOT->print_position(4, buf, sizeof buf); stream->printf("%s\n", buf);
+        THEROBOT->print_position(5, buf, sizeof buf); stream->printf("%s\n", buf);
+
+    } else if (what == "wcs") {
+        // print the wcs state
+        grblDP_command("-v", stream);
+
+    } else if (what == "state") {
+        // also $G
+        // [G0 G54 G17 G21 G90 G94 M0 M5 M9 T0 F0.]
+        stream->printf("[G%d %s G%d G%d G%d G94 M0 M5 M9 T%d F%1.4f]\n",
+            THEKERNEL->gcode_dispatch->get_modal_command(),
+            wcs2gcode(THEROBOT->get_current_wcs()).c_str(),
+            THEROBOT->plane_axis_0 == X_AXIS && THEROBOT->plane_axis_1 == Y_AXIS && THEROBOT->plane_axis_2 == Z_AXIS ? 17 :
+              THEROBOT->plane_axis_0 == X_AXIS && THEROBOT->plane_axis_1 == Z_AXIS && THEROBOT->plane_axis_2 == Y_AXIS ? 18 :
+              THEROBOT->plane_axis_0 == Y_AXIS && THEROBOT->plane_axis_1 == Z_AXIS && THEROBOT->plane_axis_2 == X_AXIS ? 19 : 17,
+            THEROBOT->inch_mode ? 20 : 21,
+            THEROBOT->absolute_mode ? 90 : 91,
+            get_active_tool(),
+            THEROBOT->from_millimeters(THEROBOT->get_feed_rate()));
+
+    } else if (what == "status") {
+        // also ? on serial and usb
+        stream->printf("%s\n", THEKERNEL->get_query_string().c_str());
+
+    } else {
+        stream->printf("error:unknown option %s\n", what.c_str());
     }
 }
 
@@ -619,11 +852,14 @@ void SimpleShell::set_temp_command( string parameters, StreamOutput *stream)
 
 void SimpleShell::print_thermistors_command( string parameters, StreamOutput *stream)
 {
+    #ifndef NO_TOOLS_TEMPERATURECONTROL
     Thermistor::print_predefined_thermistors(stream);
+    #endif
 }
 
 void SimpleShell::calc_thermistor_command( string parameters, StreamOutput *stream)
 {
+    #ifndef NO_TOOLS_TEMPERATURECONTROL
     string s = shift_parameter( parameters );
     int saveto= -1;
     // see if we have -sn as first argument
@@ -655,6 +891,7 @@ void SimpleShell::calc_thermistor_command( string parameters, StreamOutput *stre
         // give help
         stream->printf("Usage: calc_thermistor T1,R1,T2,R2,T3,R3\n");
     }
+    #endif
 }
 
 // used to test out the get public data events for switch
@@ -692,13 +929,164 @@ void SimpleShell::md5sum_command( string parameters, StreamOutput *stream )
     do {
         size_t n= fread(buf, 1, sizeof buf, lp);
         if(n > 0) md5.update(buf, n);
+        THEKERNEL->call_event(ON_IDLE);
     } while(!feof(lp));
 
     stream->printf("%s %s\n", md5.finalize().hexdigest().c_str(), filename.c_str());
     fclose(lp);
 }
 
+// runs several types of test on the mechanisms
+void SimpleShell::test_command( string parameters, StreamOutput *stream)
+{
+    string what = shift_parameter( parameters );
 
+    if (what == "jog") {
+        // jogs back and forth usage: axis distance iterations [feedrate]
+        string axis = shift_parameter( parameters );
+        string dist = shift_parameter( parameters );
+        string iters = shift_parameter( parameters );
+        string speed = shift_parameter( parameters );
+        if(axis.empty() || dist.empty() || iters.empty()) {
+            stream->printf("error: Need axis distance iterations\n");
+            return;
+        }
+        float d= strtof(dist.c_str(), NULL);
+        float f= speed.empty() ? THEROBOT->get_feed_rate() : strtof(speed.c_str(), NULL);
+        uint32_t n= strtol(iters.c_str(), NULL, 10);
+
+        bool toggle= false;
+        for (uint32_t i = 0; i < n; ++i) {
+            char cmd[64];
+            snprintf(cmd, sizeof(cmd), "G91 G0 %c%f F%f G90", toupper(axis[0]), toggle ? -d : d, f);
+            stream->printf("%s\n", cmd);
+            struct SerialMessage message{&StreamOutput::NullStream, cmd};
+            THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message );
+            if(THEKERNEL->is_halted()) break;
+            THECONVEYOR->wait_for_idle();
+            toggle= !toggle;
+        }
+        stream->printf("done\n");
+
+    }else if (what == "circle") {
+        // draws a circle around origin. usage: radius iterations [feedrate]
+        string radius = shift_parameter( parameters );
+        string iters = shift_parameter( parameters );
+        string speed = shift_parameter( parameters );
+         if(radius.empty() || iters.empty()) {
+            stream->printf("error: Need radius iterations\n");
+            return;
+        }
+
+        float r= strtof(radius.c_str(), NULL);
+        uint32_t n= strtol(iters.c_str(), NULL, 10);
+        float f= speed.empty() ? THEROBOT->get_feed_rate() : strtof(speed.c_str(), NULL);
+
+        THEROBOT->push_state();
+        char cmd[64];
+        snprintf(cmd, sizeof(cmd), "G91 G0 X%f Y0 F%f", -r, f);
+        stream->printf("%s\n", cmd);
+        struct SerialMessage message{&StreamOutput::NullStream, cmd};
+        THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message );
+
+        for (uint32_t i = 0; i < n; ++i) {
+            if(THEKERNEL->is_halted()) break;
+            snprintf(cmd, sizeof(cmd), "G2 X%f Y0 I%f J0 F%f", -r, r, f);
+            stream->printf("%s\n", cmd);
+            message.message= cmd;
+            THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message );
+            THECONVEYOR->wait_for_idle();
+        }
+        THEROBOT->pop_state();
+        stream->printf("done\n");
+
+    }else if (what == "square") {
+        // draws a square usage: size iterations [feedrate]
+        string size = shift_parameter( parameters );
+        string iters = shift_parameter( parameters );
+        string speed = shift_parameter( parameters );
+        if(size.empty() || iters.empty()) {
+            stream->printf("error: Need size iterations\n");
+            return;
+        }
+        float d= strtof(size.c_str(), NULL);
+        float f= speed.empty() ? THEROBOT->get_feed_rate() : strtof(speed.c_str(), NULL);
+        uint32_t n= strtol(iters.c_str(), NULL, 10);
+
+        for (uint32_t i = 0; i < n; ++i) {
+            char cmd[64];
+            {
+                snprintf(cmd, sizeof(cmd), "G91 G0 X%f F%f", d, f);
+                stream->printf("%s\n", cmd);
+                struct SerialMessage message{&StreamOutput::NullStream, cmd};
+                THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message );
+            }
+            {
+                snprintf(cmd, sizeof(cmd), "G0 Y%f", d);
+                stream->printf("%s\n", cmd);
+                struct SerialMessage message{&StreamOutput::NullStream, cmd};
+                THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message );
+            }
+            {
+                snprintf(cmd, sizeof(cmd), "G0 X%f", -d);
+                stream->printf("%s\n", cmd);
+                struct SerialMessage message{&StreamOutput::NullStream, cmd};
+                THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message );
+            }
+            {
+                snprintf(cmd, sizeof(cmd), "G0 Y%f G90", -d);
+                stream->printf("%s\n", cmd);
+                struct SerialMessage message{&StreamOutput::NullStream, cmd};
+                THEKERNEL->call_event(ON_CONSOLE_LINE_RECEIVED, &message );
+            }
+            if(THEKERNEL->is_halted()) break;
+            THECONVEYOR->wait_for_idle();
+        }
+        stream->printf("done\n");
+
+    }else if (what == "raw") {
+        // issues raw steps to the specified axis usage: axis steps steps/sec
+        string axis = shift_parameter( parameters );
+        string stepstr = shift_parameter( parameters );
+        string stepspersec = shift_parameter( parameters );
+        if(axis.empty() || stepstr.empty() || stepspersec.empty()) {
+            stream->printf("error: Need axis steps steps/sec\n");
+            return;
+        }
+
+        uint8_t a= toupper(axis[0]) - 'X';
+        int steps= strtol(stepstr.c_str(), NULL, 10);
+        bool dir= steps >= 0;
+        steps= std::abs(steps);
+
+        if(a > Z_AXIS) {
+            stream->printf("error: axis must be x y or z\n");
+            return;
+        }
+
+        uint32_t sps= strtol(stepspersec.c_str(), NULL, 10);
+        sps= std::max(sps, 1UL);
+
+        uint32_t delayus= 1000000.0F / sps;
+        for(int s= 0;s<steps;s++) {
+            if(THEKERNEL->is_halted()) break;
+            THEROBOT->actuators[a]->manual_step(dir);
+            // delay but call on_idle
+            safe_delay_us(delayus);
+        }
+
+        // reset the position based on current actuator position
+        THEROBOT->reset_position_from_current_actuator_position();
+
+        stream->printf("done\n");
+
+    }else {
+        stream->printf("usage:\n test jog axis distance iterations [feedrate]\n");
+        stream->printf(" test square size iterations [feedrate]\n");
+        stream->printf(" test circle radius iterations [feedrate]\n");
+        stream->printf(" test raw axis steps steps/sec\n");
+    }
+}
 
 void SimpleShell::help_command( string parameters, StreamOutput *stream )
 {
@@ -708,7 +1096,7 @@ void SimpleShell::help_command( string parameters, StreamOutput *stream )
     stream->printf("ls [-s] [folder]\r\n");
     stream->printf("cd folder\r\n");
     stream->printf("pwd\r\n");
-    stream->printf("cat file [limit]\r\n");
+    stream->printf("cat file [limit] [-d 10]\r\n");
     stream->printf("rm file\r\n");
     stream->printf("mv file newfile\r\n");
     stream->printf("remount\r\n");
@@ -720,9 +1108,9 @@ void SimpleShell::help_command( string parameters, StreamOutput *stream )
     stream->printf("break - break into debugger\r\n");
     stream->printf("config-get [<configuration_source>] <configuration_setting>\r\n");
     stream->printf("config-set [<configuration_source>] <configuration_setting> <value>\r\n");
+    stream->printf("get [pos|wcs|state|status|fk|ik]\r\n");
     stream->printf("get temp [bed|hotend]\r\n");
     stream->printf("set_temp bed|hotend 185\r\n");
-    stream->printf("get pos\r\n");
     stream->printf("net\r\n");
     stream->printf("load [file] - loads a configuration override file from soecified name or config-override\r\n");
     stream->printf("save [file] - saves a configuration override file as specified filename or as config-override\r\n");