Hi,
In my project, data is continuously sent to the UART in packets of 6 bytes and I am reading these 6 bytes by using UartRead(6,0). Now sometimes, I am expecting a special string of data to arrive at the UART. In order to differentiate this special string from the usual 6 byte data, I need to check the first 6 bytes, which is simply accomplish with by same UartRead(6,0) as mentioned above.
My problem is when I try to get the rest of the data - after the first 6 bytes - from that special string, the data is random and is not what I expect. Is there a way to retreive the correct data? I am using the UartRead(data_length, 0) which does not accomplish what I want. And I had also tried using the *p_additional_req_data_length (found in the uartRxDataCallback) to specify any additional bytes I want to read. This also does not give me the data I desire.
Is the problem due to the UartRead(6,0) call? Does this function store the first 6 bytes of the special string then discard the rest of the data in the UART? Is this why I get random data when I call UartRead() again or use *p_additional_req_data_length?
How should I go about retrieving the data after detecting the special string with UartRead(6,0) and given that I know the length of the data from those 6 bytes I have?