Is there way to stop datalogger in movesense when memory is full using internal access?

42 Views Asked by At

Performed tests:

Test1: The whole memory 383KB (left the first 1KB for BLE stack) is allocated to Datalogger and Logbook.
All the previous logs are cleared and datalogger is started with a new id and data paths to use full memory.
When all the memory is used and full, it starts to overwrite the previously saved content in the same log and the size stagnates at (382-383 KB). I could all the 383kB of data right after stopping the datalogger without resetting the sensor, but if I reset the device and check the size of the saved log it gives a different size (something way less than 383kB, I am assuming it's the size of data that is left after overwriting)

Test2: Cleared the whole memory and created two logs of the sizes 50kB, 100kB and started another log (all with different log Id's) to full capacity.
Now when the memory is full, it starts to overwrite the firs most log that is saved and then the next and finally it overwrites itself and size again stagnates at 383kB.
Could read the whole contents before reset but after a reset the size changes as it happened with the previous test.

I tried to subscribe to /Mem/Logbook/IsFull/Subscription but it throws an error like res=FULL, unsuported datatype. etc
Couldn't find a way to resolve that.
How to make the Datalogger stop logging when memory is full?
And get a call back to the application when it happens?

1

There are 1 best solutions below

0
PetriL On

You can subscribe to the /Mem/Logbook/IsFull with the following firmware code:

// Subscribe to mem full notification
asyncSubscribe(WB_RES::LOCAL::MEM_LOGBOOK_ISFULL());

And stop the logging by adding this piece in the switch statement in onNotify() callback:

case WB_RES::LOCAL::MEM_LOGBOOK_ISFULL::LID:
{
    // Stop Logging when logbook mem is full
    const bool isFull = value.convertTo<bool>();
    DEBUGLOG("onNotify MEM_LOGBOOK_ISFULL: %d", isFull);
    if (isFull)
    {
        asyncPut(WB_RES::LOCAL::MEM_DATALOGGER_STATE(), AsyncRequestOptions::Empty, WB_RES::DataLoggerStateValues::DATALOGGER_READY);
    }
    break;
}

Full disclosure: I work for the Movesense team