private void Test()
        {
            Debug.Print("Program started - memory = " + Debug.GC(false));

            var isInserted = Mainboard.IsSDCardInserted;
            var isMounted  = Mainboard.IsSDCardMounted;

            if (!isMounted)
            {
                Mainboard.MountStorageDevice(@"SD");
            }

            var mb = Mainboard;
            var sd = mb.SDCardStorageDevice;
            var vi = sd.Volume;

            //vi.Format("FAT", 0, "TEST", true);
            vi.Refresh();
            var totalSize = vi.TotalSize;
            var freeSpace = vi.TotalFreeSpace;

            Debug.Print("totalSize = " + totalSize);
            Debug.Print("freeSpace = " + freeSpace);

            for (var preAlloc = 20000; preAlloc < 40000; preAlloc += 1000)
            {
                Thread.Sleep(250);
                Debug.GC(true);
                RunTests(preAlloc);
            }
        }
Esempio n. 2
0
        /// <summary>Attempts to mount the card.</summary>
        /// <returns>Whether or not the card was successfully mounted.</returns>
        public bool Mount()
        {
            if (this.IsCardMounted)
            {
                throw new InvalidOperationException("The card is already mounted.");
            }

            return(Mainboard.MountStorageDevice("SD"));
        }
Esempio n. 3
0
        /// <summary>Attempts to mount the mass storage device.</summary>
        /// <returns>Whether or not the mass storage device was successfully mounted.</returns>
        public bool MountMassStorage()
        {
            if (this.IsMassStorageMounted)
            {
                throw new InvalidOperationException("The mass storage is already mounted.");
            }
            if (!this.IsMassStorageConnected)
            {
                throw new InvalidOperationException("There is no mass storage device connected.");
            }

            return(Mainboard.MountStorageDevice("USB"));
        }
Esempio n. 4
0
        //
        // SD Card
        //

        private void SDCardTest()
        {
            Debug.Print("MEM: " + Debug.GC(false));

            string[] vols = Mainboard.GetStorageDeviceVolumeNames();
            foreach (string vol in vols)
            {
                Debug.Print("volume: " + vol);
                bool result = Mainboard.MountStorageDevice(vol);
                Debug.Print("mounted: " + result);
            }
            Debug.Print("MEM: " + Debug.GC(false));

            VolumeInfo[] volInfos = VolumeInfo.GetVolumes();
            foreach (VolumeInfo volInfo in volInfos)
            {
                Thread.Sleep(50);
                Debug.Print("MEM: " + Debug.GC(false));

                string rootDir = volInfo.RootDirectory;
                Debug.Print("root dir: " + rootDir);

                string[] fileNames = Directory.GetFiles(rootDir);
                foreach (string fileName in fileNames)
                {
                    Thread.Sleep(50);
                    Debug.Print("MEM: " + Debug.GC(false));

                    Debug.Print("file name: " + fileName);

                    String filePath = Path.Combine(rootDir, fileName);
                    Debug.Print("file path: " + fileName);

                    Thread.Sleep(50);
                    Debug.Print("MEM: " + Debug.GC(false));

                    string fileText = GetFileText(filePath);
                    Debug.Print(">>>");
                    Debug.Print(fileText);
                    Debug.Print("<<<");
                }
            }

            Debug.Print("Program Started");
        }
Esempio n. 5
0
 /// <summary>
 /// Attempts to mount the file system of a non-volatile memory card
 /// and create a <see cref="T:Microsoft.Gadgeteer.StorageDevice"/> object
 /// associated with the card.
 /// </summary>
 /// <remarks>
 /// <para>
 ///  Use <see cref="MountSDCard"/> and <see cref="UnmountSDCard"/>
 ///  to manually mount and dismount the file system on the non-volatile memory card.
 /// </para>
 /// <para>
 ///  If you call this method when there is no memory card inserted into the
 ///  slot, or the card is already mounted, this method has no effect.
 /// </para>
 /// <para>
 ///  For more information on when you need to use this method, see <see cref="SDCard"/>.
 /// </para>
 /// </remarks>
 public void MountSDCard()
 {
     if (!IsCardMounted)
     {
         try
         {
             //_storage = new PersistentStorage("SD");
             //_storage.Mount();
             Mainboard.MountStorageDevice("SD");
             IsCardMounted = true;
             Thread.Sleep(500);
         }
         catch
         {
             ErrorPrint("Error mounting SD card - no card detected.");
         }
     }
 }