AnsweredAssumed Answered

How to reduce UART buffer size according to the received data ?

Question asked by Amit Kumar on Mar 19, 2014
Latest reply on Mar 27, 2014 by Amit Kumar


I am Using K60, I am trying to communicate with a GPS using some AT commands. The input coming from the GPS is of 79 bits including CRC, LF,CR bits. So I declared the buffer size to char receive_buff[79]. So while receiving 79 bits its giving the complete value, but in case when GPS signal is not present the data being received from the GPS varies from 40 bits to 65 bits and is random.

So in this case the values is not displayed until the buffer is full by the next data.

My concern is I want to display the coming data no matter if the data is on full signal strength or low signal. so How do i operate with half filled buffer?

also, If I want to flush the data of the buffer , how do I do it?

Is there any way to insert '\0' to the remaining bits of the buffer which is larger than data received?  As per the datasheet, the bufffer should be filled according to  the size of UART buffer declared initially otherwise 2 data will be added and the result will be displayed skipping the accordingly. Please look into the matter




Amit Kumar