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"); } } }
Detecting SD card insert, eject
Started by Llaves, Feb 04 2012 12:40 AM
1 reply to this topic
#1
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.
#2
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