Add C# dotnet exact EXI codec implementation
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
* (at your option) any later version.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using V2GDecoderNet.EXI;
|
||||
|
||||
namespace V2GDecoderNet.V2G
|
||||
@@ -57,21 +58,26 @@ namespace V2GDecoderNet.V2G
|
||||
return inputData ?? Array.Empty<byte>();
|
||||
}
|
||||
|
||||
// Check for V2G Transfer Protocol header
|
||||
if (inputData[0] == V2G_PROTOCOL_VERSION && inputData[1] == V2G_INV_PROTOCOL_VERSION)
|
||||
// First, look for V2G Transfer Protocol header anywhere in the data
|
||||
// Pattern: 0x01 0xFE 0x80 0x01 (V2GTP header for ISO/DIN/SAP)
|
||||
for (int i = 0; i <= inputData.Length - 8; i++)
|
||||
{
|
||||
ushort payloadType = (ushort)((inputData[2] << 8) | inputData[3]);
|
||||
|
||||
if (payloadType == V2G_PAYLOAD_ISO_DIN_SAP || payloadType == V2G_PAYLOAD_ISO2)
|
||||
if (inputData[i] == V2G_PROTOCOL_VERSION && inputData[i + 1] == V2G_INV_PROTOCOL_VERSION)
|
||||
{
|
||||
// Valid V2GTP header detected: skip 8-byte header
|
||||
var exiBody = new byte[inputData.Length - 8];
|
||||
Array.Copy(inputData, 8, exiBody, 0, exiBody.Length);
|
||||
return exiBody;
|
||||
ushort payloadType = (ushort)((inputData[i + 2] << 8) | inputData[i + 3]);
|
||||
|
||||
if (payloadType == V2G_PAYLOAD_ISO_DIN_SAP || payloadType == V2G_PAYLOAD_ISO2)
|
||||
{
|
||||
// Valid V2GTP header found: skip 8-byte header to get EXI body
|
||||
int exiStart = i + 8;
|
||||
var exiBody = new byte[inputData.Length - exiStart];
|
||||
Array.Copy(inputData, exiStart, exiBody, 0, exiBody.Length);
|
||||
return exiBody;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Look for EXI start pattern anywhere in the data
|
||||
// If no V2GTP header found, look for EXI start pattern anywhere in the data
|
||||
for (int i = 0; i <= inputData.Length - 2; i++)
|
||||
{
|
||||
ushort pattern = (ushort)((inputData[i] << 8) | inputData[i + 1]);
|
||||
|
||||
Reference in New Issue
Block a user