![](/media/cache/profiles/0f0ee3310223fe38a989b2c818709393.50x50_q85.jpg)
Generate up to 8 different digital waeforms from serial port
jmMessages.c@0:374d47623fab, 2011-02-12 (annotated)
- Committer:
- jm
- Date:
- Sat Feb 12 16:41:07 2011 +0000
- Revision:
- 0:374d47623fab
jmPulse Command Line Interface Module
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jm | 0:374d47623fab | 1 | /************************************************************************* |
jm | 0:374d47623fab | 2 | * @file jmMessages.c |
jm | 0:374d47623fab | 3 | * @brief Control System Messages |
jm | 0:374d47623fab | 4 | * |
jm | 0:374d47623fab | 5 | * @date December 27,2010 |
jm | 0:374d47623fab | 6 | */ |
jm | 0:374d47623fab | 7 | |
jm | 0:374d47623fab | 8 | #include "jmCommands.h" |
jm | 0:374d47623fab | 9 | #include "jmRingBuffer.h" |
jm | 0:374d47623fab | 10 | #include "stdio.h" |
jm | 0:374d47623fab | 11 | #include "jmMessages.h" |
jm | 0:374d47623fab | 12 | #include "stdint.h" |
jm | 0:374d47623fab | 13 | |
jm | 0:374d47623fab | 14 | uint8_t Help; |
jm | 0:374d47623fab | 15 | uint8_t Feedback; |
jm | 0:374d47623fab | 16 | uint8_t Echo; |
jm | 0:374d47623fab | 17 | |
jm | 0:374d47623fab | 18 | |
jm | 0:374d47623fab | 19 | /** @brief Enable only help messages |
jm | 0:374d47623fab | 20 | * @param none |
jm | 0:374d47623fab | 21 | * @returns none |
jm | 0:374d47623fab | 22 | */ |
jm | 0:374d47623fab | 23 | void InitMessages(void){ |
jm | 0:374d47623fab | 24 | Help = 1; |
jm | 0:374d47623fab | 25 | Echo = 0; |
jm | 0:374d47623fab | 26 | Feedback = 0; |
jm | 0:374d47623fab | 27 | } |
jm | 0:374d47623fab | 28 | |
jm | 0:374d47623fab | 29 | /** @brief Send all command names in a project |
jm | 0:374d47623fab | 30 | * @param none |
jm | 0:374d47623fab | 31 | * @returns none |
jm | 0:374d47623fab | 32 | */ |
jm | 0:374d47623fab | 33 | void cli_list(void){ |
jm | 0:374d47623fab | 34 | int i,j; |
jm | 0:374d47623fab | 35 | printf("Commands:\n"); |
jm | 0:374d47623fab | 36 | printf(".......................\n"); |
jm | 0:374d47623fab | 37 | // for each command |
jm | 0:374d47623fab | 38 | for(i=0,j=0; i<nbCommands; i++,j++){ |
jm | 0:374d47623fab | 39 | // print name |
jm | 0:374d47623fab | 40 | while(cmdNames[j]) printf("%c",cmdNames[j++]); |
jm | 0:374d47623fab | 41 | printf("\n"); |
jm | 0:374d47623fab | 42 | } |
jm | 0:374d47623fab | 43 | printf("........................\n"); |
jm | 0:374d47623fab | 44 | } |
jm | 0:374d47623fab | 45 | |
jm | 0:374d47623fab | 46 | /** @brief Send Message Unknown Command from interpreter |
jm | 0:374d47623fab | 47 | * @param none |
jm | 0:374d47623fab | 48 | * @returns none |
jm | 0:374d47623fab | 49 | */ |
jm | 0:374d47623fab | 50 | void UnknownCommand(void){ |
jm | 0:374d47623fab | 51 | printf("\n?\n"); |
jm | 0:374d47623fab | 52 | } |
jm | 0:374d47623fab | 53 | |
jm | 0:374d47623fab | 54 | /** @brief Send Build Version Message |
jm | 0:374d47623fab | 55 | * @param none |
jm | 0:374d47623fab | 56 | * @returns none |
jm | 0:374d47623fab | 57 | */ |
jm | 0:374d47623fab | 58 | void cli_version(void){ |
jm | 0:374d47623fab | 59 | printf(jmCLIG); |
jm | 0:374d47623fab | 60 | } |
jm | 0:374d47623fab | 61 | |
jm | 0:374d47623fab | 62 | /** @brief Help Command Line Control. |
jm | 0:374d47623fab | 63 | * Enable/disable help messages |
jm | 0:374d47623fab | 64 | * When enabled, Typing name only prints Command Format |
jm | 0:374d47623fab | 65 | * @param none |
jm | 0:374d47623fab | 66 | * @returns none |
jm | 0:374d47623fab | 67 | */ |
jm | 0:374d47623fab | 68 | void cli_help(void){ |
jm | 0:374d47623fab | 69 | unsigned int value; |
jm | 0:374d47623fab | 70 | if(ExtractUInteger(pLine,&value,0,1)){ |
jm | 0:374d47623fab | 71 | if(value == 1) printf("Help Enabled ! type command name to print its format\n"); |
jm | 0:374d47623fab | 72 | else printf("Help Disabled !\n"); |
jm | 0:374d47623fab | 73 | |
jm | 0:374d47623fab | 74 | Help = (uint8_t) value; // save status |
jm | 0:374d47623fab | 75 | return; |
jm | 0:374d47623fab | 76 | } |
jm | 0:374d47623fab | 77 | // Error on input, show format |
jm | 0:374d47623fab | 78 | if(Help)printf("help (value)0..1\n"); |
jm | 0:374d47623fab | 79 | // Ignore pending command line |
jm | 0:374d47623fab | 80 | NextCommand(nl,pLine); |
jm | 0:374d47623fab | 81 | } |
jm | 0:374d47623fab | 82 | |
jm | 0:374d47623fab | 83 | /** @brief Feedback Command Line Control. |
jm | 0:374d47623fab | 84 | * Enable/disable feedback messages |
jm | 0:374d47623fab | 85 | * When enabled, feedback from user input commands are returned |
jm | 0:374d47623fab | 86 | * @param none |
jm | 0:374d47623fab | 87 | * @returns none |
jm | 0:374d47623fab | 88 | */ |
jm | 0:374d47623fab | 89 | void cli_feedback(void){ |
jm | 0:374d47623fab | 90 | unsigned int value; |
jm | 0:374d47623fab | 91 | if(ExtractUInteger(pLine,&value,0,1)){ |
jm | 0:374d47623fab | 92 | if(value == 1) printf("Feedback Enabled !\n"); |
jm | 0:374d47623fab | 93 | else printf("Feedback Disabled !\n"); |
jm | 0:374d47623fab | 94 | |
jm | 0:374d47623fab | 95 | Feedback = (uint8_t)value; // save status |
jm | 0:374d47623fab | 96 | return; |
jm | 0:374d47623fab | 97 | } |
jm | 0:374d47623fab | 98 | |
jm | 0:374d47623fab | 99 | // Error on input, show format |
jm | 0:374d47623fab | 100 | if(Help)printf("feedback (value)0..1\n"); |
jm | 0:374d47623fab | 101 | // Ignore pending command line |
jm | 0:374d47623fab | 102 | NextCommand(nl,pLine); |
jm | 0:374d47623fab | 103 | } |
jm | 0:374d47623fab | 104 | |
jm | 0:374d47623fab | 105 | /** @brief Echo Command Line Control. |
jm | 0:374d47623fab | 106 | * Enable/disable communication echoes |
jm | 0:374d47623fab | 107 | * When enabled, user inputs are echoed back |
jm | 0:374d47623fab | 108 | * @param none |
jm | 0:374d47623fab | 109 | * @returns none |
jm | 0:374d47623fab | 110 | */ |
jm | 0:374d47623fab | 111 | void cli_echo(void){ |
jm | 0:374d47623fab | 112 | unsigned int value; |
jm | 0:374d47623fab | 113 | if(ExtractUInteger(pLine,&value,0,1)){ |
jm | 0:374d47623fab | 114 | if(value == 1) printf("Echo Enabled !\n"); |
jm | 0:374d47623fab | 115 | else printf("Echo Disabled !\n"); |
jm | 0:374d47623fab | 116 | |
jm | 0:374d47623fab | 117 | Echo = (uint8_t)value; // save status |
jm | 0:374d47623fab | 118 | return; |
jm | 0:374d47623fab | 119 | } |
jm | 0:374d47623fab | 120 | |
jm | 0:374d47623fab | 121 | // Error on input, show format |
jm | 0:374d47623fab | 122 | if(Help)printf("echo (value)0..1\n"); |
jm | 0:374d47623fab | 123 | // Ignore pending command line |
jm | 0:374d47623fab | 124 | NextCommand(nl,pLine); |
jm | 0:374d47623fab | 125 | } |