Пример #1
0
        private async void _stream_DataReceived(object sender, SerialDataReceivedEventArgs e)
        {
            await _semaphoreSlim.WaitAsync();

            try
            {
                var packet = await ReadFrameInternal();

                if (packet == null)
                {
                    return;
                }
                try
                {
                    var telegram = EnOceanTelegramFactory.FromPacket(packet);
                    TelegramReceived?.Invoke(this, new PacketReceivedEventArgs(telegram));
                }
                catch (NotImplementedException)
                {
                    Logger.Logger.Instance.LogHexIn(packet.RawData);
                }

                if (_stream.BytesToRead > 0)
                {
                    _stream_DataReceived(sender, e);
                }
            }
            finally
            {
                _semaphoreSlim.Release();
            }
        }
Пример #2
0
        private RadioErp1Packet CreatePacket(string data)
        {
            var byteData = Automatica.Core.Driver.Utility.Utils.StringToByteArray(data);

            var packet = EnOceanPacket.Parse(byteData);

            var telegram = EnOceanTelegramFactory.FromPacket(packet) as RadioErp1Packet;

            return(telegram);
        }
Пример #3
0
        public void Test_Telegram1()
        {
            var byteData = Automatica.Core.Driver.Utility.Utils.StringToByteArray("55000A0701EBA500008E48FFA8AB000001FFFFFFFF560073");

            var packet = EnOceanPacket.Parse(byteData);

            var telegram = EnOceanTelegramFactory.FromPacket(packet) as RadioErp1Packet;

            Assert.NotNull(telegram);

            Assert.IsType <RadioErp1Packet>(telegram);

            Assert.Equal(Rorg.FourBs, telegram.Rorg);
        }