anna I also just noticed that the remaining values in the data array are not logged outside of while(!Bela_stopRequested()): How can it be ensured that any remaining values in the data array are logged if a stop is requested?
WriteFile
also waits on Bela_stopRequested()
and once that is set, it dumps all its current content to disk and it stops. So if you log()
any data after that it will likely not get written to disk. This is normally not a problem, if one is calling log()
continuously, however in this case you are not doing that, for the reasons seen above. WriteFile
could probably be amended to keep logging everything until it gets destroyed. However, as mentioned earlier, for your application you do not need the overhead of WriteFile
and you could just use std::ofstream
or similar to dump the vector's content to file at predefined intervals.
anna If WriteFile is the problem (as you indicated above
The way it is currently used it shouldn't be a problem anymore, except for what noted above.
anna Do you know what else might be causing these 10ms spikes?
Other system load of any sort ... network ... disk ... other processes ... whatever ... point is the I2C driver is not real-time safe and it cannot guarantee an upper bound on its execution time.
You could try to boost the priority of the task: replace
Bela_runAuxiliaryTask(loop);
with
Bela_runAuxiliaryTask(loop, 90);