Example #1
0
        public bool update_RTR500_bin(String comPortName, String binFileName, String datFileName)
        {
            //QQ DDD1 = new timeout_event_handler_del(update_progress);
            //QQ timeout_event_handler_del DDD2 = new timeout_event_handler_del(update_progress);

            Dfu dfu;
            DfuTransportSerial serial_backend;
            //"""Program a device with bootloader that support serial DFU"""

            DfuSerial_UW dfuSerial = new DfuSerial_UW();
            dfuSerial.portName = comPortName;

            serial_backend = new DfuTransportSerial(dfuSerial);
            //serial_backend = new DfuTransportSerial(port, baudrate, flowcontrol);

            serial_backend.register_events_callback(DfuEvent.PROGRESS_EVENT, this.update_progress);

            dfu = new Dfu(binFileName, datFileName, /*dfu_transport= (DfuTransport)*/serial_backend);

            //click.echo("Upgrading target on {1} with DFU package {0}. Flow control is {2}."
            //   .format(package, port, "enabled" if flowcontrol else "disabled"))
            logger.info(String.Format("Upgrading target on {1} with DFU package {0}. Flow control is {2}.", binFileName, comPortName, "Not used"));

            try
            {
                //    with click.progressbar(length=100) as bar:
                //        global global_bar
                //        global_bar = bar
                dfu.dfu_send_images();
            }
            catch (Exception ex)
            {
                //except Exception as e:
                //    click.echo("")
                //    click.echo("Failed to upgrade target. Error is: {0}".format(e.message))
                //    click.echo("")
                //    click.echo("Possible causes:")
                //    click.echo("- bootloader, SoftDevice or application on target "
                //               "does not match the requirements in the DFU package.")
                //    click.echo("- baud rate or flow control is not the same as in the target bootloader.")
                //    click.echo("- target is not in DFU mode. If using the SDK examples, "
                //               "press Button 4 and RESET and release both to enter DFU mode.")

                return false;
            }

            //click.echo("Device programmed.")
            logger.info(String.Format("Device programmed."));

            return (true);
        }
Example #2
0
        public bool update_Me_bin(String Address, Int32 Baud_rate, String comPortName, String binFileName, String datFileName)
        {
            bool bSts;

            Dfu dfu;
            //e.g. DfuTransportSerial serial_backend;
            DfuTransportMe me_backend;
            //"""Program a device with bootloader that support seri

            bSts = true;

            //# TODO: Fill DfuTransportMe() constructor with init parameters
            //# args.address needed
            //# args.baud_rate needed
            me_backend = new DfuTransportMe(Address, Baud_rate, comPortName);

            dfu = new Dfu(binFileName, datFileName, me_backend);

            //# Transmit the hex image to peer device.
            dfu.dfu_send_images();

            return (bSts);
        }