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