Jean Mercier / Mbed 2 deprecated jmMotor

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers jmMessages.c Source File

jmMessages.c

00001 /*************************************************************************
00002  * @file     jmMessages.c
00003  * @brief    Control System Messages
00004  *                  
00005  * @date    December 27,2010 
00006 */
00007 
00008 #include "jmCommands.h"
00009 #include "jmRingBuffer.h"
00010 #include "stdio.h"
00011 #include "jmMessages.h"
00012 #include "stdint.h"
00013 #include "LPC17xx.h"
00014 
00015 uint8_t Help;
00016 uint8_t Feedback;
00017 uint8_t Echo;
00018 
00019 
00020 /** @brief Enable only help messages
00021  * @param none
00022  * @returns none
00023  */
00024 void InitMessages(void){
00025    Help = 1;
00026    Echo = 0;
00027    Feedback = 0;
00028 }
00029  
00030 /** @brief Send all command names in a project
00031  * @param none
00032  * @returns none
00033  */
00034 void cli_list(void){
00035    int i,j;
00036    printf("Commands:\n");
00037    printf(".......................\n");
00038    // for each command 
00039    for(i=0,j=0; i<nbCommands; i++,j++){
00040       // print name
00041       while(cmdNames[j]) printf("%c",cmdNames[j++]); 
00042       printf("\n"); 
00043    }
00044    printf("........................\n");
00045 }
00046 
00047 /** @brief Send Message Unknown Command from interpreter
00048  * @param none
00049  * @returns none
00050  */
00051 void UnknownCommand(void){
00052    printf("\n?\n");
00053 }
00054 
00055 /** @brief Send Build Version Message
00056  * @param none
00057  * @returns none
00058  */
00059 void cli_version(void){
00060     printf(jmCLIG);
00061 }
00062 
00063 /** @brief Help Command Line Control.
00064  * Enable/disable help messages
00065  * When enabled, Typing name only prints Command Format
00066  * @param none
00067  * @returns none 
00068  */
00069 void cli_help(void){
00070     unsigned int  value;
00071    if(ExtractUInteger(pLine,&value,0,1)){
00072       if(value == 1)  printf("Help Enabled ! type command name to print its format\n");
00073        else printf("Help Disabled !\n");
00074         
00075         Help = (uint8_t) value;                // save status
00076         return;
00077    } 
00078    // Error on input, show format
00079    if(Help)printf("help  (value)0..1\n");
00080    // Ignore pending command line
00081    NextCommand(nl,pLine);
00082 }
00083 
00084 /** @brief Feedback Command Line Control. 
00085  * Enable/disable feedback messages
00086  * When enabled, feedback from user input commands are returned
00087  * @param none
00088  * @returns none 
00089  */
00090 void cli_feedback(void){
00091     unsigned int  value;
00092    if(ExtractUInteger(pLine,&value,0,1)){
00093       if(value == 1)  printf("Feedback Enabled !\n");
00094        else    printf("Feedback Disabled !\n");
00095        
00096         Feedback = (uint8_t)value;        // save status
00097         return;
00098    } 
00099 
00100    // Error on input, show format
00101    if(Help)printf("feedback  (value)0..1\n");
00102    // Ignore pending command line
00103    NextCommand(nl,pLine);
00104 }
00105 
00106 /** @brief Echo Command Line Control.
00107  * Enable/disable communication echoes
00108  * When enabled, user inputs are echoed back
00109  * @param none
00110  * @returns none 
00111  */
00112 void cli_echo(void){
00113     unsigned int  value;
00114    if(ExtractUInteger(pLine,&value,0,1)){
00115       if(value == 1)  printf("Echo Enabled !\n");
00116        else    printf("Echo Disabled !\n");
00117         
00118         Echo = (uint8_t)value;         // save status
00119        return;
00120    } 
00121 
00122    // Error on input, show format
00123    if(Help)printf("echo  (value)0..1\n");
00124    // Ignore pending command line
00125    NextCommand(nl,pLine);
00126 }