I’ve had a couple of Flash Modules ( https://www.ghielectronics.com/catalog/product/389 ) for a very long time and never got around to playing around with them but lately I had a project where I wanted some persistent storage and so this module fit the bill rather nicely. When I found @ taylorza very worthy FlashFileSystem module driver I thought hey this just makes it too easy to use, but their wasn’t a 4.3 driver so I’d thought I fix that and after talking with @ taylorza we decided to check the code etc into ‘Gadgeteer Community’ site on CodePlex https://wegadgeteer.codeplex.com such that both the source code and an installer https://wegadgeteer.codeplex.com/releases/view/611095 are available. Thanks again to @ taylorza for this very helpful and cool module driver.
6 Likes
Just so people get an idea of just how easy this is to use this is the code from the TestApp (I always try to have a TestApp that shows how to use a module)
if (!flashFileSystem.CheckIfFormatted())
{
flashFileSystem.Format();
}
flashFileSystem.Mount();
var newfile = "file";
var count = 0;
while (flashFileSystem.Exists(newfile + count + ".txt"))
{
count++;
}
newfile = newfile + count + ".txt";
var openfile = flashFileSystem.Create(newfile);
var stream = new StreamWriter(openfile);
stream.WriteLine("Hello World");
stream.Close();
openfile.Close();
flashFileSystem.Copy(newfile, TRASHTHIS);
var fileNames = flashFileSystem.GetFiles();
foreach (var fileName in fileNames)
{
var size = flashFileSystem.GetFileSize(fileName);
var creation = flashFileSystem.GetFileCreationTime(fileName);
Debug.Print(fileName + " " + size + " " + creation);
}
openfile = flashFileSystem.Open(newfile, FileMode.Open);
var reader = new StreamReader(openfile);
var message = reader.ReadLine();
Debug.Print(message);
reader.Close();
stream.Close();
flashFileSystem.Delete(TRASHTHIS);
if (flashFileSystem.Exists(TRASHTHIS))
Debug.Print("Delete Failed");
else
{
Debug.Print("Delete success");
}
flashFileSystem.Compact();
1 Like
How thread safe is it? Can I write different files simultaneously from different threads?
@ ianlee74 - All file operations are synchronized so you should not have issues writing to the device from multiple threads. Of course if you find any issues I will address them to the best of my abilities.
2 Likes
Oh sure, keep bragging about how smart you are! 8)
1 Like
@ Gary - My challenge is time… Being smart is just a matter of being good at Google.
1 Like