CLI encapsulation preparing for libfirmware move

This commit is contained in:
rusefillc 2023-08-08 23:02:20 -04:00
parent c4eb8fc9f8
commit b21455e178
4 changed files with 14 additions and 2 deletions

View File

@ -208,6 +208,10 @@ void onCliDuplicateError(const char *token) {
firmwareError(ObdCode::CUSTOM_SAME_TWICE, "Same action twice [%s]", token);
}
void onCliOverflowError() {
firmwareError(ObdCode::CUSTOM_CONSOLE_TOO_MANY, "Too many console actions");
}
void initializeConsole() {
initConsoleLogic();

View File

@ -14,9 +14,10 @@
* @author Andrey Belomutskiy, (c) 2012-2020
*/
#include "pch.h"
#include <cstring>
#include <cstdint>
#include <rusefi/isnan.h>
#include <rusefi/math.h>
#include "efiprintf.h"
#include "efistringutil.h"
#include "cli_registry.h"
@ -58,7 +59,11 @@ static void doAddAction(const char *token, action_type_e type, Void callback, vo
}
}
efiAssertVoid(ObdCode::CUSTOM_CONSOLE_TOO_MANY, consoleActionCount < CONSOLE_MAX_ACTIONS, "Too many console actions");
if (consoleActionCount >= CONSOLE_MAX_ACTIONS) {
onCliOverflowError();
return;
}
TokenCallback *current = &consoleActions[consoleActionCount++];
current->token = token;
current->parameterType = type;

View File

@ -105,6 +105,7 @@ void addConsoleActionSSSSS(const char *token, VoidCharPtrCharPtrCharPtrCharPtrCh
void onCliCaseError(const char *token);
void onCliDuplicateError(const char *token);
void onCliOverflowError();
#ifdef __cplusplus
}

View File

@ -34,3 +34,5 @@ void onCliCaseError(const char *token) {
void onCliDuplicateError(const char *token) {
}
void onCliOverflowError() {
}