SD card support on Cerbuino Bee

Valkyrie-MT,

What board are you using with this example? Can try to see if you can read the file data if you use C#? We tested the Cerberus with the SD Module’s mount commands and we were able to read the data from an SD card.

I created a new gadgeteer project and selected Cerberus (even though I have a CerbuinoBee). I did that because it says socket 7 is invalid if I use a CerbuinoBee on the design surface (see message earlier in thread).


            Debug.Print("Program Started");

            var sd = new SDCard(7);
            sd.MountSDCard();
            var storage = sd.GetStorageDevice();
            var s = storage.ReadFile("\\SD\\test.txt");  //  < --  Throws System.IO.IOException here
            Debug.Print(new string(Encoding.UTF8.GetChars(s)));

I am using a CerbuinoBee. Can you verify whether the new Beta works with the CerbuinoBee’s onboard MicroSD card slot?

Thanks.

The Cerbuino Bee’s Micro SD slot was tested in a Gadgeteer project but, as it is does not utilize a socket, it has to be handled differently within Gadgeteer as Gadgeteer is event driven. Wednesday morning we will be able to give a proper example how to utilize this code to make the slot work within Gadgeteer.

@ Aron - Any follow up to this…I am also trying to use the onboard SD of the Cerbuino Bee. Many thanks in advance.

We are working on a code sample to aid in Cerbuino SD Card Projects using Gadgeteer. We will post as soon as we can. :slight_smile:

1 Like

Thanks for getting the SD card working GHI! :slight_smile: I’ve got a project or two that’s been on hold until now, and I’m really excited to be able to move forward with them now that the SD card is supported.

For those of you who would like to get something working in the mean time, here’s what I did:

Usings:

using GHIElectronics.Gadgeteer;
using System.IO;
using System.Text;

Code:


            var board = new FEZCerbuinoBee();

            var fileSystems = Microsoft.SPOT.IO.VolumeInfo.GetFileSystems();

            if (fileSystems.Length < 1)//make sure there is an SD card inserted
                return;

            board.MountStorageDevice("SD");

            var volumes = Microsoft.SPOT.IO.VolumeInfo.GetVolumes();


            var rootDirectory = volumes[0].RootDirectory;

            var files = Directory.GetFiles(rootDirectory);
            var directories = Directory.GetDirectories(rootDirectory);

            var logFileName = Path.Combine(rootDirectory, "log.txt");

            Stream stream;
            if (File.Exists(logFileName))
            {
                stream = File.OpenWrite(logFileName);
                stream.Position = stream.Length;//go to end of file
            }
            else
                stream = File.Create(logFileName);
            
            using(var writer = new StreamWriter(stream))
            {
                writer.WriteLine("File system mounted");
            }

            var fileBytes = File.ReadAllBytes(logFileName);
            var logFileContents = new string(Encoding.UTF8.GetChars(fileBytes));

This probably isn’t the “right” way to do it and it doesn’t handle inserts or ejects, but at least it will get you rolling.

3 Likes

AWESOME! I should have explored the classes more. I did not notice the FEZCerbuinoBee.MountStorageDevice method. That was the missing piece.

Now I see why I was thrown off the trail… It doesn’t use the SDCard class at all! :slight_smile:

Thanks Scott! I will try it tonight!
-Valkyrie-MT

I never noticed it either, until I used Jetbrains’ DotPeek to examine the code inside of the SDCard class. Desperate times call for desperate measures!

Any more movement on this? Was an example posted? I am currently floored that the Cerbuino Bee that just arrived does not appear to have any way to access the built in SD Card… which is one of the reasons that I purchased this specific configuration!!!

@ Peter Valentine - try http://www.tinyclr.com/forum/topic?id=8556&page=2#msg84904

1 Like

@ Aron - hey any luck with creating that template for gadgeteer for the SD card slot? do you think it would be hard to implement the same thing for the zigbee slot?

I’m considering extending these ports for the sake of consistency and ease of use. Just got my first .NET MF device (Cerbuino) so just starting out :slight_smile:

Thanks