Tue, 15 Nov 2011 10:47:16 +0100
added queue busy response on command injection
blackbox/main.c | file | annotate | diff | comparison | revisions |
--- a/blackbox/main.c Tue Nov 15 10:22:13 2011 +0100 +++ b/blackbox/main.c Tue Nov 15 10:47:16 2011 +0100 @@ -41,22 +41,18 @@ case 'P': // inject a program data word to the rails // TODO: at the moment only parameters 0..9 supported // needs to build a "human" parser - program_id = buffer[3]-'0'; - program_command = buffer[1]-'0'; - program_parameter = buffer[2]-'0'; - program_count = 0x02; // send commands twice - RS232_puts_p(PSTR("Executing command: ")); -/* - RS232_putc(buffer[2]); - RS232_putc(','); - RS232_putc(buffer[3]); - RS232_puts_p(PSTR(" for slot ")); - RS232_putc(buffer[1]); -*/ - RS232_putc('\n'); + if (program_count == 0) { + program_id = buffer[3]-'0'; + program_command = buffer[1]-'0'; + program_parameter = buffer[2]-'0'; + if (program_command < 4) + program_count = 0x02; // send commands twice (fuel, speed, brake) + else + program_count = 0x01; + RS232_puts_p(PSTR("OK\n")); + } else RS232_puts_p(PSTR("BUSY\n")); + break; - break; - } // wait for the next packet @@ -150,8 +146,6 @@ return n; } - - int do_program(uint8_t controller, uint8_t command, uint8_t parameter) { // send program data packet uint16_t tmp; @@ -219,9 +213,6 @@ if (do_program(program_id, program_command, program_parameter)) { packet_index++; program_count--; -itoa(transmit_buffer_queue, s, 2); -RS232_puts(s); -RS232_putc('\n'); } } else { // output idle command