]> git.donarmstrong.com Git - kiibohd-controller.git/blobdiff - Debug/cli/cli.c
Write whole debug cli command to history
[kiibohd-controller.git] / Debug / cli / cli.c
index a5aa94c84daa80b59753800b76f946bc4c078f61..5c83ee64c98ce4bf60a39c01b80d1f76a8110020 100644 (file)
 
 // ----- Includes -----
 
-// Compiler Includes
-//#include <stdarg.h>
-
 // Project Includes
 #include <buildvars.h>
 #include "cli.h"
 #include <led.h>
 #include <print.h>
+#include <kll_defs.h>
 
 
 
@@ -161,15 +159,12 @@ void CLI_process()
                        }
                        else
                        {
-                       // Only do command-related stuff if there was actually a command
-                       // Avoids clogging command history with blanks
+                               // Add the command to the history
+                               CLI_saveHistory( CLILineBuffer );
 
                                // Process the current line buffer
                                CLI_commandLookup();
 
-                               // Add the command to the history
-                               CLI_saveHistory( CLILineBuffer );
-
                                // Keep the array circular, discarding the older entries
                                if ( CLIHistoryTail < CLIHistoryHead )
                                        CLIHistoryHead = ( CLIHistoryHead + 1 ) % CLIMaxHistorySize;
@@ -427,6 +422,11 @@ inline void CLI_saveHistory( char *buff )
                return;
        }
 
+        // Don't write empty lines to the history
+        const char *cursor = buff;
+        while (*cursor == ' ') { cursor++; } // advance past the leading whitespace
+        if (*cursor == '\0') { return ; }
+
        // Copy the line to the history
        int i;
        for (i = 0; i < CLILineBufferCurrent; i++)
@@ -517,6 +517,14 @@ void cliFunc_led( char* args )
 
 void cliFunc_reload( char* args )
 {
+       if ( flashModeEnabled_define == 0 )
+       {
+               print( NL );
+               warn_print("flashModeEnabled not set, cancelling firmware reload...");
+               info_msg("Set flashModeEnabled to 1 in your kll configuration.");
+               return;
+       }
+
        // Request to output module to be set into firmware reload mode
        Output_firmwareReload();
 }
@@ -548,5 +556,15 @@ void cliFunc_version( char* args )
        print( " \033[1mCPU:\033[0m           " CLI_CPU            NL );
        print( " \033[1mDevice:\033[0m        " CLI_Device         NL );
        print( " \033[1mModules:\033[0m       " CLI_Modules        NL );
+#if defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) || defined(_mk20dx256vlh7_)
+       print( " \033[1mUnique Id:\033[0m     " );
+       printHex32_op( SIM_UIDH, 4 );
+       printHex32_op( SIM_UIDMH, 4 );
+       printHex32_op( SIM_UIDML, 4 );
+       printHex32_op( SIM_UIDL, 4 );
+#elif defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_)
+#else
+#error "No unique id defined."
+#endif
 }