Esempio n. 1
0
        private bool DongleReset()
        {
            BlockingCommandReceiver waiter = new BlockingCommandReceiver(ZToolCMD.SYS_RESET_RESPONSE, _commandInterface);

            try
            {
                _commandInterface.SendAsynchronousCommand(new SYS_RESET(SYS_RESET.RESET_TYPE.SERIAL_BOOTLOADER));
            }
            catch (IOException e)
            {
                Log.Error("Failed to send SYS_RESET: {Exception}", e);
                return(false);
            }

            SYS_RESET_RESPONSE response = (SYS_RESET_RESPONSE)waiter.GetCommand(ResetTimeout);

            if (response == null)
            {
                Log.Warning("Dongle reset failed. Assuming bootloader is running and sending magic byte 0x{BootLoaderMagicByte}.", BOOTLOADER_MAGIC_BYTE.ToString("X2"));

                if (!BootloaderGetOut(BOOTLOADER_MAGIC_BYTE))
                {
                    Log.Warning("Attempt to get out from bootloader failed.");

                    return(false);
                }
            }

            return(true);
        }
Esempio n. 2
0
        private bool BootloaderGetOut(byte magicByte)
        {
            BlockingCommandReceiver waiter = new BlockingCommandReceiver(ZToolCMD.SYS_RESET_RESPONSE, _commandInterface);

            try
            {
                _commandInterface.SendRaw(new byte[] { magicByte });
            }
            catch (IOException e)
            {
                Log.Error("Failed to send bootloader magic byte: {Exception}", e);
            }

            SYS_RESET_RESPONSE response = (SYS_RESET_RESPONSE)waiter.GetCommand(ResetTimeout);

            return(response != null);
        }
Esempio n. 3
0
        private bool DongleReset()
        {
            BlockingCommandReceiver waiter = new BlockingCommandReceiver(ZToolCMD.SYS_RESET_RESPONSE, _commandInterface);

            try
            {
                _commandInterface.SendAsynchronousCommand(new SYS_RESET(SYS_RESET.RESET_TYPE.SERIAL_BOOTLOADER));
            }
            catch (IOException e)
            {
                _logger.Error("Failed to send SYS_RESET", e);
                return(false);
            }

            SYS_RESET_RESPONSE response = (SYS_RESET_RESPONSE)waiter.GetCommand(ResetTimeout);

            return(response != null);
        }