Search Results for

    Show / Hide Table of Contents

    Firmware Flash Updates

    This library is designed promote natural use of good design practices. One of the most important patterns you will see in the samples, tests, and the core library itself is extensive using of the using pattern. Following this design will prevent common causes of memory leaks while making your code easier to maintain. Code that is easy maintain gives you more time to focus on the features that bring value to your product.

    Code Sample

    using System;
    using PTIRelianceLib;
    
    namespace reliance_sample
    {
        class Program
        {
            static void Main(string[] args)
            {
                // Load a firmware file someplace on disk
                var file = BinaryFile.From("reliance_1.27.171.ptix");
                
                // Make sure that file loaded okay
                if (file.Empty)
                {
                    Console.WriteLine("Firmware file cannot be read. Does it exist?");
                }
                else
                {
                    // You could also use a DevNullMonitor if you want to ignore output entirely
                    var monitor = new ProgressMonitor();
                    monitor.OnFlashMessage += (s, o) => Console.WriteLine("\n{0}", o.Message);
                    
                    // Simple progress monitor
                    monitor.OnFlashProgressUpdated += (s, o) =>
                    {
                        Console.CursorLeft = 0;
                        Console.CursorVisible = false;
                        Console.Write("{0:0.00}%", o.Progress*100);
                    };
                    
                    // Wrap our printer in using so it gets disposed on properly
                    using(var printer = new ReliancePrinter())
                    {
                        // Do the update!
                        var result = printer.FlashUpdateTarget(file, monitor);
    
                        Console.WriteLine("\nFlash Update Result: {0}", result);
                    }
                }
            }
        }
    }
    
    Warning

    Exceptions

    For clarity, exception handling has been elided. It is advisable to wrap any ReliancePrinter method calls in a try/catch block for PTIException.

    Tip

    Flash udpating may be unreliable on Docker. See the Docker section for more details.

    • Improve this Doc
    In This Article
    Back to top Copyright © 2018 Pyramid Technologies
    Generated by DocFX