Returns requested data of a previous read-block-request. This packet type is usually created by the car control unit and sent to the tester. Example containing 3 data bytes: { 0x80, 0xF0, 0x10, 0x04, 0xE0, 0x01, 0x02, 0x03, 0x6A }.
Inheritance: Ssm2DataResponse
        public void Construct2()
        {
            byte[] packetData = TestPacket1;
            byte[] sourcePayloadData = TestPacket1Data;

            Ssm2ReadBlockResponse p = new Ssm2ReadBlockResponse ();
            p.Destination = Ssm2Device.DiagnosticToolF0;
            p.Source = Ssm2Device.Engine10;
            p.Data = TestPacket1Data;

            // should be ok after setting Data
            Assert.AreEqual (packetData.Length, p.Size, "Size before Construct");

            p.Finish ();

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

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

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

            IList<byte> data = p.Data;
            Assert.AreEqual (sourcePayloadData.Length, data.Count, "DataList.Count");
            Assert.AreEqual (sourcePayloadData.Length, p.DataCount, "DataCount");
            for (int i = 0; i < data.Count; i++) {
                Assert.AreEqual (TestPacket1Data[i], data[i], "data[" + i.ToString () + "]");
            }
        }
Example #2
0
        public void NewFromBytes2()
        {
            byte[] packetData = TestPacket1;
            var    p          = Ssm2ReadBlockResponse.NewFromBytes(packetData);

            Assert.IsInstanceOfType(typeof(Ssm2ReadBlockResponse), p, "type");
        }
Example #3
0
        public void NotAllPropertiesSet3()
        {
            Ssm2ReadBlockResponse p = new Ssm2ReadBlockResponse();

            p.Destination = Ssm2Device.Engine10;
            p.Source      = Ssm2Device.DiagnosticToolF0;
            p.Finish();
        }
Example #4
0
        public void NotAllPropertiesSet2()
        {
            Ssm2ReadBlockResponse p = new Ssm2ReadBlockResponse();

            p.Destination = Ssm2Device.Engine10;
            p.Data        = new byte[] { 0, 1, 2, 3, 4, 5 };
            p.Finish();
        }
Example #5
0
        public void NotAllPropertiesSet1()
        {
            Ssm2ReadBlockResponse p = new Ssm2ReadBlockResponse();

            p.Source = Ssm2Device.DiagnosticToolF0;
            p.Data   = new byte[] { 0 };
            p.Finish();
        }
Example #6
0
        /// <summary>
        /// Returns a specific Ssm2Packet type based on given content.
        /// Does not validate the packet, so manually call the Check method afterwards!
        /// </summary>
        /// <param name="bytes">
        /// A <see cref="System.Byte[]"/> containing the packet.
        /// The packet must start at index 0 though the array may be larger than needed.
        /// </param>
        /// <returns>
        /// A <see cref="Ssm2Packet"/> subclass or null if the packet type could not be recognized.
        /// </returns>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public static Ssm2Packet NewFromBytes(byte[] bytes)
        {
            if (bytes == null)
            {
                throw new ArgumentNullException();
            }
            // check generic minimum size in order to get command byte
            if (bytes.Length < PacketSizeMin)
            {
                throw new ArgumentOutOfRangeException("bytes.Length < Minimum (6)");
            }

            Ssm2Packet p;

            // Read type directly from command byte (5th byte).
            // Each derived class constructor checks its requirements.
            switch ((Ssm2Command)bytes[(int)Ssm2PacketIndex.Command])
            {
            case Ssm2Command.ReadAddressesRequestA8:
                p = new Ssm2ReadAddressesRequest(bytes);
                break;

            case Ssm2Command.ReadAddressesResponseE8:
                p = new Ssm2ReadAddressesResponse(bytes);
                break;

            case Ssm2Command.WriteAddressRequestB8:
                p = new Ssm2WriteAddressRequest(bytes);
                break;

            case Ssm2Command.WriteAddressResponseF8:
                p = new Ssm2WriteAddressResponse(bytes);
                break;

            case Ssm2Command.InitRequestBF:
                p = new Ssm2InitRequest(bytes);
                break;

            case Ssm2Command.InitResponseFF:
                p = new Ssm2InitResponse(bytes);
                break;

            case Ssm2Command.ReadBlockRequestA0:
                p = new Ssm2ReadBlockRequest(bytes);
                break;

            case Ssm2Command.ReadBlockResponseE0:
                p = new Ssm2ReadBlockResponse(bytes);
                break;

            default:
                return(null);
            }
            p.FromBytes(bytes);
            return(p);
        }
Example #7
0
        public void Construct2()
        {
            byte[] packetData        = TestPacket1;
            byte[] sourcePayloadData = TestPacket1Data;

            Ssm2ReadBlockResponse p = new Ssm2ReadBlockResponse();

            p.Destination = Ssm2Device.DiagnosticToolF0;
            p.Source      = Ssm2Device.Engine10;
            p.Data        = TestPacket1Data;

            // should be ok after setting Data
            Assert.AreEqual(packetData.Length, p.Size, "Size before Construct");

            p.Finish();


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

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

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

            IList <byte> data = p.Data;

            Assert.AreEqual(sourcePayloadData.Length, data.Count, "DataList.Count");
            Assert.AreEqual(sourcePayloadData.Length, p.DataCount, "DataCount");
            for (int i = 0; i < data.Count; i++)
            {
                Assert.AreEqual(TestPacket1Data[i], data[i], "data[" + i.ToString() + "]");
            }
        }
 public void NotAllPropertiesSet1()
 {
     Ssm2ReadBlockResponse p = new Ssm2ReadBlockResponse ();
     p.Source = Ssm2Device.DiagnosticToolF0;
     p.Data = new byte[] { 0 };
     p.Finish ();
 }
 public void NotAllPropertiesSet3()
 {
     Ssm2ReadBlockResponse p = new Ssm2ReadBlockResponse ();
     p.Destination = Ssm2Device.Engine10;
     p.Source = Ssm2Device.DiagnosticToolF0;
     p.Finish ();
 }
 public void NotAllPropertiesSet2()
 {
     Ssm2ReadBlockResponse p = new Ssm2ReadBlockResponse ();
     p.Destination = Ssm2Device.Engine10;
     p.Data = new byte[] { 0, 1, 2, 3, 4, 5 };
     p.Finish ();
 }
Example #11
0
        /// <summary>
        /// Returns a specific Ssm2Packet type based on given content.
        /// Does not validate the packet, so manually call the Check method afterwards!
        /// </summary>
        /// <param name="bytes">
        /// A <see cref="System.Byte[]"/> containing the packet.
        /// The packet must start at index 0 though the array may be larger than needed.
        /// </param>
        /// <returns>
        /// A <see cref="Ssm2Packet"/> subclass or null if the packet type could not be recognized.
        /// </returns>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public static Ssm2Packet NewFromBytes(byte[] bytes)
        {
            if (bytes == null)
                throw new ArgumentNullException ();
            // check generic minimum size in order to get command byte
            if (bytes.Length < PacketSizeMin)
                throw new ArgumentOutOfRangeException ("bytes.Length < Minimum (6)");

            Ssm2Packet p;
            // Read type directly from command byte (5th byte).
            // Each derived class constructor checks its requirements.
            switch ((Ssm2Command)bytes[(int)Ssm2PacketIndex.Command]) {
            case Ssm2Command.ReadAddressesRequestA8:
                p = new Ssm2ReadAddressesRequest (bytes);
                break;
            case Ssm2Command.ReadAddressesResponseE8:
                p = new Ssm2ReadAddressesResponse (bytes);
                break;
            case Ssm2Command.WriteAddressRequestB8:
                p = new Ssm2WriteAddressRequest (bytes);
                break;
            case Ssm2Command.WriteAddressResponseF8:
                p = new Ssm2WriteAddressResponse (bytes);
                break;
            case Ssm2Command.InitRequestBF:
                p = new Ssm2InitRequest (bytes);
                break;
            case Ssm2Command.InitResponseFF:
                p = new Ssm2InitResponse (bytes);
                break;
            case Ssm2Command.ReadBlockRequestA0:
                p = new Ssm2ReadBlockRequest (bytes);
                break;
            case Ssm2Command.ReadBlockResponseE0:
                p = new Ssm2ReadBlockResponse (bytes);
                break;
            default:
                return null;
            }
            p.FromBytes (bytes);
            return p;
        }