Andy's Workshop Forums

General Category => stm32plus C++ library => Topic started by: mhel on December 01, 2015, 01:53:34 pm

Title: Bug...maybe.
Post by: mhel on December 01, 2015, 01:53:34 pm
Hi,
I think I may have found a bug in CircularBufferInputOutputStream.
I'm testing it with usart receive interrupt. The buffer seems to get full
even if I'm reading it right away. I'm doing it this way:
In the interrupt routine

d = _usart.receive();
if (!inStream.isFull())
inStream.write(d);

then in my GetChar which I call in main, this what it does:

if (inStream.available()) {
     d = inStream.read();
     _usart.send(d);
}

In

  int16_t CircularBufferInputOutputStream::read() {
    ....
    if(_readPtr >= _buffer + _bufferSize) {
      _readPtr=_buffer;
    _wrappedWrite = false;  /* This seems to be a fix */
    }
    return value;
  }


I add _wrappedWrite = false;

It would be nice to have a confirmation if it's a bug or I'm doing it wrong again  :)
Title: Re: Bug...maybe.
Post by: Andy Brown on December 02, 2015, 03:52:15 am
Thanks for reporting this, I promise I'll investigate and fix any problem. It may take a couple of weeks though as I'm very busy with something else.