Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
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 00014 uint8_t Help; 00015 uint8_t Feedback; 00016 uint8_t Echo; 00017 00018 00019 /** @brief Enable only help messages 00020 * @param none 00021 * @returns none 00022 */ 00023 void InitMessages(void){ 00024 Help = 1; 00025 Echo = 0; 00026 Feedback = 0; 00027 } 00028 00029 /** @brief Send all command names in a project 00030 * @param none 00031 * @returns none 00032 */ 00033 void cli_list(void){ 00034 int i,j; 00035 printf("Commands:\n"); 00036 printf(".......................\n"); 00037 // for each command 00038 for(i=0,j=0; i<nbCommands; i++,j++){ 00039 // print name 00040 while(cmdNames[j]) printf("%c",cmdNames[j++]); 00041 printf("\n"); 00042 } 00043 printf("........................\n"); 00044 } 00045 00046 /** @brief Send Message Unknown Command from interpreter 00047 * @param none 00048 * @returns none 00049 */ 00050 void UnknownCommand(void){ 00051 printf("\n?\n"); 00052 } 00053 00054 /** @brief Send Build Version Message 00055 * @param none 00056 * @returns none 00057 */ 00058 void cli_version(void){ 00059 printf(jmCLIG); 00060 } 00061 00062 /** @brief Help Command Line Control. 00063 * Enable/disable help messages 00064 * When enabled, Typing name only prints Command Format 00065 * @param none 00066 * @returns none 00067 */ 00068 void cli_help(void){ 00069 unsigned int value; 00070 if(ExtractUInteger(pLine,&value,0,1)){ 00071 if(value == 1) printf("Help Enabled ! type command name to print its format\n"); 00072 else printf("Help Disabled !\n"); 00073 00074 Help = (uint8_t) value; // save status 00075 return; 00076 } 00077 // Error on input, show format 00078 if(Help)printf("help (value)0..1\n"); 00079 // Ignore pending command line 00080 NextCommand(nl,pLine); 00081 } 00082 00083 /** @brief Feedback Command Line Control. 00084 * Enable/disable feedback messages 00085 * When enabled, feedback from user input commands are returned 00086 * @param none 00087 * @returns none 00088 */ 00089 void cli_feedback(void){ 00090 unsigned int value; 00091 if(ExtractUInteger(pLine,&value,0,1)){ 00092 if(value == 1) printf("Feedback Enabled !\n"); 00093 else printf("Feedback Disabled !\n"); 00094 00095 Feedback = (uint8_t)value; // save status 00096 return; 00097 } 00098 00099 // Error on input, show format 00100 if(Help)printf("feedback (value)0..1\n"); 00101 // Ignore pending command line 00102 NextCommand(nl,pLine); 00103 } 00104 00105 /** @brief Echo Command Line Control. 00106 * Enable/disable communication echoes 00107 * When enabled, user inputs are echoed back 00108 * @param none 00109 * @returns none 00110 */ 00111 void cli_echo(void){ 00112 unsigned int value; 00113 if(ExtractUInteger(pLine,&value,0,1)){ 00114 if(value == 1) printf("Echo Enabled !\n"); 00115 else printf("Echo Disabled !\n"); 00116 00117 Echo = (uint8_t)value; // save status 00118 return; 00119 } 00120 00121 // Error on input, show format 00122 if(Help)printf("echo (value)0..1\n"); 00123 // Ignore pending command line 00124 NextCommand(nl,pLine); 00125 }
Generated on Tue Jul 12 2022 18:42:56 by
