Hi
I want to read in a sequenze of character over UARTE0 pheripheral on the NRF52840. I use the function getchar() but the first two characters I get is always the last two characters received which is always \n and \r. I solve this by running getchar() 2 times to empty the RX buffer before I start receiving new characters but is there a more elegant way to solve this, empty the buffer withput knowing hov many characters there is left in the buffer. The code below works, but is there a more elegant way to check UARTE0 events, or start/stop RX buffer or something?
else if ( strcmp(string2, "send_binary_lpc_code") == 0 ) {
char a;
int b = 0;
getchar();
getchar();
do {
printf("type new character:");
a = getchar();
printf("\r\ncharacter %i: %c\r\n", b+1, a);
b = b + 1;
} while ( b < 6 );
}

