Преглед изворни кода

Added more CLI commands.

- Hex debug for debugging VT100 control characters from the keyboard
- Renamed reset to restart (software reset)
- Added reset command (same as bash reset, which resets the VT100 variables)
- Cleaned up the version module field
simple
Jacob Alexander пре 10 година
родитељ
комит
38847b7841
3 измењених фајлова са 47 додато и 14 уклоњено
  1. 44
    12
      Debug/cli/cli.c
  2. 2
    1
      Debug/cli/cli.h
  3. 1
    1
      Lib/_buildvars.h

+ 44
- 12
Debug/cli/cli.c Прегледај датотеку

{ "help", "You're looking at it :P", cliFunc_help }, { "help", "You're looking at it :P", cliFunc_help },
{ "led", "Enables/Disables indicator LED. Try a couple times just in case the LED is in an odd state.\r\n\t\t\033[33mWarning\033[0m: May adversely affect some modules...", cliFunc_led }, { "led", "Enables/Disables indicator LED. Try a couple times just in case the LED is in an odd state.\r\n\t\t\033[33mWarning\033[0m: May adversely affect some modules...", cliFunc_led },
{ "reload", "Signals microcontroller to reflash/reload.", cliFunc_reload }, { "reload", "Signals microcontroller to reflash/reload.", cliFunc_reload },
{ "reset", "Sends a software reset, should be similar to powering on the device.", cliFunc_reset },
{ "reset", "Resets the terminal back to initial settings.", cliFunc_reset },
{ "restart", "Sends a software restart, should be similar to powering on the device.", cliFunc_restart },
{ "version", "Version information about this firmware.", cliFunc_version }, { "version", "Version information about this firmware.", cliFunc_version },
{ 0, 0, 0 } // Null entry for dictionary end { 0, 0, 0 } // Null entry for dictionary end
}; };


inline void prompt() inline void prompt()
{ {
print("\033[2K"); // Erases the current line
print(": "); print(": ");
} }


// Initialize the CLI
inline void init_cli() inline void init_cli()
{ {
// Reset the Line Buffer // Reset the Line Buffer
// Initialize main LED // Initialize main LED
init_errorLED(); init_errorLED();
CLILEDState = 0; CLILEDState = 0;

// Hex debug mode is off by default
CLIHexDebugMode = 0;
} }


// Query the serial input buffer for any new characters
void process_cli() void process_cli()
{ {
// Current buffer position // Current buffer position
CLILineBuffer[CLILineBufferCurrent++] = cur_char; CLILineBuffer[CLILineBufferCurrent++] = cur_char;
} }


// Display Hex Key Input if enabled
if ( CLIHexDebugMode && CLILineBufferCurrent > prev_buf_pos )
{
print("\033[s\r\n"); // Save cursor position, and move to the next line
print("\033[2K"); // Erases the current line

uint8_t pos = prev_buf_pos;
while ( CLILineBufferCurrent > pos )
{
printHex( CLILineBuffer[pos++] );
print(" ");
}

print("\033[u"); // Restore cursor position
}

// If buffer has changed, output to screen while there are still characters in the buffer not displayed // If buffer has changed, output to screen while there are still characters in the buffer not displayed
while ( CLILineBufferCurrent > prev_buf_pos ) while ( CLILineBufferCurrent > prev_buf_pos )
{ {


break; break;
} }

/* TODO Enable via option
uint8_t pos = prev_buf_pos;
while ( CLILineBuffer[pos] != 0 )
{
printHex( CLILineBuffer[pos++] );
print(" ");
}

print( NL );
*/
} }
} }


*second = argPtr; *second = argPtr;
} }


// Scans the CLILineBuffer for any valid commands
void commandLookup_cli() void commandLookup_cli()
{ {
// Ignore command if buffer is 0 length // Ignore command if buffer is 0 length
erro_dPrint("\"", CLILineBuffer, "\" is not a valid command...type \033[35mhelp\033[0m"); erro_dPrint("\"", CLILineBuffer, "\" is not a valid command...type \033[35mhelp\033[0m");
} }


// Registers a command dictionary with the CLI
inline void registerDictionary_cli( CLIDictItem *cmdDict ) inline void registerDictionary_cli( CLIDictItem *cmdDict )
{ {
// Make sure this max limit of dictionaries hasn't been reached // Make sure this max limit of dictionaries hasn't been reached


void cliFunc_cliDebug( char* args ) void cliFunc_cliDebug( char* args )
{ {
// Toggle Hex Debug Mode
if ( CLIHexDebugMode )
{
print( NL );
info_print("Hex debug mode disabled...");
CLIHexDebugMode = 0;
}
else
{
print( NL );
info_print("Hex debug mode enabled...");
CLIHexDebugMode = 1;
}
} }


void cliFunc_help( char* args ) void cliFunc_help( char* args )
} }


void cliFunc_reset( char* args ) void cliFunc_reset( char* args )
{
print("\033c"); // Resets the terminal
}

void cliFunc_restart( char* args )
{ {
// Trigger an overall software reset // Trigger an overall software reset
SOFTWARE_RESET(); SOFTWARE_RESET();

+ 2
- 1
Debug/cli/cli.h Прегледај датотеку

uint8_t CLIDictionariesUsed; uint8_t CLIDictionariesUsed;


uint8_t CLILEDState; uint8_t CLILEDState;
uint8_t CLIHexDebugMode;






void cliFunc_led ( char* args ); void cliFunc_led ( char* args );
void cliFunc_reload ( char* args ); void cliFunc_reload ( char* args );
void cliFunc_reset ( char* args ); void cliFunc_reset ( char* args );
void cliFunc_restart ( char* args );
void cliFunc_version ( char* args ); void cliFunc_version ( char* args );





+ 1
- 1
Lib/_buildvars.h Прегледај датотеку

#define CLI_RepoOrigin "@Git_Origin_URL@" #define CLI_RepoOrigin "@Git_Origin_URL@"
#define CLI_CommitDate "@Git_Date_INFO@" #define CLI_CommitDate "@Git_Date_INFO@"
#define CLI_CommitAuthor @Git_Commit_Author@ #define CLI_CommitAuthor @Git_Commit_Author@
#define CLI_Modules "@OutputModule@ @DebugModule@"
#define CLI_Modules "Output(@OutputModule@) Debug(@DebugModule@)"
#define CLI_BuildDate "@Build_Date@" #define CLI_BuildDate "@Build_Date@"
#define CLI_BuildOS "@CMAKE_SYSTEM@" #define CLI_BuildOS "@CMAKE_SYSTEM@"
#define CLI_Arch "@COMPILER_FAMILY@" #define CLI_Arch "@COMPILER_FAMILY@"