Beispiel #1
0
            public static Frame Parse(byte[] message)
            {
                Frame ret = null;

                switch (DetermineFrameType(message[0]))
                {
                case FrameType.Single:
                    ret = new SingleFrame(message);
                    break;

                case FrameType.First:
                    ret = new FirstFrame(message);
                    break;

                case FrameType.Consecutive:
                    ret = new ConsecutiveFrame(message);
                    break;

                case FrameType.Flow:
                    ret = new FlowControlFrame(message);
                    break;

                default:
                    break;
                }
                return(ret);
            }
Beispiel #2
0
            public static Frame Parse(byte[] message, bool awaitingConsecutive)
            {
                Frame ret = null;

                if (awaitingConsecutive)
                {
                    ret         = new Frame(message);
                    ret.RawData = message.Skip(1).ToArray();
                    return(ret);
                }

                switch (DetermineFrameType(message[0]))
                {
                case FrameType.Single:
                    ret = new SingleFrame(message);
                    break;

                case FrameType.First:
                    ret = new FirstFrame(message);
                    break;

                case FrameType.Consecutive:
                    ret = new ConsecutiveFrame(message);
                    break;

                case FrameType.Flow:
                    ret = new FlowControlFrame(message);
                    break;

                default:
                    break;
                }
                return(ret);
            }
Beispiel #3
0
        public void FlowControl_Create_TimeSpan()
        {
            var frame = new FlowControlFrame(Flag, BlockSize, SeparationTime);

            Assert.AreEqual(frame.SeparationTime, SeparationTime, "Значение свйоства SeparationTime не совпадает с переданными данными");
            Assert.AreEqual(frame.BlockSize, BlockSize, "Значение свйоства BlockSize не совпадает с переданными данными");
            Assert.AreEqual((byte)frame.Flag, (byte)Flag, "Значение свйоства Flag не совпадает с переданными данными");
        }
Beispiel #4
0
        public void FlowControl_FillWithBytes()
        {
            var frame = new FlowControlFrame();

            byte[] buff =
            {
                (byte)(((byte)frame.FrameType & 0x0f) << 4 | (byte)Flag & 0x0f), BlockSize,
                SeparationTimeCode
            };

            frame = IsoTpFrame.ParsePacket <FlowControlFrame>(buff);

            Assert.AreEqual((byte)frame.Flag, (byte)Flag, "Значение свйоства Flag не совпадает с переданными данными");
            Assert.AreEqual(frame.SeparationTime, SeparationTimeFromCode(SeparationTimeCode), "Значение свйоства SeparationTime не совпадает с переданными данными");
            Assert.AreEqual(frame.BlockSize, BlockSize, "Значение свйоства BlockSize не совпадает с переданными данными");
        }
Beispiel #5
0
        public void FlowControl_GetCanFrame()
        {
            const int descriptor = 0xfc08;
            var       frame      = new FlowControlFrame(Flag, BlockSize, SeparationTime);

            var canFrame = frame.GetCanFrame(descriptor);

            byte[] buff =
            {
                (byte)(((byte)frame.FrameType & 0x0f) << 4 | (byte)Flag & 0x0f), BlockSize,
                SeparationCodeFromTime(SeparationTime),                                  0,0, 0, 0, 0
            };

            Assert.AreEqual(canFrame.Descriptor, descriptor);
            Assert.AreEqual(BitConverter.ToString(canFrame.Data), BitConverter.ToString(buff));
        }