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

Simple implementation of an command-interface. More...

#include "cmd_interface.h"
#include <stdlib.h>
#include <string.h>
#include "string_addon.h"

Functions

int8_t execute_command ()
 internal function which executes the commands
int8_t split_command_line ()
 internal function which splits the act. command line into separated components, which are separated by split signs.
void cmd_interface_init ()
 initialisation routine for command interface variables
int8_t execute_cmd_interface (char *string)
 routine called to execute command interface

Variables

char cmd_line [_cmd_interface_max_length+1]

Detailed Description

Simple implementation of an command-interface.

Target/Compiler: AVR_MEGA / GCC(WinAVR)

Author:
Gerhard Bruenner
Version:
V2.0
Date:
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

\


Function Documentation

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
#1000 1XXX - #84 - operands have to many characters
#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

int8_t execute_command (  ) 

internal function which executes the commands

Parameters:
none 
Returns:
<0 - error
-1 - operands have to many characters (these are the ret_vals of split_command_line)
-2 - too many operands in the command-line (these are the ret_vals of split_command_line)
0 - no valid command
1 - a command hast been successfully executed.

this functions checks whether the given command exists in the command-table if it exists it executes the function referenced in the function-pointer which belongs the specific command.

int8_t split_command_line (  ) 

internal function which splits the act. command line into separated components, which are separated by split signs.

Parameters:
none 
Returns:
<0 - error
-1 - an operand has to many characters
-2 - too many operands in the command-line
>0 - number of strings/operands which have been found, means separated by split-signs.

Variable Documentation

char cmd_line[_cmd_interface_max_length+1]

* MAIN


Generated on Wed Nov 11 21:04:06 2009 for AVR_CMD_INTERFACE by  doxygen 1.6.1