Open SungMatt opened 1 year ago
I believe your proposed explanation is inaccurate. I am pretty sure many people were facing this even when properly shutting down, given how common it was. Last iteration of this fieldwork, there was no flush commands used, and most people did not properly shut down, and yet file corruption was still less common.
An addition for an index was added to the measurement code. This repeated writing and flushing (while keeping the file open) has unintended consequences when power is forcibly removed from the Pi, and the Pi shuts down without closing the file properly.
@mingyi456 pointed out that this is likely due to flush() being used, and opening and closing the file at every loop would probably prevent this.
Issue should be quickly solved by repeatedly fopen() and fclose() file upon write success!
https://github.com/nus-sps/earth-sensors-article/commit/ca6275b850a0332163c8b61dddd3e83914a9197f