I am getting the following exception error when trying to detect or connect to any device USB/SD that is not connected. Which stops me from continuing with the rest of my application. I have tried to catch/throw the exception but It doesnt get caught and get a prompt from vs to break or continue.
I have also tried the PersistentStorage.DetectSDCard() which also throws the same error! I am using the GHIElectronics.NETMF.IO version 4.1.3.0
I have disabled the following on my debugger, but still crashed.
* Go to Tools/Options/Debugging and turn off “Enable Just My code (Managed only)”. or option.
* Go to Debugger/Exceptions and turn off "User-unhandled" for Common-Language Runtime Exceptions.
An unhandled exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.IO.dll
using System;
using System.Threading;
using System.IO;
using GHIElectronics.NETMF.IO;
namespace SD.Startup
{
public static class SDCard
{
private static PersistentStorage sd;
public static void ConnectSD()
{
sd = new PersistentStorage("SD"); // Error thrown here.
sd.MountFileSystem();
}
}
}
You can’t create the PersistentStorage(“SD”) object unless there IS a SD card inserted. Before creating the object make sure there is a SD card by using the PersistentStorage.DetectSDCard()
try and catch should work fine. This is standard .NET C#.
DetectSDCard() method is not available on ChipworkX. If you want to detect the SD card, you have to connect the SD Detect pin to an InterruptPort on ChipworkX. There are other posts about this on the forum…
I am now getting alot of Microsoft.SPOT.IO.dll exceptions. That cannot be handled which terminates my application.
I have been trying to work with the sd card. But keep getting Microsoft.SPOT.IO.dll exceptions.
Detecting when a card is inserted works fine. Acessing the SD is where it starts crashing. I have formatted the card FAT 32 on my pc, but the chipwork board says its not. So, I try to format it using the volumeinfo class and format method but that crashes. I’ve tried another sd card, stripped my code to basic (below). Also, my system crashes when I use the UnmountFileSystem() function on my NAND or any hostusb.
using System;
using System.IO;
using System.Threading;
using Microsoft.SPOT;
using GHIElectronics.NETMF.IO;
namespace Test
{
class Program
{
public static void Main()
{
PersistentStorage sdcard = new PersistentStorage("SD");
sdcard.MountFileSystem();
Microsoft.SPOT.IO.VolumeInfo[] AllVol =Microsoft.SPOT.IO.VolumeInfo.GetVolumes();
if (!AllVol[1].IsFormatted)
{
// quick check make sure I dont wipe my NAND!! //
if (AllVol[1].Name.ToUpper() == "SD")
{
AllVol[1].Format("FAT", 0, true); // Crash here
}
}
}
}
}
Am I doing something wrong, or maybe it could be a hardware failure.
I found that I needed to put a delay in either after declaring the PersistantStorage object or after mounting the file system (don’t remember which). It seems some cards can be a bit slow in responding.
I have tried this already, but will try again. I’m not sure why the format option using the volumeinfo doest worked, that method worked fine on my nand.
Thanks
Ok, that never worked. I can detect the SD card. But for some reason not talk to it. I can read/write to the sd cards on my PC. hummm strange
I’m having the same problem described in this post but I’m using Domino and the newest SDK. The SD card is formated, inserted before running the program. All dll referenced are from the same SDK. This is my code:
Debug.Print("Please insert SD card...");
while (!PersistentStorage.DetectSDCard())
Thread.Sleep(1000);
Debug.Print("SD card detected");
try
{
using (var sd = new PersistentStorage("SD"))
{
sd.MountFileSystem();
var volume = VolumeInfo.GetVolumes()[0];
if (volume.IsFormatted)
{
Debug.Print(volume.RootDirectory);
foreach (var dir in Directory.GetDirectories(volume.RootDirectory))
{
Debug.Print(dir + "/");
}
foreach (var file in Directory.GetFiles(volume.RootDirectory))
{
Debug.Print(file);
}
}
else
{
Debug.Print("SD card not formatted");
}
sd.UnmountFileSystem();
}
}
catch (Exception e)
{
Debug.Print(e.Message);
}
It seems that my SD card is not compatible. I tried the same code with a 2GB card (Kingston SDC/2GB) and it works. My card however (Kingston SDC4/4GB) causes an exception. I read that PersistentStorage is able to use SD cards > 2GB (SD HC) so I assume something is wrong ? My card works on PC just fine.