bbcmicrobit / bbcmicrobit/micropython

Better filesystem support for logging (e.g. append mode for files)

Open
#677 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
646
Forks
290
PR merge metrics
No merged PRs in 30d

Description

My use case is to log various occurences to the filesystem, so they can be later retreived, regardless of power cycles. Files cannot be opened in append mode, so the current recommendation is to read the entire file, add lines to it, then write it back to the file system. Given the RAM constraints of the microbit, this is not feasible after a little while - there is ~30 KB of usable disk space, but 16KB RAM in total (presumably much less is available to the user program).

My current approach is to store my entire data structure in RAM, and periodically write it to disk, but this severely limits how much I can log as RAM is much smaller than disk space. This is also made harder as there is no way to tell how much disk space is free; the only way seems to be to try writing, and catch the OSError if it fails.

Being able to write to files in append mode would be the simplest solution here from my perspective, but if that's too difficult, are there other ideas?

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.