encapsulation
This commit is contained in:
parent
7cc8099584
commit
12e0473e19
|
@ -188,6 +188,18 @@ static void cmd_threads() {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This is just a test function
|
||||||
|
*/
|
||||||
|
static void echo(int value) {
|
||||||
|
efiPrintf("got value: %d", value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void checkStackAndHandleConsoleLine(char *line) {
|
||||||
|
assertStackVoid("console", ObdCode::STACK_USAGE_MISC, EXPECTED_REMAINING_STACK);
|
||||||
|
handleConsoleLine(line);
|
||||||
|
}
|
||||||
|
|
||||||
void initializeConsole() {
|
void initializeConsole() {
|
||||||
initConsoleLogic();
|
initConsoleLogic();
|
||||||
|
|
||||||
|
@ -195,6 +207,7 @@ void initializeConsole() {
|
||||||
|
|
||||||
sayHello();
|
sayHello();
|
||||||
addConsoleAction("test", [](){ /* do nothing */});
|
addConsoleAction("test", [](){ /* do nothing */});
|
||||||
|
addConsoleActionI("echo", echo);
|
||||||
addConsoleAction("hello", sayHello);
|
addConsoleAction("hello", sayHello);
|
||||||
#if EFI_HAS_RESET
|
#if EFI_HAS_RESET
|
||||||
addConsoleAction("reset", scheduleReset);
|
addConsoleAction("reset", scheduleReset);
|
||||||
|
|
|
@ -24,7 +24,9 @@
|
||||||
/* for isspace() */
|
/* for isspace() */
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#ifndef MAX_CMD_LINE_LENGTH
|
||||||
#define MAX_CMD_LINE_LENGTH 100
|
#define MAX_CMD_LINE_LENGTH 100
|
||||||
|
#endif
|
||||||
|
|
||||||
// todo: support \t as well
|
// todo: support \t as well
|
||||||
#define SPACE_CHAR ' '
|
#define SPACE_CHAR ' '
|
||||||
|
@ -178,21 +180,12 @@ static int getParameterCount(action_type_e parameterType) {
|
||||||
* @brief This function prints out a list of all available commands
|
* @brief This function prints out a list of all available commands
|
||||||
*/
|
*/
|
||||||
void helpCommand(void) {
|
void helpCommand(void) {
|
||||||
#if EFI_PROD_CODE || EFI_SIMULATOR
|
|
||||||
efiPrintf("%d actions available", consoleActionCount);
|
efiPrintf("%d actions available", consoleActionCount);
|
||||||
for (int i = 0; i < consoleActionCount; i++) {
|
for (int i = 0; i < consoleActionCount; i++) {
|
||||||
TokenCallback *current = &consoleActions[i];
|
TokenCallback *current = &consoleActions[i];
|
||||||
efiPrintf(" %s: %d parameters", current->token, getParameterCount(current->parameterType));
|
efiPrintf(" %s: %d parameters", current->token, getParameterCount(current->parameterType));
|
||||||
}
|
}
|
||||||
#endif
|
efiPrintf("For more visit https://github.com/rusefi/rusefi/wiki/Dev-Console-Commands");
|
||||||
efiPrintf("For more visit http://rusefi.com/wiki/index.php?title=Manual:Software:dev_console_commands");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief This is just a test function
|
|
||||||
*/
|
|
||||||
static void echo(int value) {
|
|
||||||
efiPrintf("got value: %d", value);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int findEndOfToken(const char *line) {
|
int findEndOfToken(const char *line) {
|
||||||
|
@ -461,9 +454,7 @@ int handleActionWithParameter(TokenCallback *current, char *argv[], int argc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initConsoleLogic() {
|
void initConsoleLogic() {
|
||||||
// resetConsoleActions();
|
|
||||||
addConsoleAction("help", helpCommand);
|
addConsoleAction("help", helpCommand);
|
||||||
addConsoleActionI("echo", echo);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static char handleBuffer[MAX_CMD_LINE_LENGTH + 1];
|
static char handleBuffer[MAX_CMD_LINE_LENGTH + 1];
|
||||||
|
@ -506,7 +497,6 @@ static int handleConsoleLineInternal(const char *commandLine, int lineLength) {
|
||||||
void handleConsoleLine(char *line) {
|
void handleConsoleLine(char *line) {
|
||||||
if (line == NULL)
|
if (line == NULL)
|
||||||
return; // error detected
|
return; // error detected
|
||||||
assertStackVoid("console", ObdCode::STACK_USAGE_MISC, EXPECTED_REMAINING_STACK);
|
|
||||||
|
|
||||||
int lineLength = strlen(line);
|
int lineLength = strlen(line);
|
||||||
if (lineLength > MAX_CMD_LINE_LENGTH) {
|
if (lineLength > MAX_CMD_LINE_LENGTH) {
|
||||||
|
@ -522,7 +512,5 @@ void handleConsoleLine(char *line) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if EFI_PROD_CODE || EFI_SIMULATOR
|
|
||||||
efiPrintf("confirmation_%s:%d", line, lineLength);
|
efiPrintf("confirmation_%s:%d", line, lineLength);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue