Hi Rick, thanks for the reply. Maybe I just don’t understand how this library is constructed -
In PublishQueueAsyncRK.h within the conditional compile for #if defined(__MB85RC256V_FRAM_RK) || defined(DOXYGEN_BUILD)
after the constructors in the setup() class there is this use of header.size
if (header.magic == PUBLISH_QUEUE_HEADER_MAGIC && header.size == len) {
Where len is size_t type and could be >64k whereas header.size is uint16_t?
For a FRAM of len 131072 say this would be false.
||/**|
|---|---|
|| * @brief The header, copied from FRAM|
|| */|
PublishQueueHeader header;
Where the typedef struct PublishQueueHeader is defined as:
typedef struct { // 8 bytes
uint32_t magic; //!< PUBLISH_QUEUE_HEADER_MAGIC
uint16_t size; //!< retainedBufferSize, in case it changed, or for file systems, this is the number of events that have been sent already
uint16_t numEvents; //!< number of events, see the PublishQueueEventData structure
} PublishQueueHeader;
For the second part - I am trying to implement a mechanism that stores an event just before the queue is full to later recover and explain why events have been dumped thereafter. To do this I figure I need to know the freespace before queuing an event. Unless you can think of a better way?
I am thinking that free space could be calculated as;
size_t freespace = len;
nextFree = start + sizeof(PublishQueueHeader);
for(uint16_t ii = 0; ii < header.numEvents; ii++) {
nextFree = skipEvent(nextFree, eventBuf);}
freespace -=nextFree;
return freespace;
Does this need a StMutexLock
before it like getNumEvents();
?