Header-File for cmd_interface.c. More...
#include <stdio.h>
#include <string.h>
#include "string_addon.h"
Go to the source code of this file.
Data Structures | |
struct | cmd_interface_command_table_t |
Defines | |
#define | CMD_INTERFACE_H |
#define | _CMD_INTERFACE_MAX_LENGTH 80 |
#define | _CMD_INTERFACE_MAX_OPERAND_LENGTH 12 |
#define | _CMD_INTERFACE_MAX_NO_OPERANDS 5 |
#define | _CMD_INTERFACE_NO_OF_COMMANDS 10 |
#define | _CMD_INTERFACE_OPERAND_SPLIT_SIGN _ASCII_COMMA |
#define | _CMD_INTERFACE_COMMAND_SPLIT_SIGN _ASCII_SPACE |
#define | _CMD_INTERFACE_EOL _ASCII_CR |
#define | _CMD_INTERFACE_ERR_MASK 0xF8 |
#define | _CMD_INTERFACE_ERR_OP_2_MANY 0x90 |
#define | _CMD_INTERFACE_ERR_NO_CMD 0xA0 |
#define | _CMD_INTERFACE_ERR_CMD_LINE 0xB0 |
Functions | |
int8_t | execute_cmd_interface (char *string) |
routine called to execute command interface | |
void | cmd_interface_init () |
initialisation routine for command interface variables | |
uint8_t | cmd_interface_add_cmd (char(*cmd_string), uint8_t(*cmd_func_ptr)(int8_t argc, char *argval[])) |
adding a command to internal command - table | |
Variables | |
cmd_interface_command_table_t | cmd_interface_table [_CMD_INTERFACE_NO_OF_COMMANDS] |
Header-File for cmd_interface.c.
Simple implementation of an command-interface Target/Compiler: AVR_MEGA / GCC(WinAVR)
\
#define _CMD_INTERFACE_COMMAND_SPLIT_SIGN _ASCII_SPACE |
sign which splits command from operands in a cmd-line - ascii 32=Space
#define _CMD_INTERFACE_EOL _ASCII_CR |
End of Line - Sign = carriage return
#define _CMD_INTERFACE_ERR_CMD_LINE 0xB0 |
internal mask for error-bit "command-line too long"
#define _CMD_INTERFACE_ERR_MASK 0xF8 |
internal mask for bitcoding
#define _CMD_INTERFACE_ERR_NO_CMD 0xA0 |
internal mask for error-bit "no command"
#define _CMD_INTERFACE_ERR_OP_2_MANY 0x90 |
internal mask for error-bit "two many operands"
#define _CMD_INTERFACE_MAX_LENGTH 80 |
max number of signs allowed in a command line !! MUST be lower than 127 char
#define _CMD_INTERFACE_MAX_NO_OPERANDS 5 |
max. no of operands per command line including the command
#define _CMD_INTERFACE_MAX_OPERAND_LENGTH 12 |
max.number of signs per operand in a command line
#define _CMD_INTERFACE_NO_OF_COMMANDS 10 |
amount of possible commands
#define _CMD_INTERFACE_OPERAND_SPLIT_SIGN _ASCII_COMMA |
sign which splits operands of a cmd-line - ascii 44= komma
#define CMD_INTERFACE_H |
precompiler help
uint8_t cmd_interface_add_cmd | ( | char * | cmd_string, | |
uint8_t(*)(int8_t argc, char *argval[]) | cmd_func_ptr | |||
) |
adding a command to internal command - table
argc - number of parameters, argval[]- list of pointers to parameter strings. | ||
char | *cmd_string - String representing the command | |
uint8_t | (*cmd_func_ptr) - pointer to function which shall be executed if the command has been found |
This function shall add a given string and function-pointer to the internal command-table. The string in the command-table is used by the internal functions to determine whether a command is known or not. The function where the function-pointer is pointing to is called in the case the entered command matches to the given string. The function MUST have the following interface-declaration.... uint8_t cmd_func (int8_t argc, char *argval[])
void cmd_interface_init | ( | ) |
initialisation routine for command interface variables
none |
int8_t execute_cmd_interface | ( | char * | string | ) |
routine called to execute command interface
*string | - to attach at the actual command_line buffer |
This routine has to be called to execute the command-interface It attaches the forwarded string to the internal command-line buffer and its sub-functions interprets the line before it executes the corresponding command-function given by the user
cmd_interface_command_table_t cmd_interface_table[_CMD_INTERFACE_NO_OF_COMMANDS] |
internal table used to store the differen combinations of commands and functions