Dimension
June 30th, 2004, 03:45 AM
Hi,
I have some issues regarding circular buffer for Serial Data.
Here is the scenario:
My system circular buffer is only 250 bytes, and with frequent incoming serial data, it can easily occupy the buffer, and the retrieval process (retrieve byte by byte) directly from system buffer, will not be good enough, as I face some data loss, and affect other operation as well.
Incoming message will have follow format.
{# Payload-Length Actual-Message Checksum }
{ :1byte
# :1byte
Payload Length :2 bytes (length of Actual-Message)
Actual-Message :few-bytes
Checksum: 2 bytes
} : 1 byte
There will be frequent messages like that coming in consecutively.
Possible solution is to put all the incoming data from System buffer into Circular Application Buffer, and do the analysis of the data. So that system buffer will not be jammed up, and other operations can process as well.
Let say, I have a function named retrieve_char(..) to retrieve byte by byte from system buffer as below:
char x;
retrieve_char(&x);
How can I create a proper circular app buffer and do the analysis of the Actual message, in order to avoid system buffer overflow ?
Thanks.
I have some issues regarding circular buffer for Serial Data.
Here is the scenario:
My system circular buffer is only 250 bytes, and with frequent incoming serial data, it can easily occupy the buffer, and the retrieval process (retrieve byte by byte) directly from system buffer, will not be good enough, as I face some data loss, and affect other operation as well.
Incoming message will have follow format.
{# Payload-Length Actual-Message Checksum }
{ :1byte
# :1byte
Payload Length :2 bytes (length of Actual-Message)
Actual-Message :few-bytes
Checksum: 2 bytes
} : 1 byte
There will be frequent messages like that coming in consecutively.
Possible solution is to put all the incoming data from System buffer into Circular Application Buffer, and do the analysis of the data. So that system buffer will not be jammed up, and other operations can process as well.
Let say, I have a function named retrieve_char(..) to retrieve byte by byte from system buffer as below:
char x;
retrieve_char(&x);
How can I create a proper circular app buffer and do the analysis of the Actual message, in order to avoid system buffer overflow ?
Thanks.