commit dceb2526da34607c7239a6c518b56e84dd91fdf9 Author: cfif Date: Mon Jun 2 13:26:41 2025 +0300 Init diff --git a/CliHelp.c b/CliHelp.c new file mode 100644 index 0000000..57a66ae --- /dev/null +++ b/CliHelp.c @@ -0,0 +1,27 @@ +// +// Created by zemon on 01.12.22. +// + +#include "CliPrivate.h" + +int32_t CliCmd_baseCommandHelp(void *env, tCliCmd *cli) { + CliCmd_PrintLnStatic(cli, "================================================"); + CliCmd_PrintLnStatic(cli, "ACCESS COMANDS:"); + CliCmd_PrintLnStatic(cli, ""); + CliCmd_PrintLnStatic(cli, " [setting ] - switch to variable setting mode"); + CliCmd_VarsHelp(cli); + CliCmd_PrintLnStatic(cli, + "[ gnss_mode ] - switch in gnss mode, accessing to AT interface (ONLY TERMINAL CONNECTED)"); + CliCmdSerialBridge_Help(env, cli); + CliCmd_PrintLnStatic(cli, "[ set_flip ] - switch in mode setting flip params"); + CliCmd_flipModedHelp(env, cli); + CliCmd_PrintLnStatic(cli, "[ msd_info ] - switch in mode setting flip params"); + CliCmdMsdTable_Help(cli); + CliCmd_PrintLnStatic(cli, "[ emerTest ] - testing ecall and sendn support data"); + CliCmd_EcoolSimulationHelp(cli); + CliCmd_PrintLnStatic(cli, "[ reboot ] - full devise rebooting"); + CliCmd_rebootHelp(cli); + CliCmd_PrintLnStatic(cli, "[ addFun ] - additional function"); + CliCmd_powerStateHelp(cli); + return 0; +} \ No newline at end of file diff --git a/CliPrivate.h b/CliPrivate.h new file mode 100644 index 0000000..c55df62 --- /dev/null +++ b/CliPrivate.h @@ -0,0 +1,13 @@ +// +// Created by zemon on 20.02.24. +// + +#ifndef HEAVY_TERMINAL_CLIPRIVATE_H +#define HEAVY_TERMINAL_CLIPRIVATE_H + +#include "ComandLineInterface.h" + +int32_t CliCmd_baseCommandHelp(void *env, tCliCmd *cli); +void vTaskGetRunTime(void *env, tCliCmd *cli); + +#endif //HEAVY_TERMINAL_CLIPRIVATE_H diff --git a/ComandLineInterface.c b/ComandLineInterface.c new file mode 100644 index 0000000..9fca510 --- /dev/null +++ b/ComandLineInterface.c @@ -0,0 +1,100 @@ +// +// Created by zemon on 24.10.22. +// + +#include "CliPrivate.h" +#include "SystemDelayInterface.h" +#include "AsciiStringParsingUtils.h" +#include "stream.h" +#include "EraGlonassUveos.h" +#include "CliCmd/NetGsmUpDown.h" +#include "PowerManagment.h" + +void Cli_Init( + tCli *env, + tSerialPortIO *serial, + tSerialPortIO *serialSniffer, + tVariablesTable *extTable, + tCarFlipDetection *tFlip, + tEraGlonassMsdTable *msdTable, + tUveosEmergencySimulationInterface *uvEmrgSimInter, + tUserInputButtonWatcher *userIntButtWatch, + tEraGlonassUveosDumperInterface *dumperInterface, + tPowerManagement *power, + tGsmWithGnss *gsmWithGnss, + tEraGlonassUveos *uveos, + tAccelCoor *accelCoor, + tCarCrashDetection *carCrashDetection +) { + env->serialCommandPort = serial; + env->serialSnifferPort = serialSniffer; + env->externTable = extTable; + + CliCmd_InitStatic(&env->cmd, serial, env->mem.cmdRxLine); + CliRedirectionTable_InitStatic(&env->redirectTable, env->mem.commandPrefixes); + + CliCmdMsdTable_Init(&env->sub.msdTab, msdTable, dumperInterface); + CliCmd_FlipSettingInit(&env->sub.flipSet, tFlip, extTable, accelCoor, carCrashDetection); + + CliCmd_AddInfoInit(&env->sub.addFunc, gsmWithGnss, uveos, power); + + CliCmd_EcoolSimulationInit( + &env->sub.uvEmrgSimInter, + uvEmrgSimInter, + userIntButtWatch, + msdTable->items->msd.MSD_Data.additionalData.asi15, + tFlip->current.angleCos, + gsmWithGnss + ); + + if (serialSniffer != NULL) { + CliCmdSerialBridge_Init(&env->sub.serialBridge, serialSniffer); + CliRedirectionTable_RecAddStatic( + &env->redirectTable, + "gnss_mode", + (cliCall) CliCmdSerialBridge_Process, + &env->sub.serialBridge + ); + } + + CliRedirectionTable_RecAddStatic( + &env->redirectTable, + "msd_info", (cliCall) + CliCmdMsdTable_Process, + &env->sub.msdTab + ); + + CliRedirectionTable_RecAddStatic(&env->redirectTable, "help", (cliCall) CliCmd_baseCommandHelp, NULL); + CliRedirectionTable_RecAddStatic(&env->redirectTable, "set_flip", (cliCall) CliCmd_FlipSetting, &env->sub.flipSet); + CliRedirectionTable_RecAddStatic(&env->redirectTable, "addFun", (cliCall) CliCmd_AddInfo, &env->sub.addFunc); + CliRedirectionTable_RecAddStatic(&env->redirectTable, "reboot", (cliCall) CliCmd_CmsisReboot, NULL); + CliRedirectionTable_RecAddStatic(&env->redirectTable, "emerTest", (cliCall) CliCmd_EcoolSimulation, + &env->sub.uvEmrgSimInter); + CliRedirectionTable_RecAddStatic(&env->redirectTable, "mem", (cliCall) vTaskGetRunTime, NULL); + + //Инициализируем поток + InitThreadBlock(env->thread, "Cli", osPriorityNormal); +} + +void ListenCLICommand(tCli *env) { + CliCmd_WaitLine(&env->cmd); + if (CliRedirectionTable_ProcessCmd(&env->redirectTable, &env->cmd) != 0) { + CliCmd_PrintStatic(&env->cmd, "COMMAND NOT FOUND!"); + CliCmd_PrintStatic(&env->cmd, " EXECUTE COMMAND [ help ] OF MORE INFORMATION "); + } +} + +static _Noreturn void Cli_Thread(tCli *env) { + for (;;) { + ListenCLICommand(env); + SystemDelayMs(10); + } +} + +void Cli_StartThread(tCli *env) { + if (!env->thread.id) { + env->thread.id = osThreadNew((osThreadFunc_t) (Cli_Thread), (void *) (env), &env->thread.attr); + } else { + osThreadResume(env->thread.id); + } +} \ No newline at end of file diff --git a/ComandLineInterface.h b/ComandLineInterface.h new file mode 100644 index 0000000..05f6275 --- /dev/null +++ b/ComandLineInterface.h @@ -0,0 +1,72 @@ +// +// Created by zemon on 20.02.24. +// + +#ifndef HEAVY_TERMINAL_COMANDLINEINTERFACE_H +#define HEAVY_TERMINAL_COMANDLINEINTERFACE_H + +#include "CliRedirectTable.h" +#include "ComandLineInterface.h" +#include "CmsisRtosThreadUtils.h" + +#include "EraGlonassUveos_Dumper.h" +#include "CliCmd/CmsisReboot.h" +#include "CliCmd/Vars.h" +#include "CliCmd/SerialBridge.h" +#include "CliCmd/FlipSetting.h" +#include "CliCmd/MsdTable.h" +#include "CliCmd/EcoolSimulation.h" +#include "CliCmd/NetGsmUpDown.h" + +typedef struct { + struct { + char data[128]; + size_t length; + } rxCommandBuffer; + + char res[64]; + + tSerialPortIO *serialCommandPort; + tSerialPortIO *serialSnifferPort; + tVariablesTable *externTable; + + struct { + tCliRedirectItem commandPrefixes[10]; + uint8_t cmdRxLine[512]; + } mem; + + tCliRedirectTable redirectTable; + tCliCmd cmd; + + struct { + tCliCmdSerialBridge serialBridge; + tFlipSetting flipSet; + tCliCmdMsdTable msdTab; + tEcoolSimulation uvEmrgSimInter; + tAddFunc addFunc; + } sub; + + tStaticThreadBlock(1024) thread; +} tCli; + + +void Cli_Init( + tCli *env, + tSerialPortIO *serial, + tSerialPortIO *serialSniffer, + tVariablesTable *extTable, + tCarFlipDetection *tFlip, + tEraGlonassMsdTable *msdTable, + tUveosEmergencySimulationInterface *uvEmrgSimInter, + tUserInputButtonWatcher *userIntButtWatch, + tEraGlonassUveosDumperInterface *dumperInterface, + tPowerManagement *power, + tGsmWithGnss *gsmWithGnss, + tEraGlonassUveos *uveos, + tAccelCoor *tAccelCoor, + tCarCrashDetection *carCrashDetection +); + +void Cli_StartThread(tCli *env); + +#endif //HEAVY_TERMINAL_COMANDLINEINTERFACE_H diff --git a/TasksInfo.c b/TasksInfo.c new file mode 100644 index 0000000..d0303da --- /dev/null +++ b/TasksInfo.c @@ -0,0 +1,38 @@ +// +// Created by cfif on 17.12.2024. +// +#include +#include +#include "CliPrivate.h" + +void vTaskGetRunTime(void *env, tCliCmd *cli) { + + volatile UBaseType_t uxArraySize, x; + char bufSprintf[1024]; + + uxArraySize = uxTaskGetNumberOfTasks(); + + TaskStatus_t pxTaskStatusArray[uxArraySize]; + + + uxArraySize = uxTaskGetSystemState((void *) pxTaskStatusArray, uxArraySize, NULL); + + uint16_t p = 1; + bufSprintf[0] = '\n'; + + for (x = 0; x < uxArraySize; x++) { + + sprintf(&bufSprintf[p], "%lu\t%d\t%s\n", + pxTaskStatusArray[x].xTaskNumber, + pxTaskStatusArray[x].usStackHighWaterMark, + pxTaskStatusArray[x].pcTaskName); + + p = strlen(bufSprintf); + + } + + CliCmd_Print(cli, bufSprintf, p); +// LoggerStrInfo(LOGGER, LOG_SIGN, env->bufSprintf, strlen(env->bufSprintf)); + + +} \ No newline at end of file diff --git a/modular.json b/modular.json new file mode 100644 index 0000000..74a3fa6 --- /dev/null +++ b/modular.json @@ -0,0 +1,58 @@ +{ + "dep": [ + { + "type": "git", + "provider": "Smart_Components_Aurus", + "repo": "StreamBuf" + }, + { + "type": "git", + "provider": "Smart_Components_Aurus", + "repo": "CliCmd_RedirectTable" + }, + { + "type": "git", + "provider": "Smart_Components_Aurus", + "repo": "CliCmd_EcallSimulation" + }, + { + "type": "git", + "provider": "Smart_Components_Aurus", + "repo": "CliCmd_Reboot_CM4" + }, + { + "type": "git", + "provider": "Smart_Components_Aurus", + "repo": "CliCmd_Vars" + }, + { + "type": "git", + "provider": "Smart_Components_Aurus", + "repo": "CliCmd_MsdTable" + }, + { + "type": "git", + "provider": "Smart_Components_Aurus", + "repo": "CliCmd_SerialBridge" + }, + { + "type": "git", + "provider": "Smart_Components_Aurus", + "repo": "CliCmd_FlipSetting" + }, + { + "type": "git", + "provider": "Smart_Components_Aurus", + "repo": "CliCmd_netGsmUpDown" + } + ], + "cmake": { + "inc_dirs": [ + "./" + ], + "srcs": [ + "./**.c" + ] + } +} +