I am attempting to use the implementation of PublishQueueAsyncRK that uses an sdCard for persistent storage of publish events, however at the same time a requirement of this application is to publish asynchronously the values of another SPI chip that is read every 50ms, the code looks something like this:
bool readFlag = false;
bool publishFlag = false;
void readTimerHandler() { readFlag = true; }
void publishTimerHandler() { publishFlag = true; }
Timer readTimer(50, powerTimerHandler);
Timer publishTimer(2000, publishTimerHandler);
readTimer.start();
publishTimer.start();
void loop() {
if(readFlag) {
// use SPI to read values from sensor here
}
if(publishFlag) {
// use PublishQueueAsyncSdFat to publish the data, asynchronously using the queue
publishQueue.publish(event);
}
}
I am encountering problems with this code (seizes execution and returns a loop error 1) and I believe this issue to be related to the queue library using the SPI for the sd card while at the same time my sensors using the SPI for reading.
It is paramount that the reading of the sensors take place every 50ms, I have experimented with pausing the publishing of the queue, adding all of the events, and then resuming once the readings are finished, however this results in the same loop error 1.
Thanks in advance, Ozzie