Main Page   Data Structures   File List   Data Fields   Globals  

/cmdline.h

00001 /*! \file cmdline.c \brief Command-Line Interface Library. */
00002 //*****************************************************************************
00003 //
00004 // File Name    : 'cmdline.c'
00005 // Title        : Command-Line Interface Library
00006 // Author       : Pascal Stang - Copyright (C) 2003
00007 // Created      : 2003.07.16
00008 // Revised      : 2003.07.16
00009 // Version      : 0.1
00010 // Target MCU   : Atmel AVR Series
00011 // Editor Tabs  : 4
00012 //
00013 // Description  :
00014 //      This Command-Line interface library is meant to provide a reusable
00015 //  terminal-like user interface much like a DOS command line or UNIX terminal.
00016 //
00017 //  The cmdline library does the following things for you:
00018 //      -Prints command prompts
00019 //      -Gathers a command string from the user (with editing features)
00020 //      -Parses the command string when the user presses [ENTER]
00021 //      -Compares the entered command to the command database
00022 //        \-Executes the corresponding function if a match is found
00023 //        \-Reports an error if no match is found
00024 //      -Provides functions to retrieve the command arguments:
00025 //        \-as strings
00026 //        \-as decimal integers
00027 //        \-as hex integers
00028 //
00029 //  Supported editing features include:
00030 //      -Backspace support
00031 //      -Mid-line editing, inserting and deleting (left/right-arrows)
00032 //      -Command History (up-arrow) (currently only one command deep)
00033 //
00034 //  To use the cmdline system, you will need to associate command strings
00035 //  (commands the user will be typing) with your function that you wish to have
00036 //  called when the user enters that command.  This is done by using the
00037 //  cmdlineAddCommand() function.
00038 //
00039 //  To setup the cmdline system, you must do these things:
00040 //      -Initialize it: cmdlineInit()
00041 //      -Add one or more commands to the database: cmdlineAddCommand()
00042 //      -Set an output function for your terminal: cmdlineSetOutputFunc()
00043 //
00044 //  To operate the cmdline system, you must do these things repeatedly:
00045 //      -Pass user input from the terminal to: cmdlineSetOutputFunc()
00046 //      -Call cmdlineMainLoop() from your program's main loop
00047 //
00048 //  The cmdline library does not assume an input or output device, but can be
00049 //  configured to use any user function for output using cmdlineSetOutputFunc()
00050 //  and accepts input by calling cmdlineInputFunc().  This means the cmdline
00051 //  library can operate over any interface including UART (serial port),
00052 //  I2c, ethernet, etc.
00053 //
00054 //  ***** FOR MORE INFORMATION ABOUT USING cmdline SEE THE AVRLIB EXAMPLE *****
00055 //  ***** CODE IN THE avrlib/examples DIRECTORY                           *****
00056 //
00057 // NOTE: This code is currently below version 1.0, and therefore is considered
00058 // to be lacking in some functionality or documentation, or may not be fully
00059 // tested.  Nonetheless, you can expect most functions to work.
00060 //
00061 // This code is distributed under the GNU Public License
00062 //      which can be found at http://www.gnu.org/licenses/gpl.txt
00063 //
00064 //*****************************************************************************
00065 
00066 #ifndef CMDLINE_H
00067 #define CMDLINE_H
00068 
00069 #include "global.h"
00070 
00071 // constants/macros/typdefs
00072 typedef void (*CmdlineFuncPtrType)(void);
00073 
00074 // functions
00075 
00076 //! initalize the command line system
00077 void cmdlineInit(void);
00078 
00079 //! add a new command to the database of known commands
00080 // newCmdString should be a null-terminated command string with no whitespace
00081 // newCmdFuncPtr should be a pointer to the function to execute when
00082 //   the user enters the corresponding command tring
00083 void cmdlineAddCommand(u08* newCmdString, CmdlineFuncPtrType newCmdFuncPtr);
00084 
00085 //! sets the function used for sending characters to the user terminal
00086 void cmdlineSetOutputFunc(void (*output_func)(unsigned char c));
00087 
00088 //! call this function to pass input charaters from the user terminal
00089 void cmdlineInputFunc(unsigned char c);
00090 
00091 //! call this function in your program's main loop
00092 void cmdlineMainLoop(void);
00093 
00094 // internal commands
00095 void cmdlineRepaint(void);
00096 void cmdlineDoHistory(u08 action);
00097 void cmdlineProcessInputString(void);
00098 void cmdlinePrintPrompt(void);
00099 void cmdlinePrintError(void);
00100 
00101 // argument retrieval commands
00102 //! returns a string pointer to argument number [argnum] on the command line
00103 u08* cmdlineGetArgStr(u08 argnum);
00104 //! returns the decimal integer interpretation of argument number [argnum]
00105 long cmdlineGetArgInt(u08 argnum);
00106 //! returns the hex integer interpretation of argument number [argnum]
00107 long cmdlineGetArgHex(u08 argnum);
00108 
00109 #endif

Generated on Fri Aug 1 10:42:41 2003 for Procyon AVRlib by doxygen1.2.18