Ejemplo n.º 1
0
        public AF_DATA_CONFIRM SendAFDataRequest(AF_DATA_REQUEST request)
        {
            if (!WaitForNetwork())
            {
                return(null);
            }
            AF_DATA_CONFIRM result = null;

            WaitAndLock3WayConversation(request);
            BlockingCommandReceiver waiter = new BlockingCommandReceiver(ZToolCMD.AF_DATA_CONFIRM, _commandInterface);

            AF_DATA_SRSP response = (AF_DATA_SRSP)SendSynchronous(request);

            if (response == null || response.Status != 0)
            {
                waiter.Cleanup();
            }
            else
            {
                result = (AF_DATA_CONFIRM)waiter.GetCommand(Timeout);
            }
            UnLock3WayConversation(request);

            return(result);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }