public void UpdateFirmware(string FileName, InFieldUpdate.Types Tipe)
        {
            FileInfo info = new FileInfo(CurrentPath + FileName);

            if (!info.Exists)
            {
                PrintLine("File not found, type it correctly.");
                return;
            }
            PrintLine("update in progress, please wait a moment..");
            CallPrintEvent(Screen);
            switch (Tipe)
            {
            case InFieldUpdate.Types.Application:
                InFieldUpdate.Initialize(InFieldUpdate.Types.Application);
                LoadFile(info.FullName, InFieldUpdate.Types.Application);
                break;

            case InFieldUpdate.Types.Configuration:
                InFieldUpdate.Initialize(InFieldUpdate.Types.Configuration);
                LoadFile(info.FullName, InFieldUpdate.Types.Configuration);
                break;

            case InFieldUpdate.Types.Firmware:
                InFieldUpdate.Initialize(InFieldUpdate.Types.Firmware);
                LoadFile(info.FullName, InFieldUpdate.Types.Firmware);
                break;
            }
            InFieldUpdate.FlashAndReset();
        }
        public static void FlashFirmware()
        {
            // Reserve the memory needed to buffer the update.
            // A lot of RAM is needed so it is recommended to do this at the program start.
            InFieldUpdate.Initialize(InFieldUpdate.Types.Application);

            // Start loading the new firmware on the RAM reserved in last step.
            // Nothing is written to FLASH In this stage. Power loss and failures are okay
            // Simply abort this stage any way you like!
            // Files can come from Storage, from network, from serial bus and any Other way.
            LoadFile("\\SD\\IFU\\aplikasi1.hex", InFieldUpdate.Types.Application);

            //LoadFile("\\SD\\Config.hex", InFieldUpdate.Types.Configuration);
            //LoadFile("\\SD\\Firmware.hex", InFieldUpdate.Types.Firmware);
            //LoadFile("\\SD\\Firmware2.hex", InFieldUpdate.Types.Firmware); //Only if your device has two firmware files.

            // This method will copy The new firmware from RAM to FLASH.
            // This function will not return But will reset the system when done.
            // Power loss during Before this function resets the system quill result in a corrupted firmware.
            // A manual update will be needed if this method failed, due to power loss for example.
            InFieldUpdate.FlashAndReset();
        }