Nurbol Nurdaulet / Mbed 2 deprecated state_machine_24_11_11

Dependencies:   mbed WattBob_TextLCD

Committer:
Nurbol
Date:
Thu Nov 24 16:15:02 2011 +0000
Revision:
3:0ce1c635a653
Parent:
2:0d0ec8aa4605

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Nurbol 0:99ea9a842829 1 //
Nurbol 0:99ea9a842829 2 // COM_test : program to communicate via a COM port to a PC/laptop
Nurbol 0:99ea9a842829 3 // ========
Nurbol 0:99ea9a842829 4 //
Nurbol 0:99ea9a842829 5 // Description
Nurbol 0:99ea9a842829 6 // Program to receive ASCII format commands through a virtual COM port and
Nurbol 0:99ea9a842829 7 // after executing the command return some data (optional, depending on
Nurbol 0:99ea9a842829 8 // the command) and a status value.
Nurbol 0:99ea9a842829 9 // The program understands two possible commands :
Nurbol 0:99ea9a842829 10 // "s i j" : move servo 'i (0 to 5) to postion 'j' (0 to 90)
Nurbol 0:99ea9a842829 11 // "r" : read the 'i' parameter of the last "s" command
Nurbol 0:99ea9a842829 12 //
Nurbol 0:99ea9a842829 13 // Version : 1.0
Nurbol 0:99ea9a842829 14 // Author : Jim Herd
Nurbol 0:99ea9a842829 15 // Date : 5th Oct 2011
Nurbol 0:99ea9a842829 16 //
Nurbol 0:99ea9a842829 17 #include "mbed.h"
Nurbol 0:99ea9a842829 18 #include "MCP23017.h"
Nurbol 0:99ea9a842829 19 #include "WattBob_TextLCD.h"
Nurbol 0:99ea9a842829 20 #include "cmd_io.h"
Nurbol 0:99ea9a842829 21 #include "globals.h"
Nurbol 0:99ea9a842829 22
Nurbol 0:99ea9a842829 23
Nurbol 0:99ea9a842829 24
Nurbol 0:99ea9a842829 25 Ticker timer1p;
Nurbol 0:99ea9a842829 26 Ticker timer2p;
Nurbol 0:99ea9a842829 27 Ticker timercounter1p;
Nurbol 0:99ea9a842829 28 Ticker timercounter2p;
Nurbol 1:05b399616fcd 29 Ticker timerstatemachine;
Nurbol 0:99ea9a842829 30
Nurbol 0:99ea9a842829 31 AnalogIn sensor1(p15);
Nurbol 0:99ea9a842829 32 AnalogIn sensor2(p16);
Nurbol 0:99ea9a842829 33 DigitalOut valueLED1(p23);
Nurbol 0:99ea9a842829 34 DigitalOut valueLED2(p25);
Nurbol 0:99ea9a842829 35
Nurbol 0:99ea9a842829 36
Nurbol 0:99ea9a842829 37 DigitalOut led1(LED1);
Nurbol 0:99ea9a842829 38 DigitalOut led2(LED2);
Nurbol 0:99ea9a842829 39 DigitalOut led3(LED3);
Nurbol 0:99ea9a842829 40 DigitalOut led4(LED4);
Nurbol 0:99ea9a842829 41
Nurbol 0:99ea9a842829 42 DigitalOut clk(p24);
Nurbol 0:99ea9a842829 43
Nurbol 0:99ea9a842829 44 DigitalIn counter1p(p5);
Nurbol 0:99ea9a842829 45 DigitalIn counter2p(p6);
Nurbol 0:99ea9a842829 46 DigitalIn SW1p(p11);
Nurbol 0:99ea9a842829 47 DigitalIn SW2p(p12);
Nurbol 0:99ea9a842829 48
Nurbol 0:99ea9a842829 49 bool Position1_1p;
Nurbol 0:99ea9a842829 50 bool Position2_1p;
Nurbol 0:99ea9a842829 51 bool Position1_2p;
Nurbol 0:99ea9a842829 52 bool Position2_2p;
Nurbol 0:99ea9a842829 53
Nurbol 1:05b399616fcd 54 int state;
Nurbol 0:99ea9a842829 55
Nurbol 0:99ea9a842829 56
Nurbol 0:99ea9a842829 57
Nurbol 0:99ea9a842829 58 //******************************************************************************
Nurbol 0:99ea9a842829 59 // declare functions
Nurbol 0:99ea9a842829 60 //
Nurbol 0:99ea9a842829 61 void sensor1p (void);
Nurbol 0:99ea9a842829 62 void sensor2p (void);
Nurbol 0:99ea9a842829 63 void counter1 (void);
Nurbol 0:99ea9a842829 64 void counter2 (void);
Nurbol 1:05b399616fcd 65 void state_machine (void);
Nurbol 0:99ea9a842829 66 //
Nurbol 0:99ea9a842829 67 //
Nurbol 0:99ea9a842829 68 // 2. five servo outputs
Nurbol 0:99ea9a842829 69 //
Nurbol 0:99ea9a842829 70
Nurbol 0:99ea9a842829 71 PwmOut servo_0(p26);
Nurbol 0:99ea9a842829 72 //PwmOut servo_1(p25);
Nurbol 0:99ea9a842829 73 //PwmOut servo_2(p24);
Nurbol 0:99ea9a842829 74 //PwmOut servo_3(p23);
Nurbol 0:99ea9a842829 75 PwmOut servo_4(p22);
Nurbol 0:99ea9a842829 76 PwmOut servo_5(p21);
Nurbol 0:99ea9a842829 77
Nurbol 0:99ea9a842829 78 //
Nurbol 0:99ea9a842829 79 // 3. objects necessary to use the 2*16 character MBED display
Nurbol 0:99ea9a842829 80 //
Nurbol 0:99ea9a842829 81 MCP23017 *par_port;
Nurbol 0:99ea9a842829 82 WattBob_TextLCD *lcd;
Nurbol 0:99ea9a842829 83 //
Nurbol 0:99ea9a842829 84 // 4. Virtual COM port over USB link to laptop/PC
Nurbol 0:99ea9a842829 85 //
Nurbol 0:99ea9a842829 86 Serial pc(USBTX, USBRX);
Nurbol 0:99ea9a842829 87
Nurbol 0:99ea9a842829 88 //******************************************************************************
Nurbol 0:99ea9a842829 89 // Defined GLOBAL variables and structures
Nurbol 0:99ea9a842829 90 //
Nurbol 0:99ea9a842829 91 CMD_STRUCT ext_cmd, commandcounter2; // structure to hold command data
Nurbol 0:99ea9a842829 92 STAT_STRUCT ext_stat; // structure to hold status reply
Nurbol 0:99ea9a842829 93
Nurbol 0:99ea9a842829 94
Nurbol 0:99ea9a842829 95 //CMD_STRUCT commandcounter2;
Nurbol 0:99ea9a842829 96
Nurbol 0:99ea9a842829 97 uint32_t last_servo; // store for last servo number
Nurbol 0:99ea9a842829 98
Nurbol 0:99ea9a842829 99 //************************************************************************
Nurbol 0:99ea9a842829 100 //************************************************************************
Nurbol 0:99ea9a842829 101 // init_sys : initialise the system
Nurbol 0:99ea9a842829 102 // ========
Nurbol 0:99ea9a842829 103 //
Nurbol 0:99ea9a842829 104 // 1. Configure 2*16 character display
Nurbol 0:99ea9a842829 105 // 2. Print "COM test" string
Nurbol 0:99ea9a842829 106 // 3. initialise relevant global variables
Nurbol 0:99ea9a842829 107 // 4. set COM port baud rate to 19200 bits per second
Nurbol 0:99ea9a842829 108 //
Nurbol 0:99ea9a842829 109 void init_sys(void) {
Nurbol 0:99ea9a842829 110
Nurbol 0:99ea9a842829 111 par_port = new MCP23017(p9, p10, 0x40);
Nurbol 0:99ea9a842829 112 lcd = new WattBob_TextLCD(par_port);
Nurbol 0:99ea9a842829 113
Nurbol 0:99ea9a842829 114 par_port->write_bit(1,BL_BIT); // turn LCD backlight ON
Nurbol 0:99ea9a842829 115 lcd->cls();
Nurbol 0:99ea9a842829 116 lcd->locate(0,0);
Nurbol 0:99ea9a842829 117 lcd->printf("COM ");
Nurbol 0:99ea9a842829 118
Nurbol 0:99ea9a842829 119 servo_0.period(0.020); // servo requires a 20ms period, common for all 5 servo objects
Nurbol 0:99ea9a842829 120 last_servo = SERVO_UNKNOWN;
Nurbol 0:99ea9a842829 121 pc.baud(19200);
Nurbol 0:99ea9a842829 122
Nurbol 0:99ea9a842829 123 servo_0.pulsewidth_us(1000 + (0 * 1000) / 90);
Nurbol 0:99ea9a842829 124 servo_4.pulsewidth_us(1000 + (25 * 1000) / 90);
Nurbol 0:99ea9a842829 125 servo_5.pulsewidth_us(1000 + (0 * 1000) / 90);
Nurbol 0:99ea9a842829 126
Nurbol 0:99ea9a842829 127 Position1_1p = 1;
Nurbol 0:99ea9a842829 128 Position2_1p = 0;
Nurbol 0:99ea9a842829 129 Position1_2p = 1;
Nurbol 0:99ea9a842829 130 Position2_2p = 0;
Nurbol 0:99ea9a842829 131
Nurbol 1:05b399616fcd 132 state = 0;
Nurbol 1:05b399616fcd 133
Nurbol 0:99ea9a842829 134 return;
Nurbol 0:99ea9a842829 135 } // end init_sys
Nurbol 0:99ea9a842829 136
Nurbol 0:99ea9a842829 137 //************************************************************************
Nurbol 0:99ea9a842829 138 // process_cmd : decode and execute command
Nurbol 0:99ea9a842829 139 // ===========
Nurbol 0:99ea9a842829 140 uint32_t process_cmd(CMD_STRUCT *command)
Nurbol 0:99ea9a842829 141 {
Nurbol 0:99ea9a842829 142 int32_t pulse_width;
Nurbol 0:99ea9a842829 143
Nurbol 0:99ea9a842829 144 switch (command->cmd_code) {
Nurbol 0:99ea9a842829 145 //
Nurbol 0:99ea9a842829 146 // move a servo
Nurbol 0:99ea9a842829 147 //
Nurbol 0:99ea9a842829 148 case SERVO_CMD :
Nurbol 0:99ea9a842829 149 command->nos_data = 0; // no data to be returned
Nurbol 0:99ea9a842829 150 //
Nurbol 0:99ea9a842829 151 // check that parameters are OK
Nurbol 0:99ea9a842829 152 //
Nurbol 0:99ea9a842829 153 if (command->nos_params != 2) { // check for 2 parameters
Nurbol 0:99ea9a842829 154 command->result_status = CMD_BAD_NUMBER_OF_PARAMETERS;
Nurbol 0:99ea9a842829 155 break;
Nurbol 0:99ea9a842829 156 }
Nurbol 0:99ea9a842829 157 if (command->param[0] > MAX_SERVO_NUMBER ) { // check servo number
Nurbol 0:99ea9a842829 158 command->result_status = CMD_BAD_SERVO_NUMBER;
Nurbol 0:99ea9a842829 159 break;
Nurbol 0:99ea9a842829 160 }
Nurbol 0:99ea9a842829 161 if ((command->param[1] < MIN_SERVO_ANGLE) ||
Nurbol 0:99ea9a842829 162 (command->param[1] > MAX_SERVO_ANGLE) ) {
Nurbol 0:99ea9a842829 163 command->result_status = CMD_BAD_SERVO_VALUE;
Nurbol 0:99ea9a842829 164 break;
Nurbol 0:99ea9a842829 165 }
Nurbol 0:99ea9a842829 166 if ((command->param[0] == 4) && (command->param[1] == 0)) {
Nurbol 0:99ea9a842829 167 pulse_width = 0; // convert angle to pulse width
Nurbol 0:99ea9a842829 168 }
Nurbol 0:99ea9a842829 169 else{
Nurbol 0:99ea9a842829 170 pulse_width = 1000 + (command->param[1] * 1000) / MAX_SERVO_ANGLE; // convert angle to pulse width
Nurbol 0:99ea9a842829 171 }
Nurbol 0:99ea9a842829 172
Nurbol 0:99ea9a842829 173
Nurbol 0:99ea9a842829 174
Nurbol 0:99ea9a842829 175 //
Nurbol 0:99ea9a842829 176 // implement servo move to all 5 servos
Nurbol 0:99ea9a842829 177 //
Nurbol 0:99ea9a842829 178 switch (command->param[0]) {
Nurbol 0:99ea9a842829 179 case 0 : servo_0.pulsewidth_us(pulse_width); break;
Nurbol 0:99ea9a842829 180 // case 1 : servo_1.pulsewidth_us(pulse_width); break;
Nurbol 0:99ea9a842829 181 // case 2 : servo_2.pulsewidth_us(pulse_width); break;
Nurbol 0:99ea9a842829 182 // case 3 : servo_3.pulsewidth_us(pulse_width); break;
Nurbol 0:99ea9a842829 183 case 4 : servo_4.pulsewidth_us(pulse_width); break;
Nurbol 0:99ea9a842829 184 // case 5 : servo_5.pulsewidth_us(pulse_width); break;
Nurbol 0:99ea9a842829 185
Nurbol 0:99ea9a842829 186 }
Nurbol 0:99ea9a842829 187 last_servo = command->param[0];
Nurbol 0:99ea9a842829 188 break;
Nurbol 0:99ea9a842829 189 //
Nurbol 0:99ea9a842829 190 // return last servo number
Nurbol 0:99ea9a842829 191 //
Nurbol 0:99ea9a842829 192 case READ_CMD :
Nurbol 0:99ea9a842829 193 command->nos_data = 2; // no data to be returned
Nurbol 0:99ea9a842829 194 command->result_data[0] = valueLED1;
Nurbol 0:99ea9a842829 195 command->result_data[1] = valueLED2;
Nurbol 0:99ea9a842829 196 break;
Nurbol 0:99ea9a842829 197 //
Nurbol 0:99ea9a842829 198 // catch any problems
Nurbol 0:99ea9a842829 199 //
Nurbol 0:99ea9a842829 200 default:
Nurbol 0:99ea9a842829 201 command->nos_data = 0; // no data to be returned
Nurbol 0:99ea9a842829 202 command->result_status = CMD_BAD_SERVO_VALUE;
Nurbol 0:99ea9a842829 203 break;
Nurbol 0:99ea9a842829 204 }
Nurbol 0:99ea9a842829 205 return OK;
Nurbol 0:99ea9a842829 206 }
Nurbol 0:99ea9a842829 207
Nurbol 0:99ea9a842829 208 //************************************************************************
Nurbol 0:99ea9a842829 209
Nurbol 0:99ea9a842829 210 //function to send value on the FPGA when 1p is detected
Nurbol 0:99ea9a842829 211 void sensor1p (void){
Nurbol 0:99ea9a842829 212 clk = !clk;
Nurbol 0:99ea9a842829 213 wait(0.01);
Nurbol 0:99ea9a842829 214 sensor1.read();
Nurbol 0:99ea9a842829 215 if(sensor1 > 0.5) {
Nurbol 0:99ea9a842829 216 led1 = 1;
Nurbol 0:99ea9a842829 217 valueLED1 = 1;
Nurbol 0:99ea9a842829 218 }
Nurbol 0:99ea9a842829 219 else if(sensor1 < 0.5){
Nurbol 0:99ea9a842829 220 led1 = 0;
Nurbol 0:99ea9a842829 221 valueLED1 = 0;
Nurbol 0:99ea9a842829 222 }
Nurbol 0:99ea9a842829 223 }
Nurbol 0:99ea9a842829 224
Nurbol 0:99ea9a842829 225 //function to send value on the FPGA when 2p is detected
Nurbol 0:99ea9a842829 226 void sensor2p (){
Nurbol 0:99ea9a842829 227 sensor2.read();
Nurbol 0:99ea9a842829 228 if(sensor2 > 0.5) {
Nurbol 0:99ea9a842829 229 led2 = 1;
Nurbol 0:99ea9a842829 230 valueLED2 = 1;
Nurbol 0:99ea9a842829 231 }
Nurbol 0:99ea9a842829 232 else if(sensor2 < 0.5){
Nurbol 0:99ea9a842829 233 led2 = 0;
Nurbol 0:99ea9a842829 234 valueLED2 = 0;
Nurbol 0:99ea9a842829 235 }
Nurbol 0:99ea9a842829 236 }
Nurbol 0:99ea9a842829 237
Nurbol 1:05b399616fcd 238
Nurbol 3:0ce1c635a653 239 //function for the state machine to move servos between 2 positions
Nurbol 1:05b399616fcd 240 void state_machine (){
Nurbol 1:05b399616fcd 241 switch(state)
Nurbol 1:05b399616fcd 242 {
Nurbol 1:05b399616fcd 243 case 0: // initial state
Nurbol 1:05b399616fcd 244 servo_4.pulsewidth_us(1000 + (25 * 1000) / 90); // motor is run
Nurbol 1:05b399616fcd 245 servo_0.pulsewidth_us(1000 + (0 * 1000) / 90); // servo 1p go to position 1
Nurbol 1:05b399616fcd 246 servo_5.pulsewidth_us(1000 + (0 * 1000) / 90); // servo 2p go to position 1
Nurbol 1:05b399616fcd 247 Position1_1p = 1;
Nurbol 1:05b399616fcd 248 Position2_1p = 0;
Nurbol 1:05b399616fcd 249 Position1_2p = 1;
Nurbol 1:05b399616fcd 250 Position2_2p = 0;
Nurbol 1:05b399616fcd 251 led3 = 0;
Nurbol 1:05b399616fcd 252 led4 = 0;
Nurbol 1:05b399616fcd 253 counter1p.read();
Nurbol 1:05b399616fcd 254 counter2p.read();
Nurbol 2:0d0ec8aa4605 255 if(SW1p == 0){
Nurbol 2:0d0ec8aa4605 256 if(counter1p > 0.5){
Nurbol 2:0d0ec8aa4605 257 state = 1;
Nurbol 2:0d0ec8aa4605 258 }
Nurbol 1:05b399616fcd 259 }
Nurbol 2:0d0ec8aa4605 260 if(SW2p == 0){
Nurbol 2:0d0ec8aa4605 261 if(counter2p > 0.5){
Nurbol 2:0d0ec8aa4605 262 state = 4;
Nurbol 2:0d0ec8aa4605 263 }
Nurbol 1:05b399616fcd 264 }
Nurbol 1:05b399616fcd 265 break;
Nurbol 1:05b399616fcd 266 case 1: // state 1 if counter1p = 1
Nurbol 1:05b399616fcd 267 servo_4.pulsewidth_us(0); // motor stop
Nurbol 1:05b399616fcd 268 servo_0.pulsewidth_us(1000 + (200 * 1000) / 90); // servo 1p go to position 2
Nurbol 1:05b399616fcd 269 wait(1);
Nurbol 1:05b399616fcd 270 Position1_1p = 0;
Nurbol 1:05b399616fcd 271 Position2_1p = 1;
Nurbol 2:0d0ec8aa4605 272 if((Position2_1p == 1)&&(counter1p < 0.5)){
Nurbol 1:05b399616fcd 273 state = 2;
Nurbol 1:05b399616fcd 274 }
Nurbol 1:05b399616fcd 275 break;
Nurbol 1:05b399616fcd 276 case 2: // state 2 if servo 1p is in position 2
Nurbol 1:05b399616fcd 277 servo_4.pulsewidth_us(1000 + (25 * 1000) / 90); // motor is run
Nurbol 2:0d0ec8aa4605 278 counter1p.read();
Nurbol 1:05b399616fcd 279 if(counter1p > 0.5){
Nurbol 1:05b399616fcd 280 state = 3;
Nurbol 1:05b399616fcd 281 }
Nurbol 1:05b399616fcd 282 break;
Nurbol 1:05b399616fcd 283 case 3: // state 3 if counter 1p = 1
Nurbol 1:05b399616fcd 284 servo_4.pulsewidth_us(0); // motor stop
Nurbol 1:05b399616fcd 285 led3 = 1;
Nurbol 1:05b399616fcd 286 if(SW1p == 1){ // wait SW 1p to go to the initial state
Nurbol 1:05b399616fcd 287 state = 0;
Nurbol 1:05b399616fcd 288 }
Nurbol 1:05b399616fcd 289 break;
Nurbol 1:05b399616fcd 290 case 4: // state 4 if counter 2p = 1
Nurbol 1:05b399616fcd 291 servo_4.pulsewidth_us(0); // motor stop
Nurbol 1:05b399616fcd 292 servo_5.pulsewidth_us(1000 + (200 * 1000) / 90); // servo 2p go to position 2
Nurbol 1:05b399616fcd 293 wait(1);
Nurbol 1:05b399616fcd 294 Position1_2p = 0;
Nurbol 1:05b399616fcd 295 Position2_2p = 1;
Nurbol 1:05b399616fcd 296 if((Position2_2p == 1)&&(counter2p < 0.5)){
Nurbol 1:05b399616fcd 297 state = 5;
Nurbol 1:05b399616fcd 298 }
Nurbol 1:05b399616fcd 299 break;
Nurbol 1:05b399616fcd 300 case 5: // state 5 if servo 2p is in position 2
Nurbol 1:05b399616fcd 301 servo_4.pulsewidth_us(1000 + (25 * 1000) / 90); // motor run
Nurbol 1:05b399616fcd 302 counter2p.read();
Nurbol 1:05b399616fcd 303 if(counter2p > 0.5){
Nurbol 1:05b399616fcd 304 state = 6;
Nurbol 1:05b399616fcd 305 }
Nurbol 1:05b399616fcd 306 break;
Nurbol 1:05b399616fcd 307 case 6: // state 6 if counter 2p = 1
Nurbol 1:05b399616fcd 308 servo_4.pulsewidth_us(0); // motor stop
Nurbol 1:05b399616fcd 309 led4 = 1;
Nurbol 1:05b399616fcd 310 if(SW2p == 1){ // wait SW 2p to go to the initial state
Nurbol 2:0d0ec8aa4605 311 state = 0;
Nurbol 1:05b399616fcd 312 }
Nurbol 1:05b399616fcd 313 break;
Nurbol 1:05b399616fcd 314 }
Nurbol 1:05b399616fcd 315 }
Nurbol 1:05b399616fcd 316
Nurbol 1:05b399616fcd 317
Nurbol 0:99ea9a842829 318 //************************************************************************
Nurbol 0:99ea9a842829 319 //
Nurbol 0:99ea9a842829 320 int main() {
Nurbol 0:99ea9a842829 321
Nurbol 0:99ea9a842829 322 valueLED1=0;
Nurbol 0:99ea9a842829 323 valueLED2=0;
Nurbol 0:99ea9a842829 324 clk=0;
Nurbol 0:99ea9a842829 325 init_sys();
Nurbol 0:99ea9a842829 326
Nurbol 0:99ea9a842829 327 FOREVER {
Nurbol 0:99ea9a842829 328
Nurbol 0:99ea9a842829 329 timer2p.attach(&sensor2p, 0.1); //function sensor2p is reading all the 0.1 ms
Nurbol 0:99ea9a842829 330 timer1p.attach(&sensor1p, 0.1); //function sensor1p is reading all the 0.1 ms
Nurbol 0:99ea9a842829 331
Nurbol 1:05b399616fcd 332 counter1p.read();
Nurbol 1:05b399616fcd 333 counter2p.read();
Nurbol 1:05b399616fcd 334
Nurbol 1:05b399616fcd 335 timerstatemachine.attach(&state_machine, 0.1);
Nurbol 0:99ea9a842829 336
Nurbol 3:0ce1c635a653 337
Nurbol 0:99ea9a842829 338 clk = !clk;
Nurbol 0:99ea9a842829 339 wait(0.01);
Nurbol 0:99ea9a842829 340
Nurbol 0:99ea9a842829 341 get_cmd(&ext_cmd);
Nurbol 0:99ea9a842829 342 //
Nurbol 0:99ea9a842829 343 // Check status of read command activity and return an error status if there was a problem
Nurbol 0:99ea9a842829 344 // If there is a problem, then return status code only and wait for next command.
Nurbol 0:99ea9a842829 345 //
Nurbol 0:99ea9a842829 346 if (ext_cmd.result_status != OK){
Nurbol 0:99ea9a842829 347 send_status(ext_cmd.result_status);
Nurbol 0:99ea9a842829 348 continue;
Nurbol 0:99ea9a842829 349 }
Nurbol 0:99ea9a842829 350 //
Nurbol 0:99ea9a842829 351 // Parse command and return an error staus if there is a problem
Nurbol 0:99ea9a842829 352 // If there is a problem, then return status code only and wait for next command.
Nurbol 0:99ea9a842829 353 //
Nurbol 0:99ea9a842829 354 parse_cmd(&ext_cmd);
Nurbol 0:99ea9a842829 355 lcd->locate(1,0); lcd->printf(ext_cmd.cmd_str);
Nurbol 0:99ea9a842829 356 if ((ext_cmd.result_status != OK) && (ext_cmd.cmd_code != TEXT_CMD)){
Nurbol 0:99ea9a842829 357 lcd->locate(1,0); lcd->printf("parse : error");
Nurbol 0:99ea9a842829 358 send_status(ext_cmd.result_status);
Nurbol 0:99ea9a842829 359 continue;
Nurbol 0:99ea9a842829 360 }
Nurbol 0:99ea9a842829 361 //
Nurbol 0:99ea9a842829 362 // Execute command and return an error staus if there is a problem
Nurbol 0:99ea9a842829 363 //
Nurbol 0:99ea9a842829 364 process_cmd(&ext_cmd);
Nurbol 0:99ea9a842829 365 reply_to_cmd(&ext_cmd);
Nurbol 0:99ea9a842829 366
Nurbol 0:99ea9a842829 367
Nurbol 0:99ea9a842829 368
Nurbol 0:99ea9a842829 369 }
Nurbol 0:99ea9a842829 370
Nurbol 0:99ea9a842829 371 }
Nurbol 0:99ea9a842829 372
Nurbol 0:99ea9a842829 373
Nurbol 0:99ea9a842829 374
Nurbol 0:99ea9a842829 375
Nurbol 0:99ea9a842829 376
Nurbol 0:99ea9a842829 377
Nurbol 0:99ea9a842829 378
Nurbol 0:99ea9a842829 379
Nurbol 0:99ea9a842829 380