示例#1
0
        void HandleChanged(object sender, EventArgs e)
        {
            Lexer     scnr = new Lexer(this.Source.Stream);
            IdpParser pars = new IdpParser(scnr, this);

            pars.Parse();
        }
示例#2
0
        public StreamAdaptor(IScheduler scheduler, Stream inputStream, Stream outputStream)
        {
            _parser = new IdpParser(inputStream);

            _inputStream = inputStream;

            _outputStream = outputStream;

            Observable.FromEventPattern <PacketParsedEventArgs>(_parser, nameof(_parser.PacketParsed)).ObserveOn(scheduler)
            .Subscribe(args =>
            {
                OnReceive(args.EventArgs.Packet);
            });
        }
        public void Can_Parse_Frame_With_1Byte_Payload_NoCRC()
        {
            var incomingData = new MemoryStream();

            var parser = new IdpParser(incomingData);

            var data = new byte[] { 0x02, 0x00, 0x00, 0x00, 0x08, 0x00, 0xAA, 0x03 };

            incomingData.Write(data, 0, data.Length);

            incomingData.Seek(0, SeekOrigin.Begin);

            byte[] payload = null;

            parser.PacketParsed += (sender, e) =>
            {
                payload = e.Packet.Data;
            };

            parser.Parse();

            Assert.Equal(0xaa, payload[0]);
        }