Debug Serial para programa resetar o buffer quando houver tamanhos errados na mensagem

Dependencies:   pulga-lorawan-drv PingPong-P2P-ClickButtonToWork-SX1272

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers serial_cmds.cpp Source File

serial_cmds.cpp

00001 #include "serial.h"
00002 
00003 bool SerialCommandRun(const char *msg)
00004 {
00005     char Option = msg[1]; /// recebo opcao
00006     
00007     switch (Option)
00008     {
00009     case CMD_PRINT_GPS:
00010         {
00011             gps_navPVT gps_data;
00012             gps_data = get_struct();
00013             pc.printf("<s%d,%d+%d/%d/%d-%d:%d:%d>\n", (int)gps_data.lat, (int)gps_data.lon, (int)gps_data.year, (int)gps_data.month,(int)gps_data.day, (int)gps_data.hour, (int)gps_data.min, (int)gps_data.sec);
00014         
00015         break;}
00016         
00017     case CMD_SEND_HELLO:
00018         {
00019             pc.printf("hello word!\n");
00020         break;}
00021         
00022     case CMD_SEND_LORA_P2P:
00023         {
00024             char *temp;
00025             gps_navPVT gps_data;
00026             gps_data = get_struct();
00027             pc.printf("<p%s>", msg+2);
00028             //sprintf((char*) temp ,"<t%d/%d/%d-%d:%d:%d>\n", (int)gps_data.year, (int)gps_data.month,(int)gps_data.day, (int)gps_data.hour, (int)gps_data.min, (int)gps_data.sec);
00029             //pc.printf(temp);
00030             send_msg((char*)(msg + 2));
00031             //send_msg((char*)temp);
00032         break;}    
00033     }
00034     
00035     return true;
00036 }