it seems my Rhino OEM kit has some problems reading from SDs. The display and the wiznet ethernet module are working fine.
Here is the code I’m using for accessing the SD (it is that of the beginners book):
using System;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.IO;
using Microsoft.SPOT.Hardware;
using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.IO;
using System.IO;
using System.Text;
namespace FEZ_Rhino_Application1
{
public class Program
{
public static void Main()
{
PersistentStorage mSD = new PersistentStorage("SD");
mSD.MountFileSystem();
string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
FileStream fileHandle = new FileStream(rootDirectory + @ "\records.txt", FileMode.Open, FileAccess.Read);
byte[] data = new byte[100];
int readCount = fileHandle.Read(data, 0, data.Length);
fileHandle.Close();
Debug.Print("The size of data we read is: " + readCount.ToString());
Debug.Print("data from file:");
Debug.Print(new string(Encoding.UTF8.GetChars(data),0, readCount));
mSD.UnmountFileSystem();
}
}
}
I get the error on line
FileStream fileHandle ...
Attached you can find the screenshot of the error.
Using an external power supply (7.5 volts, 500mA) I received the same error.
Same code and same SD card are working using a fez domino without external power supply.
The SD card is FAT32. I also try to format the SD card using FAT16. Nothing. I read all the posts regarding this problem. Someone solve the problem paralleling a capacitor on C10 but that was on a Domino and not on a Rhino.
All the Rhino IOs are not used.
Have you made sure you have the latest and matching firmware and GHI SDK installed? NotSupported errors tend to be related to that kind of thing. And make sure if you do have to reinstall SDKs that you create a new project.
Wow, good suggestion. Before deploying the software I checked the SDK version and firmware. But I’m going to check again… I will be back in few minutes…
What is the exception message you are getting?
Maybe you need to try to list files first? Take a look at the example in the PersistentStorage library documentation.
This is the debug window result when using the file listing example found in the documentation.
Storage “\SD” is inserted.
Getting files and folders:
Storage is not formatted. Format on PC with FAT32/FAT16 first.
Storage “\SD” is ejected.
Is there something special I have to do to format the card? I’m using Vista x64 OS; I right click on the SD and select format. I try to format again one of the SD and I got the same error (Storage is not formatted).