#include "uart.h" #include "stdio.h" #include "main.h" /* #define MAX_LEN 100 void handleCmdRx() { static int mode = -1; static unsigned char str[MAX_LEN]; static unsigned char *valP; static int reset = 1; if( reset == 1 ) { valP = str; mode = 0; reset = 0; } while( serialAvailable() ) { const unsigned char c = serialRead(); if( !(c>='0' && c<='9') && !(c>='a' && c<='z') && !(c>='A' && c<='Z') && c!='\"' && c!=',' && c!='.' && c!='{' && c!='}') { reset = 1; } else { if( mode == 0 && c=='{' ) { *(valP)++ = c; mode = 1; } else if( mode == 1 && c=='}' ) { *(valP)++ = c; *(valP)++ = '\0'; int val=-1; const int no = sscanf((const char *)str,"{%d}",&val); if( no == 1 ) { HAL_GPIO_WritePin(GPIOC, GPIO_PIN_13, (val==1)?GPIO_PIN_RESET:GPIO_PIN_SET); } reset=1; } else if( mode==1 ){ *(valP)++ = c; } } } } */