Issue #26: Add overtemp function to shell
This commit is contained in:
		@@ -641,6 +641,48 @@ shellmatta_retCode_t shell_cmd_update(const shellmatta_handle_t handle, const ch
 | 
			
		||||
	return SHELLMATTA_OK;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
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;
 | 
			
		||||
 | 
			
		||||
	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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
//typedef struct shellmatta_cmd
 | 
			
		||||
//{
 | 
			
		||||
//    char                    *cmd;       /**< command name                           */
 | 
			
		||||
@@ -650,7 +692,7 @@ shellmatta_retCode_t shell_cmd_update(const shellmatta_handle_t handle, const ch
 | 
			
		||||
//    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[19] = {
 | 
			
		||||
static shellmatta_cmd_t cmd[20] = {
 | 
			
		||||
	{
 | 
			
		||||
		.cmd = "version",
 | 
			
		||||
		.cmdAlias = "ver",
 | 
			
		||||
@@ -801,8 +843,16 @@ static shellmatta_cmd_t cmd[19] = {
 | 
			
		||||
		.helpText = "Update Firmware",
 | 
			
		||||
		.usageText = "",
 | 
			
		||||
		.cmdFct = shell_cmd_update,
 | 
			
		||||
		.next = NULL,
 | 
			
		||||
		.next = &cmd[19],
 | 
			
		||||
 | 
			
		||||
	},
 | 
			
		||||
	{
 | 
			
		||||
		.cmd = "overtemp",
 | 
			
		||||
		.cmdAlias = NULL,
 | 
			
		||||
		.helpText = "Overtemperature Config",
 | 
			
		||||
		.usageText = "",
 | 
			
		||||
		.cmdFct = shell_cmd_overtemp_cfg,
 | 
			
		||||
		.next = NULL,
 | 
			
		||||
	}
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user