Mercurial > louis > kiibohd-controller
annotate Debug/cli/cli.h @ 319:3994a5a68793
Cleanup CLI history
Add all the spaces :)
author | Rowan Decker <Smasher816@gmail.com> |
---|---|
date | Thu, 02 Apr 2015 23:53:19 -0700 |
parents | 217e7bd8a0a4 |
children | 18c3c4924f20 |
rev | line source |
---|---|
307
ecd2ae35d25c
Initial commit for UARTConnect module
Jacob Alexander <haata@kiibohd.com>
parents:
239
diff
changeset
|
1 /* Copyright (C) 2014-2015 by Jacob Alexander |
104
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
2 * |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
3 * Permission is hereby granted, free of charge, to any person obtaining a copy |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
4 * of this software and associated documentation files (the "Software"), to deal |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
5 * in the Software without restriction, including without limitation the rights |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
7 * copies of the Software, and to permit persons to whom the Software is |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
8 * furnished to do so, subject to the following conditions: |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
9 * |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
10 * The above copyright notice and this permission notice shall be included in |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
11 * all copies or substantial portions of the Software. |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
12 * |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
19 * THE SOFTWARE. |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
20 */ |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
21 |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
22 #ifndef cli_h__ |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
23 #define cli_h__ |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
24 |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
25 // ----- Includes ----- |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
26 |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
27 // Compiler Includes |
109
2c1a9e6ae70e
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
108
diff
changeset
|
28 #include <Lib/MainLib.h> |
104
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
29 |
109
2c1a9e6ae70e
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
108
diff
changeset
|
30 // Project Includes |
2c1a9e6ae70e
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
108
diff
changeset
|
31 #include <output_com.h> |
104
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
32 |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
33 |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
34 // ----- Defines ----- |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
35 |
106
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
36 #define CLILineBufferMaxSize 100 |
307
ecd2ae35d25c
Initial commit for UARTConnect module
Jacob Alexander <haata@kiibohd.com>
parents:
239
diff
changeset
|
37 #define CLIMaxDictionaries 10 |
111
59391aa888aa
Initial Force Gauge CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
110
diff
changeset
|
38 #define CLIEntryTabAlign 13 |
318 | 39 #define CLIMaxHistorySize 10 |
106
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
40 |
239
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
41 |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
42 // ----- Macros ----- |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
43 |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
44 // AVR CLI Dictionary definitions (has to deal with the annoying PROGMEM |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
45 // Only using PROGMEM with descriptions (all the string comparison tools need to be re-written otherwise) |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
46 #if defined(_at90usb162_) || defined(_atmega32u4_) || defined(_at90usb646_) || defined(_at90usb1286_) // AVR |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
47 #define CLIDict_Def(name,description) \ |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
48 const PROGMEM char name##Name[] = description; \ |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
49 const CLIDictItem name[] |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
50 |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
51 #define CLIDict_Item(name) \ |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
52 { #name, name##CLIDict_DescEntry, (const void (*)(char*))cliFunc_##name } |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
53 |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
54 #define CLIDict_Entry(name,description) \ |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
55 const PROGMEM char name##CLIDict_DescEntry[] = description; |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
56 |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
57 // ARM is easy :P |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
58 #elif defined(_mk20dx128_) || defined(_mk20dx128vlf5_) || defined(_mk20dx256_) // ARM |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
59 #define CLIDict_Def(name,description) \ |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
60 const char name##Name[] = description; \ |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
61 const CLIDictItem name[] |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
62 |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
63 #define CLIDict_Item(name) \ |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
64 { #name, name##CLIDict_DescEntry, (const void (*)(char*))cliFunc_##name } |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
65 |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
66 #define CLIDict_Entry(name,description) \ |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
67 const char name##CLIDict_DescEntry[] = description; |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
68 #endif |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
69 |
318 | 70 #define RING_PREV(i) wrap(i-1,0,CLIMaxHistorySize-1) |
71 #define RING_NEXT(i) wrap(i+1,0,CLIMaxHistorySize-1) | |
239
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
72 |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
73 |
106
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
74 // ----- Structs ----- |
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
75 |
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
76 // Each item has a name, description, and function pointer with an argument for arguments |
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
77 typedef struct CLIDictItem { |
239
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
78 const char* name; |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
79 const char* description; |
2a4c99da1276
HUGE AVR RAM optimization (~28%).
Jacob Alexander <haata@kiibohd.com>
parents:
192
diff
changeset
|
80 const void (*function)(char*); |
106
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
81 } CLIDictItem; |
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
82 |
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
83 |
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
84 |
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
85 // ----- Variables ----- |
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
86 |
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
87 char CLILineBuffer[CLILineBufferMaxSize+1]; // +1 for an additional NULL |
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
88 uint8_t CLILineBufferCurrent; |
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
89 |
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
90 // Main command dictionary |
112
0cb43cb8f683
Adding dictionary titles.
Jacob Alexander <haata@kiibohd.com>
parents:
111
diff
changeset
|
91 CLIDictItem *CLIDict [CLIMaxDictionaries]; |
0cb43cb8f683
Adding dictionary titles.
Jacob Alexander <haata@kiibohd.com>
parents:
111
diff
changeset
|
92 char* CLIDictNames[CLIMaxDictionaries]; |
0cb43cb8f683
Adding dictionary titles.
Jacob Alexander <haata@kiibohd.com>
parents:
111
diff
changeset
|
93 uint8_t CLIDictionariesUsed; |
106
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
94 |
318 | 95 // History |
96 char CLIHistoryBuffer[CLIMaxHistorySize][CLILineBufferMaxSize]; | |
97 uint8_t CLIHistoryHead; | |
98 uint8_t CLIHistoryTail; | |
99 int8_t CLIHistoryCurrent; | |
100 | |
101 // Debug | |
109
2c1a9e6ae70e
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
108
diff
changeset
|
102 uint8_t CLILEDState; |
110
98d940b60d12
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
103 uint8_t CLIHexDebugMode; |
106
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
104 |
104
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
105 |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
106 |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
107 // ----- Functions and Corresponding Function Aliases ----- |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
108 |
125
8dab4014c398
Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
114
diff
changeset
|
109 void CLI_init(); |
8dab4014c398
Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
114
diff
changeset
|
110 void CLI_process(); |
192
6ac92b8614c0
Fixing RAM calculator and reduced actual SRAM usage
Jacob Alexander <haata@kiibohd.com>
parents:
125
diff
changeset
|
111 void CLI_registerDictionary( const CLIDictItem *cmdDict, const char* dictName ); |
125
8dab4014c398
Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
114
diff
changeset
|
112 void CLI_argumentIsolation( char* string, char** first, char** second ); |
104
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
113 |
319 | 114 int CLI_wrap( int x, int low, int high ); |
125
8dab4014c398
Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
114
diff
changeset
|
115 void CLI_commandLookup(); |
8dab4014c398
Major code cleanup and preparation for PartialMap Macro Module
Jacob Alexander <haata@kiibohd.com>
parents:
114
diff
changeset
|
116 void CLI_tabCompletion(); |
319 | 117 void CLI_saveHistory( char *buff ); |
118 void CLI_retreiveHistory( int index ); | |
106
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
119 |
15961894eaeb
Adding basic CLI functionality.
Jacob Alexander <haata@kiibohd.com>
parents:
105
diff
changeset
|
120 // CLI Command Functions |
109
2c1a9e6ae70e
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
108
diff
changeset
|
121 void cliFunc_arch ( char* args ); |
2c1a9e6ae70e
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
108
diff
changeset
|
122 void cliFunc_chip ( char* args ); |
316 | 123 void cliFunc_clear ( char* args ); |
109
2c1a9e6ae70e
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
108
diff
changeset
|
124 void cliFunc_cliDebug( char* args ); |
2c1a9e6ae70e
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
108
diff
changeset
|
125 void cliFunc_device ( char* args ); |
2c1a9e6ae70e
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
108
diff
changeset
|
126 void cliFunc_help ( char* args ); |
2c1a9e6ae70e
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
108
diff
changeset
|
127 void cliFunc_led ( char* args ); |
2c1a9e6ae70e
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
108
diff
changeset
|
128 void cliFunc_reload ( char* args ); |
2c1a9e6ae70e
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
108
diff
changeset
|
129 void cliFunc_reset ( char* args ); |
110
98d940b60d12
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
109
diff
changeset
|
130 void cliFunc_restart ( char* args ); |
109
2c1a9e6ae70e
Added more CLI commands.
Jacob Alexander <haata@kiibohd.com>
parents:
108
diff
changeset
|
131 void cliFunc_version ( char* args ); |
104
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
132 |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
133 |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
134 #endif |
e84738d174bc
Moving USB to Output in preparation for additional Output types.
Jacob Alexander <haata@kiibohd.com>
parents:
diff
changeset
|
135 |