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

Detecting SD card insert, eject


  • Please log in to reply
1 reply to this topic

#1 Llaves

Llaves

    New Member

  • Members
  • Pip
  • 9 posts

Posted 04 February 2012 - 12:40 AM

I wrote the code below to detect the insertion of the microSD card and tested it using an 8GB (Transcend) card. It failed to detect the card. When I tried it with a 1GB card, it worked. I've seen the other posts that show that larger cards don't consistently work (and I'm still running the default 4.1.0 release), but I expected the insert interrupt to be triggered by the mechanical insertion of the card, not the actual mount. So, I'm posting this here for the next person who gets surprised by this behavior and starts tearing out his/her hair.

using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.IO;
using SecretLabs.NETMF.Hardware;
using SecretLabs.NETMF.Hardware.NetduinoPlus;

namespace CardReadWriteTest
{
  public class CardReadWriteTest
  {
    static void SD_Insert(object sender, MediaEventArgs args)
    {
      Debug.Print("Card Inserted");
    }

    public static void Main()
    {
      RemovableMedia.Insert += new InsertEventHandler(SD_Insert);
      Debug.Print("Insert card now");
      Thread.Sleep(10000);
      if (VolumeInfo.GetVolumes().Length > 0)
        Debug.Print("Volume found");
      else
        Debug.Print("No volumes found");
      Debug.Print("Exiting");
    }


  }
}


#2 Chad Kittel

Chad Kittel

    New Member

  • Members
  • Pip
  • 4 posts
  • LocationBeaver Dam, WI

Posted 06 March 2012 - 01:29 AM

Thanks a lot for posting this observation. I guess it makes sense that the Insert event only happens once the volume is actually usable.




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.