diff --git a/mpu_user_console_etu.c b/mpu_user_console_etu.c index 52a3be43538088b5bf764147c7eb09d983eaab36..03e0d5b119f35e538b4a336bce7fc6676c3d6895 100644 --- a/mpu_user_console_etu.c +++ b/mpu_user_console_etu.c @@ -66,12 +66,12 @@ void ask_user_input(void) { char switch_cmd[] = "switch"; char status_cmd[] = "status"; - PRINT("(%s) Would you like to `switch` or display `status` errors : ", - is_supervisor_mode ? "Supervisor" : "User") - ; + PRINT("\r\n(%s) Would you like to `switch` or display `status` errors : ", + is_supervisor_mode ? "Supervisor" : "User"); // fflush(stdin); // fscanf(stdin, "%s", buff); uart_scanf(buff); + PRINT("\r\n"); if (strncmp(buff, switch_cmd, strlen(switch_cmd)) == 0) { // permute through svc depending on flag @@ -81,14 +81,14 @@ void ask_user_input(void) { if (strncmp(buff, status_cmd, strlen(status_cmd)) == 0) { if (idx_error == 0) { - PRINT("No errors have occurred yet\n") + PRINT("No errors have occurred yet\r\n") ; return; } for (int i = 0; i < idx_error; i++) { if (i < BUF_SIZE) { - PRINT("Address that shat the bed : 0x%x\tError code : 0x%x\n", + PRINT("Address that shat the bed : 0x%x\tError code : 0x%x\r\n", arr_addr[i], arr_err_code[i]) ; } diff --git a/user_cmd.c b/user_cmd.c index 409f9e42b7f497f9ccf2d782cf21201f31e2e291..cdb3b6a351ce321ab9f1b378348fb0843f6768bf 100644 --- a/user_cmd.c +++ b/user_cmd.c @@ -31,15 +31,16 @@ void SVC_Handler() { void uart_scanf(char *buff) { char user_input[USER_INPUT_SIZE] = { 0 }; - size_t idx = 1; + char current = 0; + size_t idx = 0; - while (user_input[idx - 1] != '\n') { - idx--; - user_input[idx] = uart0_rec_byte_ref(); + while (current != '\r') { + current = uart0_rec_byte_ref(); + user_input[idx] = current; idx++; } - user_input[idx - 1] = '\0'; + user_input[idx-1] = '\0'; memcpy(buff, user_input, USER_INPUT_SIZE); } @@ -49,10 +50,8 @@ void exec_user_read_write() { int i = 0, coma_nb = 0, value_idx; unsigned addr, value; - PRINT( - "Write an hexadecimal address for reading <addr> or <addr>,<value> for writing (%s):\n", - is_supervisor_mode ? "Supervisor" : "User") - ; + PRINT("Write an hexadecimal address for reading <addr> or <addr>,<value> for writing (%s):\r\n", + is_supervisor_mode ? "Supervisor" : "User"); // fflush(stdin); // fscanf(stdin, "%s", str); diff --git a/user_cmd.h b/user_cmd.h index 5554108c1ebd1dbfd5a384eca2550e0a23b91729..39aa642ebd59629a542329c74b255a4691e318d1 100644 --- a/user_cmd.h +++ b/user_cmd.h @@ -18,7 +18,8 @@ static char uart_stdout[UART_STDOUT_SIZE] = { 0 }; #define uart_printf(...) \ snprintf(uart_stdout, UART_STDOUT_SIZE, __VA_ARGS__); \ - uart0_send_ref((uint8_t *)uart_stdout, UART_STDOUT_SIZE); + uart0_send_ref((uint8_t *)uart_stdout, UART_STDOUT_SIZE); \ + memset(uart_stdout, 0, UART_STDOUT_SIZE); #if !UART_ENABLE #define PRINT printf