From 84138fa47df01ed25b8adcb119d828d53b9f8af8 Mon Sep 17 00:00:00 2001 From: jsphuebner Date: Wed, 13 Sep 2023 22:48:50 +0200 Subject: [PATCH] Removed legacy terminal commands Use queue for CAN printing --- include/param_prj.h | 4 +- libopeninv | 2 +- src/stm32_sine.cpp | 6 ++- src/terminal_prj.cpp | 89 ++------------------------------------------ 4 files changed, 12 insertions(+), 89 deletions(-) diff --git a/include/param_prj.h b/include/param_prj.h index 195c298..0412184 100644 --- a/include/param_prj.h +++ b/include/param_prj.h @@ -24,7 +24,7 @@ 2. Temporary parameters 3. Display values */ -//Next param id (increase when adding new parameter!): 157 +//Next param id (increase when adding new parameter!): 158 //Next value Id: 2052 /* category name unit min max default id */ @@ -154,6 +154,7 @@ PARAM_ENTRY(CAT_COMM, canperiod, CANPERIODS,0, 1, 0, 88 ) \ PARAM_ENTRY(CAT_COMM, nodeid, "", 1, 63, 1, 129 ) \ PARAM_ENTRY(CAT_COMM, controlid, "", 1, 2047, 63, 156 ) \ + PARAM_ENTRY(CAT_COMM, controlcheck,CHECKS, 0, 1, 1, 157 ) \ TESTP_ENTRY(CAT_TEST, manualstart, ONOFF, 0, 1, 0, 150 ) \ #define VALUE_BLOCK1 \ @@ -274,6 +275,7 @@ #define HWREVS "0=Rev1, 1=Rev2, 2=Rev3, 3=Tesla, 4=BluePill, 5=Prius" #define SWAPS "0=None, 1=Currents12, 2=SinCos, 4=PWMOutput13, 8=PWMOutput23" #define STATUS "0=None, 1=UdcLow, 2=UdcHigh, 4=UdcBelowUdcSw, 8=UdcLim, 16=EmcyStop, 32=MProt, 64=PotPressed, 128=TmpHs, 256=WaitStart, 512=BrakeCheck" +#define CHECKS "0=CounterOnly, 1=StmCrc8" #define CAT_MOTOR "Motor" #define CAT_INVERTER "Inverter" #define CAT_THROTTLE "Throttle" diff --git a/libopeninv b/libopeninv index 3e70495..614dc63 160000 --- a/libopeninv +++ b/libopeninv @@ -1 +1 @@ -Subproject commit 3e704952f9ee74d790ee01abcc66e46642787dc0 +Subproject commit 614dc63d3cc414abf47403502fbe0b89a1ef8528 diff --git a/src/stm32_sine.cpp b/src/stm32_sine.cpp index 8d309f7..e28be38 100644 --- a/src/stm32_sine.cpp +++ b/src/stm32_sine.cpp @@ -217,9 +217,14 @@ static void Ms10Task(void) VehicleControl::SetContactorsOffState(); PwmGeneration::SetOpmode(MOD_OFF); Throttle::cruiseSpeed = -1; + TerminalCommands::EnableSaving(); + canSdo->EnableSaving(); } else if (0 == initWait) { + //Disable saving in Run mode + TerminalCommands::DisableSaving(); + canSdo->DisableSaving(); PwmGeneration::SetTorquePercent(0); Throttle::RampThrottle(0); //Restart ramp Encoder::Reset(); @@ -430,7 +435,6 @@ extern "C" int main(void) if (canSdo->GetPrintRequest() == PRINT_JSON) { TerminalCommands::PrintParamsJson(canSdo, &c); - canSdo->SignalPrintComplete(); } } diff --git a/src/terminal_prj.cpp b/src/terminal_prj.cpp index 0c5435e..96380ba 100644 --- a/src/terminal_prj.cpp +++ b/src/terminal_prj.cpp @@ -32,15 +32,10 @@ #include "terminalcommands.h" static void LoadDefaults(Terminal* term, char *arg); -static void GetAll(Terminal* term, char *arg); -static void PrintList(Terminal* term, char *arg); -static void PrintAtr(Terminal* term, char *arg); static void StopInverter(Terminal* term, char *arg); static void StartInverter(Terminal* term, char *arg); -static void Help(Terminal* term, char *arg); static void PrintSerial(Terminal* term, char *arg); static void PrintErrors(Terminal* term, char *arg); -static void SaveParameters(Terminal* term, char *arg); extern "C" const TERM_CMD TermCmds[] = { @@ -51,75 +46,17 @@ extern "C" const TERM_CMD TermCmds[] = { "binstream", TerminalCommands::ParamStreamBinary }, { "json", TerminalCommands::PrintParamsJson }, { "can", TerminalCommands::MapCan }, - { "save", SaveParameters }, + { "save", TerminalCommands::SaveParameters }, { "load", TerminalCommands::LoadParameters }, { "reset", TerminalCommands::Reset }, { "defaults", LoadDefaults }, - { "all", GetAll }, - { "list", PrintList }, - { "atr", PrintAtr }, { "stop", StopInverter }, { "start", StartInverter }, - { "help", Help }, { "serial", PrintSerial }, { "errors", PrintErrors }, { NULL, NULL } }; -static void SaveParameters(Terminal* term, char *arg) -{ - arg = arg; - if (Param::GetInt(Param::opmode) == 0) - { - TerminalCommands::SaveParameters(term, arg); - } - else - { - fprintf(term, "Will not write to flash in run modes, please stop inverter before saving!\r\n"); - } -} - -static void PrintList(Terminal* term, char *arg) -{ - const Param::Attributes *pAtr; - - arg = arg; - term = term; - - printf("Available parameters and values\r\n"); - - for (uint32_t idx = 0; idx < Param::PARAM_LAST; idx++) - { - pAtr = Param::GetAttrib((Param::PARAM_NUM)idx); - - if ((Param::GetFlag((Param::PARAM_NUM)idx) & Param::FLAG_HIDDEN) == 0) - printf("%s [%s]\r\n", pAtr->name, pAtr->unit); - } -} - -static void PrintAtr(Terminal* term, char *arg) -{ - const Param::Attributes *pAtr; - - arg = arg; - term = term; - - printf("Parameter attributes\r\n"); - printf("Name\t\tmin - max [default]\r\n"); - - for (uint32_t idx = 0; idx < Param::PARAM_LAST; idx++) - { - pAtr = Param::GetAttrib((Param::PARAM_NUM)idx); - /* Only display for params */ - if ((Param::GetType((Param::PARAM_NUM)idx) == Param::TYPE_PARAM || - Param::GetType((Param::PARAM_NUM)idx) == Param::TYPE_TESTPARAM) && - (Param::GetFlag((Param::PARAM_NUM)idx) & Param::FLAG_HIDDEN) == 0) - { - printf("%s\t\t%f - %f [%f]\r\n", pAtr->name,pAtr->min,pAtr->max,pAtr->def); - } - } -} - static void LoadDefaults(Terminal* term, char *arg) { arg = arg; @@ -128,20 +65,6 @@ static void LoadDefaults(Terminal* term, char *arg) printf("Defaults loaded\r\n"); } -static void GetAll(Terminal* term, char *arg) -{ - const Param::Attributes *pAtr; - - arg = arg; - term = term; - - for (uint32_t idx = 0; idx < Param::PARAM_LAST; idx++) - { - pAtr = Param::GetAttrib((Param::PARAM_NUM)idx); - printf("%s\t\t%f\r\n", pAtr->name, Param::Get((Param::PARAM_NUM)idx)); - } -} - static void StopInverter(Terminal* term, char *arg) { arg = arg; @@ -167,7 +90,7 @@ static void StartInverter(Terminal* term, char *arg) printf("Invalid inverter mode"); } #else - printf("Not implemented in FOC variant\r\n"); + printf("Not implemented in FOC variant: openinverter.org/forum/viewtopic.php?t=2809\r\n"); #endif } @@ -182,12 +105,6 @@ static void PrintSerial(Terminal* term, char *arg) { arg = arg; term = term; - printf("%X%X%X\r\n", DESIG_UNIQUE_ID2, DESIG_UNIQUE_ID1, DESIG_UNIQUE_ID0); -} - -static void Help(Terminal* term, char *arg) -{ - arg = arg; - term = term; + printf("%X:%X:%X\r\n", DESIG_UNIQUE_ID2, DESIG_UNIQUE_ID1, DESIG_UNIQUE_ID0); }