Add temperature profile executer and add shell command

This commit is contained in:
2021-03-19 20:19:37 +01:00
parent 1b4eba1871
commit 1ecd5edd93
7 changed files with 359 additions and 9 deletions

View File

@@ -41,6 +41,7 @@
#include <reflow-controller/safety/fault.h>
#include <reflow-controller/safety/safety-memory.h>
#include <reflow-controller/hw-version-detect.h>
#include <reflow-controller/temp-profile-executer.h>
#ifndef GIT_VER
#define GIT_VER "VERSION NOT SET"
@@ -683,6 +684,58 @@ shellmatta_retCode_t shell_cmd_overtemp_cfg(const shellmatta_handle_t handle, co
return ret;
}
shellmatta_retCode_t shell_cmd_execute(const shellmatta_handle_t handle, const char *args, uint32_t len)
{
enum pl_ret_val res;
const struct tpe_current_state *state;
static bool running = false;
char *data;
uint32_t dlen;
shellmatta_read(handle, &data, &dlen);
if (!running) {
res = temp_profile_executer_start("profile.tpr");
if (res != PL_RET_SUCCESS) {
switch (res) {
case PL_RET_DISK_ERR:
shellmatta_printf(handle, "Error reading file\r\n");
break;
case PL_RET_LIST_FULL:
shellmatta_printf(handle, "Script too long!\r\n");
break;
case PL_RET_SCRIPT_ERR:
shellmatta_printf(handle, "Error in script\r\n");
break;
default:
shellmatta_printf(handle, "Unspecified error occured\r\n");
break;
}
return SHELLMATTA_ERROR;
}
running = true;
} else {
state = temp_profile_executer_status();
if (state->status != TPE_RUNNING) {
shellmatta_printf(handle, "Profile executed.\r\n");
running = false;
if(state->status == TPE_ABORT) {
shellmatta_printf(handle, "Profile execution aborted!\r\n");
}
return SHELLMATTA_OK;
}
if (dlen > 0 && *data == '\x03') {
temp_profile_executer_stop();
return SHELLMATTA_OK;
}
}
return SHELLMATTA_CONTINUE;
}
//typedef struct shellmatta_cmd
//{
// char *cmd; /**< command name */
@@ -692,7 +745,7 @@ shellmatta_retCode_t shell_cmd_overtemp_cfg(const shellmatta_handle_t handle, co
// shellmatta_cmdFct_t cmdFct; /**< pointer to the cmd callack function */
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */
//} shellmatta_cmd_t;
static shellmatta_cmd_t cmd[20] = {
static shellmatta_cmd_t cmd[21] = {
{
.cmd = "version",
.cmdAlias = "ver",
@@ -852,6 +905,14 @@ static shellmatta_cmd_t cmd[20] = {
.helpText = "Overtemperature Config",
.usageText = "",
.cmdFct = shell_cmd_overtemp_cfg,
.next = &cmd[20],
},
{
.cmd = "execute",
.cmdAlias = NULL,
.helpText = "Execute Temp Profile",
.usageText = "",
.cmdFct = shell_cmd_execute,
.next = NULL,
}
};