2020-02-15 22:09:55 +01:00
|
|
|
/* Reflow Oven Controller
|
|
|
|
*
|
|
|
|
* Copyright (C) 2020 Mario Hüttel <mario.huettel@gmx.net>
|
|
|
|
*
|
|
|
|
* This file is part of the Reflow Oven Controller Project.
|
|
|
|
*
|
|
|
|
* The reflow oven controller is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
2020-02-21 21:22:01 +01:00
|
|
|
* The Reflow Oven Control Firmware is distributed in the hope that it will be useful,
|
2020-02-15 22:09:55 +01:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with the reflow oven controller project.
|
|
|
|
* If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2020-04-26 21:23:25 +02:00
|
|
|
#include <stm32/stm32f4xx.h>
|
|
|
|
#include <cmsis/core_cm4.h>
|
2020-02-12 21:00:35 +01:00
|
|
|
#include <reflow-controller/shell.h>
|
2020-02-12 21:06:52 +01:00
|
|
|
#include <stm-periph/uart.h>
|
2020-02-09 19:13:37 +01:00
|
|
|
#include <string.h>
|
2020-02-12 21:00:35 +01:00
|
|
|
#include <reflow-controller/adc-meas.h>
|
|
|
|
#include <reflow-controller/digio.h>
|
2020-02-10 22:38:24 +01:00
|
|
|
#include <stdlib.h>
|
2020-04-20 01:05:48 +02:00
|
|
|
#include <malloc.h>
|
2020-02-10 22:38:24 +01:00
|
|
|
#include <helper-macros/helper-macros.h>
|
2020-02-12 21:00:35 +01:00
|
|
|
#include <reflow-controller/systick.h>
|
2020-02-12 22:24:17 +01:00
|
|
|
#include <stm-periph/unique-id.h>
|
2020-02-15 01:04:40 +01:00
|
|
|
#include <reflow-controller/calibration.h>
|
2020-02-15 20:31:38 +01:00
|
|
|
#include <reflow-controller/temp-converter.h>
|
2020-04-26 21:23:25 +02:00
|
|
|
#include <fatfs/ff.h>
|
2020-09-07 21:56:04 +02:00
|
|
|
#include <reflow-controller/safety/stack-check.h>
|
2020-02-16 18:17:10 +01:00
|
|
|
#include <reflow-controller/rotary-encoder.h>
|
2020-07-28 22:55:02 +02:00
|
|
|
#include <reflow-controller/safety/safety-controller.h>
|
2020-08-16 01:24:59 +02:00
|
|
|
#include <reflow-controller/settings/settings.h>
|
2020-08-30 18:44:36 +02:00
|
|
|
#include <reflow-controller/button.h>
|
2020-09-05 16:56:56 +02:00
|
|
|
#include <reflow-controller/safety/fault.h>
|
2020-11-01 20:43:59 +01:00
|
|
|
#include <reflow-controller/safety/safety-memory.h>
|
2020-11-29 19:02:30 +01:00
|
|
|
#include <reflow-controller/hw-version-detect.h>
|
2021-03-19 20:19:37 +01:00
|
|
|
#include <reflow-controller/temp-profile-executer.h>
|
2021-04-06 20:55:41 +02:00
|
|
|
#include <reflow-controller/updater/updater.h>
|
2020-02-09 19:13:37 +01:00
|
|
|
|
|
|
|
#ifndef GIT_VER
|
|
|
|
#define GIT_VER "VERSION NOT SET"
|
|
|
|
#endif
|
|
|
|
|
2020-04-19 16:37:33 +02:00
|
|
|
extern struct stm_uart shell_uart;
|
2020-02-09 19:13:37 +01:00
|
|
|
static shellmatta_instance_t shell;
|
|
|
|
static char shell_buffer[512];
|
2020-11-29 17:19:40 +01:00
|
|
|
static char IN_SECTION(.ccm.bss) history_buffer[512];
|
2020-02-09 19:13:37 +01:00
|
|
|
|
|
|
|
static shellmatta_retCode_t shell_cmd_ver(const shellmatta_handle_t handle,
|
2020-02-21 23:08:38 +01:00
|
|
|
const char *arguments,
|
|
|
|
uint32_t length)
|
2020-02-09 19:13:37 +01:00
|
|
|
{
|
|
|
|
(void)arguments;
|
|
|
|
(void)length;
|
2020-02-12 22:24:17 +01:00
|
|
|
uint32_t low_id;
|
|
|
|
uint32_t mid_id;
|
|
|
|
uint32_t high_id;
|
2020-11-29 19:02:30 +01:00
|
|
|
const char *hw_rev_str;
|
|
|
|
enum hw_revision pcb_rev;
|
2020-02-12 22:24:17 +01:00
|
|
|
|
|
|
|
unique_id_get(&high_id, &mid_id, &low_id);
|
2020-02-09 19:13:37 +01:00
|
|
|
|
2020-02-12 21:53:13 +01:00
|
|
|
shellmatta_printf(handle, "Reflow Oven Controller Firmware " xstr(GIT_VER) "\r\n"
|
2020-08-30 18:44:36 +02:00
|
|
|
"Compiled: " __DATE__ " at " __TIME__ "\r\n");
|
2020-11-29 19:02:30 +01:00
|
|
|
shellmatta_printf(handle, "Serial: %08X-%08X-%08X\r\n", high_id, mid_id, low_id);
|
|
|
|
|
|
|
|
pcb_rev = get_pcb_hardware_version();
|
|
|
|
switch (pcb_rev) {
|
|
|
|
case HW_REV_V1_2:
|
|
|
|
hw_rev_str = "Hardware: v1.2";
|
|
|
|
break;
|
|
|
|
case HW_REV_V1_3:
|
|
|
|
hw_rev_str = "Hardware: v1.3";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
hw_rev_str = "Hardware: Unknown Revision. You might have to update the firmware!";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
shellmatta_printf(handle, "%s", hw_rev_str);
|
2020-02-09 19:13:37 +01:00
|
|
|
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
|
2020-02-10 22:38:24 +01:00
|
|
|
static shellmatta_retCode_t shell_cmd_digio_get(const shellmatta_handle_t handle,
|
2020-02-21 23:08:38 +01:00
|
|
|
const char *arguments,
|
|
|
|
uint32_t length)
|
2020-02-10 22:38:24 +01:00
|
|
|
{
|
|
|
|
(void)arguments;
|
|
|
|
(void)length;
|
|
|
|
|
|
|
|
shellmatta_printf(handle,
|
2020-02-21 23:08:38 +01:00
|
|
|
"DIGIO0 DIGIO1 DIGIO2 DIGIO3 LED0 LED1 LS\r\n"
|
|
|
|
"%d %d %d %d %d %d %d\r\n",
|
2020-02-10 22:38:24 +01:00
|
|
|
digio_get(0), digio_get(1), digio_get(2), digio_get(3),
|
|
|
|
led_get(0), led_get(1), loudspeaker_get());
|
|
|
|
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static shellmatta_retCode_t shell_cmd_digio_set(const shellmatta_handle_t handle,
|
2020-02-21 23:08:38 +01:00
|
|
|
const char *arguments,
|
|
|
|
uint32_t length)
|
2020-02-10 22:38:24 +01:00
|
|
|
{
|
2020-02-12 21:19:11 +01:00
|
|
|
(void)length;
|
|
|
|
(void)handle;
|
2020-02-10 22:38:24 +01:00
|
|
|
int num = 100;
|
|
|
|
int state;
|
|
|
|
char buff[64];
|
|
|
|
char *curr_token;
|
|
|
|
|
2020-02-23 21:57:50 +01:00
|
|
|
strncpy(buff, arguments, sizeof(buff)-1);
|
|
|
|
buff[63] = '\0';
|
2020-02-10 22:38:24 +01:00
|
|
|
|
|
|
|
curr_token = strtok(buff, " ");
|
|
|
|
curr_token = strtok(NULL, " ");
|
|
|
|
if (!curr_token)
|
|
|
|
return SHELLMATTA_ERROR;
|
|
|
|
|
|
|
|
num = atoi(curr_token);
|
|
|
|
|
|
|
|
if (!curr_token)
|
|
|
|
return SHELLMATTA_ERROR;
|
|
|
|
|
|
|
|
curr_token = strtok(NULL, " ");
|
|
|
|
state = atoi(curr_token);
|
|
|
|
|
|
|
|
if (num < 4 && num >= 0)
|
|
|
|
digio_set(num, state);
|
|
|
|
else if (num >= 4 && num <= 5)
|
|
|
|
led_set(num - 4, state);
|
|
|
|
else if (num == 6)
|
|
|
|
loudspeaker_set(state);
|
|
|
|
else
|
|
|
|
return SHELLMATTA_ERROR;
|
|
|
|
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
|
2020-02-09 19:13:37 +01:00
|
|
|
static shellmatta_retCode_t shell_cmd_pt1000_res(const shellmatta_handle_t handle,
|
|
|
|
const char *arguments,
|
|
|
|
uint32_t length)
|
|
|
|
{
|
|
|
|
(void)arguments;
|
|
|
|
(void)length;
|
|
|
|
float resistance;
|
|
|
|
int pt1000_status;
|
2020-02-15 01:04:40 +01:00
|
|
|
char display_status[100];
|
2020-02-15 20:31:38 +01:00
|
|
|
float temp;
|
|
|
|
int temp_conv_status;
|
|
|
|
const char *temp_prefix;
|
2020-02-09 19:13:37 +01:00
|
|
|
|
2020-02-15 01:04:40 +01:00
|
|
|
display_status[0] = 0;
|
2020-02-09 19:13:37 +01:00
|
|
|
|
|
|
|
pt1000_status = adc_pt1000_get_current_resistance(&resistance);
|
|
|
|
|
|
|
|
if (pt1000_status == 2) {
|
2020-02-15 01:04:40 +01:00
|
|
|
strcat(display_status, " UNSTABLE ");
|
2020-02-09 19:13:37 +01:00
|
|
|
} else if (pt1000_status) {
|
2020-07-27 22:15:01 +02:00
|
|
|
strcpy(display_status, "ERROR");
|
2020-02-15 01:04:40 +01:00
|
|
|
} else {
|
|
|
|
strcpy(display_status, "VALID");
|
2020-02-09 19:13:37 +01:00
|
|
|
}
|
|
|
|
|
2020-02-15 20:31:38 +01:00
|
|
|
temp_conv_status = temp_converter_convert_resistance_to_temp(resistance, &temp);
|
|
|
|
switch (temp_conv_status) {
|
|
|
|
case 1:
|
|
|
|
temp_prefix = ">";
|
|
|
|
break;
|
|
|
|
case -1:
|
|
|
|
temp_prefix = "<";
|
|
|
|
break;
|
|
|
|
case 0:
|
2020-02-15 21:06:45 +01:00
|
|
|
/* FALLTHRU */
|
2020-02-15 20:31:38 +01:00
|
|
|
default:
|
|
|
|
temp_prefix = "";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
shellmatta_printf(handle, "PT1000 resistance: %.2f Ohm (%s%.1f °C) [%s]\r\n", resistance, temp_prefix,temp, display_status);
|
2020-02-09 19:13:37 +01:00
|
|
|
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
2020-02-11 22:59:30 +01:00
|
|
|
|
|
|
|
static shellmatta_retCode_t shell_cmd_uptime(const shellmatta_handle_t handle,
|
|
|
|
const char *arguments,
|
|
|
|
uint32_t length)
|
|
|
|
{
|
|
|
|
(void)arguments;
|
|
|
|
(void)length;
|
2020-06-14 14:45:58 +02:00
|
|
|
uint32_t days;
|
|
|
|
uint32_t hours;
|
|
|
|
uint32_t mins;
|
|
|
|
uint32_t secs;
|
|
|
|
|
|
|
|
systick_get_uptime_from_tick(&days, &hours, &mins, &secs);
|
|
|
|
|
|
|
|
shellmatta_printf(handle, "Uptime: %u day%s %02u:%02u:%02u",
|
2020-08-30 18:44:36 +02:00
|
|
|
days, (days == 1 ? "" : "s"),
|
|
|
|
hours,
|
|
|
|
mins,
|
|
|
|
secs);
|
2020-02-11 22:59:30 +01:00
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
2020-02-15 01:04:40 +01:00
|
|
|
|
2020-02-15 17:53:15 +01:00
|
|
|
static shellmatta_retCode_t shell_cmd_cal(const shellmatta_handle_t handle,
|
2020-02-21 23:08:38 +01:00
|
|
|
const char *arguments,
|
|
|
|
uint32_t length)
|
2020-02-15 01:04:40 +01:00
|
|
|
{
|
2020-02-15 17:53:15 +01:00
|
|
|
(void)arguments;
|
|
|
|
(void)length;
|
2020-02-15 01:04:40 +01:00
|
|
|
|
2020-05-11 21:59:08 +02:00
|
|
|
return calibration_sequence_shell_cmd(handle, arguments, length);
|
2020-02-15 01:04:40 +01:00
|
|
|
}
|
2020-02-21 23:01:04 +01:00
|
|
|
|
2020-04-20 01:05:48 +02:00
|
|
|
static shellmatta_retCode_t shell_meminfo(const shellmatta_handle_t handle,
|
2020-05-09 20:40:31 +02:00
|
|
|
const char *arguments,
|
|
|
|
uint32_t length)
|
2020-02-21 23:01:04 +01:00
|
|
|
{
|
|
|
|
(void)arguments;
|
|
|
|
(void)length;
|
2020-04-20 01:05:48 +02:00
|
|
|
struct mallinfo mi;
|
2020-02-21 23:01:04 +01:00
|
|
|
|
|
|
|
shellmatta_printf(handle,
|
2020-02-21 23:08:38 +01:00
|
|
|
"Stack pointer: %p\r\n"
|
|
|
|
"Stack usage: 0x%x bytes\r\n"
|
|
|
|
"Lim to heap: 0x%x bytes\r\n",
|
|
|
|
read_stack_pointer(),
|
|
|
|
stack_check_get_usage(),
|
|
|
|
stack_check_get_free());
|
2020-04-20 01:05:48 +02:00
|
|
|
|
|
|
|
mi = mallinfo();
|
|
|
|
shellmatta_printf(handle, "\r\nDynamic Memory Management\r\n");
|
|
|
|
shellmatta_printf(handle, "Allocated bytes: %d\r\n", mi.arena, mi.arena);
|
|
|
|
shellmatta_printf(handle, "Number of free chunks: %d\r\n", mi.ordblks);
|
|
|
|
shellmatta_printf(handle, "Top-most, releasable space: %d\r\n", mi.keepcost);
|
|
|
|
shellmatta_printf(handle, "Total free space: %d\r\n", mi.fordblks);
|
|
|
|
shellmatta_printf(handle, "Total allocated space: %d\r\n", mi.uordblks);
|
|
|
|
|
2020-02-21 23:08:38 +01:00
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
|
2020-02-16 18:17:10 +01:00
|
|
|
static shellmatta_retCode_t shell_cmd_rot(const shellmatta_handle_t handle,
|
2020-02-21 23:08:38 +01:00
|
|
|
const char *arguments,
|
|
|
|
uint32_t length)
|
2020-02-16 18:17:10 +01:00
|
|
|
{
|
|
|
|
(void)arguments;
|
|
|
|
(void)length;
|
|
|
|
uint32_t rot_val;
|
|
|
|
|
|
|
|
rot_val = rotary_encoder_get_abs_val();
|
2020-06-12 01:35:37 +02:00
|
|
|
//delta = rotary_encoder_get_change_val();
|
|
|
|
shellmatta_printf(handle, "Rotary encoder value: %u\r\n", rot_val);
|
2020-02-16 18:17:10 +01:00
|
|
|
|
2020-02-21 23:01:04 +01:00
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
|
2020-04-19 16:37:33 +02:00
|
|
|
static shellmatta_retCode_t shell_cmd_pt1000_res_loop(const shellmatta_handle_t handle, const char *arguments,
|
|
|
|
uint32_t length)
|
|
|
|
{
|
2020-05-09 20:40:31 +02:00
|
|
|
(void)arguments;
|
|
|
|
(void)length;
|
|
|
|
static uint64_t timestamp = 0ULL;
|
2020-04-19 16:37:33 +02:00
|
|
|
|
2020-05-09 20:40:31 +02:00
|
|
|
if (systick_ticks_have_passed(timestamp, 150)) {
|
|
|
|
shell_cmd_pt1000_res(handle, "", 0UL);
|
|
|
|
timestamp = systick_get_global_tick();
|
2020-04-19 16:37:33 +02:00
|
|
|
}
|
|
|
|
|
2020-05-09 20:40:31 +02:00
|
|
|
return SHELLMATTA_CONTINUE;
|
2020-04-19 16:37:33 +02:00
|
|
|
}
|
|
|
|
|
2020-04-26 21:23:25 +02:00
|
|
|
static shellmatta_retCode_t shell_cmd_ls(const shellmatta_handle_t handle, const char *arguments,
|
2020-05-09 20:40:31 +02:00
|
|
|
uint32_t length)
|
2020-04-26 21:23:25 +02:00
|
|
|
{
|
|
|
|
(void)length;
|
|
|
|
(void)arguments;
|
|
|
|
DIR dir;
|
|
|
|
FRESULT res;
|
|
|
|
FILINFO fno;
|
|
|
|
|
|
|
|
res = f_opendir(&dir, "/");
|
|
|
|
if (res != FR_OK) {
|
|
|
|
shellmatta_printf(handle, "Filesystem inaccessible. Is an SD Card inserted?\r\n");
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (f_readdir(&dir, &fno) == FR_OK) {
|
|
|
|
if (fno.fname[0] == 0)
|
|
|
|
break;
|
|
|
|
shellmatta_printf(handle, "%c\t%s\r\n", (fno.fattrib & AM_DIR ? 'd' : 'f'), fno.fname);
|
|
|
|
}
|
|
|
|
|
|
|
|
f_closedir(&dir);
|
|
|
|
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
static shellmatta_retCode_t shell_cmd_reset(const shellmatta_handle_t handle, const char *arguments,
|
2020-05-09 20:40:31 +02:00
|
|
|
uint32_t length)
|
2020-04-26 21:23:25 +02:00
|
|
|
{
|
|
|
|
(void)handle;
|
|
|
|
(void)length;
|
|
|
|
(void)arguments;
|
|
|
|
|
|
|
|
NVIC_SystemReset();
|
|
|
|
|
|
|
|
return SHELLMATTA_BUSY;
|
|
|
|
}
|
2020-04-27 21:52:52 +02:00
|
|
|
|
2020-07-28 22:55:02 +02:00
|
|
|
static shellmatta_retCode_t shell_cmd_read_flags(const shellmatta_handle_t handle, const char *arguments,
|
2020-08-30 18:44:36 +02:00
|
|
|
uint32_t length)
|
2020-07-28 22:55:02 +02:00
|
|
|
{
|
|
|
|
(void)length;
|
|
|
|
(void)arguments;
|
2020-07-30 20:29:41 +02:00
|
|
|
uint32_t count;
|
2020-07-28 22:55:02 +02:00
|
|
|
uint32_t i;
|
|
|
|
char name[64];
|
|
|
|
bool flag;
|
2021-04-10 14:10:17 +02:00
|
|
|
bool tryack = false;
|
2020-07-28 22:55:02 +02:00
|
|
|
int status;
|
2020-09-21 21:51:00 +02:00
|
|
|
enum safety_flag flag_enum;
|
2020-07-30 20:29:41 +02:00
|
|
|
struct analog_monitor_info amon_info;
|
2020-08-16 12:34:41 +02:00
|
|
|
struct timing_monitor_info timing_info;
|
2021-04-10 14:10:17 +02:00
|
|
|
char *argument;
|
|
|
|
uint32_t len;
|
|
|
|
char option;
|
|
|
|
shellmatta_retCode_t opt_ret;
|
|
|
|
static const shellmatta_opt_long_t options[] = {
|
|
|
|
{"ack", 'a', SHELLMATTA_OPT_ARG_NONE},
|
|
|
|
{NULL, '\0', SHELLMATTA_OPT_ARG_NONE}
|
|
|
|
};
|
|
|
|
|
|
|
|
do {
|
|
|
|
opt_ret = shellmatta_opt_long(handle, options, &option, &argument, &len);
|
|
|
|
if (opt_ret != SHELLMATTA_OK) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (option) {
|
|
|
|
case 'a':
|
|
|
|
tryack = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while(1);
|
|
|
|
|
2020-07-28 22:55:02 +02:00
|
|
|
|
2020-09-21 21:51:00 +02:00
|
|
|
|
2021-01-09 23:44:25 +01:00
|
|
|
shellmatta_printf(handle, "Error Flags\r\n"
|
2020-08-30 18:44:36 +02:00
|
|
|
"-----------\r\n");
|
2020-07-28 22:55:02 +02:00
|
|
|
|
2020-07-30 20:29:41 +02:00
|
|
|
count = safety_controller_get_flag_count();
|
|
|
|
for (i = 0; i < count; i++) {
|
2020-07-28 22:55:02 +02:00
|
|
|
status = safety_controller_get_flag_name_by_index(i, name, sizeof(name));
|
|
|
|
if (status) {
|
|
|
|
shellmatta_printf(handle, "Error getting flag name %lu\r\n", i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-09-21 21:51:00 +02:00
|
|
|
status = safety_controller_get_flag_by_index(i, &flag, &flag_enum);
|
2020-07-28 22:55:02 +02:00
|
|
|
if (status) {
|
|
|
|
shellmatta_printf(handle, "Error getting flag value %lu\r\n", i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-09-21 21:51:00 +02:00
|
|
|
if (tryack)
|
|
|
|
safety_controller_ack_flag(flag_enum);
|
|
|
|
|
2020-07-30 20:29:41 +02:00
|
|
|
shellmatta_printf(handle, "\t%2lu) %-20s\t[%s]\r\n", i+1, name, (flag ? "\e[1;31mERR\e[m" : "\e[32mOK\e[m"));
|
|
|
|
}
|
|
|
|
|
|
|
|
shellmatta_printf(handle, "\r\nAnalog Monitors\r\n"
|
|
|
|
"---------------\r\n");
|
|
|
|
count = safety_controller_get_analog_monitor_count();
|
|
|
|
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
status = safety_controller_get_analog_mon_name_by_index(i, name, sizeof(name));
|
|
|
|
if (status) {
|
|
|
|
shellmatta_printf(handle, "Error getting analog value monitor %lu name\r\n", i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
status = safety_controller_get_analog_mon_by_index(i, &amon_info);
|
|
|
|
if (status) {
|
|
|
|
shellmatta_printf(handle, "Error reading analog monitor status %lu\r\n", i);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
shellmatta_printf(handle, "\t%2lu) %-20s\t[%s%8.2f%s]", i+1, name,
|
|
|
|
amon_info.status == ANALOG_MONITOR_OK ? "\e[32m" : "\e[1;31m",
|
|
|
|
amon_info.value,
|
|
|
|
"\e[m");
|
|
|
|
if (amon_info.status == ANALOG_MONITOR_INACTIVE) {
|
|
|
|
shellmatta_printf(handle, "Inactive\r\n");
|
|
|
|
} else {
|
|
|
|
shellmatta_printf(handle, " valid from %-8.2f to %-8.2f", amon_info.min, amon_info.max);
|
2020-09-27 22:13:49 +02:00
|
|
|
shellmatta_printf(handle, "\tchecked %llu ms ago\r\n",
|
|
|
|
systick_get_global_tick() - amon_info.timestamp);
|
2020-07-30 20:29:41 +02:00
|
|
|
}
|
2020-07-28 22:55:02 +02:00
|
|
|
}
|
2020-06-14 23:36:49 +02:00
|
|
|
|
2020-08-16 12:34:41 +02:00
|
|
|
shellmatta_printf(handle, "\r\nTiming Monitors\r\n"
|
2021-01-09 23:44:25 +01:00
|
|
|
"---------------\r\n");
|
2020-08-16 12:34:41 +02:00
|
|
|
|
|
|
|
|
|
|
|
count = safety_controller_get_timing_monitor_count();
|
|
|
|
for (i = 0; i < count; i++) {
|
|
|
|
(void)safety_controller_get_timing_mon_by_index(i, &timing_info);
|
|
|
|
(void)safety_controller_get_timing_mon_name_by_index(i, name, sizeof(name));
|
|
|
|
|
|
|
|
shellmatta_printf(handle, "\t%2lu) %-20s\t", i+1, name);
|
|
|
|
if (timing_info.enabled)
|
2020-08-21 00:20:16 +02:00
|
|
|
shellmatta_printf(handle, "last tick: %lu ms\r\n", (unsigned long int)timing_info.delta);
|
2020-08-16 12:34:41 +02:00
|
|
|
else
|
2020-08-21 00:20:16 +02:00
|
|
|
shellmatta_printf(handle, "\e[1;31mDISABLED\e[m\r\n");
|
2020-08-16 12:34:41 +02:00
|
|
|
}
|
|
|
|
|
2020-05-16 21:00:55 +02:00
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
|
2020-08-16 01:24:59 +02:00
|
|
|
static shellmatta_retCode_t shell_cmd_save_cal(const shellmatta_handle_t handle, const char *arguments,
|
2020-08-30 18:44:36 +02:00
|
|
|
uint32_t length)
|
2020-08-16 01:24:59 +02:00
|
|
|
|
|
|
|
{
|
|
|
|
(void)length;
|
|
|
|
(void)arguments;
|
|
|
|
int res;
|
2020-08-16 12:52:16 +02:00
|
|
|
float offset, sens_dev;
|
|
|
|
bool active;
|
|
|
|
|
|
|
|
adc_pt1000_get_resistance_calibration(&offset, &sens_dev, &active);
|
|
|
|
res = settings_save_calibration(sens_dev, offset, active);
|
2020-08-16 01:24:59 +02:00
|
|
|
|
|
|
|
if (res) {
|
|
|
|
shellmatta_printf(handle, "Error saving %d\r\n", res);
|
|
|
|
} else {
|
|
|
|
shellmatta_printf(handle, "Saved!\r\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
2020-08-21 00:29:19 +02:00
|
|
|
|
|
|
|
static shellmatta_retCode_t shell_cmd_hang(const shellmatta_handle_t handle, const char *arguments,
|
2020-08-30 18:44:36 +02:00
|
|
|
uint32_t length)
|
2020-08-21 00:29:19 +02:00
|
|
|
{
|
|
|
|
(void)handle;
|
|
|
|
(void)arguments;
|
|
|
|
(void)length;
|
|
|
|
|
|
|
|
while (1337);
|
|
|
|
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
|
2020-08-30 18:44:36 +02:00
|
|
|
static shellmatta_retCode_t shell_cmd_ui_emulation(const shellmatta_handle_t handle, const char *arguments,
|
|
|
|
uint32_t length)
|
|
|
|
{
|
|
|
|
(void)length;
|
|
|
|
(void)arguments;
|
|
|
|
uint32_t i;
|
|
|
|
uint32_t len;
|
|
|
|
char *buff;
|
|
|
|
|
|
|
|
shellmatta_read(handle, &buff, &len);
|
|
|
|
|
|
|
|
for (i = 0; i < len; i++) {
|
|
|
|
switch (buff[i]) {
|
|
|
|
case 'W':
|
|
|
|
case 'w':
|
|
|
|
rotary_encoder_override_delta(4);
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
case 'S':
|
|
|
|
rotary_encoder_override_delta(-4);
|
|
|
|
break;
|
|
|
|
case '\r':
|
|
|
|
button_override_event(BUTTON_SHORT_RELEASED);
|
|
|
|
break;
|
|
|
|
case 'l':
|
|
|
|
case 'L':
|
|
|
|
button_override_event(BUTTON_LONG);
|
|
|
|
break;
|
|
|
|
case 'k':
|
|
|
|
case 'K':
|
|
|
|
button_override_event(BUTTON_SHORT);
|
|
|
|
break;
|
|
|
|
case 'r':
|
|
|
|
case 'R':
|
|
|
|
button_override_event(BUTTON_LONG_RELEASED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return SHELLMATTA_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2020-09-05 16:56:56 +02:00
|
|
|
static shellmatta_retCode_t shell_cmd_panic(const shellmatta_handle_t handle, const char *arguments,
|
|
|
|
uint32_t length)
|
|
|
|
|
|
|
|
{
|
|
|
|
(void)handle;
|
|
|
|
(void)arguments;
|
|
|
|
(void)length;
|
|
|
|
|
|
|
|
panic_mode();
|
|
|
|
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
|
2020-11-01 20:43:59 +01:00
|
|
|
static char *get_safety_mem_dump(size_t *used_bytes)
|
|
|
|
{
|
|
|
|
char *buffer;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
buffer = (char *)malloc(5470);
|
|
|
|
|
|
|
|
res = safety_memory_dump_base64(buffer, 5470UL, used_bytes);
|
|
|
|
if (res) {
|
|
|
|
if (buffer)
|
|
|
|
free(buffer);
|
|
|
|
buffer = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
|
|
|
static shellmatta_retCode_t shell_cmd_dump_safety_mem(const shellmatta_handle_t handle, const char *arguments,
|
|
|
|
uint32_t length)
|
|
|
|
{
|
|
|
|
static char *buffer;
|
|
|
|
static const char *ptr;
|
|
|
|
size_t used_bytes;
|
|
|
|
static size_t full_lines = 0;
|
|
|
|
static size_t current_line;
|
|
|
|
size_t remainder;
|
|
|
|
static const char *hline = "----------------------------------------------------------------";
|
2020-11-02 18:21:24 +01:00
|
|
|
char string[200];
|
|
|
|
const char *token;
|
|
|
|
const char * const token_delim = "\t ";
|
|
|
|
FRESULT fres;
|
|
|
|
FIL file;
|
|
|
|
UINT bw;
|
|
|
|
|
|
|
|
/* Check if the dump shall be stored to disk */
|
|
|
|
strncpy(string, arguments, MIN(sizeof(string), length+1));
|
|
|
|
string[sizeof(string) - 1] = '\0';
|
|
|
|
|
|
|
|
token = strtok(string, token_delim);
|
|
|
|
token = strtok(NULL, token_delim);
|
|
|
|
|
|
|
|
if (token) {
|
|
|
|
buffer = get_safety_mem_dump(&used_bytes);
|
|
|
|
if (!buffer) {
|
|
|
|
shellmatta_printf(handle, "Error generating dump");
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
fres = f_open(&file, token, FA_CREATE_NEW | FA_WRITE);
|
|
|
|
if (fres == FR_EXIST) {
|
|
|
|
free(buffer);
|
|
|
|
shellmatta_printf(handle, "File already esists!\r\n");
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
} else if (fres != FR_OK) {
|
|
|
|
free(buffer);
|
|
|
|
shellmatta_printf(handle, "Error opening file %s\r\n", token);
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
fres = f_write(&file, buffer, used_bytes - 1, &bw);
|
|
|
|
if (fres != FR_OK) {
|
|
|
|
shellmatta_printf(handle, "Error writing to file %s\r\n", token);
|
|
|
|
}
|
|
|
|
free(buffer);
|
|
|
|
f_close(&file);
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
2020-11-01 20:43:59 +01:00
|
|
|
|
|
|
|
if (full_lines == 0) {
|
|
|
|
shellmatta_printf(handle, "Safety memory content\r\n%s\r\n", hline);
|
|
|
|
|
|
|
|
buffer = get_safety_mem_dump(&used_bytes);
|
|
|
|
if (!buffer) {
|
|
|
|
shellmatta_printf(handle, "Error dumping memory!\r\n");
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
full_lines = (used_bytes - 1) / 64;
|
|
|
|
remainder = (used_bytes - 1) % 64;
|
|
|
|
if (remainder)
|
|
|
|
full_lines++;
|
|
|
|
|
|
|
|
ptr = buffer;
|
|
|
|
current_line = 0;
|
|
|
|
return SHELLMATTA_BUSY;
|
|
|
|
} else {
|
|
|
|
if (current_line < full_lines) {
|
|
|
|
shellmatta_printf(handle, "%.64s\r\n", ptr);
|
|
|
|
ptr += 64;
|
|
|
|
current_line++;
|
|
|
|
} else {
|
|
|
|
shellmatta_printf(handle, "%s\r\n", hline);
|
|
|
|
full_lines = 0;
|
|
|
|
if (buffer)
|
|
|
|
free(buffer);
|
|
|
|
buffer = NULL;
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return SHELLMATTA_BUSY;
|
|
|
|
}
|
|
|
|
|
2020-11-17 00:53:21 +01:00
|
|
|
shellmatta_retCode_t shell_cmd_reset_cal(const shellmatta_handle_t handle, const char *arguments, uint32_t length)
|
|
|
|
{
|
|
|
|
(void)handle;
|
|
|
|
(void)arguments;
|
|
|
|
(void)length;
|
|
|
|
|
|
|
|
adc_pt1000_set_resistance_calibration(0.0f, 0.0f, false);
|
|
|
|
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
|
2020-12-14 20:29:51 +01:00
|
|
|
shellmatta_retCode_t shell_cmd_update(const shellmatta_handle_t handle, const char *arguments, uint32_t length)
|
|
|
|
{
|
|
|
|
(void)handle;
|
|
|
|
(void)arguments;
|
|
|
|
(void)length;
|
|
|
|
|
2021-04-07 13:26:39 +02:00
|
|
|
updater_update_from_file("update.hex");
|
2020-12-14 20:29:51 +01:00
|
|
|
|
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
|
2021-03-14 21:56:21 +01:00
|
|
|
shellmatta_retCode_t shell_cmd_overtemp_cfg(const shellmatta_handle_t handle, const char *args, uint32_t len)
|
|
|
|
{
|
|
|
|
float overtemp_lim;
|
|
|
|
shellmatta_retCode_t ret;
|
|
|
|
char *argument;
|
|
|
|
uint32_t arg_length;
|
|
|
|
char option;
|
|
|
|
bool temp_passed = false;
|
|
|
|
bool persistent = false;
|
2021-03-19 20:24:49 +01:00
|
|
|
(void)args;
|
|
|
|
(void)len;
|
2021-03-14 21:56:21 +01:00
|
|
|
|
|
|
|
static const shellmatta_opt_long_t options[] = {
|
|
|
|
{"persistent", 'p', SHELLMATTA_OPT_ARG_NONE},
|
|
|
|
{NULL, '\0', SHELLMATTA_OPT_ARG_NONE},
|
|
|
|
};
|
|
|
|
|
|
|
|
do {
|
|
|
|
ret = shellmatta_opt_long(handle, options, &option, &argument, &arg_length);
|
|
|
|
if (ret != SHELLMATTA_OK)
|
|
|
|
break;
|
|
|
|
switch (option) {
|
|
|
|
case 'p':
|
|
|
|
persistent = true;
|
|
|
|
break;
|
|
|
|
case '\0':
|
|
|
|
temp_passed = true;
|
|
|
|
overtemp_lim = strtof(argument, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} while (1);
|
|
|
|
|
|
|
|
if (temp_passed) {
|
|
|
|
safety_controller_set_overtemp_limit(overtemp_lim);
|
|
|
|
if (persistent)
|
|
|
|
settings_save_overtemp_limit(overtemp_lim, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
overtemp_lim = safety_controller_get_overtemp_limit();
|
|
|
|
shellmatta_printf(handle, "Overtemperature configured for: %.1f °C\r\n", overtemp_lim);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-03-19 20:19:37 +01:00
|
|
|
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;
|
2021-03-19 20:24:49 +01:00
|
|
|
(void)args;
|
|
|
|
(void)len;
|
2021-03-21 21:07:54 +01:00
|
|
|
int opt_stat;
|
|
|
|
char option;
|
|
|
|
char *argument;
|
|
|
|
uint32_t arg_len;
|
|
|
|
const char *script_name = NULL;
|
|
|
|
const shellmatta_opt_long_t options[] = {
|
|
|
|
{NULL, '\0', SHELLMATTA_OPT_ARG_NONE},
|
|
|
|
};
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
opt_stat = shellmatta_opt_long(handle, options, &option, &argument, &arg_len);
|
|
|
|
if (opt_stat != SHELLMATTA_OK)
|
|
|
|
break;
|
|
|
|
switch (option) {
|
|
|
|
case '\0':
|
|
|
|
script_name = argument;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!script_name) {
|
|
|
|
shellmatta_printf(handle, "No script name specified!\r\n");
|
|
|
|
return SHELLMATTA_ERROR;
|
|
|
|
}
|
2021-03-19 20:19:37 +01:00
|
|
|
|
|
|
|
shellmatta_read(handle, &data, &dlen);
|
|
|
|
|
|
|
|
if (!running) {
|
2021-03-21 21:07:54 +01:00
|
|
|
res = temp_profile_executer_start(script_name);
|
2021-03-19 20:19:37 +01:00
|
|
|
|
|
|
|
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();
|
2021-03-21 19:21:36 +01:00
|
|
|
running = false;
|
2021-03-19 20:19:37 +01:00
|
|
|
return SHELLMATTA_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return SHELLMATTA_CONTINUE;
|
|
|
|
}
|
|
|
|
|
2020-02-09 19:13:37 +01:00
|
|
|
//typedef struct shellmatta_cmd
|
|
|
|
//{
|
|
|
|
// char *cmd; /**< command name */
|
|
|
|
// char *cmdAlias; /**< command alias */
|
|
|
|
// char *helpText; /**< help text to print in "help" command */
|
|
|
|
// char *usageText; /**< usage text to print on parameter error */
|
|
|
|
// shellmatta_cmdFct_t cmdFct; /**< pointer to the cmd callack function */
|
|
|
|
// struct shellmatta_cmd *next; /**< pointer to next command or NULL */
|
|
|
|
//} shellmatta_cmd_t;
|
2021-03-19 20:19:37 +01:00
|
|
|
static shellmatta_cmd_t cmd[21] = {
|
2020-02-09 19:13:37 +01:00
|
|
|
{
|
|
|
|
.cmd = "version",
|
|
|
|
.cmdAlias = "ver",
|
|
|
|
.helpText = "Print firmware version",
|
|
|
|
.usageText = NULL,
|
|
|
|
.cmdFct = shell_cmd_ver,
|
|
|
|
.next = &cmd[1],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = "pt1000",
|
|
|
|
.cmdAlias = "pt",
|
|
|
|
.helpText = "Get current filtered and calibrated PT1000 resistance",
|
|
|
|
.usageText = NULL,
|
|
|
|
.cmdFct = shell_cmd_pt1000_res,
|
|
|
|
.next = &cmd[2],
|
|
|
|
},
|
2020-04-19 16:37:33 +02:00
|
|
|
{
|
|
|
|
.cmd = "pt1000-dump",
|
|
|
|
.cmdAlias = "ptdump",
|
|
|
|
.helpText = "Get current filtered and calibrated PT1000 resistance in a loop",
|
2020-05-09 20:40:31 +02:00
|
|
|
.usageText = "pt1000-dump",
|
2020-04-19 16:37:33 +02:00
|
|
|
.cmdFct = shell_cmd_pt1000_res_loop,
|
|
|
|
.next = &cmd[3],
|
|
|
|
},
|
2020-02-10 22:38:24 +01:00
|
|
|
{
|
|
|
|
.cmd = "digio-get",
|
|
|
|
.cmdAlias = "dg",
|
|
|
|
.helpText = "Read all digital input/output ports",
|
|
|
|
.usageText = NULL,
|
|
|
|
.cmdFct = shell_cmd_digio_get,
|
2020-07-27 22:15:01 +02:00
|
|
|
.next = &cmd[4],
|
2020-02-10 22:38:24 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = "digio-set",
|
|
|
|
.cmdAlias = "ds",
|
|
|
|
.helpText = "Set DIGIO Port",
|
|
|
|
.usageText = "digio-set <num> <state>",
|
|
|
|
.cmdFct = shell_cmd_digio_set,
|
2020-07-27 22:15:01 +02:00
|
|
|
.next = &cmd[5],
|
2020-02-11 22:59:30 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = "uptime",
|
|
|
|
.cmdAlias = "upt",
|
|
|
|
.helpText = "Get uptime in seconds",
|
|
|
|
.usageText = "",
|
|
|
|
.cmdFct = shell_cmd_uptime,
|
2020-07-27 22:15:01 +02:00
|
|
|
.next = &cmd[6],
|
2020-02-09 19:13:37 +01:00
|
|
|
},
|
2020-02-15 01:04:40 +01:00
|
|
|
{
|
2020-02-15 17:53:15 +01:00
|
|
|
.cmd = "calibrate",
|
|
|
|
.cmdAlias = "cal",
|
|
|
|
.helpText = "Calibrate resistance measurement",
|
2020-02-15 01:04:40 +01:00
|
|
|
.usageText = "",
|
2020-02-15 17:53:15 +01:00
|
|
|
.cmdFct = shell_cmd_cal,
|
2020-07-27 22:15:01 +02:00
|
|
|
.next = &cmd[7],
|
2020-02-21 23:01:04 +01:00
|
|
|
},
|
|
|
|
{
|
2020-04-20 01:05:48 +02:00
|
|
|
.cmd = "meminfo",
|
|
|
|
.cmdAlias = NULL,
|
|
|
|
.helpText = "Get information about memory usage",
|
2020-02-21 23:01:04 +01:00
|
|
|
.usageText = "",
|
2020-04-20 01:05:48 +02:00
|
|
|
.cmdFct = shell_meminfo,
|
2020-07-27 22:15:01 +02:00
|
|
|
.next = &cmd[8],
|
2020-02-21 23:08:38 +01:00
|
|
|
},
|
2020-02-16 18:17:10 +01:00
|
|
|
{
|
|
|
|
.cmd = "rotary-encoder",
|
|
|
|
.cmdAlias = "rot",
|
|
|
|
.helpText = "Get current rotary encoder value",
|
|
|
|
.usageText = "",
|
|
|
|
.cmdFct = shell_cmd_rot,
|
2020-07-27 22:15:01 +02:00
|
|
|
.next = &cmd[9],
|
2020-04-26 21:23:25 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = "ls",
|
|
|
|
.cmdAlias = NULL,
|
|
|
|
.helpText = "List filesystem contents",
|
|
|
|
.usageText = "",
|
|
|
|
.cmdFct = shell_cmd_ls,
|
2020-07-27 22:15:01 +02:00
|
|
|
.next = &cmd[10],
|
2020-04-26 21:23:25 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = "reset",
|
|
|
|
.cmdAlias = NULL,
|
|
|
|
.helpText = "Reset controller",
|
2020-04-27 21:52:52 +02:00
|
|
|
.usageText = "reset",
|
2020-04-26 21:23:25 +02:00
|
|
|
.cmdFct = shell_cmd_reset,
|
2020-07-27 22:15:01 +02:00
|
|
|
.next = &cmd[11],
|
2020-04-27 21:52:52 +02:00
|
|
|
},
|
2020-07-28 22:55:02 +02:00
|
|
|
{
|
|
|
|
.cmd = "safety-flags",
|
|
|
|
.cmdAlias = "flags",
|
2020-09-21 21:51:00 +02:00
|
|
|
.helpText = "Reads and may clear safety flags",
|
|
|
|
.usageText = "flags [--ack]",
|
2020-07-28 22:55:02 +02:00
|
|
|
.cmdFct = shell_cmd_read_flags,
|
2021-02-15 20:35:54 +01:00
|
|
|
.next = &cmd[12],
|
2020-08-16 01:24:59 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = "save-calibration",
|
|
|
|
.cmdAlias = "save-cal",
|
|
|
|
.helpText = "",
|
|
|
|
.usageText = "",
|
|
|
|
.cmdFct = shell_cmd_save_cal,
|
2021-02-15 20:35:54 +01:00
|
|
|
.next = &cmd[13],
|
2020-08-16 01:24:59 +02:00
|
|
|
},
|
2020-08-21 00:29:19 +02:00
|
|
|
{
|
|
|
|
.cmd = "hang",
|
|
|
|
.cmdAlias = NULL,
|
|
|
|
.helpText = "",
|
|
|
|
.usageText = "",
|
|
|
|
.cmdFct = shell_cmd_hang,
|
2021-02-15 20:35:54 +01:00
|
|
|
.next = &cmd[14],
|
2020-08-30 18:44:36 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = "ui-emulate",
|
|
|
|
.cmdAlias = NULL,
|
|
|
|
.helpText = "",
|
|
|
|
.usageText = "",
|
|
|
|
.cmdFct = shell_cmd_ui_emulation,
|
2021-02-15 20:35:54 +01:00
|
|
|
.next = &cmd[15],
|
2020-09-05 16:56:56 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = "panic",
|
|
|
|
.cmdAlias = NULL,
|
|
|
|
.helpText = "Panic Mode!",
|
|
|
|
.usageText = "",
|
|
|
|
.cmdFct = shell_cmd_panic,
|
2021-02-15 20:35:54 +01:00
|
|
|
.next = &cmd[16],
|
2020-11-01 20:43:59 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = "safety-mem-dump",
|
|
|
|
.cmdAlias = NULL,
|
|
|
|
.helpText = "",
|
2020-11-02 18:21:24 +01:00
|
|
|
.usageText = "safety-mem-dump [output-file]",
|
2020-11-01 20:43:59 +01:00
|
|
|
.cmdFct = shell_cmd_dump_safety_mem,
|
2021-02-15 20:35:54 +01:00
|
|
|
.next = &cmd[17],
|
2020-08-30 18:44:36 +02:00
|
|
|
},
|
2020-11-17 00:53:21 +01:00
|
|
|
{
|
|
|
|
.cmd = "reset-cal",
|
|
|
|
.cmdAlias = NULL,
|
|
|
|
.helpText = "Reset Calibration",
|
|
|
|
.usageText = "",
|
|
|
|
.cmdFct = shell_cmd_reset_cal,
|
2021-02-15 20:35:54 +01:00
|
|
|
.next = &cmd[18],
|
2020-12-14 20:29:51 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = "update",
|
|
|
|
.cmdAlias = NULL,
|
2021-04-06 20:55:41 +02:00
|
|
|
.helpText = "Update Firmware. The updater searches for a file called update.hex",
|
|
|
|
.usageText = "update",
|
2020-12-14 20:29:51 +01:00
|
|
|
.cmdFct = shell_cmd_update,
|
2021-03-14 21:56:21 +01:00
|
|
|
.next = &cmd[19],
|
2020-12-14 20:29:51 +01:00
|
|
|
|
2021-03-14 21:56:21 +01:00
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = "overtemp",
|
|
|
|
.cmdAlias = NULL,
|
|
|
|
.helpText = "Overtemperature Config",
|
|
|
|
.usageText = "",
|
|
|
|
.cmdFct = shell_cmd_overtemp_cfg,
|
2021-03-19 20:19:37 +01:00
|
|
|
.next = &cmd[20],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
.cmd = "execute",
|
|
|
|
.cmdAlias = NULL,
|
|
|
|
.helpText = "Execute Temp Profile",
|
2021-04-04 17:43:31 +02:00
|
|
|
.usageText = "execute /path/to/script.tpr",
|
2021-03-19 20:19:37 +01:00
|
|
|
.cmdFct = shell_cmd_execute,
|
2021-03-14 21:56:21 +01:00
|
|
|
.next = NULL,
|
2020-11-17 00:53:21 +01:00
|
|
|
}
|
2020-02-09 19:13:37 +01:00
|
|
|
};
|
|
|
|
|
2020-02-24 18:50:09 +01:00
|
|
|
shellmatta_handle_t shell_init(shellmatta_write_t write_func)
|
2020-02-09 19:13:37 +01:00
|
|
|
{
|
|
|
|
shellmatta_handle_t handle;
|
|
|
|
shellmatta_retCode_t ret;
|
|
|
|
|
|
|
|
ret = shellmatta_doInit(&shell, &handle, shell_buffer, sizeof(shell_buffer), history_buffer, sizeof(history_buffer),
|
2020-04-20 00:15:37 +02:00
|
|
|
"\e[1;32mReflow Controller>\e[m ", cmd, write_func);
|
2020-02-09 19:13:37 +01:00
|
|
|
if (ret != SHELLMATTA_OK)
|
|
|
|
handle = NULL;
|
|
|
|
|
|
|
|
return handle;
|
|
|
|
}
|
|
|
|
|
2020-04-26 21:23:25 +02:00
|
|
|
void shell_print_motd(shellmatta_handle_t shell)
|
|
|
|
{
|
2020-04-27 20:19:38 +02:00
|
|
|
/* Clear display and set cursor to home position */
|
|
|
|
shellmatta_printf(shell, "\e[2J\e[H");
|
2020-07-30 20:29:41 +02:00
|
|
|
shellmatta_printf(shell, "Shimatta Reflow Controller ready\r\n\r\n");
|
2020-04-26 21:23:25 +02:00
|
|
|
shell_cmd_ver(shell, NULL, 0UL);
|
|
|
|
shell_handle_input(shell, "\r\n", 2UL);
|
|
|
|
}
|
2020-02-09 19:13:37 +01:00
|
|
|
|
|
|
|
void shell_handle_input(shellmatta_handle_t shell, const char *data, size_t len)
|
|
|
|
{
|
2020-02-21 23:08:38 +01:00
|
|
|
if (!shell)
|
|
|
|
return;
|
2020-02-09 19:13:37 +01:00
|
|
|
|
2020-02-21 23:08:38 +01:00
|
|
|
shellmatta_processData(shell, (char *)data, (uint32_t)len);
|
2020-02-09 19:13:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void shell_print_string(shellmatta_handle_t shell, const char *string)
|
|
|
|
{
|
|
|
|
if (!shell)
|
|
|
|
return;
|
|
|
|
|
|
|
|
shellmatta_write(shell, (char *)string, strlen(string));
|
|
|
|
}
|