Random Projects and Comments

Home Arduino Libraries Arduino Producer-Consumer Library

Arduino Producer-Consumer Library

Links two arduinos together using a buffer on the producer side. One 32bit word
one byte of metadata, and one byte of checksum is transmitted in each message.

The library can be found at gitHub http://github.com/suttonr/Arduino-Producer-Consumer-Library



        • Wire.begin(addr) should be done in calling program’s setup() func
          Producer will be setup as a I2C slave with the address specified in
          Producer::Producer(int address);
        • Wire.onRequest(void(*)()) must be setup in calling program’s setup() to
          call a local function which references Producer::i2cRequest()
          ***TODO: FIX THIS***


      • When the buffer is written one byte of metadata is attached to the data.
        Producer::writeBuffer(word data,byte meta);



      • Wire.begin() should be done in calling program’s setup() func
      • Consumer will be setup as a I2C master and read from the slave with address
        specified in Consumer::Consumer(int address);


        • Consumer::readBuffer() returns the meta for the received data
            Special metas:

          • 0xFF – Buffer full
          • 0xFE – Checksum failed ( data lost )
        • Consumer::getValue(meta) returns the most recent data for that meta
        • Consumer::getUpdate() reads all avaiable data in buffer, only data for most
          recent meta is avaiable


      • Arduino 0019 or greater


      • Only I2C implemented
      • No data handshake, if checksum failes data is lost.
      • Does not tell the producer when buffer is full (dumps the buffer and ‘resets’ the buffer)


      • To install copy the ProducerConsumer/ directory into your arduino ‘libraries’



        cp -a ProducerConsumer [/path/to/arduino]/libraries

One Response

  1. […] 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: […]

© Ryan M Sutton, 2015