Check() public method

Validate packet completely including checksum. Checks common and packet type specific characteristics.
public Check ( ) : bool
return bool
Ejemplo n.º 1
0
        public void EmptyPacketSpecifyingBuffer()
        {
            byte[] buffer = new byte[Ssm2Packet.PacketSizeMax];

            // Constructor for initializing packet object by
            // providing own (empty) buffer

            // For parsing existing content use instance method .FromBytes (buffer) or
            // static method Ssm2Packet.NewFromBytes (buffer) instead!

            Ssm2Packet p = new Ssm2Packet(buffer);

            // packet buffer mostly contains zeroes
            // undefined, don't check:
            // Size, CheckSum, etc.

            //Assert.AreEqual (0, p.Size, "Size");

            Assert.AreEqual((Ssm2Command)0, p.Command, "Command");

            // Assert.AreEqual (0, p.ChecksumCalculated, "ChecksumCalculated");
            Assert.AreEqual(false, p.Check(), "Check");

            // not useful, just demonstrating that packet is invalid
            // byte[] buf = p.ToBytesCopy ();
            //Assert.AreEqual (0, buf.Length, "buf.Length");
        }
Ejemplo n.º 2
0
        static void AssertProperties1(Ssm2Packet p)
        {
            byte[] expectedPacketData = EcuInit1;

            Assert.IsInstanceOfType(typeof(Ssm2InitRequest), p, "type");
            Assert.IsInstanceOfType(typeof(Ssm2Packet), p, "base type");

            Assert.AreEqual(expectedPacketData.Length, p.Size, "Size");
            Assert.AreEqual(true, p.Check(), "Check()");

            Assert.AreEqual(Ssm2Device.Engine10, p.Destination, "Destination");
            Assert.AreEqual(Ssm2Device.DiagnosticToolF0, p.Source, "Source");
            Assert.AreEqual(Ssm2Command.InitRequestBF, p.Command, "Command");

            byte[] bytes = p.ToBytesCopy();
            for (int i = 0; i < expectedPacketData.Length; i++)
            {
                Assert.AreEqual(expectedPacketData[i], bytes[i], "bytes[]");
            }
        }
Ejemplo n.º 3
0
        public void DefaultPacket()
        {
            Ssm2Packet p = new Ssm2Packet();

            Assert.AreEqual(false, p.Check(), "Check");

            // Following tests are very implementation specific
            // and rather for debugging purposes!
            // Real code should not depend on most packet properties
            // except Check(), Capacity, Size.

            // packet is almost empty since no properties haven't been set yet
            Assert.AreEqual(Ssm2Packet.PacketSizeMin, p.Size, "Size");
            // only 1st byte is set to 128, all other bytes are 0,
            // therefore checksum is 128, too.
            Assert.AreEqual(128, p.ChecksumCalculated, "ChecksumCalculated");

            // not useful, just demonstrating that packet is invalid
            byte[] buf = p.ToBytesCopy();

            // generic packet type has minimum size
            Assert.AreEqual(Ssm2Packet.PacketSizeMin, buf.Length, "buf.Length");
        }
Ejemplo n.º 4
0
        static void AssertProperties1(Ssm2Packet p)
        {
            byte[] expectedPacketData = EcuInit1;

            Assert.IsInstanceOfType (typeof(Ssm2InitRequest), p, "type");
            Assert.IsInstanceOfType (typeof(Ssm2Packet), p, "base type");

            Assert.AreEqual (expectedPacketData.Length, p.Size, "Size");
            Assert.AreEqual (true, p.Check (), "Check()");

            Assert.AreEqual (Ssm2Device.Engine10, p.Destination, "Destination");
            Assert.AreEqual (Ssm2Device.DiagnosticToolF0, p.Source, "Source");
            Assert.AreEqual (Ssm2Command.InitRequestBF, p.Command, "Command");

            byte[] bytes = p.ToBytesCopy ();
            for (int i = 0; i < expectedPacketData.Length; i++) {
                Assert.AreEqual (expectedPacketData[i], bytes[i], "bytes[]");
            }
        }