Files
HC_APTBS/Infrastructure/Kwp/Packets/Packet.cs
2026-04-11 12:45:18 +02:00

32 lines
773 B
C#

using System.Collections.Generic;
using System.Linq;
namespace HC_APTBS.Infrastructure.Kwp.Packets
{
/// <summary>
/// KWP1281 packet
/// </summary>
public class Packet
{
public Packet(List<byte> bytes)
{
Bytes = bytes;
}
public List<byte> Bytes { get; }
public byte Title => Bytes[2];
/// <summary>
/// Returns the body of the packet, excluding the length, counter, command and end bytes.
/// </summary>
public List<byte> Body => Bytes.Skip(3).Take(Bytes.Count - 4).ToList();
public bool IsAck => Title == (byte)PacketCommand.ACK;
public bool IsNak => Title == (byte)PacketCommand.NAK;
public bool IsAckNak => IsAck || IsNak;
}
}