cancel
Showing results for 
Search instead for 
Did you mean: 

Handling UART receive

mm.51
Associate II

I'm looking into creating a splashscreen and handling the uart responses. How can I wait for the input without consistently sending the response messaging. I'm unsure how to handle responses from the uart receive line.

 

 

enum splashscreen_response_type { TEST_RESPONSE_VALID, TEST_RESPONSE_INVALID, TEST_RESPONSE_UNKNOWN, TEST_RESPONSE_MAX }; int bootup_disp() { int test_type_response = TEST_RESPONSE_UNKNOWN; char input[100]; // Buffer to hold the user input int processed_input; int chosen_test; int resp_buff[1]; HAL_UART_Transmit(&hlpuart1,(uint8_t*)"USER CHOICE TYPE 1 for test:", sizeof("USER CHOICE TYPE 1 for test:"), 500); HAL_UART_Transmit(&hlpuart1,(uint8_t*)"TYPE USER CHOICE:", sizeof("TYPE USER CHOICE:"), 500); do{ HAL_UART_Receive(&hlpuart1,splash_resp_buff, 1,500); if(resp_buff == 1) { HAL_UART_Transmit(&hlpuart1,(uint8_t*)"CORRECT CHOICE", sizeof("CORRECT CHOICE"), 500); test_type_response = TEST_RESPONSE_VALID); } else { HAL_UART_Transmit(&hlpuart1,(uint8_t*)"INCORRECT CHOICE", sizeof("INCORRECT CHOICE"), 500); } } while (test_type_response != TEST_RESPONSE_VALID);*/ HAL_UART_Transmit(&hlpuart1,(uint8_t*)splash_resp_buff, sizeof(splash_resp_buff)-1, 500);
View more

 

 

2 REPLIES 2
Uwe Bonnes
Principal III

Your code accepts any input as valid and no user input as invalid. You should consider no user input as a NO-OP and not as a incorrect choice.

What do you mean by NO-OP ? So are you saying I should accept no response as incorrect ? What would you recommend doing ?