private async void DeveloperCommandToMcuAsync()
        {
            byte[] byteCommand;
            try
            {
                if (IsHex)
                {
                    byteCommand = Conversion.StringToByteArray(DeveloperCommand);
                }
                else
                {
                    byteCommand = Encoding.ASCII.GetBytes(DeveloperCommand + "\n");
                }

                ReplyPacket reply = await Mcu.SendTcpAsync(byteCommand, true, fireOnSent : (isSent) =>
                {
                    ReplyPacket replyPacket = new ReplyPacket()
                    {
                        IsSent = isSent
                    };
                    replyPacket.SetReply(byteCommand);
                    DevSentCommandInfo?.Invoke(this, replyPacket);
                }).ConfigureAwait(false);

                if (reply.IsSentAndReplyReceived)
                {
                    DevReplyIncoming?.Invoke(this, reply);
                }
            }
            catch (Exception ex)
            {
                ListenerTcp.ExceptionHandler?.Invoke(this, ex);
            }
        }
Esempio n. 2
0
        public async Task SendTcpAsyncTest()
        {
            var packet = new byte[] { 0x01, 0x02, 0x03, 0x04 };
            var reply  = await mcu.SendTcpAsync(packet).ConfigureAwait(false);

            if (reply.IsSent)
            {
            }
            if (reply.IsSentAndReplyReceived)
            {
            }
            if (reply.Error != null)
            {
            }
        }