rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions
cli_registry.h File Reference

Detailed Description

Command-line interface commands registry.

Date
Nov 15, 2012
Author
Andrey Belomutskiy, (c) 2012-2020

Definition in file cli_registry.h.

Data Structures

struct  TokenCallback
 

Typedefs

typedef void(* Void) (void)
 
typedef void(* VoidPtr) (void *)
 
typedef void(* VoidInt) (int)
 
typedef void(* VoidIntVoidPtr) (int, void *)
 
typedef void(* VoidFloat) (float)
 
typedef void(* VoidFloatFloat) (float, float)
 
typedef void(* VoidFloatFloatFloat) (float, float, float)
 
typedef void(* VoidFloatFloatFloatFloat) (float, float, float, float)
 
typedef void(* VoidFloatFloatVoidPtr) (float, float, void *)
 
typedef void(* VoidIntInt) (int, int)
 
typedef void(* VoidIntIntVoidPtr) (int, int, void *)
 
typedef void(* VoidIntFloat) (int, float)
 
typedef void(* VoidCharPtr) (const char *)
 
typedef void(* VoidCharPtrVoidPtr) (const char *, void *)
 
typedef void(* VoidCharPtrCharPtr) (const char *, const char *)
 
typedef void(* VoidCharPtrCharPtrVoidPtr) (const char *, const char *, void *)
 
typedef void(* VoidCharPtrCharPtrCharPtr) (const char *, const char *, const char *)
 
typedef void(* VoidCharPtrCharPtrCharPtrCharPtrCharPtr) (const char *, const char *, const char *, const char *, const char *)
 

Enumerations

enum  action_type_e {
  NO_PARAMETER , NO_PARAMETER_P , ONE_PARAMETER , ONE_PARAMETER_P ,
  FLOAT_PARAMETER_NAN_ALLOWED , FLOAT_PARAMETER , FLOAT_PARAMETER_P , STRING_PARAMETER ,
  STRING_PARAMETER_P , STRING2_PARAMETER , STRING2_PARAMETER_P , STRING3_PARAMETER ,
  STRING5_PARAMETER , TWO_INTS_PARAMETER , TWO_INTS_PARAMETER_P , FLOAT_FLOAT_PARAMETER ,
  FLOAT_FLOAT_FLOAT_PARAMETER , FLOAT_FLOAT_FLOAT_FLOAT_PARAMETER , FLOAT_FLOAT_PARAMETER_P , INT_FLOAT_PARAMETER
}
 

Functions

int tokenLength (const char *msgp)
 
int findEndOfToken (const char *line)
 
charunquote (char *line)
 
void resetConsoleActions (void)
 
void helpCommand (void)
 This function prints out a list of all available commands.
 
void initConsoleLogic ()
 
void handleConsoleLine (char *line)
 This function takes care of one command line once we have it.
 
void addConsoleAction (const char *token, Void callback)
 Register console action without parameters.
 
void addConsoleActionP (const char *token, VoidPtr callback, void *param)
 
void addConsoleActionI (const char *token, VoidInt callback)
 Register a console command with one Integer parameter.
 
void addConsoleActionIP (const char *token, VoidIntVoidPtr callback, void *param)
 
void addConsoleActionIF (const char *token, VoidIntFloat callback)
 
void addConsoleActionII (const char *token, VoidIntInt callback)
 Register a console command with two Integer parameters.
 
void addConsoleActionIIP (const char *token, VoidIntIntVoidPtr callback, void *param)
 
void addConsoleActionF (const char *token, VoidFloat callback)
 
void addConsoleActionNANF (const char *token, VoidFloat callback)
 
void addConsoleActionFF (const char *token, VoidFloatFloat callback)
 
void addConsoleActionFFF (const char *token, VoidFloatFloatFloat callback)
 
void addConsoleActionFFFF (const char *token, VoidFloatFloatFloatFloat callback)
 
void addConsoleActionFFP (const char *token, VoidFloatFloatVoidPtr callback, void *param)
 
void addConsoleActionS (const char *token, VoidCharPtr callback)
 
void addConsoleActionSP (const char *token, VoidCharPtrVoidPtr callback, void *param)
 
void addConsoleActionSS (const char *token, VoidCharPtrCharPtr callback)
 
void addConsoleActionSSP (const char *token, VoidCharPtrCharPtrVoidPtr callback, void *param)
 
void addConsoleActionSSS (const char *token, VoidCharPtrCharPtrCharPtr callback)
 
void addConsoleActionSSSSS (const char *token, VoidCharPtrCharPtrCharPtrCharPtrCharPtr callback)
 
void onCliCaseError (const char *token)
 
void onCliDuplicateError (const char *token)
 
void onCliOverflowError ()
 

Typedef Documentation

◆ Void

typedef void(* Void) (void)

Definition at line 52 of file cli_registry.h.

◆ VoidCharPtr

typedef void(* VoidCharPtr) (const char *)

Definition at line 65 of file cli_registry.h.

◆ VoidCharPtrCharPtr

typedef void(* VoidCharPtrCharPtr) (const char *, const char *)

Definition at line 68 of file cli_registry.h.

◆ VoidCharPtrCharPtrCharPtr

typedef void(* VoidCharPtrCharPtrCharPtr) (const char *, const char *, const char *)

Definition at line 71 of file cli_registry.h.

◆ VoidCharPtrCharPtrCharPtrCharPtrCharPtr

typedef void(* VoidCharPtrCharPtrCharPtrCharPtrCharPtr) (const char *, const char *, const char *, const char *, const char *)

Definition at line 72 of file cli_registry.h.

◆ VoidCharPtrCharPtrVoidPtr

typedef void(* VoidCharPtrCharPtrVoidPtr) (const char *, const char *, void *)

Definition at line 69 of file cli_registry.h.

◆ VoidCharPtrVoidPtr

typedef void(* VoidCharPtrVoidPtr) (const char *, void *)

Definition at line 66 of file cli_registry.h.

◆ VoidFloat

typedef void(* VoidFloat) (float)

Definition at line 56 of file cli_registry.h.

◆ VoidFloatFloat

typedef void(* VoidFloatFloat) (float, float)

Definition at line 57 of file cli_registry.h.

◆ VoidFloatFloatFloat

typedef void(* VoidFloatFloatFloat) (float, float, float)

Definition at line 58 of file cli_registry.h.

◆ VoidFloatFloatFloatFloat

typedef void(* VoidFloatFloatFloatFloat) (float, float, float, float)

Definition at line 59 of file cli_registry.h.

◆ VoidFloatFloatVoidPtr

typedef void(* VoidFloatFloatVoidPtr) (float, float, void *)

Definition at line 60 of file cli_registry.h.

◆ VoidInt

typedef void(* VoidInt) (int)

Definition at line 54 of file cli_registry.h.

◆ VoidIntFloat

typedef void(* VoidIntFloat) (int, float)

Definition at line 63 of file cli_registry.h.

◆ VoidIntInt

typedef void(* VoidIntInt) (int, int)

Definition at line 61 of file cli_registry.h.

◆ VoidIntIntVoidPtr

typedef void(* VoidIntIntVoidPtr) (int, int, void *)

Definition at line 62 of file cli_registry.h.

◆ VoidIntVoidPtr

typedef void(* VoidIntVoidPtr) (int, void *)

Definition at line 55 of file cli_registry.h.

◆ VoidPtr

typedef void(* VoidPtr) (void *)

Definition at line 53 of file cli_registry.h.

Enumeration Type Documentation

◆ action_type_e

Enumerator
NO_PARAMETER 
NO_PARAMETER_P 
ONE_PARAMETER 
ONE_PARAMETER_P 
FLOAT_PARAMETER_NAN_ALLOWED 
FLOAT_PARAMETER 
FLOAT_PARAMETER_P 
STRING_PARAMETER 
STRING_PARAMETER_P 
STRING2_PARAMETER 
STRING2_PARAMETER_P 
STRING3_PARAMETER 
STRING5_PARAMETER 
TWO_INTS_PARAMETER 
TWO_INTS_PARAMETER_P 
FLOAT_FLOAT_PARAMETER 
FLOAT_FLOAT_FLOAT_PARAMETER 
FLOAT_FLOAT_FLOAT_FLOAT_PARAMETER 
FLOAT_FLOAT_PARAMETER_P 
INT_FLOAT_PARAMETER 

Definition at line 11 of file cli_registry.h.

11 {
action_type_e
@ STRING5_PARAMETER
@ NO_PARAMETER_P
@ FLOAT_FLOAT_FLOAT_PARAMETER
@ FLOAT_FLOAT_PARAMETER_P
@ ONE_PARAMETER_P
@ NO_PARAMETER
@ FLOAT_PARAMETER
@ FLOAT_PARAMETER_NAN_ALLOWED
@ TWO_INTS_PARAMETER_P
@ STRING_PARAMETER_P
@ TWO_INTS_PARAMETER
@ FLOAT_PARAMETER_P
@ STRING2_PARAMETER
@ INT_FLOAT_PARAMETER
@ STRING2_PARAMETER_P
@ FLOAT_FLOAT_PARAMETER
@ FLOAT_FLOAT_FLOAT_FLOAT_PARAMETER
@ STRING_PARAMETER
@ STRING3_PARAMETER
@ ONE_PARAMETER

Function Documentation

◆ addConsoleAction()

void addConsoleAction ( const char token,
Void  callback 
)

◆ addConsoleActionF()

void addConsoleActionF ( const char token,
VoidFloat  callback 
)

Definition at line 145 of file cli_registry.cpp.

145 {
146 doAddAction(token, FLOAT_PARAMETER, (Void) callback, NULL);
147}
void(* Void)(void)

Referenced by initBenchTest(), and initSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addConsoleActionFF()

void addConsoleActionFF ( const char token,
VoidFloatFloat  callback 
)

Definition at line 149 of file cli_registry.cpp.

149 {
150 doAddAction(token, FLOAT_FLOAT_PARAMETER, (Void) callback, NULL);
151}
Here is the call graph for this function:

◆ addConsoleActionFFF()

void addConsoleActionFFF ( const char token,
VoidFloatFloatFloat  callback 
)

Definition at line 153 of file cli_registry.cpp.

153 {
154 doAddAction(token, FLOAT_FLOAT_FLOAT_PARAMETER, (Void) callback, NULL);
155}

Referenced by initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addConsoleActionFFFF()

void addConsoleActionFFFF ( const char token,
VoidFloatFloatFloatFloat  callback 
)

Definition at line 157 of file cli_registry.cpp.

157 {
158 doAddAction(token, FLOAT_FLOAT_FLOAT_FLOAT_PARAMETER, (Void) callback, NULL);
159}

Referenced by initBenchTest().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addConsoleActionFFP()

void addConsoleActionFFP ( const char token,
VoidFloatFloatVoidPtr  callback,
void *  param 
)

Definition at line 161 of file cli_registry.cpp.

161 {
162 doAddAction(token, FLOAT_FLOAT_PARAMETER_P, (Void) callback, param);
163}
static tstrWifiInitParam param
Here is the call graph for this function:

◆ addConsoleActionI()

void addConsoleActionI ( const char token,
VoidInt  callback 
)

Register a console command with one Integer parameter.

Definition at line 98 of file cli_registry.cpp.

98 {
99 doAddAction(token, ONE_PARAMETER, (Void) callback, NULL);
100}

Referenced by initAdcInputs(), initBenchTest(), initConfigActions(), initializeConsole(), initPotentiometers(), initQcBenchControls(), initSensorCli(), initSettings(), initTimePerfActions(), initTriggerEmulator(), initWaveChart(), setEepromTestConfiguration(), and startTunerStudioConnectivity().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addConsoleActionIF()

void addConsoleActionIF ( const char token,
VoidIntFloat  callback 
)

Definition at line 117 of file cli_registry.cpp.

117 {
118 doAddAction(token, INT_FLOAT_PARAMETER, (Void) callback, NULL);
119}
Here is the call graph for this function:

◆ addConsoleActionII()

void addConsoleActionII ( const char token,
VoidIntInt  callback 
)

Register a console command with two Integer parameters.

Definition at line 109 of file cli_registry.cpp.

109 {
110 doAddAction(token, TWO_INTS_PARAMETER, (Void) callback, NULL);
111}

Referenced by initBenchTest(), initConfigActions(), initKLine(), initPotentiometers(), initQcBenchControls(), and startLua().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addConsoleActionIIP()

void addConsoleActionIIP ( const char token,
VoidIntIntVoidPtr  callback,
void *  param 
)

Definition at line 113 of file cli_registry.cpp.

113 {
114 doAddAction(token, TWO_INTS_PARAMETER_P, (Void) callback, param);
115}
Here is the call graph for this function:

◆ addConsoleActionIP()

void addConsoleActionIP ( const char token,
VoidIntVoidPtr  callback,
void *  param 
)

Definition at line 102 of file cli_registry.cpp.

102 {
103 doAddAction(token, ONE_PARAMETER_P, (Void) callback, param);
104}
Here is the call graph for this function:

◆ addConsoleActionNANF()

void addConsoleActionNANF ( const char token,
VoidFloat  callback 
)

Definition at line 141 of file cli_registry.cpp.

141 {
142 doAddAction(token, FLOAT_PARAMETER_NAN_ALLOWED, (Void) callback, NULL);
143}
Here is the call graph for this function:

◆ addConsoleActionP()

void addConsoleActionP ( const char token,
VoidPtr  callback,
void *  param 
)

Definition at line 80 of file cli_registry.cpp.

80 {
81 doAddAction(token, NO_PARAMETER_P, (Void) callback, param);
82}
Here is the call graph for this function:

◆ addConsoleActionS()

void addConsoleActionS ( const char token,
VoidCharPtr  callback 
)

Definition at line 121 of file cli_registry.cpp.

121 {
122 doAddAction(token, STRING_PARAMETER, (Void) callback, NULL);
123}

Referenced by initEarlyMmcCard(), initSettings(), and startLua().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addConsoleActionSP()

void addConsoleActionSP ( const char token,
VoidCharPtrVoidPtr  callback,
void *  param 
)

Definition at line 125 of file cli_registry.cpp.

125 {
126 doAddAction(token, STRING_PARAMETER_P, (Void) callback, param);
127}
Here is the call graph for this function:

◆ addConsoleActionSS()

void addConsoleActionSS ( const char token,
VoidCharPtrCharPtr  callback 
)

Definition at line 129 of file cli_registry.cpp.

129 {
130 doAddAction(token, STRING2_PARAMETER, (Void) callback, NULL);
131}

Referenced by initConfigActions(), initSensorCli(), and initSettings().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addConsoleActionSSP()

void addConsoleActionSSP ( const char token,
VoidCharPtrCharPtrVoidPtr  callback,
void *  param 
)

Definition at line 84 of file cli_registry.cpp.

84 {
85 doAddAction(token, STRING2_PARAMETER_P, (Void) callback, param);
86}
Here is the call graph for this function:

◆ addConsoleActionSSS()

void addConsoleActionSSS ( const char token,
VoidCharPtrCharPtrCharPtr  callback 
)

Definition at line 133 of file cli_registry.cpp.

133 {
134 doAddAction(token, STRING3_PARAMETER, (Void) callback, NULL);
135}

Referenced by initConfigActions(), and startTunerStudioConnectivity().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ addConsoleActionSSSSS()

void addConsoleActionSSSSS ( const char token,
VoidCharPtrCharPtrCharPtrCharPtrCharPtr  callback 
)

Definition at line 137 of file cli_registry.cpp.

137 {
138 doAddAction(token, STRING5_PARAMETER, (Void) callback, NULL);
139}
Here is the call graph for this function:

◆ findEndOfToken()

int findEndOfToken ( const char line)

Looks like this is a quoted token

Matching closing quote not found

Skipping first quote and the symbol after closing quote

Definition at line 207 of file cli_registry.cpp.

207 {
208 if (line[0] == '"') {
209 /**
210 * Looks like this is a quoted token
211 */
212 int v = indexOf(line + 1, '"');
213 if (v == -1) {
214 /**
215 * Matching closing quote not found
216 */
217 return -1;
218 }
219 /**
220 * Skipping first quote and the symbol after closing quote
221 */
222 return v + 2;
223 }
224 return indexOf(line, SPACE_CHAR);
225}

◆ handleConsoleLine()

void handleConsoleLine ( char line)

This function takes care of one command line once we have it.

Definition at line 510 of file cli_registry.cpp.

510 {
511 if (line == NULL)
512 return; // error detected
513
514 int lineLength = std::strlen(line);
515 if (lineLength > MAX_CMD_LINE_LENGTH) {
516 // todo: better reaction to excessive line
517 efiPrintf("Long line?");
518 return;
519 }
520
521 int ret = handleConsoleLineInternal(line);
522
523 if (ret < 0) {
524 efiPrintf("failed to handle command [%s]", line);
525 return;
526 }
527
528 efiPrintf("confirmation_%s:%d", line, lineLength);
529}
static int handleConsoleLineInternal(const char *commandLine)

Referenced by checkStackAndHandleConsoleLine(), and initializeConsole().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ helpCommand()

void helpCommand ( void  )

This function prints out a list of all available commands.

Definition at line 198 of file cli_registry.cpp.

198 {
199 efiPrintf("%d actions available", consoleActionCount);
200 for (int i = 0; i < consoleActionCount; i++) {
201 TokenCallback *current = &consoleActions[i];
202 efiPrintf(" %s: %d parameters", current->token, getParameterCount(current->parameterType));
203 }
204 efiPrintf("For more visit https://github.com/rusefi/rusefi/wiki/Dev-Console-Commands");
205}
static TokenCallback consoleActions[CONSOLE_MAX_ACTIONS]
static int consoleActionCount
static int getParameterCount(action_type_e parameterType)
action_type_e parameterType
const char * token

Referenced by initConsoleLogic().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initConsoleLogic()

void initConsoleLogic ( )

Definition at line 472 of file cli_registry.cpp.

472 {
474}
void helpCommand(void)
This function prints out a list of all available commands.
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.

Referenced by initializeConsole().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onCliCaseError()

void onCliCaseError ( const char token)

Definition at line 232 of file eficonsole.cpp.

232 {
233 firmwareError(ObdCode::CUSTOM_ERR_COMMAND_LOWER_CASE_EXPECTED, "lowerCase expected [%s]", token);
234}
void firmwareError(ObdCode code, const char *fmt,...)
@ CUSTOM_ERR_COMMAND_LOWER_CASE_EXPECTED

Referenced by doAddAction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onCliDuplicateError()

void onCliDuplicateError ( const char token)

Definition at line 236 of file eficonsole.cpp.

236 {
237 firmwareError(ObdCode::CUSTOM_SAME_TWICE, "Same action twice [%s]", token);
238}
@ CUSTOM_SAME_TWICE

Referenced by doAddAction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ onCliOverflowError()

void onCliOverflowError ( )

Definition at line 240 of file eficonsole.cpp.

240 {
241 firmwareError(ObdCode::CUSTOM_CONSOLE_TOO_MANY, "Too many console actions");
242}
@ CUSTOM_CONSOLE_TOO_MANY

Referenced by doAddAction().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resetConsoleActions()

void resetConsoleActions ( void  )

Definition at line 47 of file cli_registry.cpp.

47 {
49}

◆ tokenLength()

int tokenLength ( const char msgp)
Returns
Number of space-separated tokens in the string

Definition at line 230 of file cli_registry.cpp.

230 {
231 int result = 0;
232 while (*msgp) {
233 char ch = *msgp++;
234 if (ch == SPACE_CHAR) {
235 break;
236 }
237 result++;
238 }
239 return result;
240}
pwm_settings ch[2]

◆ unquote()

char * unquote ( char line)

Definition at line 242 of file cli_registry.cpp.

242 {
243 if (line[0] == '"') {
244 int len = std::strlen(line);
245 if (line[len - 1] == '"') {
246 line[len - 1] = 0;
247 return line + 1;
248 }
249 }
250 return line;
251}

Go to the source code of this file.