diff --git a/main.cpp b/main.cpp index eb60797..3aacfd3 100644 --- a/main.cpp +++ b/main.cpp @@ -50,9 +50,8 @@ static void printf_sync(const char *fmt, ...){ static void serial_command_handler(CommandTask *cmd_task){ const char *cmd_str = (const char *)cmd_task->command; - if(strstr(cmd_str, PING_COMMAND) == cmd_str){ + if(strstr(cmd_str, PING_COMMAND) == cmd_str) printf_sync("%d:%s\n", cmd_task->id, PING_RESPONSE); - } } static void read_serial_line_task(void *params){ @@ -69,9 +68,7 @@ static void read_serial_line_task(void *params){ continue; } - if(c == '\r'){ - continue; - } + if(c == '\r') continue; if(c == '\n'){ buf[it] = '\0'; @@ -81,9 +78,7 @@ static void read_serial_line_task(void *params){ continue; } - if(it < MAX_COMMAND_LENGTH - 1){ - buf[it++] = (char)c; - } + if(it < MAX_COMMAND_LENGTH - 1) buf[it++] = (char)c; else{ printf_sync("Command too long, discarding\n"); it = 0; @@ -153,7 +148,6 @@ static void serial_processing_task(void *params){ if(cmd_task_p->id == -1 || cmd_task_p->command[0] == '\0' || !is_valid_command(cmd_task_p->command)){ - printf_sync("Invalid command format: %s\n", buf); clear_command_task(cmd_task_p); xQueueSendToBack(command_handler_task_queue, &cmd_task_p, portMAX_DELAY); @@ -187,18 +181,14 @@ extern "C" void vApplicationStackOverflowHook(TaskHandle_t task, char *task_name (void)task_name; taskDISABLE_INTERRUPTS(); - while(true){ - tight_loop_contents(); - } + while(true) tight_loop_contents(); } static void init_serial_queue(){ serial_queue = xQueueCreate(MAX_SERIAL_QUEUE_COUNT, sizeof(char[64])); if (serial_queue == NULL) { printf("Failed to create serial queue\n"); - while(true){ - tight_loop_contents(); - } + while(true) tight_loop_contents(); } } @@ -206,25 +196,19 @@ static void init_command_handler(){ command_handler_task_queue = xQueueCreate(COMMAND_HANDLER_TASK_COUNT, sizeof(CommandTask*)); if (command_handler_task_queue == NULL) { printf("Failed to create command handler task queue\n"); - while(true){ - tight_loop_contents(); - } + while(true) tight_loop_contents(); } for(int i = 0; i < COMMAND_HANDLER_TASK_COUNT; i++){ CommandTask *cmd_task = (CommandTask*)malloc(sizeof(CommandTask)); if(cmd_task == nullptr){ printf("Failed to allocate memory for command task\n"); - while(true){ - tight_loop_contents(); - } + while(true) tight_loop_contents(); } if(xTaskCreateAffinitySet(command_handler_task, "CmdHandler", DEFAULT_TASK_STACK_SIZE, cmd_task, COMMAND_HANDLER_TASK_PRIO, distilleCore(0), &cmd_task->task_handle) != pdPASS){ printf("Failed to create command handler task\n"); - while(true){ - tight_loop_contents(); - } + while(true) tight_loop_contents(); } clear_command_task(cmd_task); @@ -236,9 +220,7 @@ static void init_serial_out_mutex(){ serial_out_mutex = xSemaphoreCreateMutex(); if (serial_out_mutex == NULL) { printf("Failed to create serial output mutex\n"); - while(true){ - tight_loop_contents(); - } + while(true) tight_loop_contents(); } } @@ -255,9 +237,7 @@ int main(){ vTaskStartScheduler(); - while (true) { - tight_loop_contents(); - } + while (true) tight_loop_contents(); } /*