Fine!
I have got another idea, the opposite of resizing buffers: optionally using global static ones. I think about an additional constructor, that takes two buffers (pointer and size), or a replaceBuffer method. The buffers can be static (not dynamic allocated), so the memory usage calculation of the compiler recognizes them. What do you think about?
Or is there a preprocessor directive to tell the compiler the additional memory usage? So MODSERIAL keeps full control over the buffers. Like this:
#pragma ram_add("pc serial tx buffer", 256) // <-- such thing existing?
#pragma ram_add("pc serial rx buffer", 512)
MODSERIAL pc(USBTX, USBRX, 256, 512);
The Cookbook page needs an update too. There are links to Andy Kirkhams old MODSERIAL repository. The complete page, not only a link at the bottom ;)
And the rtos methods.... I think a remake would be good, because MODSERIAL has grown to a big confusing construct. Some things (like the Parity-Enum, or the macros) are not necessary and the buffers used with enum IrqType? Wouldn't an enum BufferType do a better job? I know, never touch a running system.... But the next person, who want's to bugfix something, should be able to understand it.
Hi! I am using the latest MODSERIAL library from "Erik Olieman".
I have tried the Buffer Resize Example from Cookbook but there are some bugs. First of all: The BufferOversize (shouldn't its name be BufferUndersize?) is thrown at the false condition. size is new buffers size, buffer_count[type] is current buffers content size, which should fit in the new buffer.
RESIZE.cpp, line 58
After this change, the resize returns no error code. But with a filled buffer, it does not work. If I start transmission of some bytes and immediately calling txBufferResize and adding some more bytes, the output is completely rubbish.
Here is my test program with the MODSERIAL library and the "<= >= fix" (to avoid BufferOversize Error): http://developer.mbed.org/users/BlazeX/code/Test_MODSERIAL_BufferResize/
In short: this source code is transmitting "DHello World! newÝõ!T"
The sourcecode looks like it would stop Interrupts, to prevent buffer modification. And the old buffer gets coppied into the new buffer, the ring buffer cursors are getting updated too. But something goes wrong.
Erik, please help!