Go Down

Topic: Yun V:2 SD card file locking - Yun shield and arduino  (Read 3130 times) previous topic - next topic


I'm in well into writing a web server running on the Yun shield which creates and modifies files on the SD card.  The Arduino reads those files to perform some timed I/O tasks.

Has anybody addressed the issue of writing code to implement locking those files so that only one of those processors can access the files at a time? A search here returned no results.



I've not tried it, but the way I would approach it is to skip the FileIO class in your sketch. Instead, write some sort of Linux code (Python, shell script, or your favorite language) to do the file access and call that script from your sketch using a Process object. Do your file I/O through the Process object.

What this does is it performs all of the SD card access through Linux code that you control. Now your problem is reduced to one of being strictly Linux file locking - the Arduino side is removed from the equation. It should be simpler to find a solution that way.

Go Up