Exemple #1
0
        private void usartBytesReceived(object sender, BytesReceivedEventArgs e)
        {
            if (timeoutTimer != null)
            {
                timeoutTimer.Change(1000, Timeout.Infinite);
            }
            //System.Diagnostics.Debug.WriteLine("---");
            int lo = -1;
            int hi = -1;

            for (int co = 0; co < e.count; co++)
            {
                if (e.bytes[co] >= 128)
                {
                    hi = (e.bytes[co] - 128) << 5;
                }
                else
                {
                    lo = e.bytes[co] - 64;
                }
            }
            if (lo != -1 && hi != -1 && encGrayVal != lo + hi)
            {
                encGrayVal = lo + hi;
                int val = encGrayVal;
                for (int mask = val >> 1; mask != 0; mask = mask >> 1)
                {
                    val = val ^ mask;
                }
                this.Invoke((MethodInvoker) delegate { setCurrentAngle(val); });
            }
        }
Exemple #2
0
        private void bytesReceived(object Sender, BytesReceivedEventArgs e)
        {
            GCHandle pinnedBuffer = GCHandle.Alloc(e.bytes, GCHandleType.Pinned);
            Message  msg          = (Message)Marshal.PtrToStructure(pinnedBuffer.AddrOfPinnedObject(),
                                                                    typeof(Message));

            onMessage?.Invoke(this, new MessageEventArgs
            {
                modulation = msg.modulation,
                vfoa       = msg.vfoa,
                vfob       = msg.vfob,
                trx        = msg.trx == 1
            });
        }
        protected void ReceiveMessage(BytesReceivedEventArgs e)
        {
            MessageCodec.DecodeMessages(e.Message, out List <ProtocolMessage> messages, out this.remainderBytes, this.remainderBytes);
            foreach (ProtocolMessage protocolMessage in messages)
            {
                switch (protocolMessage.Command)
                {
                case Command.GetVersion:
                    this.DispatchVersionMessage(protocolMessage);
                    break;

                case Command.GetInfo:
                    break;

                case Command.WriteRegister:
                    break;

                case Command.QueryRegister:
                    this.DispatchQueryRegisterMessage(protocolMessage);
                    break;

                case Command.ConfigChannel:
                    break;

                case Command.Decimation:
                    break;

                case Command.ResetTime:
                    break;

                case Command.ReadChannelData:
                    DispatchReadChannelDataMessage(protocolMessage);
                    break;

                case Command.DebugString:
                    break;

                case Command.EmbeddedConfiguration:
                    break;

                case Command.Tracing:
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
Exemple #4
0
        private void Client_BytesReceived(object sender, BytesReceivedEventArgs e)
        {
            if (InvokeRequired)
            {
                BeginInvoke(new DelMethod(Client_BytesReceived), new object[] { sender, e });
                return;
            }

            Console.WriteLine("Byte count = " + e.ReceivedBytes.Length);
            Console.WriteLine("Bytes recv array = " + ByteArrayToString(e.ReceivedBytes));

            txtInput.Text = System.Text.ASCIIEncoding.ASCII.GetString(e.ReceivedBytes);
            if (txtInput.Text.Length > 0)
            {
                if (e.Client.Connected)
                {
                    e.Client.WriteToClient(txtReply.Text);
                }
            }
        }
Exemple #5
0
 private void timyUsb_BytesReceived(object sender, BytesReceivedEventArgs e)
 {
     logger.Trace($"Device {e.Device.Id} Bytes: {e.Data.Length}");
 }
 protected virtual void OnBytesReceived(BytesReceivedEventArgs e) => BytesReceived?.Invoke(this, e);
Exemple #7
0
 private void TcpServerTest_BytesReceived(object sender, BytesReceivedEventArgs e)
 {
     Data = e.ReceivedBytes;
 }
        private void Client_BytesReceived(object sender, BytesReceivedEventArgs e)
        {
            var numbers = e.ReceivedBytes.Where(_ => _ >= '0' && _ <= '9');

            _requestPool.UpdateResponse(e.RequestId, numbers);
        }