Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

SD card I/O exception thrown

SD Card I/O exception

  • Please log in to reply
7 replies to this topic

#1 upswing

upswing

    New Member

  • Members
  • Pip
  • 8 posts

Posted 23 August 2013 - 12:10 AM

The following code throws an I/O exception

 

string message = "This is a test";

try

{

System.Collections.IEnumerable x = Directory.EnumerateDirectories(@"SD");

}

catch (Exception exc)

{

message = exc.Message;

}

 

 



#2 upswing

upswing

    New Member

  • Members
  • Pip
  • 8 posts

Posted 23 August 2013 - 02:59 PM

I get an exception when trying to write read a micros SD card 4GB Fat32 using a netduino 2 plus

 

Exception was thrown: System.NotSupportedException

Stack Trace

Microsoft.SPOT.IO.NativeIO::GetAttributes
System.IO.FileStream::.ctor
System.IO.FileStream::.ctor
System.IO.StreamWriter::.ctor
System.IO.StreamWriter::.ctor
NetduinoApplication1.Program::Main

 

Code is

try

{

using (StreamWriter SW = new StreamWriter("SDtest.txt"))

SW.WriteLine("test");

using (StreamReader SR = new StreamReader("SDtest.txt"))

Debug.Print(SR.ReadLine());

}

catch (Exception exc)

{

message = exc.Message;

}

 

 

 

Can anyone help please

?



#3 upswing

upswing

    New Member

  • Members
  • Pip
  • 8 posts

Posted 23 August 2013 - 03:09 PM

I have tested this on two different netduino 2 +

 

I have tried SD cards 2GB, 4 GB, 8GB. 

 

I use Micro framework version 4.2

 

Can anyone help, please



#4 xelatan

xelatan

    New Member

  • Members
  • Pip
  • 3 posts

Posted 23 August 2013 - 05:57 PM

I am Having the same issue with my Netduino and SD cards.

 

Also I have been trying to use the simulator to write to and SD card.

 

That has also proven futile. Seems like the simulator does not support creating a directory.

 

So any hints on where to go would be great.

 

Thanks



#5 xelatan

xelatan

    New Member

  • Members
  • Pip
  • 3 posts

Posted 23 August 2013 - 05:59 PM

I did the same test under the 4.3  Micro framework version. With the same result 

 

 

string message = "This is a test"; try { System.Collections.IEnumerable x = Directory.EnumerateDirectories(@"SD"); } catch (Exception exc) { message = exc.Message; }



#6 Maurice

Maurice

    New Member

  • Members
  • Pip
  • 8 posts
  • LocationSeattle, WA

Posted 24 August 2013 - 12:08 AM

I have tested this on two different netduino 2 +

 

I have tried SD cards 2GB, 4 GB, 8GB. 

 

I use Micro framework version 4.2

 

Can anyone help, please

 

Upswing, The specsfor the N2+ state that only up 2GB is supported. Be sure the card is formated as FAT or FAT32.



#7 upswing

upswing

    New Member

  • Members
  • Pip
  • 8 posts

Posted 28 August 2013 - 05:56 PM

Got a new 2GB card today and I can read it now. However I could not buy that size in any store and I had to order it on the internet.  Which leads to the following question:

 

Why are the newer SD cards (4GB, 8GB etc..) not supported? These cards are the only ones that can be purchased in brick and mortar stores.  Are there any plans to lift this really restrictive restriction soon?



#8 David Weaver

David Weaver

    Advanced Member

  • Members
  • PipPipPip
  • 50 posts
  • LocationBloomington IL

Posted 29 August 2013 - 05:32 PM

This is some code that works on my Netduino 2 + using  VS Express for desktop 2012. 

 

 

        '*****Rem use this line for appending files
        '***** Dim MyStreamWriter As New StreamWriter(File.Open("sdsettingsmyfirstfile.txt", FileMode.Append))
     
        '*****Rem writes over the existing file
        Dim MyStreamWriter As New StreamWriter(File.OpenWrite("sdsettingsMyfirstfile.txt"))
 
        MyStreamWriter.WriteLine("This is the first line.")
        MyStreamWriter.WriteLine("This is the second line.")
        MyStreamWriter.Flush()
        MyStreamWriter.BaseStream.Flush()
        MyStreamWriter.BaseStream.Close()
        MyStreamWriter.Dispose()
 
             
        Dim MyFileStream As FileStream = File.OpenRead("sdsettingsmyfirstfile.txt")
        Dim MyStreamReader As New StreamReader(MyFileStream)
 
        '****Rem Change this line to read one line MyStreamReader.ReadLine()
        'Dim MyReadtoEnd As String = MyStreamReader.ReadToEnd
     
        Debug.Print(MyReadtoEnd)
 
        MyStreamReader.Close()
        MyStreamReader.Dispose()





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.