This question may be a duplicate of this question or this question
I am using C and trying to communicate with a device which works on serial communication. I am reading a single byte and storing it in an array and then checking the array element to '\0'
(0x00
). If it's '\0'
then that means the data is now not available.
volatile int rxFlag = 0;
volatile int index = 0;
void function() //event based function, whenever a byte is received
{
Rx[index] = ReadUSART(); //reading a byte
if(Rx[index] == '\0' ) //checking if its null
{
rxFlag = 1; //raise a flag
}
index++; //increment index
}
Below is the screenshot of the Rx:
In the image you can see the from Rx[0]-Rx[24]
it contains data but Rx[25]
is a null terminator (0x00
) and the rxFlag
should be set to 1. But it is not set.
What is the another way of checking if the array element is '\0'
.