Piccolo
Dependencies: mbed
Fork of 02_LAB_serial_protocol by
Diff: main.cpp
- Revision:
- 2:200a9507b696
- Parent:
- 1:0bcd96e56022
- Child:
- 3:7c26d338e372
--- a/main.cpp Wed Apr 26 18:22:36 2017 +0000 +++ b/main.cpp Wed Apr 26 18:31:32 2017 +0000 @@ -2,7 +2,7 @@ #include "mbed.h" Serial command(USBTX, USBRX); - +DigitalOut led(LED1); #define DEBUG 1 //***************************************************************************** @@ -32,7 +32,7 @@ if (val <10) command.putc(val+0x30); else - command.putc(val-10+0x40); + command.putc(val-9+0x40); } void print_bin2hex (uint8_t val) @@ -60,24 +60,25 @@ } -void check_command() +uint8_t check_command() { if (buffer_command[BUFF_SIZE-1]== '>' && buffer_command[COMM_SEPARADOR]==','){ - #if DEBUG - command.printf("\nMover Motor:"); - print_bin2hex(buffer_command[COMM_NUM_MOTOR]); - command.printf(" -> "); - print_bin2hex(buffer_command[COMM_GRADOS_MOTOR]); - command.printf(" grados \n"); - #endif - }else{ + #if DEBUG + command.printf("\nMover Motor:"); + print_bin2hex(buffer_command[COMM_NUM_MOTOR]); + command.printf(" -> "); + print_bin2hex(buffer_command[COMM_GRADOS_MOTOR]); + command.printf(" grados \n"); + #endif + return 1; + } #if DEBUG command.printf("\n ERROR COMANDO -> "); echo_command(); #endif + return 0; - } } int main() { @@ -91,8 +92,10 @@ val=command.getc(); if (val== '<'){ Read_command(); - check_command(); - + if (check_command()) + led=1; + else + led=0; } } }