Random Projects and Comments

Home Arduino Arduino Producer-Consumer Library v0.1

Arduino Producer-Consumer Library v0.1

As I mentioned in my last post I have cleaned up the Producer-Consumer library I started yesterday. It now includes the Producer class and some examples.

Technically I believe the Producer::writeBuffer(…) method should report back that the buffer is full so that the Producer stops writing to the buffer until the Consumer has read something from the buffer. The particular use I have for this I am more interested in the most recent values rater then stale values in the buffer so if the buffer overflows it will send a buffer overflow message to the Consumer on the next read, then reset the buffer ( _buffRead = _buffWrite ).

Right now the setup of the Producer is a bit complicated since the calling program must setup the function pointers for the Wire library. I can not figure out how to do this internally with the way function pointers work in c++. I have tried making the Producer class an extension of the Wire (TwoWire actually) and overloading the onRequest() method which got me the closest but w/o a JTAG debugger I can’t see why that wasn’t working so I just have the calling program handle it for now.

Anyways, the little documentation I have written is over here: http://www.ryanmsutton.com/arduino-producer-consumer-library/ The examples on gitHub are probaly the most useful: https://github.com/suttonr/Arduino-Producer-Consumer-Library/tree/master/ProducerConsumer/Examples

Tags: ,
© Ryan M Sutton, 2015