Exemplo n.º 1
0
        /// <summary>
        /// Create a block-read response packet
        /// </summary>
        public static SsmPacket CreateBlockReadResponse(byte[] payload)
        {
            SsmPacket packet = new SsmPacket();

            packet.SetHeader(SsmDirection.FromEcu, SsmCommand.ReadBlockResponse);
            packet.AppendPayload(payload);
            packet.SetLengthByte();
            packet.AppendChecksum();
            return(packet);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create an ECU request packet with an arbitrary command and payload.
        /// </summary>
        /// <remarks>
        /// For experimentation...
        /// </remarks>
        /// <param name="direction">Which direction the packet will be traveling.</param>
        /// <param name="command">Command byte.</param>
        /// <param name="payload">Payload.</param>
        /// <returns>SsmPacket built from the given parameters.</returns>
        public static SsmPacket CreateArbitrary(
            SsmDirection direction,
            SsmCommand command,
            byte[] payload)
        {
            SsmPacket packet = new SsmPacket();

            packet.SetHeader(direction, command);
            packet.AppendPayload(payload);
            packet.SetLengthByte();
            packet.AppendChecksum();
            return(packet);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Create a request packet for an arbitrary device with an arbitrary command and payload.
        /// </summary>
        /// <remarks>
        /// For experimentation...
        /// </remarks>
        /// <param name="device">Which device the packet will to go.</param>
        /// <param name="command">Command byte.</param>
        /// <param name="pad">If true, an extra byte will be added to the header.</param>
        /// <param name="payload">Payload.</param>
        /// <returns>SsmPacket built from the given parameters.</returns>
        public static SsmPacket CreateArbitrary(
            byte device,
            byte command,
            bool pad,
            byte[] payload)
        {
            SsmPacket packet = new SsmPacket();

            packet.SetHeader(device, command, pad);
            packet.AppendPayload(payload);
            packet.SetLengthByte();
            packet.AppendChecksum();
            return(packet);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Create an ECU identifier response packet
        /// </summary>
        public static SsmPacket CreateEcuIdentifierResponse()
        {
            SsmPacket packet = new SsmPacket();

            packet.SetHeader(SsmDirection.FromEcu, SsmCommand.EcuInitResponse);

            // Remove header and checksum from sample packet data
            List <byte> payload = new List <byte>(SamplePacketData.EcuInitResponse);

            payload.RemoveRange(0, 5);
            payload.RemoveRange(payload.Count - 1, 1);

            packet.AppendPayload(payload.ToArray());
            packet.SetLengthByte();
            packet.AppendChecksum();
            return(packet);
        }