I am transmitting and receiving between a terminal on my phone and a bluetooth module connected to a microcontroller (pic18f).
I set up an array of 4, char input[4] = ""
to store the user input from the terminal. The function getsUSART(input,4)
places input in there.
The problem is, when I check what is in input, I see that this is 'ABC/UN' when I type ABC in the terminal. Is /UN an escape sequence? If so, what key is it for?
Also, if I'd like to compare input to a string, let's say the string is 'hey'
would I do char str1[4] = "hey/UN"
and then strcmp(input, str1) == 0
?
Edit:
So the compiler library (USART) can be accessed here, page 66 I believe: http://ww1.microchip.com/downloads/en/DeviceDoc/MPLAB_C18_Libraries_51297f.pdf
This is the relevant code, just for getting the input and putting null:
char input[4] = "";
while(BusyUSART());
while (!DataRdyUSART());
getsUSART(input, 4); //Get the input.
// NULL terminate the string for putsUSART call.
input[4] = '/0';
putrsUSART("Input:");
putsUSART(input);
I am trying to null terminate it when I do input[4] = '/0', am I doing something wrong here if it isn't null terminating?