Hoping for some ideas on why my SD card no longer reads or writes after my upgrade to Firmware_NetduinoPlus_4.2.0.0_RC3.
I am using a 4gig HD SD card that worked with the same source code on a later version of 4.1, in fact its been logging data and running a threaded web server for about a month without this problem.
Today, after the upgrade, my code no longer works, so to try to debug it I have been using someones test code that reproduces the same fault. See below.(Thanks for the demo code)
Firstly an exception gets thrown as the first line runs. This has been mentioned in the forums and after about 30 seconds the code continues.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files\Secret Labs\Netduino SDK\Assemblies\v4.2\le\SecretLabs.NETMF.Hardware.NetduinoPlus.dll', Symbols loaded.
A first chance exception of type 'System.NotImplementedException' occurred in Microsoft.SPOT.Native.dll
(I am not sure if this is part of the main problem, I just included it for completeness, apparently it will be suppressed in the release build. All I can say is that waiting 30 seconds or so is annoying.)
The real problem happens when an exception gets thrown on Directory.SetCurrentDirectory(root);
A first chance exception of type 'System.NotSupportedException' occurred in Microsoft.SPOT.IO.dll
A first chance exception of type 'System.IO.IOException' occurred in System.IO.dll
If I dig deeper into the exception I get
ErrorCode DirectoryNotFound System.IO.IOException.IOExceptionErrorCode
There is also m_HResult -486539264 int
There clearly is a directory here because the previous line
System.IO.Directory.GetDirectories(@"\") returns an array of which element the first element is "\\SD";
Other things to bear in mind are I installed the RC3 in the correct order as per the instructions and all the referenced .net micro framework assemblies have a version of 4.2 and a runtime version of v4.0.30319 (Although I dont know what the difference is)
Here is the full test code.
using System; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading; using Microsoft.SPOT; using Microsoft.SPOT.Hardware; using SecretLabs.NETMF.Hardware; using SecretLabs.NETMF.Hardware.NetduinoPlus; namespace MicroSdTest { public class Program { private static System.Text.UTF8Encoding encoding = new System.Text.UTF8Encoding(); const String root = "\\SD"; public static void Main() { try { System.IO.Directory.GetDirectories(@"\"); Directory.SetCurrentDirectory(root); String[] files = Directory.GetFiles("."); foreach (String file in files) { Debug.Print(file); } String dir = Directory.GetCurrentDirectory(); String fileName = "testsdcard4gig.txt"; Debug.Print(fileName); String testWrite = "Hejsan hoppsan i lingonskogen!"; File.WriteAllBytes(fileName, encoding.GetBytes(testWrite)); byte[] testRead = File.ReadAllBytes(fileName); Debug.Print(new String(encoding.GetChars(testRead))); Thread.Sleep(100000); } catch (Exception ex) { Debug.Print(ex.Message); } } } }