X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=Debug%2Fcli%2Fcli.c;h=e91046903cd32f6d2bda1d669bef67a3e46f941a;hb=ed71f7fad5ff899af0cfab02267cdd134d201f7e;hp=2ee4d5ac79b959cd02e3ace3a51f396c2a63518c;hpb=97308d37496cc004f3ff9f38b50956a66b4139a2;p=kiibohd-controller.git diff --git a/Debug/cli/cli.c b/Debug/cli/cli.c index 2ee4d5a..e910469 100644 --- a/Debug/cli/cli.c +++ b/Debug/cli/cli.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 by Jacob Alexander +/* Copyright (C) 2014-2015 by Jacob Alexander * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -35,15 +35,22 @@ // ----- Variables ----- // Basic command dictionary -char* basicCLIDictName = "General Commands"; -CLIDictItem basicCLIDict[] = { - { "cliDebug", "Enables/Disables hex output of the most recent cli input.", cliFunc_cliDebug }, - { "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 }, - { "reload", "Signals microcontroller to reflash/reload.", cliFunc_reload }, - { "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 }, +CLIDict_Entry( cliDebug, "Enables/Disables hex output of the most recent cli input." ); +CLIDict_Entry( help, "You're looking at it :P" ); +CLIDict_Entry( 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..." ); +CLIDict_Entry( reload, "Signals microcontroller to reflash/reload." ); +CLIDict_Entry( reset, "Resets the terminal back to initial settings." ); +CLIDict_Entry( restart, "Sends a software restart, should be similar to powering on the device." ); +CLIDict_Entry( version, "Version information about this firmware." ); + +CLIDict_Def( basicCLIDict, "General Commands" ) = { + CLIDict_Item( cliDebug ), + CLIDict_Item( help ), + CLIDict_Item( led ), + CLIDict_Item( reload ), + CLIDict_Item( reset ), + CLIDict_Item( restart ), + CLIDict_Item( version ), { 0, 0, 0 } // Null entry for dictionary end }; @@ -250,11 +257,11 @@ void CLI_commandLookup() for ( uint8_t cmd = 0; CLIDict[dict][cmd].name != 0; cmd++ ) { // Compare the first argument and each command entry - if ( eqStr( cmdPtr, CLIDict[dict][cmd].name ) == -1 ) + if ( eqStr( cmdPtr, (char*)CLIDict[dict][cmd].name ) == -1 ) { // Run the specified command function pointer // argPtr is already pointing at the first character of the arguments - (*CLIDict[dict][cmd].function)( argPtr ); + (*(void (*)(char*))CLIDict[dict][cmd].function)( argPtr ); return; } @@ -267,7 +274,7 @@ void CLI_commandLookup() } // Registers a command dictionary with the CLI -void CLI_registerDictionary( CLIDictItem *cmdDict, char* dictName ) +void CLI_registerDictionary( const CLIDictItem *cmdDict, const char* dictName ) { // Make sure this max limit of dictionaries hasn't been reached if ( CLIDictionariesUsed >= CLIMaxDictionaries ) @@ -277,8 +284,8 @@ void CLI_registerDictionary( CLIDictItem *cmdDict, char* dictName ) } // Add dictionary - CLIDictNames[CLIDictionariesUsed] = dictName; - CLIDict[CLIDictionariesUsed++] = cmdDict; + CLIDictNames[CLIDictionariesUsed] = (char*)dictName; + CLIDict[CLIDictionariesUsed++] = (CLIDictItem*)cmdDict; } inline void CLI_tabCompletion() @@ -310,11 +317,11 @@ inline void CLI_tabCompletion() // NOTE: To save on processing, we only care about the commands and ignore the arguments // If there are arguments, and a valid tab match is found, buffer is cleared (args lost) // Also ignores full matches - if ( eqStr( cmdPtr, CLIDict[dict][cmd].name ) == 0 ) + if ( eqStr( cmdPtr, (char*)CLIDict[dict][cmd].name ) == 0 ) { // TODO Make list of commands if multiple matches matches++; - tabMatch = CLIDict[dict][cmd].name; + tabMatch = (char*)CLIDict[dict][cmd].name; } } } @@ -367,7 +374,9 @@ void cliFunc_help( char* args ) for ( uint8_t dict = 0; dict < CLIDictionariesUsed; dict++ ) { // Print the name of each dictionary as a title - dPrintStrsNL( NL, "\033[1;32m", CLIDictNames[dict], "\033[0m" ); + print( NL "\033[1;32m" ); + _print( CLIDictNames[dict] ); // This print is requride by AVR (flash) + print( "\033[0m" NL ); // Parse each cmd/description until a null command entry is found for ( uint8_t cmd = 0; CLIDict[dict][cmd].name != 0; cmd++ ) @@ -375,11 +384,12 @@ void cliFunc_help( char* args ) dPrintStrs(" \033[35m", CLIDict[dict][cmd].name, "\033[0m"); // Determine number of spaces to tab by the length of the command and TabAlign - uint8_t padLength = CLIEntryTabAlign - lenStr( CLIDict[dict][cmd].name ); + uint8_t padLength = CLIEntryTabAlign - lenStr( (char*)CLIDict[dict][cmd].name ); while ( padLength-- > 0 ) print(" "); - dPrintStrNL( CLIDict[dict][cmd].description ); + _print( CLIDict[dict][cmd].description ); // This print is required by AVR (flash) + print( NL ); } } } @@ -412,7 +422,7 @@ void cliFunc_version( char* args ) print( NL ); print( " \033[1mRevision:\033[0m " CLI_Revision NL ); print( " \033[1mBranch:\033[0m " CLI_Branch NL ); - print( " \033[1mTree Status:\033[0m " CLI_ModifiedStatus NL ); + print( " \033[1mTree Status:\033[0m " CLI_ModifiedStatus CLI_ModifiedFiles NL ); print( " \033[1mRepo Origin:\033[0m " CLI_RepoOrigin NL ); print( " \033[1mCommit Date:\033[0m " CLI_CommitDate NL ); print( " \033[1mCommit Author:\033[0m " CLI_CommitAuthor NL );