Exemplo n.º 1
0
        static int upgradeSerialList(List <string> allserials)
        {
            string errmsg = "";

            foreach (string serial in allserials)
            {
                YModule module  = YModule.FindModule(serial);
                string  product = module.get_productName();
                string  current = module.get_firmwareRelease();

                // check if a new firmare is available on yoctopuce.com
                string newfirm = module.checkFirmware("www.yoctopuce.com", true);
                if (newfirm == "")
                {
                    Console.WriteLine(product + " " + serial + "(rev=" + current + ") is up to date");
                }
                else
                {
                    Console.WriteLine(product + " " + serial + "(rev=" + current +
                                      ") need be updated with firmare : ");
                    Console.WriteLine("    " + newfirm);
                    // execute the firmware upgrade
                    YFirmwareUpdate update = module.updateFirmware(newfirm);
                    int             status = update.startUpdate();
                    do
                    {
                        int newstatus = update.get_progress();
                        if (newstatus != status)
                        {
                            Console.WriteLine(newstatus + "% " + update.get_progressMessage());
                        }
                        YAPI.Sleep(500, ref errmsg);
                        status = newstatus;
                    } while (status < 100 && status >= 0);
                    if (status < 0)
                    {
                        Console.WriteLine("Firmware Update failed: " + update.get_progressMessage());
                        Environment.Exit(1);
                    }
                    else
                    {
                        if (module.isOnline())
                        {
                            Console.WriteLine(status + "% Firmware Updated Successfully!");
                        }
                        else
                        {
                            Console.WriteLine(status + " Firmware Update failed: module " + serial + "is not online");
                            Environment.Exit(1);
                        }
                    }
                }
            }
            return(0);
        }
Exemplo n.º 2
0
 internal YFirmwareUpdateProxy(YFirmwareUpdate objref)
 {
     _objref = objref;
 }
Exemplo n.º 3
0
        //--- (end of YFirmwareUpdate class start)
        //--- (YFirmwareUpdate definitions)
        //--- (end of YFirmwareUpdate definitions)
        //--- (YFirmwareUpdate implementation)

        /**
         * <summary>
         *   Returns a list of all the modules in "firmware update" mode.
         * <para>
         *   Only devices
         *   connected over USB are listed. For devices connected to a YoctoHub, you
         *   must connect yourself to the YoctoHub web interface.
         * </para>
         * <para>
         * </para>
         * </summary>
         * <returns>
         *   an array of strings containing the serial numbers of devices in "firmware update" mode.
         * </returns>
         */
        public static string[] GetAllBootLoaders()
        {
            return(YFirmwareUpdate.GetAllBootLoaders().ToArray());
        }
Exemplo n.º 4
0
 /**
  * <summary>
  *   Test if the byn file is valid for this module.
  * <para>
  *   It is possible to pass a directory instead of a file.
  *   In that case, this method returns the path of the most recent appropriate byn file. This method will
  *   ignore any firmware older than minrelease.
  * </para>
  * <para>
  * </para>
  * </summary>
  * <param name="serial">
  *   the serial number of the module to update
  * </param>
  * <param name="path">
  *   the path of a byn file or a directory that contains byn files
  * </param>
  * <param name="minrelease">
  *   a positive integer
  * </param>
  * <returns>
  *   : the path of the byn file to use, or an empty string if no byn files matches the requirement
  * </returns>
  * <para>
  *   On failure, returns a string that starts with "error:".
  * </para>
  */
 public static string CheckFirmware(string serial, string path, int minrelease)
 {
     return(YFirmwareUpdate.CheckFirmware(serial, path, minrelease));
 }