rusEFI
The most advanced open source ECU
Functions | Variables
cli_registry.cpp File Reference

Detailed Description

Command-line interface commands registry.

Here we have a data structure which holds all the dynamically-registered command line interface action names & callback. This logic is invoked in user context by the console thread - see consoleThreadEntryPoint

TODO: there is too much copy-paste here, this class needs some refactoring :)

see testConsoleLogic()

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

Definition in file cli_registry.cpp.

Functions

void resetConsoleActions (void)
 
static void doAddAction (const char *token, action_type_e type, Void callback, void *param)
 
void addConsoleActionP (const char *token, VoidPtr callback, void *param)
 
void addConsoleActionSSP (const char *token, VoidCharPtrCharPtrVoidPtr callback, void *param)
 
void addConsoleAction (const char *token, Void callback)
 Register console action without parameters. More...
 
void addConsoleActionI (const char *token, VoidInt callback)
 Register a console command with one Integer parameter. More...
 
void addConsoleActionIP (const char *token, VoidIntVoidPtr callback, void *param)
 
void addConsoleActionII (const char *token, VoidIntInt callback)
 Register a console command with two Integer parameters. More...
 
void addConsoleActionIIP (const char *token, VoidIntIntVoidPtr callback, void *param)
 
void addConsoleActionIF (const char *token, VoidIntFloat callback)
 
void addConsoleActionS (const char *token, VoidCharPtr callback)
 
void addConsoleActionSP (const char *token, VoidCharPtrVoidPtr callback, void *param)
 
void addConsoleActionSS (const char *token, VoidCharPtrCharPtr callback)
 
void addConsoleActionSSS (const char *token, VoidCharPtrCharPtrCharPtr callback)
 
void addConsoleActionSSSSS (const char *token, VoidCharPtrCharPtrCharPtrCharPtrCharPtr callback)
 
void addConsoleActionNANF (const char *token, VoidFloat callback)
 
void addConsoleActionF (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)
 
static int getParameterCount (action_type_e parameterType)
 
void helpCommand (void)
 This function prints out a list of all available commands. More...
 
int findEndOfToken (const char *line)
 
int tokenLength (const char *msgp)
 
char * unquote (char *line)
 
static int setargs (char *args, char **argv, int max_args)
 
int handleActionWithParameter (TokenCallback *current, char *argv[], int argc)
 
void initConsoleLogic ()
 
static int handleConsoleLineInternal (const char *commandLine)
 
void handleConsoleLine (char *line)
 This function takes care of one command line once we have it. More...
 

Variables

static int consoleActionCount = 0
 
static TokenCallback consoleActions [CONSOLE_MAX_ACTIONS]
 
static char handleBuffer [MAX_CMD_LINE_LENGTH+1]
 

Function Documentation

◆ addConsoleAction()

void addConsoleAction ( const char *  token,
Void  callback 
)

◆ addConsoleActionF()

void addConsoleActionF ( const char *  token,
VoidFloat  callback 
)

Definition at line 143 of file cli_registry.cpp.

143  {
144  doAddAction(token, FLOAT_PARAMETER, (Void) callback, NULL);
145 }
void(* Void)(void)
Definition: cli_registry.h:52
@ FLOAT_PARAMETER
Definition: cli_registry.h:17

Referenced by hip_addconsoleActions(), 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 147 of file cli_registry.cpp.

147  {
148  doAddAction(token, FLOAT_FLOAT_PARAMETER, (Void) callback, NULL);
149 }
@ FLOAT_FLOAT_PARAMETER
Definition: cli_registry.h:27
Here is the call graph for this function:

◆ addConsoleActionFFF()

void addConsoleActionFFF ( const char *  token,
VoidFloatFloatFloat  callback 
)

Definition at line 151 of file cli_registry.cpp.

151  {
152  doAddAction(token, FLOAT_FLOAT_FLOAT_PARAMETER, (Void) callback, NULL);
153 }
@ FLOAT_FLOAT_FLOAT_PARAMETER
Definition: cli_registry.h:28

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 155 of file cli_registry.cpp.

155  {
156  doAddAction(token, FLOAT_FLOAT_FLOAT_FLOAT_PARAMETER, (Void) callback, NULL);
157 }
@ FLOAT_FLOAT_FLOAT_FLOAT_PARAMETER
Definition: cli_registry.h:29

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 159 of file cli_registry.cpp.

159  {
160  doAddAction(token, FLOAT_FLOAT_PARAMETER_P, (Void) callback, param);
161 }
@ FLOAT_FLOAT_PARAMETER_P
Definition: cli_registry.h:30
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 96 of file cli_registry.cpp.

96  {
97  doAddAction(token, ONE_PARAMETER, (Void) callback, NULL);
98 }
@ ONE_PARAMETER
Definition: cli_registry.h:14

Referenced by hip_addconsoleActions(), 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 115 of file cli_registry.cpp.

115  {
116  doAddAction(token, INT_FLOAT_PARAMETER, (Void) callback, NULL);
117 }
@ INT_FLOAT_PARAMETER
Definition: cli_registry.h:31
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 107 of file cli_registry.cpp.

107  {
108  doAddAction(token, TWO_INTS_PARAMETER, (Void) callback, NULL);
109 }
@ TWO_INTS_PARAMETER
Definition: cli_registry.h:25

Referenced by initConfigActions(), initKLine(), initPotentiometers(), initQcBenchControls(), startIdleThread(), 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 111 of file cli_registry.cpp.

111  {
112  doAddAction(token, TWO_INTS_PARAMETER_P, (Void) callback, param);
113 }
@ TWO_INTS_PARAMETER_P
Definition: cli_registry.h:26
Here is the call graph for this function:

◆ addConsoleActionIP()

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

Definition at line 100 of file cli_registry.cpp.

100  {
101  doAddAction(token, ONE_PARAMETER_P, (Void) callback, param);
102 }
@ ONE_PARAMETER_P
Definition: cli_registry.h:15
Here is the call graph for this function:

◆ addConsoleActionNANF()

void addConsoleActionNANF ( const char *  token,
VoidFloat  callback 
)

Definition at line 139 of file cli_registry.cpp.

139  {
140  doAddAction(token, FLOAT_PARAMETER_NAN_ALLOWED, (Void) callback, NULL);
141 }
@ FLOAT_PARAMETER_NAN_ALLOWED
Definition: cli_registry.h:16
Here is the call graph for this function:

◆ addConsoleActionP()

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

Definition at line 78 of file cli_registry.cpp.

78  {
79  doAddAction(token, NO_PARAMETER_P, (Void) callback, param);
80 }
@ NO_PARAMETER_P
Definition: cli_registry.h:13
Here is the call graph for this function:

◆ addConsoleActionS()

void addConsoleActionS ( const char *  token,
VoidCharPtr  callback 
)

Definition at line 119 of file cli_registry.cpp.

119  {
120  doAddAction(token, STRING_PARAMETER, (Void) callback, NULL);
121 }
@ STRING_PARAMETER
Definition: cli_registry.h:19

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 123 of file cli_registry.cpp.

123  {
124  doAddAction(token, STRING_PARAMETER_P, (Void) callback, param);
125 }
@ STRING_PARAMETER_P
Definition: cli_registry.h:20
Here is the call graph for this function:

◆ addConsoleActionSS()

void addConsoleActionSS ( const char *  token,
VoidCharPtrCharPtr  callback 
)

Definition at line 127 of file cli_registry.cpp.

127  {
128  doAddAction(token, STRING2_PARAMETER, (Void) callback, NULL);
129 }
@ STRING2_PARAMETER
Definition: cli_registry.h:21

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 82 of file cli_registry.cpp.

82  {
83  doAddAction(token, STRING2_PARAMETER_P, (Void) callback, param);
84 }
@ STRING2_PARAMETER_P
Definition: cli_registry.h:22
Here is the call graph for this function:

◆ addConsoleActionSSS()

void addConsoleActionSSS ( const char *  token,
VoidCharPtrCharPtrCharPtr  callback 
)

Definition at line 131 of file cli_registry.cpp.

131  {
132  doAddAction(token, STRING3_PARAMETER, (Void) callback, NULL);
133 }
@ STRING3_PARAMETER
Definition: cli_registry.h:23

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 135 of file cli_registry.cpp.

135  {
136  doAddAction(token, STRING5_PARAMETER, (Void) callback, NULL);
137 }
@ STRING5_PARAMETER
Definition: cli_registry.h:24
Here is the call graph for this function:

◆ doAddAction()

static void doAddAction ( const char *  token,
action_type_e  type,
Void  callback,
void *  param 
)
static

Definition at line 49 of file cli_registry.cpp.

49  {
50 #if !defined(EFI_DISABLE_CONSOLE_ACTIONS)
51  for (uint32_t i = 0; i < strlen(token);i++) {
52  char ch = token[i];
53  if (isupper(ch)) {
54  onCliCaseError(token);
55  return;
56  }
57  }
58  for (int i = 0; i < consoleActionCount; i++) {
59  if (strcmp(token, consoleActions[i].token) == 0 /* zero result means strings are equal */) {
60  onCliDuplicateError(token);
61  return;
62  }
63  }
64 
65  if (consoleActionCount >= CONSOLE_MAX_ACTIONS) {
67  return;
68  }
69 
71  current->token = token;
72  current->parameterType = type;
73  current->callback = callback;
74  current->param = param;
75 #endif /* EFI_DISABLE_CONSOLE_ACTIONS */
76 }
pwm_settings ch[2]
static TokenCallback consoleActions[CONSOLE_MAX_ACTIONS]
static int consoleActionCount
void onCliOverflowError()
Definition: eficonsole.cpp:246
void onCliDuplicateError(const char *token)
Definition: eficonsole.cpp:242
void onCliCaseError(const char *token)
Definition: eficonsole.cpp:238
action_type_e parameterType
Definition: cli_registry.h:36
void(* callback)(void)
Definition: cli_registry.h:37
const char * token
Definition: cli_registry.h:35

Referenced by addConsoleAction(), addConsoleActionF(), addConsoleActionFF(), addConsoleActionFFF(), addConsoleActionFFFF(), addConsoleActionFFP(), addConsoleActionI(), addConsoleActionIF(), addConsoleActionII(), addConsoleActionIIP(), addConsoleActionIP(), addConsoleActionNANF(), addConsoleActionP(), addConsoleActionS(), addConsoleActionSP(), addConsoleActionSS(), addConsoleActionSSP(), addConsoleActionSSS(), and addConsoleActionSSSSS().

Here is the call graph for this function:
Here is the caller 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 205 of file cli_registry.cpp.

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

◆ getParameterCount()

static int getParameterCount ( action_type_e  parameterType)
static

Definition at line 163 of file cli_registry.cpp.

163  {
164  switch (parameterType) {
165  case NO_PARAMETER:
166  case NO_PARAMETER_P:
167  return 0;
168  case ONE_PARAMETER:
169  case ONE_PARAMETER_P:
170  case FLOAT_PARAMETER:
171  case STRING_PARAMETER:
172  return 1;
175  case STRING2_PARAMETER:
176  case STRING2_PARAMETER_P:
177  case TWO_INTS_PARAMETER:
179  case INT_FLOAT_PARAMETER:
180  return 2;
181  case STRING3_PARAMETER:
183  return 3;
185  return 4;
186  case STRING5_PARAMETER:
187  return 5;
188  default:
189  return -1;
190  }
191 }

Referenced by handleConsoleLineInternal(), and helpCommand().

Here is the caller graph for this function:

◆ handleActionWithParameter()

int handleActionWithParameter ( TokenCallback current,
char *  argv[],
int  argc 
)

Definition at line 290 of file cli_registry.cpp.

290  {
291  (void)argc;
292 
293  switch (current->parameterType) {
294  case NO_PARAMETER:
295  {
296  (*current->callback)();
297  return 0;
298  }
299  case NO_PARAMETER_P:
300  {
301  VoidPtr callbackS = (VoidPtr) current->callback;
302  (*callbackS)(current->param);
303  return 0;
304  }
305  case STRING_PARAMETER:
306  {
307  VoidCharPtr callbackS = (VoidCharPtr) current->callback;
308  (*callbackS)(argv[0]);
309  return 0;
310  }
311  case STRING_PARAMETER_P:
312  {
313  VoidCharPtrVoidPtr callbackS = (VoidCharPtrVoidPtr) current->callback;
314  (*callbackS)(argv[0], current->param);
315  return 0;
316  }
317  case STRING2_PARAMETER:
318  {
319  VoidCharPtrCharPtr callbackS = (VoidCharPtrCharPtr) current->callback;
320  (*callbackS)(argv[0], argv[1]);
321  return 0;
322  }
323  case STRING2_PARAMETER_P:
324  {
326  (*callbackS)(argv[0], argv[1], current->param);
327  return 0;
328  }
329  case STRING3_PARAMETER:
330  {
332  (*callbackS)(argv[0], argv[1], argv[2]);
333  return 0;
334  }
335  case STRING5_PARAMETER:
336  {
338  (*callbackS)(argv[0], argv[1], argv[2], argv[3], argv[4]);
339  return 0;
340  }
341  case TWO_INTS_PARAMETER:
342  {
343  int value[2];
344  for (int i = 0; i < 2; i++) {
345  value[i] = atoi(argv[i]);
346  if (absI(value[i]) == ATOI_ERROR_CODE) {
347  #if EFI_PROD_CODE || EFI_SIMULATOR
348  efiPrintf("not an integer [%s]", argv[0]);
349  #endif
350  return -1;
351  }
352  }
353  VoidIntInt callbackS = (VoidIntInt) current->callback;
354  (*callbackS)(value[0], value[1]);
355  return 0;
356  }
358  {
359  float value = atoff(argv[0]);
360  VoidFloat callbackF = (VoidFloat) current->callback;
361  (*callbackF)(value);
362  return 0;
363  }
364 
365  case FLOAT_PARAMETER:
366  {
367  float value = atoff(argv[0]);
368  if (std::isnan(value)) {
369  efiPrintf("invalid float [%s]", argv[0]);
370  return -1;
371  }
372  VoidFloat callbackF = (VoidFloat) current->callback;
373  (*callbackF)(value);
374  return 0;
375  }
376 
379  {
380  float value[2];
381  for (int i = 0; i < 2; i++) {
382  value[i] = atoff(argv[i]);
383  if (std::isnan(value[i])) {
384  efiPrintf("invalid float [%s]", argv[i]);
385  return -1;
386  }
387  }
388  if (current->parameterType == FLOAT_FLOAT_PARAMETER) {
389  VoidFloatFloat callbackS = (VoidFloatFloat) current->callback;
390  (*callbackS)(value[0], value[1]);
391  } else {
393  (*callbackS)(value[0], value[1], current->param);
394  }
395  return 0;
396  }
398  {
399  float value[3];
400  for (int i = 0; i < 3; i++) {
401  value[i] = atoff(argv[i]);
402  if (std::isnan(value[i])) {
403  efiPrintf("invalid float [%s]", argv[i]);
404  return -1;
405  }
406  }
407  VoidFloatFloatFloat callbackS = (VoidFloatFloatFloat) current->callback;
408  (*callbackS)(value[0], value[1], value[2]);
409  return 0;
410  }
412  {
413  float value[4];
414  for (int i = 0; i < 4; i++) {
415  value[i] = atoff(argv[i]);
416  if (std::isnan(value[i])) {
417  efiPrintf("invalid float [%s]", argv[i]);
418  return -1;
419  }
420  }
422  (*callbackS)(value[0], value[1], value[2], value[3]);
423  return 0;
424  }
425  case INT_FLOAT_PARAMETER:
426  {
427  int value1 = atoi(argv[0]);
428  if (absI(value1) == ATOI_ERROR_CODE) {
429  #if EFI_PROD_CODE || EFI_SIMULATOR
430  efiPrintf("not an integer [%s]", argv[0]);
431  #endif
432  return -1;
433  }
434  float value2 = atoff(argv[1]);
435  if (std::isnan(value2)) {
436  efiPrintf("invalid float [%s]", argv[1]);
437  return -1;
438  }
439  VoidIntFloat callback = (VoidIntFloat) current->callback;
440  callback(value1, value2);
441  return 0;
442  }
443  case ONE_PARAMETER_P:
444  case ONE_PARAMETER:
445  {
446  int value = atoi(argv[0]);
447  if (absI(value) == ATOI_ERROR_CODE) {
448  #if EFI_PROD_CODE || EFI_SIMULATOR
449  efiPrintf("not an integer [%s]", argv[0]);
450  #endif
451  return -1;
452  }
453  if (current->parameterType == ONE_PARAMETER_P) {
454  VoidIntVoidPtr callback1 = (VoidIntVoidPtr) current->callback;
455  (*callback1)(value, current->param);
456 
457  } else {
458  VoidInt callback1 = (VoidInt) current->callback;
459  (*callback1)(value);
460  }
461  return 0;
462  }
463  default:
464  efiPrintf("Unsupported parameterType %d", current->parameterType);
465  break;
466  }
467  return -1;
468 }
void(* VoidCharPtrCharPtr)(const char *, const char *)
Definition: cli_registry.h:68
void(* VoidFloat)(float)
Definition: cli_registry.h:56
void(* VoidCharPtrCharPtrVoidPtr)(const char *, const char *, void *)
Definition: cli_registry.h:69
void(* VoidIntInt)(int, int)
Definition: cli_registry.h:61
void(* VoidFloatFloatFloatFloat)(float, float, float, float)
Definition: cli_registry.h:59
void(* VoidCharPtrVoidPtr)(const char *, void *)
Definition: cli_registry.h:66
void(* VoidPtr)(void *)
Definition: cli_registry.h:53
void(* VoidIntVoidPtr)(int, void *)
Definition: cli_registry.h:55
void(* VoidCharPtr)(const char *)
Definition: cli_registry.h:65
void(* VoidInt)(int)
Definition: cli_registry.h:54
void(* VoidFloatFloatFloat)(float, float, float)
Definition: cli_registry.h:58
void(* VoidFloatFloat)(float, float)
Definition: cli_registry.h:57
void(* VoidCharPtrCharPtrCharPtrCharPtrCharPtr)(const char *, const char *, const char *, const char *, const char *)
Definition: cli_registry.h:72
void(* VoidIntFloat)(int, float)
Definition: cli_registry.h:63
void(* VoidCharPtrCharPtrCharPtr)(const char *, const char *, const char *)
Definition: cli_registry.h:71
void(* VoidFloatFloatVoidPtr)(float, float, void *)
Definition: cli_registry.h:60
value1("SENT ch0 value1", SensorCategory.SENSOR_INPUTS, FieldType.INT16, 1794, 1.0, 0.0, 4095.0, "RAW")

Referenced by handleConsoleLineInternal().

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

◆ handleConsoleLine()

void handleConsoleLine ( char *  line)

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

Definition at line 508 of file cli_registry.cpp.

508  {
509  if (line == NULL)
510  return; // error detected
511 
512  int lineLength = strlen(line);
513  if (lineLength > MAX_CMD_LINE_LENGTH) {
514  // todo: better reaction to excessive line
515  efiPrintf("Long line?");
516  return;
517  }
518 
519  int ret = handleConsoleLineInternal(line);
520 
521  if (ret < 0) {
522  efiPrintf("failed to handle command [%s]", line);
523  return;
524  }
525 
526  efiPrintf("confirmation_%s:%d", line, lineLength);
527 }
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:

◆ handleConsoleLineInternal()

static int handleConsoleLineInternal ( const char *  commandLine)
static

Definition at line 476 of file cli_registry.cpp.

476  {
477  strncpy(handleBuffer, commandLine, sizeof(handleBuffer) - 1);
478 
479  char *argv[10];
480  int argc = setargs(handleBuffer, argv, 10);
481 
482  if (argc <= 0) {
483  efiPrintf("invalid input");
484  return -1;
485  }
486 
487  for (int i = 0; i < consoleActionCount; i++) {
488  TokenCallback *current = &consoleActions[i];
489  if (strEqual(argv[0], current->token)) {
490  if ((argc - 1) != getParameterCount(current->parameterType)) {
491  efiPrintf("Incorrect argument count %d, expected %d",
492  (argc - 1), getParameterCount(current->parameterType));
493  return -1;
494  }
495 
496  /* skip commant name */
497  return handleActionWithParameter(current, argv + 1, argc - 1);
498  }
499  }
500 
501  efiPrintf("unknown command [%s]", commandLine);
502  return -1;
503 }
static int setargs(char *args, char **argv, int max_args)
static int getParameterCount(action_type_e parameterType)
static char handleBuffer[MAX_CMD_LINE_LENGTH+1]
int handleActionWithParameter(TokenCallback *current, char *argv[], int argc)

Referenced by handleConsoleLine().

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 196 of file cli_registry.cpp.

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

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 470 of file cli_registry.cpp.

470  {
471  addConsoleAction("help", helpCommand);
472 }
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:

◆ resetConsoleActions()

void resetConsoleActions ( void  )

Definition at line 45 of file cli_registry.cpp.

45  {
47 }

◆ setargs()

static int setargs ( char *  args,
char **  argv,
int  max_args 
)
static

Definition at line 251 of file cli_registry.cpp.

252 {
253  int count = 0;
254 
255  while (isspace(*args)) {
256  *args = '\0';
257  args++;
258  }
259  while ((*args) && (count < max_args)) {
260  if (argv) {
261  argv[count] = args;
262  }
263  while ((*args) && (!isspace(*args))) {
264  if (*args == '"') {
265  args++;
266  /* find closing quote */
267  while ((*args) && (*args != '"')) {
268  args++;
269  }
270  /* failed? */
271  if (*args == '\0') {
272  return -1;
273  }
274  }
275  args++;
276  }
277  if (*args) {
278  *args = '\0';
279  args++;
280  }
281  while (isspace(*args)) {
282  *args = '\0';
283  args++;
284  }
285  count++;
286  }
287  return count;
288 }

Referenced by handleConsoleLineInternal().

Here is the caller graph for this function:

◆ tokenLength()

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

Definition at line 228 of file cli_registry.cpp.

228  {
229  int result = 0;
230  while (*msgp) {
231  char ch = *msgp++;
232  if (ch == SPACE_CHAR) {
233  break;
234  }
235  result++;
236  }
237  return result;
238 }

◆ unquote()

char* unquote ( char *  line)

Definition at line 240 of file cli_registry.cpp.

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

Variable Documentation

◆ consoleActionCount

int consoleActionCount = 0
static

◆ consoleActions

TokenCallback consoleActions[CONSOLE_MAX_ACTIONS]
static

Definition at line 43 of file cli_registry.cpp.

Referenced by doAddAction(), handleConsoleLineInternal(), and helpCommand().

◆ handleBuffer

char handleBuffer[MAX_CMD_LINE_LENGTH+1]
static

Definition at line 474 of file cli_registry.cpp.

Referenced by handleConsoleLineInternal().

Go to the source code of this file.