Skip to content

Commit

Permalink
Removed legacy terminal commands
Browse files Browse the repository at this point in the history
Use queue for CAN printing
  • Loading branch information
jsphuebner committed Sep 13, 2023
1 parent 462509f commit 84138fa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 89 deletions.
4 changes: 3 additions & 1 deletion include/param_prj.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion libopeninv
6 changes: 5 additions & 1 deletion src/stm32_sine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -430,7 +435,6 @@ extern "C" int main(void)
if (canSdo->GetPrintRequest() == PRINT_JSON)
{
TerminalCommands::PrintParamsJson(canSdo, &c);
canSdo->SignalPrintComplete();
}
}

Expand Down
89 changes: 3 additions & 86 deletions src/terminal_prj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[] =
{
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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
}

Expand All @@ -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);
}

0 comments on commit 84138fa

Please sign in to comment.