-
May 2nd, 2010, 02:29 PM
#1
need help with circularbuffer warkmark level
I am treating a circular buffer like a buffer.
I have a situation that can occur in my design. I could receive 384 bytes into the circular buffer, and I only read 48 bytes. I don't want to keep turning on an off the RTS signal, for the validity of the checkWaterMarkLevel. I do this check after I have received data do not want to drop any data.
If you have better way of doing this let me know.
bool CircularBuffer::checkWaterMarkLevel()
{
bool waterMarkLevelcheck = false;
int waterMarkLevel;
waterMarkLevel = bufferSize/2;
if( writeCount - readCount >= waterMarkLevel)
{
waterMarkLevelcheck = false;
}
else
{
waterMarkLevelcheck = true;
}
return waterMarkLevelcheck;
}
-
May 2nd, 2010, 04:33 PM
#2
Re: need help with circularbuffer warkmark level
I have no idea what you are trying to do, and since I have no information on what a watermark or how you implemented you circular buffer, I can't help much either.
I will say this though. boost has a circular_buffer container. Maybe using that could help?
I don't see how a watermark could be part of a circular buffer. Don't mix container and containee details.
Is your question related to IO?
Read this C++ FAQ article at parashift by Marshall Cline. In particular points 1-6.
It will explain how to correctly deal with IO, how to validate input, and why you shouldn't count on "while(!in.eof())". And it always makes for excellent reading.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|