E:/Ablage_Gerhard/10_Hobby/Elektronik/30_Atmel/20_Prog/AVR_CMD_INTERFACE/cmd_interface.h File Reference

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]

Detailed Description

Header-File for cmd_interface.c.

Simple implementation of an command-interface Target/Compiler: AVR_MEGA / GCC(WinAVR)

Author:
Gerhard Bruenner
Version:
V2.03
Date:
2009.12.29 - GB created new function split_command_line() - now using own version of strtok. This reduced the operating-time of this function to the half of the previous version. Although changed the function-parameter interface of the user-function to uint8_t cmd_func (int8_t argc, char *argval[])
2009.11.15 - added function cmd_interface_add_cmd and Backspace-Function - GB
2009.10.31 - changed the way how commandline is interpret - GB
2009.10.21 - small updates - GB
2009.02.01 - Created - GB
Bug:
none that I am aware so far

\


Define Documentation

#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


Function Documentation

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

Parameters:
 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
Returns:
0 - all fine -1 - command-table is full

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

Parameters:
none 
Returns:
void
int8_t execute_cmd_interface ( char *  string  ) 

routine called to execute command interface

Parameters:
*string - to attach at the actual command_line buffer
Returns:
The content of the return-value have been split into two parts
The three lowest bits are used as counter for executed commands
The remaining "upper" bits represent bit-coded errors,
due to the possibilitiy of multiple errors per call.
<0 - error occured
#1001 0XXX - #84 - not used
#1001 0XXX - #90 - too many operands in the command-line
#1010 0XXX - A0 - no valid command found
#1100 0XXX - B0 - too many signs in comand-line
0 - no end of command-line detects
0> - number of commands which have been executed

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


Variable Documentation

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


Generated on Fri Jan 1 18:18:57 2010 for AVR_CMD_INTERFACE by  doxygen 1.6.1