Beispiel #1
0
        public static void Main()
        {
            SDCard sdCard = new SDCard();
            //todo: need sdCard mode detection
            ILogger logger = new PersistenceWriter(new FileStream(@"\SD\telemetry.bin", FileMode.CreateNew), new TelemetryFormatter());
            //ILogger logger = new DebugLogger(); // use for debugging
            //ILogger logger = new NullLogger(); // use for release

            //Assumes one type of speed controller on quad
            //ISpeedControllerSettings speedControllerSettings = new HobbyKingSs2530Settings();

            //IPWM pwmFront = new SecretLabsPWM(Pins.GPIO_PIN_D9);
            //SpeedController electricSpeedControllerFront = new SpeedController(speedControllerSettings, pwmFront);

            //IPWM pwmRear = new SecretLabsPWM(Pins.GPIO_PIN_D8);
            //SpeedController electricSpeedControllerRear = new SpeedController(speedControllerSettings, pwmRear);

            //IPWM pwmRight = new SecretLabsPWM(Pins.GPIO_PIN_D8);
            //SpeedController electricSpeedControllerRight = new SpeedController(speedControllerSettings, pwmRight);

            //IPWM pwmLeft = new SecretLabsPWM(Pins.GPIO_PIN_D8);
            //SpeedController electricSpeedControllerLeft = new SpeedController(speedControllerSettings, pwmLeft);


            MotorMixer mixer = null;

            PIDSettings[]          pidSettings    = GetPIDSettings();
            AxesController         axesController = new AxesController(pidSettings[0], pidSettings[1], pidSettings[2], true);
            Gyro                   gyro           = new DefaultGyro(new AircraftPrincipalAxes());
            Radio                  radio          = new DefaultRadio(null, null);
            ControllerLoopSettings loopSettings   = GetLoopSettings();
            Controller             controller     = new Controller(mixer, axesController, gyro, radio, loopSettings, GetMotorSettings(), logger);
        }
Beispiel #2
0
        // Method No. 2
        private void sdCardController_CardMounted(SDCard sender, SDCardController sdController)
        {
            display.SimpleGraphics.Clear();
            display.SimpleGraphics.DisplayText("SD card mounted", font, GT.Color.Red, 0, 0);

            // Reading config
            string configText = sdController.GetTextFile(CONFIG_FILENAME);

            this.configManager = new ConfigManager(configText);

            this.emptyTemplate = sdController.GetTemplate(this.configManager.EmptyTemplatePath);

            if (this.emptyTemplate == null)
            {
                display.SimpleGraphics.Clear();
                display.SimpleGraphics.DisplayText("Template not found. Reload required.", font, GT.Color.Red, 0, 0);
                throw new EGDNoTemplateFile("Could not load template file. Check SD card content if EMPTY_TEMPLATE_FILENAME exists.");
            }

            // SD card initialized
            // Initializing GSM network

            this.gsm = new NetworkConnector(cellularRadio, display);
            this.gsm.NetworkRegistered += gsm_NetworkRegistered;
            this.gsm.EnsureNetwork();

            // Async code. End point: Method No. 3
        }
 private void InitializeModules()
 {
     Button = new Button(4);
     Camera = new Camera(3);
     Screen = new Display_T35(14, 13, 12, 10);
     SdCard = new SDCard(5);
 }
        /// <summary>
        /// Constructor for mounting SD card or internal storage..
        /// Example NfStorage SD = new SDCardSPI("SPI1",26)
        /// One or more SPI pins can be changed
        /// </summary>
        public NfStorage(string SpiDevice, int CSPin)
        {
            try
            {
                // Mount a SPI connected SDCard passing the SPI bus and the Chip select pin
                SDCard.MountSpi(SpiDevice, CSPin);

                if (SDCard.IsMounted)
                {
                    Debug.WriteLine("Success SDCard is mounted");

                    StorageFolder externalDevices = Windows.Storage.KnownFolders.RemovableDevices;

                    var removableDevices = externalDevices.GetFolders();

                    //Set the Storage variable
                    SDevice = removableDevices[0];
                }
            }

            catch (Exception ex)
            {
                Debug.WriteLine("Failed to mount SDCard \n" + ex.Message);
            }
        }
        public static void Execute()
        {
            Debug.WriteLine($"== Scenario0_mountDevice ==");

            //  With Esp32 we need to mount the SDCard, STM32 CHibios devices are mounted automatically

            //  Windows.Storage.Devices.SDCard is a static class used to mount the SDcard.
            //  Currently implemented for ESP32 as the SDCard is not automatically mounted when the card is inserted.
            //  Also this allows the mount parameters to be passed depending on configuration of the running ESP32 module.
            //  Currently only 1 SDCard can be mounted which becomes drive "D:\", this may change later.
            try
            {
                // Uncomment the mount statement for the type of connected SDCard

                // Mount a MMC sdcard using 4 bit data ( e.g Wrover boards )
                //SDCard.MountMMC(false);

                // Mount a MMC sdcard using 1 bit data ( e.g Olimex EVB boards )
                //SDCard.MountMMC(true);

                // Mount a SPI connected SDCard passing the SPI bus and the Chip select pin
                // Default pins for "SPI1" : Mosi=23  Miso=25  Clk=19
                // Or use different pins by calling the Hardware.ESp32.Configuration.SetPinFunction()
                // Use Chip select on another pin like gpio 26

                SDCard.MountSpi("SPI1", 26);
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Failed to mount SDCard :-{ex.Message}");
                // No point continuing
                throw new Exception("Mount failed");
            }
        }
Beispiel #6
0
    public SDCard Sandisk(SDCard sd)
    {
        SDCard sdc = new SDCard();

        sdc.memory = memory + sd.memory;
        return(sdc);
    }
Beispiel #7
0
        public void correct_time_stamp(SDCard sdCard)
        {
            Measurement mymeasure     = new Measurement();
            string      rootDirectory = sdCard.StorageDevice.RootDirectory;
            FileStream  FileHandle    = new FileStream(rootDirectory + @"\SetUp.txt", FileMode.Open, FileAccess.Read);

            byte[] data       = new byte[100];
            int    read_count = FileHandle.Read(data, 0, data.Length);
            string str        = new string(Encoding.UTF8.GetChars(data), 0, read_count);

            Debug.Print(str);
            string[] parts = str.Split(' ');
            lastSent   = Int32.Parse(parts[0]);
            lastTosend = Int32.Parse(parts[1]);
            FileHandle.Close();
            //FileStream
            //public static TimeSpan operator -(DateTime d1, DateTime d2);

            int j;

            if (lastSent == 0)
            {
                j = lastSent;
            }
            else
            {
                j = lastSent + 1;
            }
            for (int i = j; i <= lastTosend; i++)
            {
                FileStream fs = new FileStream(rootDirectory + @"\wrong_toSend" + i + ".JSON", FileMode.Open, FileAccess.Read);
                try
                {
                    byte[]         data1        = new byte[100];
                    int            read_count1  = fs.Read(data1, 0, data1.Length);
                    string         str1         = new string(Encoding.UTF8.GetChars(data), 0, read_count1);
                    JsonSerializer myserializer = new Json.NETMF.JsonSerializer(DateTimeFormat.Default);
                    mymeasure = (Measurement)myserializer.Deserialize(str1);
                    Debug.Print(i + " " + mymeasure.iso_timestamp.ToString());
                    DateTime d2 = mymeasure.iso_timestamp;
                    DateTime d1 = DateTime.Now; //starting local time
                    TimeSpan T  = d2 - d1;
                    DateTime d3 = DateTime.Now - T;
                    mymeasure.iso_timestamp = d3;
                    JSON.printString(sdCard, mymeasure, true);
                    // d1 =


                    //File.Delete(rootDirectory + @"\wrong_tosend" + i + ".JSON");

                    fs.Close();
                }
                catch (System.IO.IOException)
                {
                    Debug.Print("File " + i + "not found.\n");
                }
            }
        }
Beispiel #8
0
        static void SDMountThread()
        {
            SDCard    SD        = null;
            const int POLL_TIME = 500; // check every 500 millisecond

            bool sdExists;

            while (true)
            {
                try // If SD card was removed while mounting, it may throw exceptions
                {
                    sdExists = !sdCardDetect.Read();

                    // make sure it is fully inserted and stable
                    if (sdExists)
                    {
                        Thread.Sleep(50);
                        sdExists = !sdCardDetect.Read();
                    }

                    if (sdExists && SD == null)
                    {
                        SD = new SDCard();
                        SD.Mount();
                    }
                    else if (!sdExists && SD != null)
                    {
                        SD.Unmount();
                        SD.Dispose();
                        SD = null;
                    }
                    else if (sdExists && SD != null)
                    {
                        if (sdCardWriteProtect.Read() == true)
                        {
                            ReadyWrite = false;
                            //Debug.Print("ReadyWrite: false");
                        }
                        else
                        {
                            ReadyWrite = true;
                            //Debug.Print("ReadyWrite: true. Flushing!");
                            volume_info.FlushAll();
                        }
                    }
                }
                catch
                {
                    if (SD != null)
                    {
                        SD.Dispose();
                        SD = null;
                    }
                }

                Thread.Sleep(POLL_TIME);
            }
        }
 public PromptForm(ref GHI.Glide.Display.Window window, ref Gadgeteer.Modules.GHIElectronics.DisplayTE35 displayTE35, ref SDCard sdCard, ref USBHost usbHost, ref USBClientEDP usbClientEDP, ref WiFiRS21 wifiRS21)
     : base(ref window)
 {
     this.usbClientEDP = usbClientEDP;
     this.usbHost      = usbHost;
     this.sdCard       = sdCard;
     this.displayTE35  = displayTE35;
     this.wifiRS21     = wifiRS21;
 }
Beispiel #10
0
 /// <summary>
 /// If SDcard is mounted Unmount the SDCard
 /// </summary>
 public void SDCardUnmount()
 {
     //  Currently the mount card class only allows for 1 device to be mounted
     if (SDCard.IsMounted)
     {
         SDCard.Unmount();
         Debug.WriteLine("SDCard successfully unmounted");
     }
 }
        public static void Main()
        {
            //  Windows.Storage.Devices.SDCard is a static class used to mount the SDcard.
            //  Currently implemented for ESP32 as the SDCard is not automatically mounted when the card is inserted.
            //  Also to enable the mount parameters to be passed depending on the running ESP32 module.
            //  Currently only 1 SDCard can be mounted, this may change later.
            try
            {
                // Mount a MMC sdcard using 4 bit data ( e.g Wrover boards )
                SDCard.MountMMC(false);

                // Mount a MMC sdcard using 1 bit data ( e.g Olimex EVB boards )
                //    SDCard.MountMMC(true);

                // Mount a SPI connected SDCard passing the SPI bus and the Chip select pin
                //    SDCard.MountSpi("SPI1", 26);
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Failed to mount SDCard :-{ex.Message}");
            }

            // SDCard is mounted ?
            if (SDCard.IsMounted)
            {
                // Get the logical root folder for all removable storage devices
                // in nanoFramework the drive letters are fixed, being:
                // D: SD Card
                StorageFolder externalDevices = Windows.Storage.KnownFolders.RemovableDevices;

                // list all removable storage devices
                var removableDevices = externalDevices.GetFolders();

                if (removableDevices.Length > 0)
                {
                    // get folders on 1st removable device
                    var foldersInDevice = removableDevices[0].GetFolders();
                    // List all folders
                    foreach (StorageFolder folder in foldersInDevice)
                    {
                        Console.WriteLine($"Folder ->{folder.Path}");
                    }


                    // get files on the root of the 1st removable device
                    var filesInDevice = removableDevices[0].GetFiles();
                    // List all files
                    foreach (StorageFile file in filesInDevice)
                    {
                        Console.WriteLine($"file ->{file.Path}");
                    }
                }
            }

            Thread.Sleep(Timeout.Infinite);
        }
        void sdCard_SDCardMounted(SDCard sender, GT.StorageDevice SDCard)
        {
            sd_mounted = true;

            //Se pinta un cuadrado verde indicando que la tarjeta SD se ha cargado
            graphics.fillScreen(8, 8, GTM.Efelunte.AdafruitLedBackpack.LED_GREEN);

            Debug.Print("SD card has been successfully mounted. You can now read/write/create/delete files");
            Debug.Print("Unmount before removing");
        }
        private static void sdCard_Mounted(SDCard sender, GT.StorageDevice device)
        {
            Debug.Print("SDCard has been Mounted");
            Display.UpdateSDState(true);

            // Delete unsynched files written before reboot
            if (unsynchedToBeRemoved)
            {
                RemoveUnsynchedFiles();
            }
        }
Beispiel #14
0
 private void cardReader_Mounted(SDCard sender, Gadgeteer.StorageDevice device)
 {
     if (sender.StorageDevice.Volume.IsFormatted)
     {
         if (sdCard.IsCardMounted)
         {
             Logger.WriteInfo("RPTR", "Media directory/file listing: ");
             FileListing(sdCard.StorageDevice.RootDirectory);
         }
     }
 }
Beispiel #15
0
 private void cardReader_Mounted(SDCard sender, Gadgeteer.StorageDevice device)
 {
     if (sender.StorageDevice.Volume.IsFormatted)
     {
         if (sdCard.IsCardMounted)
         {
             Logger.WriteInfo("RPTR", "Media directory/file listing: ");
             FileListing(sdCard.StorageDevice.RootDirectory);
         }
     }
 }
        void sdCard_SDCardUnmounted(SDCard sender)
        {
            sd_mounted = false;

            //Se pinta un cuadrado amarillo indicando que la tarjeta SD se ha desmontado
            //graphics.fillScreen(8, 8, GTM.Efelunte.AdafruitLedBackpack.LED_YELLOW);
            graphics.blinkScreen(8, 8, GTM.Efelunte.AdafruitLedBackpack.LED_YELLOW, 10);

            Debug.Print("The SD card has been unmounted");
            Debug.Print("DO NOT try to access it without mounting it again first");
        }
Beispiel #17
0
        public void delete_wrong_file(SDCard sdCard)
        {
            //string json;
            // Measurement mymeasure = new Measurement();
            //string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
            string rootDirectory = sdCard.StorageDevice.RootDirectory;

            FileStream FileHandle = new FileStream(rootDirectory + @"\SetUp.txt", FileMode.Open, FileAccess.Read);

            byte[] data       = new byte[100];
            int    read_count = FileHandle.Read(data, 0, data.Length);
            string str        = new string(Encoding.UTF8.GetChars(data), 0, read_count);

            Debug.Print(str);
            string[] parts = str.Split(' ');
            lastSent = Int32.Parse(parts[0]);

            Debug.Print(lastSent.ToString() + " this is the last sent");
            lastTosend = Int32.Parse(parts[1]);
            Debug.Print(lastTosend.ToString() + " this is the last to send");
            FileHandle.Close();
            FileStream Fs = new FileStream(rootDirectory + @"\SetUp.txt", FileMode.Open, FileAccess.Read);
            int        j;

            if (lastSent == 0)
            {
                j = lastSent;
            }
            else
            {
                j = lastSent + 1;
            }
            for (int i = j; i <= lastTosend; i++)
            {
                try
                {
                    File.Delete(rootDirectory + @"\wrong_toSend" + i + ".JSON");
                }
                catch (System.IO.IOException)
                {
                    Debug.Print("File " + i + "not found.\n");
                }
            }
            string[] list = sdCard.StorageDevice.ListRootDirectoryFiles();
            int      ll   = list.Length;

            Debug.Print("files present in the sd card after deleting the wrong files");
            for (int k = 0; k < ll; k++)
            {
                Debug.Print(list[k]);
            }
            Fs.Close();
        }
Beispiel #18
0
 void sdCard_SDCardMounted(SDCard sender, GT.StorageDevice SDCard)
 {
     sdCard.MountSDCard();
     if (sdCard.IsCardMounted)
     {
         Debug.Print("SD card is mounted");
         Thread.Sleep(2000);
     }
     else {
         Debug.Print("Problem with sd card");
     }
 }
Beispiel #19
0
        public SDCardController(SDCard sdCard, Display_T35 display)
        {
            this.sdCard  = sdCard;
            this.display = display;

            // checking if card inserted INITIALLY
            if (sdCard.IsCardInserted == false)
            {
                display.SimpleGraphics.Clear();
                display.SimpleGraphics.DisplayText("No card on start up.", mainFont, GT.Color.Red, 0, 0);
            }
        }
Beispiel #20
0
        /// <summary>Unmounts the device with the given name.</summary>
        /// <param name="volumeName">The device to unmount.</param>
        /// <returns>Whether or not the unmount was successful.</returns>
        public override bool UnmountStorageDevice(string volumeName)
        {
            if (volumeName == "SD")
            {
                this.sdCard.Dispose();
                this.sdCard = null;

                return(true);
            }

            return(false);
        }
Beispiel #21
0
        /// <summary>Mounts the device with the given name.</summary>
        /// <param name="volumeName">The device to mount.</param>
        /// <returns>Whether or not the mount was successful.</returns>
        public override bool MountStorageDevice(string volumeName)
        {
            if (volumeName == "SD")
            {
                this.sdCard = new SDCard();
                this.sdCard.Mount();

                return(true);
            }

            return(false);
        }
Beispiel #22
0
    public void testSDCard()
    {
        SDCard m1 = new SDCard();
        SDCard m2 = new SDCard();

        m1.setData("4 GB ");
        m2.setData("8 GB ");

        SDCard m3 = m1.Sandisk(m2);

        m1.display();
        m2.display();
        m3.display();
    }
        public static void Execute()
        {
            Debug.WriteLine($"== ScenarioA_UnmountDevice ==");

            //
            //  Unmount device if its been previously mounted.
            //  This is done to allow the card to be removed
            //
            //  Currently the mount card class only allows for 1 device to be mounted
            //
            if (SDCard.IsMounted)
            {
                SDCard.Unmount();
            }
        }
Beispiel #24
0
        public static string GetRootDirectory()
        {
            try
            {
                Logger.Info("Mount", "SD");
                sdCard = new SDCard(SDCard.SDInterface.MCI);
                sdCard.Mount();
                Logger.Info("Mounted", "SD");
            }
            catch
            {
                Logger.Info("Not mounted", "SD");
                return(null);
            }
            try
            {
                if (VolumeInfo.GetVolumes()[0].IsFormatted)
                {
                    string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
                    Logger.Info("Root directory: " + rootDirectory, "SD");

                    /*string[] files = Directory.GetFiles(rootDirectory);
                     * string[] folders = Directory.GetDirectories(rootDirectory);
                     *
                     * Logger.Info("Files available on " + rootDirectory + ":");
                     * for (int i = 0; i < files.Length; i++)
                     *  Logger.Info(files[i]);
                     *
                     * Logger.Info("Folders available on " + rootDirectory + ":");
                     * for (int i = 0; i < folders.Length; i++)
                     *  Logger.Info(folders[i]);*/
                    return(rootDirectory);
                }
                else
                {
                    Logger.Error("Card not formatted!", "SD");
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "getting root directory", "SD");
            }
            return(null);
        }
Beispiel #25
0
        public static string GetRootDirectory()
        {
            try
            {
                Logger.Info("Mount", "SD");
                sdCard = new SDCard(SDCard.SDInterface.MCI);
                sdCard.Mount();
                Logger.Info("Mounted", "SD");
            }
            catch
            {
                Logger.Info("Not mounted", "SD");
                return null;
            }
            try
            {
                if (VolumeInfo.GetVolumes()[0].IsFormatted)
                {
                    string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
                    Logger.Info("Root directory: " + rootDirectory, "SD");
                    /*string[] files = Directory.GetFiles(rootDirectory);
                    string[] folders = Directory.GetDirectories(rootDirectory);

                    Logger.Info("Files available on " + rootDirectory + ":");
                    for (int i = 0; i < files.Length; i++)
                        Logger.Info(files[i]);

                    Logger.Info("Folders available on " + rootDirectory + ":");
                    for (int i = 0; i < folders.Length; i++)
                        Logger.Info(folders[i]);*/
                    return rootDirectory;
                }
                else
                {
                    Logger.Error("Card not formatted!", "SD");
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "getting root directory", "SD");
            }
            return null;
        }
Beispiel #26
0
        public static void Main()
        {
            Debug.WriteLine("Hello from nanoFramework - SD card Mount example");

            // Initialise an instance of SDCard using constructor specific to your board/adapter

            // Boards with SD card interface and parameters built in to firmware
            // mycard = new SDCard();

            // Boards with SDIO/MMC interface with 1 bit data lines ( e.g. ESP32 Olimex EVB , POE )
            // mycard = new SDCard(new SDCard.SDCardMmcParameters { dataWidth = SDCard.SDDataWidth._1_bit });

            // Boards with SDIO/MMC and 4 data lines like Espressif Esp32 Wrover all models, these also support card detect
            //mycard = new SDCard(new SDCard.SDCardMmcParameters { dataWidth = SDCard.SDDataWidth._4_bit, enableCardDetectPin = true, cardDetectPin = 21 });

            // SPI constructors, check SPI bus pins and chip select pins are correct for your board
            // Boards with SDCard on SPI bus, SPI 1 default , no card detect
            mycard = new SDCard(new SDCard.SDCardSpiParameters {
                spiBus = 1, chipSelectPin = 22
            });

            // SPI adapter with Card detect
            // mycard = new SDCard(new SDCard.SDCardSpiParameters { spiBus = 1, chipSelectPin = 22, enableCardDetectPin = true, cardDetectPin = 21 });

            Debug.WriteLine("SDcard inited");

            // Option 1 - No card detect
            // Try to mount card
            MountMyCard();

            // Option 2 use events to mount
            // if Card detect available, enable events and mount when card inserted
            // Enable Storage events if you have Card detect on adapter
            StorageEventManager.RemovableDeviceInserted += StorageEventManager_RemovableDeviceInserted;
            StorageEventManager.RemovableDeviceRemoved  += StorageEventManager_RemovableDeviceRemoved;

            // Unmount drive
            UnMountIfMounted();

            Thread.Sleep(Timeout.Infinite);
        }
Beispiel #27
0
 public GvShell(ref SDCard sdCard, ref USBHost usbHost, ref DisplayTE35 displayT35, ref USBClientEDP usbClientEdp, ref WiFiRS21 wifiRS21)
 {
     //initial / default params
     ForeGround        = GT.Color.White;
     BackGround        = GT.Color.Black;
     ScreenWidth       = 320;
     ScreenHeight      = 240;
     this.wifiRS21     = wifiRS21;
     this.displayTE35  = displayT35;
     this.usbHost      = usbHost;
     this.usbClientEDP = usbClientEdp;
     this.sdCard       = sdCard;
     Screen            = new Bitmap(ScreenWidth, ScreenHeight);
     ClearScreen();
     MaxLine     = ScreenHeight / 20;
     CurrentLine = 0;
     CurrentFont = Resources.GetFont(Resources.FontResources.NinaB);
     CurrentPath = "\\SD\\";
     DataLines   = new ArrayList();
     for (int i = 0; i < MaxLine; i++)
     {
         DataLines.Add(string.Empty);
     }
     TypedCommand = string.Empty; if (basic == null)
     {
         if (basic == null)
         {
             basic              = new SBASIC();
             basic.Print       += Basic_Print;
             basic.ClearScreen += Basic_ClearScreen;
         }
     }
     //setup network
     wifiRS21.DebugPrintEnabled = true;
     NetworkChange.NetworkAvailabilityChanged += NetworkChange_NetworkAvailabilityChanged;
     NetworkChange.NetworkAddressChanged      += NetworkChange_NetworkAddressChanged;
     //setup network
     wifiRS21.NetworkInterface.Open();
     wifiRS21.NetworkInterface.EnableDhcp();
     wifiRS21.NetworkInterface.EnableDynamicDns();
 }
Beispiel #28
0
        public static void printConfiguration(SDCard sdCard, object o)
        {
            string     rootDirectory = sdCard.StorageDevice.RootDirectory;
            string     json;
            FileStream fs;

            fs = new FileStream(rootDirectory + @"\Configuration.JSON", FileMode.Create, FileAccess.ReadWrite);
            JsonSerializer mySerializer = new Json.NETMF.JsonSerializer(DateTimeFormat.Default);

            json = mySerializer.Serialize(o);

            byte[] data = Encoding.UTF8.GetBytes(json);
            fs.Write(data, 0, data.Length);
            fs.Close();
            //write immediately on the sdCard
            VolumeInfo[] vi = VolumeInfo.GetVolumes();
            for (int i = 0; i < vi.Length; i++)
            {
                vi[i].FlushAll();
            }
        }
Beispiel #29
0
        public static void printString(SDCard sdCard, object o, bool connection)
        {
            string     rootDirectory = sdCard.StorageDevice.RootDirectory;
            string     json;
            FileStream fs;

            //Debug.Print("I am here");
            //timestamp applied is corretc no need to change it
            if (connection)
            {
                fs = new FileStream(rootDirectory + @"\correct_toSend" + numbOnline + ".JSON", FileMode.Create, FileAccess.ReadWrite);
                increseOnline();
                //SetUp.setLastToSend(numbOnline);
            }
            //timestamp applied is not correct change it, before sending
            else
            {
                fs = new FileStream(rootDirectory + @"\wrong_toSend" + numbOffline + ".JSON", FileMode.Create, FileAccess.ReadWrite);
                increaseOffline();
                //SetUp.setWrong(numbOffline);
            }
            JsonSerializer mySerializer = new Json.NETMF.JsonSerializer(DateTimeFormat.Default);

            json = mySerializer.Serialize(o);

            byte[] data = Encoding.UTF8.GetBytes(json);
            fs.Write(data, 0, data.Length);
            fs.Close();

            //write immediately on the sdCard
            VolumeInfo[] vi = VolumeInfo.GetVolumes();
            for (int i = 0; i < vi.Length; i++)
            {
                vi[i].FlushAll();
            }

            //Debug.Print("pringt data to SD!"+properties.Humidity+properties.Temperature+properties.iso_timestamp);
        }
Beispiel #30
0
        public static void writeFile(SDCard sdCard)
        {
            string     rootDirectory = sdCard.StorageDevice.RootDirectory;;
            FileStream fs;

            try
            {
                fs = new FileStream(rootDirectory + @"\SetUp.txt", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
                byte[] data = Encoding.UTF8.GetBytes(Wrong.ToString() + " " + lastToSend.ToString());
                fs.Write(data, 0, data.Length);
                fs.Close();
            }
            catch (System.IO.IOException e) {
                Debug.Print(e.ToString() + " " + e.Message);
            }

            //write immediately on the sdCard
            VolumeInfo[] vi = VolumeInfo.GetVolumes();
            for (int i = 0; i < vi.Length; i++)
            {
                vi[i].FlushAll();
            }
        }
 public ArduinoHttpHandler()
 {
     SD = new SDCard(@"c:\Users\DELL\Documents\Arduino\SmartHouse\SmartHouseWeb\");
 }
Beispiel #32
0
 private void cardReader_Unmounted(SDCard sender, EventArgs e)
 {
     Logger.WriteInfo("RPTR", "Media unmounted");
 }
Beispiel #33
0
 public SDCardPlugin(SDCard PrinterSDCardStatus, SDCardPlugin.ActiveSDPrintCallback activePrintCallback)
 {
     m_oPrinterSDCardStatus = PrinterSDCardStatus;
     m_OnActiveSDPrint      = activePrintCallback;
 }
Beispiel #34
0
 void sdCard_Mounted(SDCard sender, GT.StorageDevice device)
 {
     //sdCard.Mount();
     Debug.Print("Mount");
 }
Beispiel #35
0
 private void sdCard_Mounted(SDCard sender, StorageDevice SDCard)
 {
     Debug.Print("SD card mounted. Unmount before removing");
 }
Beispiel #36
0
 private void sdCard_SDCardMounted(SDCard sender, GT.StorageDevice SDCard)
 {
     CardMounted(sender, this);
 }
Beispiel #37
0
 void sdCard_SDCardUnmounted(SDCard sender)
 {
     ledSD.TurnRed();
     sdStorageDevice = null;
 }
Beispiel #38
0
 void sdCard_SDCardMounted(SDCard sender, GT.StorageDevice storageDevice)
 {
     ledSD.TurnGreen();
     sdStorageDevice = storageDevice;
     CheckAndTransfer();
 }
Beispiel #39
0
 private void sdCard_Unmounted(SDCard sender)
 {
     Debug.Print("SD card unmounted. Don't try to access it without mounting it again first.");
 }
Beispiel #40
0
 public SQL_Wrapper(SDCard sd)
 {
     this.sd = sd;
 }
 public static BciCommand Simple(SDCard cmd)
 {
     return(new BciCommand((char)cmd));
 }
Beispiel #42
0
 private void sdCard_Mounted(SDCard sender, GT.StorageDevice device)
 {
     Debug.Print("SD Card Unmounted");
 }
Beispiel #43
0
 private void sdCard_Unmounted(SDCard sender, EventArgs e)
 {
     Debug.Print("SD Card Unmounted");
     if (_sw != null)
         _sw.Close();
 }
Beispiel #44
0
 void sdCard_SDCardMounted(SDCard sender, GT.StorageDevice SDCard)
 {
     led1.TurnGreen();
 }
Beispiel #45
0
 void sdCard_Mounted(SDCard sender, GT.StorageDevice device)
 {
     Debug.Print("MEMORY pERFECT");
 }
Beispiel #46
0
 void sdCard_SDCardUnmounted(SDCard sender)
 {
     led1.TurnRed();
 }
Beispiel #47
0
 void sdCard_Mounted(SDCard sender, GT.StorageDevice device)
 {
     Debug.Print("sd insertada");
 }