Add temperature profile executer and add shell command
This commit is contained in:
		@@ -108,27 +108,37 @@ static int parse_line(char *line, struct pl_command *cmd)
 | 
			
		||||
	const char * const delim = " \t";
 | 
			
		||||
	const struct pl_command_list_map *map;
 | 
			
		||||
	char *endptr;
 | 
			
		||||
	struct pl_command c;
 | 
			
		||||
 | 
			
		||||
	if (!line || !cmd)
 | 
			
		||||
		return -1000;
 | 
			
		||||
 | 
			
		||||
	token = strtok(line, delim);
 | 
			
		||||
 | 
			
		||||
	if (!token) {
 | 
			
		||||
		/* Empty line or command line */
 | 
			
		||||
		return 1;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	while (token && token_idx <= PROFILE_LANG_MAX_NUM_ARGS) {
 | 
			
		||||
		switch (token_idx) {
 | 
			
		||||
		case 0:
 | 
			
		||||
			map = string_to_command(token);
 | 
			
		||||
			cmd->cmd = map->command;
 | 
			
		||||
			c.cmd = map->command;
 | 
			
		||||
			break;
 | 
			
		||||
		default:
 | 
			
		||||
			if (!map) {
 | 
			
		||||
				/* No valid command found */
 | 
			
		||||
				return -1;
 | 
			
		||||
			}
 | 
			
		||||
			cmd->params[token_idx - 1] = strtof(token, &endptr);
 | 
			
		||||
			c.params[token_idx - 1] = strtof(token, &endptr);
 | 
			
		||||
			if (endptr == token) {
 | 
			
		||||
				/* Invalid parameter */
 | 
			
		||||
				return -2;
 | 
			
		||||
			}
 | 
			
		||||
			if (token_idx > map->expected_param_count)
 | 
			
		||||
				return -3;
 | 
			
		||||
 | 
			
		||||
			break;
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@@ -136,6 +146,12 @@ static int parse_line(char *line, struct pl_command *cmd)
 | 
			
		||||
		token_idx++;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (token_idx - 1 < map->expected_param_count) {
 | 
			
		||||
		return -3;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	memcpy(cmd, &c, sizeof(struct pl_command));
 | 
			
		||||
 | 
			
		||||
	return 0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@@ -180,12 +196,14 @@ enum pl_ret_val temp_profile_parse_from_file(const char *filename,
 | 
			
		||||
 | 
			
		||||
		/* Parse the line */
 | 
			
		||||
		res = parse_line(workbuff, &cmd_list[cmd_idx]);
 | 
			
		||||
		if (res) {
 | 
			
		||||
		if (res < 0) {
 | 
			
		||||
			ret = PL_RET_SCRIPT_ERR;
 | 
			
		||||
			goto exit_close;
 | 
			
		||||
		} else if (res == 0) {
 | 
			
		||||
			cmd_idx++;
 | 
			
		||||
			*cmds_parsed= cmd_idx;
 | 
			
		||||
		}
 | 
			
		||||
		cmd_idx++;
 | 
			
		||||
		*cmds_parsed= cmd_idx;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	} while (!f_eof(&script_file));
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user