Netduino home hardware projects downloads community

Jump to content


Photo

SD Card cannot get basic example working


  • Please log in to reply
10 replies to this topic

#1 Julian de Wit

Julian de Wit

    New Member

  • Members
  • Pip
  • 6 posts

Posted 13 December 2010 - 02:38 PM

Hi I want to try my SD card on de the netduino plus.
I downloaded the SDK from this website yesterday.

I could not find documentation so I figured out the following code.
However it gives "CLR_E_VOLUME_NOT_FOUND".. What do I do wrong ?
I read something online about mounting and a certain dll (SecretLabs.NETMF.IO.dll ) but I cannot find that dll.

Can anybody help me getting started ?

    public class Program
    {
        public static void Main()
        {
            var dir = Directory.GetCurrentDirectory();
            var fileName = Path.Combine(dir, "test.txt");
            Debug.Print(fileName);
            byte[] testBytes = new byte[] { 1,2,3,4 };
            File.WriteAllBytes(fileName, testBytes);
        }

    }

Output :

\test.txt
#### Exception System.IO.IOException - CLR_E_VOLUME_NOT_FOUND (1) ####
#### Message:
#### System.IO.Path::NormalizePath [IP: 0070] ####
#### System.IO.Path::GetFullPath [IP: 001a] ####
#### System.IO.FileStream::.ctor [IP: 0009] ####
#### System.IO.File::WriteAllBytes [IP: 0012] ####
#### NetduinoPlusApplication1.Program::Main [IP: 0025] ####
A first chance exception of type 'System.IO.IOException' occurred in System.IO.dll
An unhandled exception of type 'System.IO.IOException' occurred in System.IO.dll

#2 AlfredBr

AlfredBr

    Advanced Member

  • Members
  • PipPipPip
  • 138 posts
  • LocationConnecticut, USA

Posted 13 December 2010 - 05:41 PM

What size SD card are you using?

#3 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7103 posts
  • LocationNew York, NY

Posted 13 December 2010 - 05:44 PM

Hi Julian, Welcome to the Netduino community. Three quick things: 1. The MicroSD card will be mounted at \SD\ rather than \ 2. MicroSD cards up to 2GB are generally supported. 3. SecretLabs.NETMF.IO is only needed for manually mounting and dismounting--on the regular Netduino. The Netduino Plus automatically mounts and dismounts MicroSD Cards. Does that help? Chris

#4 Julian de Wit

Julian de Wit

    New Member

  • Members
  • Pip
  • 6 posts

Posted 13 December 2010 - 07:11 PM

Thanks for the fast replies... I needed to write to the "\SD\" map... That was it... I'm still wondering if there is any documentation about this in the wild ? But I can go on with my project !!

#5 Chris Walker

Chris Walker

    Secret Labs Staff

  • Moderators
  • 7103 posts
  • LocationNew York, NY

Posted 13 December 2010 - 08:00 PM

Thanks for the fast replies...

I needed to write to the "\SD\" map... That was it...

I'm still wondering if there is any documentation about this in the wild ?

But I can go on with my project !!


Hi Julian,

It works exactly like the file IO commands on the desktop... Card is auto-mounted. Would you like us to recommend a few good pointers on .NET file system code?

Chris

#6 nturpin77

nturpin77

    Advanced Member

  • Members
  • PipPipPip
  • 42 posts
  • LocationNewfoundland, Canada

Posted 19 January 2011 - 05:30 PM

are there any examples of sending data from the serial lines to a file on the SD card?

#7 Govind

Govind

    New Member

  • Members
  • Pip
  • 5 posts

Posted 14 November 2012 - 06:47 PM

when i try to read a text file from sd card i am getting the below error

Exception:
Exception was thrown: System.IO.IOException

StackTrace:
Microsoft.SPOT.IO.NativeIO::GetAttributes
System.IO.FileStream::.ctor
System.IO.FileStream::.ctor
System.IO.StreamReader::.ctor
NetduinoPlusApplication1.Program::ReadTextFile
NetduinoPlusApplication1.Program::Main

can someone let me know what is wrong in this code.
Code:
        public static void ReadTextFile()
        {
            try
            {
                var dir = Directory.GetCurrentDirectory();

                using (var reader = new StreamReader(@"\SD\" + "Sample1.txt"))
                {
                    string line;

                    while ((line = reader.ReadLine()).Length != 0)
                    {

                    }
                }
            }
            catch (Exception ex)
            {

            }
        }

Edited by Chris Walker, 14 November 2012 - 06:50 PM.
added [code][/code] tags


#8 Coyttl

Coyttl

    Advanced Member

  • Members
  • PipPipPip
  • 54 posts
  • LocationSilver Spring, MD, USA

Posted 14 November 2012 - 06:50 PM

Try reformatting your card (to be safe, FAT, not FAT32) and making sure the file exists.. :)

#9 Govind

Govind

    New Member

  • Members
  • Pip
  • 5 posts

Posted 22 November 2012 - 06:42 PM

Thanks for your help. After formatting the sd card i was able to read the file. Now I am trying to read every pixel value of a bitmap file present in sd car, but got struck could you please give some links or sample code? Below is what i tried using (var filestream = new FileStream(@"\SD\Sample.bmp", FileMode.Open)) { StreamReader sr = new StreamReader(filestream); Stream strm = sr.BaseStream; int len = int.Parse( strm.Length.ToString()); Byte[] bt = new Byte[len]; strm.Read(bt, 0, len); strm.Close(); sr.Close(); } bt will have only 346 elements where as my bitmap file has 24*19 => 456 pixels. Please help me to read every pixel(all 456 pixel) value of a bitmap. Thanks in advance for your help.

#10 Govind

Govind

    New Member

  • Members
  • Pip
  • 5 posts

Posted 26 November 2012 - 04:44 PM

Can any one help me on the above post? Thanks in Adavance Srinivas R

#11 tim c

tim c

    Advanced Member

  • Members
  • PipPipPip
  • 31 posts

Posted 26 November 2012 - 06:33 PM

Can any one help me on the above post?

Thanks in Adavance
Srinivas R



What happens if you replace all your code with this:

Byte[] bt = File.ReadAllBytes(@"\SD\Sample.bmp");




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

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